mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00
Re-org SIMD code structure for non-x86 target (#611)
This commit is contained in:
parent
46db353017
commit
7706e4b151
|
@ -90,7 +90,6 @@ fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: instructions for other CPUs */
|
|
||||||
/* shufflevector is not an option, since it requires *mask as a const */
|
/* shufflevector is not an option, since it requires *mask as a const */
|
||||||
bool
|
bool
|
||||||
aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
|
@ -158,17 +157,13 @@ fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
aot_compile_simd_swizzle(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
aot_compile_simd_swizzle_common(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef vector, mask, default_lane_value, condition, max_lane_id,
|
LLVMValueRef vector, mask, default_lane_value, condition, max_lane_id,
|
||||||
result, idx, id, replace_with_zero, elem, elem_or_zero, undef;
|
result, idx, id, replace_with_zero, elem, elem_or_zero, undef;
|
||||||
uint8 i;
|
uint8 i;
|
||||||
|
|
||||||
if (is_target_x86(comp_ctx)) {
|
|
||||||
return aot_compile_simd_swizzle_x86(comp_ctx, func_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
int const_lane_ids[16] = { 16, 16, 16, 16, 16, 16, 16, 16,
|
int const_lane_ids[16] = { 16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
16, 16, 16, 16, 16, 16, 16, 16 },
|
16, 16, 16, 16, 16, 16, 16, 16 },
|
||||||
const_zeors[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
const_zeors[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
@ -261,6 +256,17 @@ fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
aot_compile_simd_swizzle(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
|
{
|
||||||
|
if (is_target_x86(comp_ctx)) {
|
||||||
|
return aot_compile_simd_swizzle_x86(comp_ctx, func_ctx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return aot_compile_simd_swizzle_common(comp_ctx, func_ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
aot_compile_simd_extract(AOTCompContext *comp_ctx,
|
aot_compile_simd_extract(AOTCompContext *comp_ctx,
|
||||||
AOTFuncContext *func_ctx,
|
AOTFuncContext *func_ctx,
|
||||||
|
|
|
@ -153,8 +153,8 @@ aot_compile_simd_i16x8_narrow_i32x4_x86(AOTCompContext *comp_ctx,
|
||||||
is_signed ? "llvm.x86.sse2.packssdw.128" : "llvm.x86.sse41.packusdw");
|
is_signed ? "llvm.x86.sse2.packssdw.128" : "llvm.x86.sse41.packusdw");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
aot_compile_simd_i8x16_narrow_i16x8(AOTCompContext *comp_ctx,
|
aot_compile_simd_i8x16_narrow_i16x8_common(AOTCompContext *comp_ctx,
|
||||||
AOTFuncContext *func_ctx,
|
AOTFuncContext *func_ctx,
|
||||||
bool is_signed)
|
bool is_signed)
|
||||||
{
|
{
|
||||||
|
@ -163,11 +163,6 @@ aot_compile_simd_i8x16_narrow_i16x8(AOTCompContext *comp_ctx,
|
||||||
shuffle_vector;
|
shuffle_vector;
|
||||||
LLVMValueRef v1_gt_max, v1_lt_min, v2_gt_max, v2_lt_min;
|
LLVMValueRef v1_gt_max, v1_lt_min, v2_gt_max, v2_lt_min;
|
||||||
|
|
||||||
if (is_target_x86(comp_ctx)) {
|
|
||||||
return aot_compile_simd_i8x16_narrow_i16x8_x86(comp_ctx, func_ctx,
|
|
||||||
is_signed);
|
|
||||||
}
|
|
||||||
|
|
||||||
int min_s_array[8] = { 0xff80, 0xff80, 0xff80, 0xff80,
|
int min_s_array[8] = { 0xff80, 0xff80, 0xff80, 0xff80,
|
||||||
0xff80, 0xff80, 0xff80, 0xff80 };
|
0xff80, 0xff80, 0xff80, 0xff80 };
|
||||||
int max_s_array[8] = { 0x007f, 0x007f, 0x007f, 0x007f,
|
int max_s_array[8] = { 0x007f, 0x007f, 0x007f, 0x007f,
|
||||||
|
@ -290,7 +285,22 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx,
|
aot_compile_simd_i8x16_narrow_i16x8(AOTCompContext *comp_ctx,
|
||||||
|
AOTFuncContext *func_ctx,
|
||||||
|
bool is_signed)
|
||||||
|
{
|
||||||
|
if (is_target_x86(comp_ctx)) {
|
||||||
|
return aot_compile_simd_i8x16_narrow_i16x8_x86(comp_ctx, func_ctx,
|
||||||
|
is_signed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return aot_compile_simd_i8x16_narrow_i16x8_common(comp_ctx, func_ctx,
|
||||||
|
is_signed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
aot_compile_simd_i16x8_narrow_i32x4_common(AOTCompContext *comp_ctx,
|
||||||
AOTFuncContext *func_ctx,
|
AOTFuncContext *func_ctx,
|
||||||
bool is_signed)
|
bool is_signed)
|
||||||
{
|
{
|
||||||
|
@ -299,11 +309,6 @@ aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx,
|
||||||
shuffle_vector;
|
shuffle_vector;
|
||||||
LLVMValueRef v1_gt_max, v1_lt_min, v2_gt_max, v2_lt_min;
|
LLVMValueRef v1_gt_max, v1_lt_min, v2_gt_max, v2_lt_min;
|
||||||
|
|
||||||
if (is_target_x86(comp_ctx)) {
|
|
||||||
return aot_compile_simd_i16x8_narrow_i32x4_x86(comp_ctx, func_ctx,
|
|
||||||
is_signed);
|
|
||||||
}
|
|
||||||
|
|
||||||
int min_s_array[4] = { 0xffff8000, 0xffff8000, 0xffff8000, 0xffff8000 };
|
int min_s_array[4] = { 0xffff8000, 0xffff8000, 0xffff8000, 0xffff8000 };
|
||||||
int32 max_s_array[4] = { 0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff };
|
int32 max_s_array[4] = { 0x00007fff, 0x00007fff, 0x00007fff, 0x00007fff };
|
||||||
|
|
||||||
|
@ -420,6 +425,21 @@ fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx,
|
||||||
|
AOTFuncContext *func_ctx,
|
||||||
|
bool is_signed)
|
||||||
|
{
|
||||||
|
if (is_target_x86(comp_ctx)) {
|
||||||
|
return aot_compile_simd_i16x8_narrow_i32x4_x86(comp_ctx, func_ctx,
|
||||||
|
is_signed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return aot_compile_simd_i16x8_narrow_i32x4_common(comp_ctx, func_ctx,
|
||||||
|
is_signed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_compile_simd_i16x8_widen_i8x16(AOTCompContext *comp_ctx,
|
aot_compile_simd_i16x8_widen_i8x16(AOTCompContext *comp_ctx,
|
||||||
AOTFuncContext *func_ctx,
|
AOTFuncContext *func_ctx,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user