Apply clang-format for core/iwasm compilation and libraries (#784)
Apply clang-format for core/iwasm/compilation and core/iwasm/libraries files. Add wasm-c-api empty_imports sample to workflow test. And enable triggering workflow when core/config.h changes.
This commit is contained in:
@ -9,8 +9,7 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
bool
|
||||
aot_compile_simd_shuffle(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_shuffle(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
const uint8 *frame_ip)
|
||||
{
|
||||
LLVMValueRef vec1, vec2, mask, result;
|
||||
@ -34,8 +33,8 @@ aot_compile_simd_shuffle(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
/* build a vector <16 x i32> */
|
||||
if (!(mask =
|
||||
simd_build_const_integer_vector(comp_ctx, I32_TYPE, values, 16))) {
|
||||
if (!(mask = simd_build_const_integer_vector(comp_ctx, I32_TYPE, values,
|
||||
16))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -54,8 +53,7 @@ fail:
|
||||
/*TODO: llvm.experimental.vector.*/
|
||||
/* shufflevector is not an option, since it requires *mask as a const */
|
||||
bool
|
||||
aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
LLVMValueRef vector, mask, max_lanes, condition, mask_lanes, result;
|
||||
LLVMTypeRef param_types[2];
|
||||
@ -71,15 +69,17 @@ aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
/* icmp uge <16 x i8> mask, <16, 16, 16, 16, ...> */
|
||||
if (!(max_lanes = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, INT8_TYPE, 16, 16))) {
|
||||
if (!(max_lanes = simd_build_splat_const_integer_vector(comp_ctx, INT8_TYPE,
|
||||
16, 16))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* if the highest bit of every i8 of mask is 1, means doesn't pick up from vector */
|
||||
/* select <16 x i1> %condition, <16 x i8> <0x80, 0x80, ...>, <16 x i8> %mask */
|
||||
/* if the highest bit of every i8 of mask is 1, means doesn't pick up
|
||||
from vector */
|
||||
/* select <16 x i1> %condition, <16 x i8> <0x80, 0x80, ...>,
|
||||
<16 x i8> %mask */
|
||||
if (!(mask_lanes = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, INT8_TYPE, 0x80, 16))) {
|
||||
comp_ctx, INT8_TYPE, 0x80, 16))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -89,8 +89,8 @@ aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(mask = LLVMBuildSelect(comp_ctx->builder, condition, mask_lanes,
|
||||
mask, "mask"))) {
|
||||
if (!(mask = LLVMBuildSelect(comp_ctx->builder, condition, mask_lanes, mask,
|
||||
"mask"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSelect");
|
||||
goto fail;
|
||||
}
|
||||
@ -98,8 +98,8 @@ aot_compile_simd_swizzle_x86(AOTCompContext *comp_ctx,
|
||||
param_types[0] = V128_i8x16_TYPE;
|
||||
param_types[1] = V128_i8x16_TYPE;
|
||||
if (!(result = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, "llvm.x86.ssse3.pshuf.b.128", V128_i8x16_TYPE,
|
||||
param_types, 2, vector, mask))) {
|
||||
comp_ctx, func_ctx, "llvm.x86.ssse3.pshuf.b.128", V128_i8x16_TYPE,
|
||||
param_types, 2, vector, mask))) {
|
||||
HANDLE_FAILURE("LLVMBuildCall");
|
||||
goto fail;
|
||||
}
|
||||
@ -122,7 +122,7 @@ aot_compile_simd_swizzle_common(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
{
|
||||
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;
|
||||
|
||||
if (!(mask = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, V128_i8x16_TYPE,
|
||||
@ -142,7 +142,7 @@ aot_compile_simd_swizzle_common(AOTCompContext *comp_ctx,
|
||||
|
||||
/* icmp uge <16 x i8> mask, <16, 16, 16, 16, ...> */
|
||||
if (!(max_lane_id = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, INT8_TYPE, 16, 16))) {
|
||||
comp_ctx, INT8_TYPE, 16, 16))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -152,9 +152,9 @@ aot_compile_simd_swizzle_common(AOTCompContext *comp_ctx,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* if the id is out of range (>=16), set the id as 0 */
|
||||
/* if the id is out of range (>=16), set the id as 0 */
|
||||
if (!(default_lane_value = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, INT8_TYPE, 0, 16))) {
|
||||
comp_ctx, INT8_TYPE, 0, 16))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -172,8 +172,8 @@ aot_compile_simd_swizzle_common(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(replace_with_zero =
|
||||
LLVMBuildExtractElement(comp_ctx->builder, condition,
|
||||
I8_CONST(i), "replace_with_zero"))) {
|
||||
LLVMBuildExtractElement(comp_ctx->builder, condition,
|
||||
I8_CONST(i), "replace_with_zero"))) {
|
||||
HANDLE_FAILURE("LLVMBuildExtractElement");
|
||||
goto fail;
|
||||
}
|
||||
@ -185,15 +185,15 @@ aot_compile_simd_swizzle_common(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(elem_or_zero =
|
||||
LLVMBuildSelect(comp_ctx->builder, replace_with_zero,
|
||||
I8_CONST(0), elem, "elem_or_zero"))) {
|
||||
LLVMBuildSelect(comp_ctx->builder, replace_with_zero,
|
||||
I8_CONST(0), elem, "elem_or_zero"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSelect");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(undef =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undef, elem_or_zero,
|
||||
I8_CONST(i), "new_vector"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undef, elem_or_zero,
|
||||
I8_CONST(i), "new_vector"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
goto fail;
|
||||
}
|
||||
@ -224,13 +224,9 @@ aot_compile_simd_swizzle(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
}
|
||||
|
||||
static bool
|
||||
aot_compile_simd_extract(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id,
|
||||
bool need_extend,
|
||||
bool is_signed,
|
||||
LLVMTypeRef vector_type,
|
||||
LLVMTypeRef result_type,
|
||||
aot_compile_simd_extract(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 lane_id, bool need_extend, bool is_signed,
|
||||
LLVMTypeRef vector_type, LLVMTypeRef result_type,
|
||||
unsigned aot_value_type)
|
||||
{
|
||||
LLVMValueRef vector, lane, result;
|
||||
@ -256,16 +252,16 @@ aot_compile_simd_extract(AOTCompContext *comp_ctx,
|
||||
if (need_extend) {
|
||||
if (is_signed) {
|
||||
/* sext <element_type> %element to <result_type> */
|
||||
if (!(result = LLVMBuildSExt(comp_ctx->builder, result,
|
||||
result_type, "ret"))) {
|
||||
if (!(result = LLVMBuildSExt(comp_ctx->builder, result, result_type,
|
||||
"ret"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSExt");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* sext <element_type> %element to <result_type> */
|
||||
if (!(result = LLVMBuildZExt(comp_ctx->builder, result,
|
||||
result_type, "ret"))) {
|
||||
if (!(result = LLVMBuildZExt(comp_ctx->builder, result, result_type,
|
||||
"ret"))) {
|
||||
HANDLE_FAILURE("LLVMBuildZExt");
|
||||
goto fail;
|
||||
}
|
||||
@ -281,8 +277,7 @@ fail:
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id,
|
||||
AOTFuncContext *func_ctx, uint8 lane_id,
|
||||
bool is_signed)
|
||||
{
|
||||
return aot_compile_simd_extract(comp_ctx, func_ctx, lane_id, true,
|
||||
@ -292,8 +287,7 @@ aot_compile_simd_extract_i8x16(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id,
|
||||
AOTFuncContext *func_ctx, uint8 lane_id,
|
||||
bool is_signed)
|
||||
{
|
||||
return aot_compile_simd_extract(comp_ctx, func_ctx, lane_id, true,
|
||||
@ -303,8 +297,7 @@ aot_compile_simd_extract_i16x8(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_extract(comp_ctx, func_ctx, lane_id, false, false,
|
||||
V128_i32x4_TYPE, I32_TYPE, VALUE_TYPE_I32);
|
||||
@ -312,8 +305,7 @@ aot_compile_simd_extract_i32x4(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_extract(comp_ctx, func_ctx, lane_id, false, false,
|
||||
V128_i64x2_TYPE, I64_TYPE, VALUE_TYPE_I64);
|
||||
@ -321,8 +313,7 @@ aot_compile_simd_extract_i64x2(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_f32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_extract(comp_ctx, func_ctx, lane_id, false, false,
|
||||
V128_f32x4_TYPE, F32_TYPE, VALUE_TYPE_F32);
|
||||
@ -330,20 +321,16 @@ aot_compile_simd_extract_f32x4(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_f64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_extract(comp_ctx, func_ctx, lane_id, false, false,
|
||||
V128_f64x2_TYPE, F64_TYPE, VALUE_TYPE_F64);
|
||||
}
|
||||
|
||||
static bool
|
||||
aot_compile_simd_replace(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id,
|
||||
unsigned new_value_type,
|
||||
LLVMTypeRef vector_type,
|
||||
bool need_reduce,
|
||||
aot_compile_simd_replace(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 lane_id, unsigned new_value_type,
|
||||
LLVMTypeRef vector_type, bool need_reduce,
|
||||
LLVMTypeRef element_type)
|
||||
{
|
||||
LLVMValueRef vector, new_value, lane, result;
|
||||
@ -368,7 +355,8 @@ aot_compile_simd_replace(AOTCompContext *comp_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* insertelement <vector_type> %vector, <element_type> %element, i32 lane */
|
||||
/* insertelement <vector_type> %vector, <element_type> %element,
|
||||
i32 lane */
|
||||
if (!(result = LLVMBuildInsertElement(comp_ctx->builder, vector, new_value,
|
||||
lane, "new_vector"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
@ -383,60 +371,48 @@ fail:
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id,
|
||||
VALUE_TYPE_I32, V128_i8x16_TYPE, true,
|
||||
INT8_TYPE);
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id, VALUE_TYPE_I32,
|
||||
V128_i8x16_TYPE, true, INT8_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id,
|
||||
VALUE_TYPE_I32, V128_i16x8_TYPE, true,
|
||||
INT16_TYPE);
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id, VALUE_TYPE_I32,
|
||||
V128_i16x8_TYPE, true, INT16_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id,
|
||||
VALUE_TYPE_I32, V128_i32x4_TYPE, false,
|
||||
I32_TYPE);
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id, VALUE_TYPE_I32,
|
||||
V128_i32x4_TYPE, false, I32_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id,
|
||||
VALUE_TYPE_I64, V128_i64x2_TYPE, false,
|
||||
I64_TYPE);
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id, VALUE_TYPE_I64,
|
||||
V128_i64x2_TYPE, false, I64_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_f32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id,
|
||||
VALUE_TYPE_F32, V128_f32x4_TYPE, false,
|
||||
F32_TYPE);
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id, VALUE_TYPE_F32,
|
||||
V128_f32x4_TYPE, false, F32_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_f64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id)
|
||||
AOTFuncContext *func_ctx, uint8 lane_id)
|
||||
{
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id,
|
||||
VALUE_TYPE_F64, V128_f64x2_TYPE, false,
|
||||
F64_TYPE);
|
||||
return aot_compile_simd_replace(comp_ctx, func_ctx, lane_id, VALUE_TYPE_F64,
|
||||
V128_f64x2_TYPE, false, F64_TYPE);
|
||||
}
|
||||
|
||||
@ -13,8 +13,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
aot_compile_simd_shuffle(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_shuffle(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
const uint8 *frame_ip);
|
||||
|
||||
bool
|
||||
@ -22,84 +21,68 @@ aot_compile_simd_swizzle(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id,
|
||||
AOTFuncContext *func_ctx, uint8 lane_id,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id,
|
||||
AOTFuncContext *func_ctx, uint8 lane_id,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_i64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_f32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_extract_f64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_i64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_f32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_replace_f64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
AOTFuncContext *func_ctx, uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load8_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_load8_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load16_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_load16_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load32_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_load32_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load64_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_load64_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 lane_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -16,10 +16,8 @@ enum integer_shift {
|
||||
};
|
||||
|
||||
static bool
|
||||
simd_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntShift shift_op,
|
||||
enum integer_shift itype)
|
||||
simd_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op, enum integer_shift itype)
|
||||
{
|
||||
LLVMValueRef vector, offset, result = NULL;
|
||||
LLVMTypeRef vector_type[] = { V128_i8x16_TYPE, V128_i16x8_TYPE,
|
||||
@ -27,8 +25,7 @@ simd_shift(AOTCompContext *comp_ctx,
|
||||
LLVMTypeRef element_type[] = { INT8_TYPE, INT16_TYPE, I32_TYPE, I64_TYPE };
|
||||
|
||||
LLVMValueRef undef[] = { LLVM_CONST(i8x16_undef), LLVM_CONST(i16x8_undef),
|
||||
LLVM_CONST(i32x4_undef),
|
||||
LLVM_CONST(i64x2_undef) };
|
||||
LLVM_CONST(i32x4_undef), LLVM_CONST(i64x2_undef) };
|
||||
LLVMValueRef mask[] = { LLVM_CONST(i8x16_vec_zero),
|
||||
LLVM_CONST(i16x8_vec_zero),
|
||||
LLVM_CONST(i32x4_vec_zero),
|
||||
@ -49,8 +46,8 @@ simd_shift(AOTCompContext *comp_ctx,
|
||||
|
||||
/* offset mod LaneBits */
|
||||
if (!lane_bits[itype]
|
||||
|| !(offset = LLVMBuildSRem(comp_ctx->builder, offset,
|
||||
lane_bits[itype], "offset_fix"))) {
|
||||
|| !(offset = LLVMBuildSRem(comp_ctx->builder, offset, lane_bits[itype],
|
||||
"offset_fix"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSRem");
|
||||
return false;
|
||||
}
|
||||
@ -72,15 +69,15 @@ simd_shift(AOTCompContext *comp_ctx,
|
||||
|
||||
/* splat to a vector */
|
||||
if (!(offset =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undef[itype], offset,
|
||||
I32_ZERO, "offset_vector_base"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undef[itype], offset,
|
||||
I32_ZERO, "offset_vector_base"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(offset =
|
||||
LLVMBuildShuffleVector(comp_ctx->builder, offset, undef[itype],
|
||||
mask[itype], "offset_vector"))) {
|
||||
LLVMBuildShuffleVector(comp_ctx->builder, offset, undef[itype],
|
||||
mask[itype], "offset_vector"))) {
|
||||
HANDLE_FAILURE("LLVMBuildShuffleVector");
|
||||
return false;
|
||||
}
|
||||
@ -119,32 +116,28 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i8x16_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op)
|
||||
{
|
||||
return simd_shift(comp_ctx, func_ctx, shift_op, e_shift_i8x16);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i16x8_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op)
|
||||
{
|
||||
return simd_shift(comp_ctx, func_ctx, shift_op, e_shift_i16x8);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i32x4_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op)
|
||||
{
|
||||
return simd_shift(comp_ctx, func_ctx, shift_op, e_shift_i32x4);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i64x2_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op)
|
||||
{
|
||||
return simd_shift(comp_ctx, func_ctx, shift_op, e_shift_i64x2);
|
||||
|
||||
@ -13,23 +13,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i8x16_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i16x8_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i32x4_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_shift(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i64x2_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntShift shift_op);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -47,8 +47,8 @@ simd_build_bitmask(const AOTCompContext *comp_ctx,
|
||||
|
||||
/* fill every bit in a lange with its sign bit */
|
||||
if (!(ashr_distance = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, element_type[itype], lane_bits[itype] - 1,
|
||||
lanes[itype]))) {
|
||||
comp_ctx, element_type[itype], lane_bits[itype] - 1,
|
||||
lanes[itype]))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -64,8 +64,8 @@ simd_build_bitmask(const AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (e_bitmask_i64x2 != itype) {
|
||||
if (!(vector = LLVMBuildSExt(comp_ctx->builder, vector,
|
||||
vector_ext_type, "zext_to_i64"))) {
|
||||
if (!(vector = LLVMBuildSExt(comp_ctx->builder, vector, vector_ext_type,
|
||||
"zext_to_i64"))) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -74,25 +74,25 @@ simd_build_bitmask(const AOTCompContext *comp_ctx,
|
||||
mask_element[i] = 0x1 << i;
|
||||
}
|
||||
|
||||
if (!(mask = simd_build_const_integer_vector(
|
||||
comp_ctx, I64_TYPE, mask_element, lanes[itype]))) {
|
||||
if (!(mask = simd_build_const_integer_vector(comp_ctx, I64_TYPE,
|
||||
mask_element, lanes[itype]))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(vector =
|
||||
LLVMBuildAnd(comp_ctx->builder, vector, mask, "mask_bits"))) {
|
||||
LLVMBuildAnd(comp_ctx->builder, vector, mask, "mask_bits"))) {
|
||||
HANDLE_FAILURE("LLVMBuildAnd");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic[itype],
|
||||
I64_TYPE, &vector_ext_type, 1, vector))) {
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic[itype],
|
||||
I64_TYPE, &vector_ext_type, 1, vector))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildTrunc(comp_ctx->builder, result, I32_TYPE, "to_i32"))) {
|
||||
LLVMBuildTrunc(comp_ctx->builder, result, I32_TYPE, "to_i32"))) {
|
||||
HANDLE_FAILURE("LLVMBuildTrunc");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
static bool
|
||||
v128_bitwise_two_component(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
v128_bitwise_two_component(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Bitwise bitwise_op)
|
||||
{
|
||||
LLVMValueRef vector1, vector2, result;
|
||||
@ -27,7 +26,7 @@ v128_bitwise_two_component(AOTCompContext *comp_ctx,
|
||||
break;
|
||||
case V128_OR:
|
||||
if (!(result =
|
||||
LLVMBuildOr(comp_ctx->builder, vector1, vector2, "or"))) {
|
||||
LLVMBuildOr(comp_ctx->builder, vector1, vector2, "or"))) {
|
||||
HANDLE_FAILURE("LLVMBuildAnd");
|
||||
goto fail;
|
||||
}
|
||||
@ -95,7 +94,7 @@ v128_bitwise_bitselect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
POP_V128(vector1);
|
||||
|
||||
if (!(vector1 =
|
||||
LLVMBuildAnd(comp_ctx->builder, vector1, vector3, "a_and_c"))) {
|
||||
LLVMBuildAnd(comp_ctx->builder, vector1, vector3, "a_and_c"))) {
|
||||
HANDLE_FAILURE("LLVMBuildAdd");
|
||||
goto fail;
|
||||
}
|
||||
@ -106,13 +105,13 @@ v128_bitwise_bitselect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
}
|
||||
|
||||
if (!(vector2 =
|
||||
LLVMBuildAnd(comp_ctx->builder, vector2, vector3, "b_and_c"))) {
|
||||
LLVMBuildAnd(comp_ctx->builder, vector2, vector3, "b_and_c"))) {
|
||||
HANDLE_FAILURE("LLVMBuildAdd");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildOr(comp_ctx->builder, vector1, vector2, "a_or_b"))) {
|
||||
LLVMBuildOr(comp_ctx->builder, vector1, vector2, "a_or_b"))) {
|
||||
HANDLE_FAILURE("LLVMBuildOr");
|
||||
goto fail;
|
||||
}
|
||||
@ -126,8 +125,7 @@ fail:
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_bitwise(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Bitwise bitwise_op)
|
||||
AOTFuncContext *func_ctx, V128Bitwise bitwise_op)
|
||||
{
|
||||
switch (bitwise_op) {
|
||||
case V128_AND:
|
||||
|
||||
@ -14,8 +14,7 @@ extern "C" {
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_bitwise(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Bitwise bitwise_op);
|
||||
AOTFuncContext *func_ctx, V128Bitwise bitwise_op);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
|
||||
@ -16,8 +16,7 @@ enum integer_all_true {
|
||||
};
|
||||
|
||||
static bool
|
||||
simd_all_true(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
simd_all_true(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
enum integer_all_true itype)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
@ -56,14 +55,14 @@ simd_all_true(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
/* check zero */
|
||||
if (!(result = aot_call_llvm_intrinsic(comp_ctx, func_ctx,
|
||||
intrinsic[itype], INT1_TYPE,
|
||||
&vector_i1_type, 1, result))) {
|
||||
if (!(result =
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic[itype],
|
||||
INT1_TYPE, &vector_i1_type, 1, result))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildZExt(comp_ctx->builder, result, I32_TYPE, "to_i32"))) {
|
||||
LLVMBuildZExt(comp_ctx->builder, result, I32_TYPE, "to_i32"))) {
|
||||
HANDLE_FAILURE("LLVMBuildZExt");
|
||||
goto fail;
|
||||
}
|
||||
@ -120,13 +119,13 @@ aot_compile_simd_v128_any_true(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, "llvm.vector.reduce.or.v128i1", INT1_TYPE,
|
||||
&vector_type, 1, vector))) {
|
||||
comp_ctx, func_ctx, "llvm.vector.reduce.or.v128i1", INT1_TYPE,
|
||||
&vector_type, 1, vector))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildZExt(comp_ctx->builder, result, I32_TYPE, "to_i32"))) {
|
||||
LLVMBuildZExt(comp_ctx->builder, result, I32_TYPE, "to_i32"))) {
|
||||
HANDLE_FAILURE("LLVMBuildZExt");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -7,8 +7,7 @@
|
||||
|
||||
LLVMValueRef
|
||||
simd_pop_v128_and_bitcast(const AOTCompContext *comp_ctx,
|
||||
const AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vec_type,
|
||||
const AOTFuncContext *func_ctx, LLVMTypeRef vec_type,
|
||||
const char *name)
|
||||
{
|
||||
LLVMValueRef number;
|
||||
@ -16,7 +15,7 @@ simd_pop_v128_and_bitcast(const AOTCompContext *comp_ctx,
|
||||
POP_V128(number);
|
||||
|
||||
if (!(number =
|
||||
LLVMBuildBitCast(comp_ctx->builder, number, vec_type, name))) {
|
||||
LLVMBuildBitCast(comp_ctx->builder, number, vec_type, name))) {
|
||||
HANDLE_FAILURE("LLVMBuildBitCast");
|
||||
goto fail;
|
||||
}
|
||||
@ -28,8 +27,7 @@ fail:
|
||||
|
||||
bool
|
||||
simd_bitcast_and_push_v128(const AOTCompContext *comp_ctx,
|
||||
const AOTFuncContext *func_ctx,
|
||||
LLVMValueRef vector,
|
||||
const AOTFuncContext *func_ctx, LLVMValueRef vector,
|
||||
const char *name)
|
||||
{
|
||||
if (!(vector = LLVMBuildBitCast(comp_ctx->builder, vector, V128_i64x2_TYPE,
|
||||
@ -66,8 +64,7 @@ simd_lane_id_to_llvm_value(AOTCompContext *comp_ctx, uint8 lane_id)
|
||||
LLVMValueRef
|
||||
simd_build_const_integer_vector(const AOTCompContext *comp_ctx,
|
||||
const LLVMTypeRef element_type,
|
||||
const int *element_value,
|
||||
uint32 length)
|
||||
const int *element_value, uint32 length)
|
||||
{
|
||||
LLVMValueRef vector = NULL;
|
||||
LLVMValueRef *elements;
|
||||
@ -79,7 +76,7 @@ simd_build_const_integer_vector(const AOTCompContext *comp_ctx,
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (!(elements[i] =
|
||||
LLVMConstInt(element_type, element_value[i], true))) {
|
||||
LLVMConstInt(element_type, element_value[i], true))) {
|
||||
HANDLE_FAILURE("LLVMConstInst");
|
||||
goto fail;
|
||||
}
|
||||
@ -98,8 +95,7 @@ fail:
|
||||
LLVMValueRef
|
||||
simd_build_splat_const_integer_vector(const AOTCompContext *comp_ctx,
|
||||
const LLVMTypeRef element_type,
|
||||
const int64 element_value,
|
||||
uint32 length)
|
||||
const int64 element_value, uint32 length)
|
||||
{
|
||||
LLVMValueRef vector = NULL, element;
|
||||
LLVMValueRef *elements;
|
||||
@ -131,8 +127,7 @@ fail:
|
||||
LLVMValueRef
|
||||
simd_build_splat_const_float_vector(const AOTCompContext *comp_ctx,
|
||||
const LLVMTypeRef element_type,
|
||||
const float element_value,
|
||||
uint32 length)
|
||||
const float element_value, uint32 length)
|
||||
{
|
||||
LLVMValueRef vector = NULL, element;
|
||||
LLVMValueRef *elements;
|
||||
|
||||
@ -17,14 +17,12 @@ is_target_x86(AOTCompContext *comp_ctx)
|
||||
|
||||
LLVMValueRef
|
||||
simd_pop_v128_and_bitcast(const AOTCompContext *comp_ctx,
|
||||
const AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vec_type,
|
||||
const AOTFuncContext *func_ctx, LLVMTypeRef vec_type,
|
||||
const char *name);
|
||||
|
||||
bool
|
||||
simd_bitcast_and_push_v128(const AOTCompContext *comp_ctx,
|
||||
const AOTFuncContext *func_ctx,
|
||||
LLVMValueRef vector,
|
||||
const AOTFuncContext *func_ctx, LLVMValueRef vector,
|
||||
const char *name);
|
||||
|
||||
LLVMValueRef
|
||||
@ -33,18 +31,15 @@ simd_lane_id_to_llvm_value(AOTCompContext *comp_ctx, uint8 lane_id);
|
||||
LLVMValueRef
|
||||
simd_build_const_integer_vector(const AOTCompContext *comp_ctx,
|
||||
const LLVMTypeRef element_type,
|
||||
const int *element_value,
|
||||
uint32 length);
|
||||
const int *element_value, uint32 length);
|
||||
|
||||
LLVMValueRef
|
||||
simd_build_splat_const_integer_vector(const AOTCompContext *comp_ctx,
|
||||
const LLVMTypeRef element_type,
|
||||
const int64 element_value,
|
||||
uint32 length);
|
||||
const int64 element_value, uint32 length);
|
||||
|
||||
LLVMValueRef
|
||||
simd_build_splat_const_float_vector(const AOTCompContext *comp_ctx,
|
||||
const LLVMTypeRef element_type,
|
||||
const float element_value,
|
||||
uint32 length);
|
||||
const float element_value, uint32 length);
|
||||
#endif /* _SIMD_COMMON_H_ */
|
||||
@ -86,10 +86,8 @@ fail:
|
||||
}
|
||||
|
||||
static bool
|
||||
interger_vector_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond,
|
||||
LLVMTypeRef vector_type)
|
||||
interger_vector_compare(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
IntCond cond, LLVMTypeRef vector_type)
|
||||
{
|
||||
LLVMValueRef vec1, vec2, result;
|
||||
LLVMIntPredicate int_pred;
|
||||
@ -110,14 +108,14 @@ interger_vector_compare(AOTCompContext *comp_ctx,
|
||||
}
|
||||
/* icmp <N x iX> %vec1, %vec2 */
|
||||
if (!(result =
|
||||
LLVMBuildICmp(comp_ctx->builder, int_pred, vec1, vec2, "cmp"))) {
|
||||
LLVMBuildICmp(comp_ctx->builder, int_pred, vec1, vec2, "cmp"))) {
|
||||
HANDLE_FAILURE("LLVMBuildICmp");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* sext <N x i1> %result to <N x iX> */
|
||||
if (!(result =
|
||||
LLVMBuildSExt(comp_ctx->builder, result, vector_type, "ext"))) {
|
||||
LLVMBuildSExt(comp_ctx->builder, result, vector_type, "ext"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSExt");
|
||||
goto fail;
|
||||
}
|
||||
@ -138,41 +136,35 @@ fail:
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond)
|
||||
AOTFuncContext *func_ctx, IntCond cond)
|
||||
{
|
||||
return interger_vector_compare(comp_ctx, func_ctx, cond, V128_i8x16_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond)
|
||||
AOTFuncContext *func_ctx, IntCond cond)
|
||||
{
|
||||
return interger_vector_compare(comp_ctx, func_ctx, cond, V128_i16x8_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond)
|
||||
AOTFuncContext *func_ctx, IntCond cond)
|
||||
{
|
||||
return interger_vector_compare(comp_ctx, func_ctx, cond, V128_i32x4_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond)
|
||||
AOTFuncContext *func_ctx, IntCond cond)
|
||||
{
|
||||
return interger_vector_compare(comp_ctx, func_ctx, cond, V128_i64x2_TYPE);
|
||||
}
|
||||
|
||||
static bool
|
||||
float_vector_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatCond cond,
|
||||
LLVMTypeRef vector_type,
|
||||
float_vector_compare(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatCond cond, LLVMTypeRef vector_type,
|
||||
LLVMTypeRef result_type)
|
||||
{
|
||||
LLVMValueRef vec1, vec2, result;
|
||||
@ -194,14 +186,14 @@ float_vector_compare(AOTCompContext *comp_ctx,
|
||||
}
|
||||
/* fcmp <N x iX> %vec1, %vec2 */
|
||||
if (!(result =
|
||||
LLVMBuildFCmp(comp_ctx->builder, real_pred, vec1, vec2, "cmp"))) {
|
||||
LLVMBuildFCmp(comp_ctx->builder, real_pred, vec1, vec2, "cmp"))) {
|
||||
HANDLE_FAILURE("LLVMBuildFCmp");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* sext <N x i1> %result to <N x iX> */
|
||||
if (!(result =
|
||||
LLVMBuildSExt(comp_ctx->builder, result, result_type, "ext"))) {
|
||||
LLVMBuildSExt(comp_ctx->builder, result, result_type, "ext"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSExt");
|
||||
goto fail;
|
||||
}
|
||||
@ -222,8 +214,7 @@ fail:
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatCond cond)
|
||||
AOTFuncContext *func_ctx, FloatCond cond)
|
||||
{
|
||||
return float_vector_compare(comp_ctx, func_ctx, cond, V128_f32x4_TYPE,
|
||||
V128_i32x4_TYPE);
|
||||
@ -231,8 +222,7 @@ aot_compile_simd_f32x4_compare(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatCond cond)
|
||||
AOTFuncContext *func_ctx, FloatCond cond)
|
||||
{
|
||||
return float_vector_compare(comp_ctx, func_ctx, cond, V128_f64x2_TYPE,
|
||||
V128_i64x2_TYPE);
|
||||
|
||||
@ -14,33 +14,27 @@ extern "C" {
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond);
|
||||
AOTFuncContext *func_ctx, IntCond cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond);
|
||||
AOTFuncContext *func_ctx, IntCond cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond);
|
||||
AOTFuncContext *func_ctx, IntCond cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
IntCond cond);
|
||||
AOTFuncContext *func_ctx, IntCond cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatCond cond);
|
||||
AOTFuncContext *func_ctx, FloatCond cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_compare(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatCond cond);
|
||||
AOTFuncContext *func_ctx, FloatCond cond);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
|
||||
@ -10,8 +10,7 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_const(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_v128_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
const uint8 *imm_bytes)
|
||||
{
|
||||
uint64 imm1, imm2;
|
||||
@ -26,8 +25,8 @@ aot_compile_simd_v128_const(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(agg1 =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, LLVM_CONST(i64x2_undef),
|
||||
first_long, I32_ZERO, "agg1"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, LLVM_CONST(i64x2_undef),
|
||||
first_long, I32_ZERO, "agg1"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
goto fail;
|
||||
}
|
||||
@ -51,8 +50,7 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_splat(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_splat(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode)
|
||||
{
|
||||
uint32 opcode_index = opcode - SIMD_i8x16_splat;
|
||||
@ -63,9 +61,8 @@ aot_compile_simd_splat(AOTCompContext *comp_ctx,
|
||||
LLVM_CONST(f32x4_undef), LLVM_CONST(f64x2_undef),
|
||||
};
|
||||
LLVMValueRef masks[] = {
|
||||
LLVM_CONST(i32x16_zero), LLVM_CONST(i32x8_zero),
|
||||
LLVM_CONST(i32x4_zero), LLVM_CONST(i32x2_zero),
|
||||
LLVM_CONST(i32x4_zero), LLVM_CONST(i32x2_zero),
|
||||
LLVM_CONST(i32x16_zero), LLVM_CONST(i32x8_zero), LLVM_CONST(i32x4_zero),
|
||||
LLVM_CONST(i32x2_zero), LLVM_CONST(i32x4_zero), LLVM_CONST(i32x2_zero),
|
||||
};
|
||||
|
||||
switch (opcode) {
|
||||
@ -75,7 +72,7 @@ aot_compile_simd_splat(AOTCompContext *comp_ctx,
|
||||
POP_I32(input);
|
||||
/* trunc i32 %input to i8 */
|
||||
value =
|
||||
LLVMBuildTrunc(comp_ctx->builder, input, INT8_TYPE, "trunc");
|
||||
LLVMBuildTrunc(comp_ctx->builder, input, INT8_TYPE, "trunc");
|
||||
break;
|
||||
}
|
||||
case SIMD_i16x8_splat:
|
||||
@ -84,7 +81,7 @@ aot_compile_simd_splat(AOTCompContext *comp_ctx,
|
||||
POP_I32(input);
|
||||
/* trunc i32 %input to i16 */
|
||||
value =
|
||||
LLVMBuildTrunc(comp_ctx->builder, input, INT16_TYPE, "trunc");
|
||||
LLVMBuildTrunc(comp_ctx->builder, input, INT16_TYPE, "trunc");
|
||||
break;
|
||||
}
|
||||
case SIMD_i32x4_splat:
|
||||
@ -118,23 +115,21 @@ aot_compile_simd_splat(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
/* insertelement <n x ty> undef, ty %value, i32 0 */
|
||||
if (!(base =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undefs[opcode_index],
|
||||
value, I32_ZERO, "base"))) {
|
||||
if (!(base = LLVMBuildInsertElement(comp_ctx->builder, undefs[opcode_index],
|
||||
value, I32_ZERO, "base"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* shufflevector <ty1> %base, <ty2> undef, <n x i32> zeroinitializer */
|
||||
if (!(new_vector = LLVMBuildShuffleVector(
|
||||
comp_ctx->builder, base, undefs[opcode_index], masks[opcode_index],
|
||||
"new_vector"))) {
|
||||
comp_ctx->builder, base, undefs[opcode_index],
|
||||
masks[opcode_index], "new_vector"))) {
|
||||
HANDLE_FAILURE("LLVMBuildShuffleVector");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return simd_bitcast_and_push_v128(comp_ctx, func_ctx, new_vector,
|
||||
"result");
|
||||
return simd_bitcast_and_push_v128(comp_ctx, func_ctx, new_vector, "result");
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -13,13 +13,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_const(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_v128_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
const uint8 *imm_bytes);
|
||||
|
||||
bool
|
||||
aot_compile_simd_splat(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_splat(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 splat_opcode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -10,10 +10,8 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
static bool
|
||||
simd_integer_narrow_x86(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef in_vector_type,
|
||||
LLVMTypeRef out_vector_type,
|
||||
simd_integer_narrow_x86(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef in_vector_type, LLVMTypeRef out_vector_type,
|
||||
const char *instrinsic)
|
||||
{
|
||||
LLVMValueRef vector1, vector2, result;
|
||||
@ -44,13 +42,9 @@ enum integer_sat_type {
|
||||
};
|
||||
|
||||
static LLVMValueRef
|
||||
simd_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
enum integer_sat_type itype,
|
||||
LLVMValueRef vector,
|
||||
LLVMValueRef min,
|
||||
LLVMValueRef max,
|
||||
bool is_signed)
|
||||
simd_saturate(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
enum integer_sat_type itype, LLVMValueRef vector,
|
||||
LLVMValueRef min, LLVMValueRef max, bool is_signed)
|
||||
{
|
||||
LLVMValueRef result;
|
||||
LLVMTypeRef vector_type;
|
||||
@ -101,13 +95,13 @@ simd_saturate(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx,
|
||||
is_signed ? smin_intrinsic[itype] : umin_intrinsic[itype],
|
||||
param_types[itype][0], param_types[itype], 2, vector, max))
|
||||
comp_ctx, func_ctx,
|
||||
is_signed ? smin_intrinsic[itype] : umin_intrinsic[itype],
|
||||
param_types[itype][0], param_types[itype], 2, vector, max))
|
||||
|| !(result = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx,
|
||||
is_signed ? smax_intrinsic[itype] : umax_intrinsic[itype],
|
||||
param_types[itype][0], param_types[itype], 2, result, min))) {
|
||||
comp_ctx, func_ctx,
|
||||
is_signed ? smax_intrinsic[itype] : umax_intrinsic[itype],
|
||||
param_types[itype][0], param_types[itype], 2, result, min))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -115,10 +109,8 @@ simd_saturate(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_integer_narrow_common(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
enum integer_sat_type itype,
|
||||
bool is_signed)
|
||||
simd_integer_narrow_common(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
enum integer_sat_type itype, bool is_signed)
|
||||
{
|
||||
LLVMValueRef vec1, vec2, min, max, mask, result;
|
||||
LLVMTypeRef in_vector_type[] = { V128_i16x8_TYPE, V128_i32x4_TYPE,
|
||||
@ -152,17 +144,17 @@ simd_integer_narrow_common(AOTCompContext *comp_ctx,
|
||||
|
||||
if (!(vec2 = simd_pop_v128_and_bitcast(comp_ctx, func_ctx,
|
||||
in_vector_type[itype], "vec2"))
|
||||
|| !(vec1 = simd_pop_v128_and_bitcast(
|
||||
comp_ctx, func_ctx, in_vector_type[itype], "vec1"))) {
|
||||
|| !(vec1 = simd_pop_v128_and_bitcast(comp_ctx, func_ctx,
|
||||
in_vector_type[itype], "vec1"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(max = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, min_max_type[itype],
|
||||
is_signed ? smax[itype] : umax[itype], length[itype]))
|
||||
comp_ctx, min_max_type[itype],
|
||||
is_signed ? smax[itype] : umax[itype], length[itype]))
|
||||
|| !(min = simd_build_splat_const_integer_vector(
|
||||
comp_ctx, min_max_type[itype],
|
||||
is_signed ? smin[itype] : umin[itype], length[itype]))) {
|
||||
comp_ctx, min_max_type[itype],
|
||||
is_signed ? smin[itype] : umin[itype], length[itype]))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -200,14 +192,13 @@ simd_integer_narrow_common(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_narrow_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
if (is_target_x86(comp_ctx)) {
|
||||
return simd_integer_narrow_x86(
|
||||
comp_ctx, func_ctx, V128_i16x8_TYPE, V128_i8x16_TYPE,
|
||||
is_signed ? "llvm.x86.sse2.packsswb.128"
|
||||
: "llvm.x86.sse2.packuswb.128");
|
||||
comp_ctx, func_ctx, V128_i16x8_TYPE, V128_i8x16_TYPE,
|
||||
is_signed ? "llvm.x86.sse2.packsswb.128"
|
||||
: "llvm.x86.sse2.packuswb.128");
|
||||
}
|
||||
else {
|
||||
return simd_integer_narrow_common(comp_ctx, func_ctx, e_sat_i16x8,
|
||||
@ -217,8 +208,7 @@ aot_compile_simd_i8x16_narrow_i16x8(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
if (is_target_x86(comp_ctx)) {
|
||||
return simd_integer_narrow_x86(comp_ctx, func_ctx, V128_i32x4_TYPE,
|
||||
@ -234,8 +224,7 @@ aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_narrow_i64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
/* TODO: x86 intrinsics */
|
||||
return simd_integer_narrow_common(comp_ctx, func_ctx, e_sat_i64x2,
|
||||
@ -249,12 +238,9 @@ enum integer_extend_type {
|
||||
};
|
||||
|
||||
static LLVMValueRef
|
||||
simd_integer_extension(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
enum integer_extend_type itype,
|
||||
LLVMValueRef vector,
|
||||
bool lower_half,
|
||||
bool is_signed)
|
||||
simd_integer_extension(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
enum integer_extend_type itype, LLVMValueRef vector,
|
||||
bool lower_half, bool is_signed)
|
||||
{
|
||||
LLVMValueRef mask, sub_vector, result;
|
||||
LLVMValueRef bits[] = {
|
||||
@ -308,8 +294,7 @@ simd_integer_extension(AOTCompContext *comp_ctx,
|
||||
static bool
|
||||
simd_integer_extension_wrapper(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
enum integer_extend_type itype,
|
||||
bool lower_half,
|
||||
enum integer_extend_type itype, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
@ -332,8 +317,7 @@ simd_integer_extension_wrapper(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_extend_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
return simd_integer_extension_wrapper(comp_ctx, func_ctx, e_ext_i8x16,
|
||||
@ -342,8 +326,7 @@ aot_compile_simd_i16x8_extend_i8x16(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_extend_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
return simd_integer_extension_wrapper(comp_ctx, func_ctx, e_ext_i16x8,
|
||||
@ -352,8 +335,7 @@ aot_compile_simd_i32x4_extend_i16x8(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_extend_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
return simd_integer_extension_wrapper(comp_ctx, func_ctx, e_ext_i32x4,
|
||||
@ -361,17 +343,15 @@ aot_compile_simd_i64x2_extend_i32x4(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
static LLVMValueRef
|
||||
simd_trunc_sat(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
const char *intrinsics,
|
||||
LLVMTypeRef in_vector_type,
|
||||
simd_trunc_sat(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
const char *intrinsics, LLVMTypeRef in_vector_type,
|
||||
LLVMTypeRef out_vector_type)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
LLVMTypeRef param_types[] = { in_vector_type };
|
||||
|
||||
if (!(vector = simd_pop_v128_and_bitcast(comp_ctx, func_ctx,
|
||||
in_vector_type, "vector"))) {
|
||||
if (!(vector = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, in_vector_type,
|
||||
"vector"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -386,8 +366,7 @@ simd_trunc_sat(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_trunc_sat_f32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
LLVMValueRef result;
|
||||
if (!(result = simd_trunc_sat(comp_ctx, func_ctx,
|
||||
@ -402,8 +381,7 @@ aot_compile_simd_i32x4_trunc_sat_f32x4(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_trunc_sat_f64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
LLVMValueRef result, zero, mask;
|
||||
LLVMTypeRef out_vector_type;
|
||||
@ -425,7 +403,7 @@ aot_compile_simd_i32x4_trunc_sat_f64x2(AOTCompContext *comp_ctx,
|
||||
V128_f64x2_TYPE, out_vector_type))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!(zero = LLVMConstNull(out_vector_type))) {
|
||||
HANDLE_FAILURE("LLVMConstNull");
|
||||
return false;
|
||||
@ -437,8 +415,8 @@ aot_compile_simd_i32x4_trunc_sat_f64x2(AOTCompContext *comp_ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(result = LLVMBuildShuffleVector(comp_ctx->builder, result, zero,
|
||||
mask, "extend"))) {
|
||||
if (!(result = LLVMBuildShuffleVector(comp_ctx->builder, result, zero, mask,
|
||||
"extend"))) {
|
||||
HANDLE_FAILURE("LLVMBuildShuffleVector");
|
||||
return false;
|
||||
}
|
||||
@ -447,10 +425,8 @@ aot_compile_simd_i32x4_trunc_sat_f64x2(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
static LLVMValueRef
|
||||
simd_integer_convert(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed,
|
||||
LLVMValueRef vector,
|
||||
simd_integer_convert(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool is_signed, LLVMValueRef vector,
|
||||
LLVMTypeRef out_vector_type)
|
||||
|
||||
{
|
||||
@ -468,8 +444,7 @@ simd_integer_convert(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_convert_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
|
||||
@ -488,8 +463,7 @@ aot_compile_simd_f32x4_convert_i32x4(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_convert_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed)
|
||||
AOTFuncContext *func_ctx, bool is_signed)
|
||||
{
|
||||
LLVMValueRef vector, mask, result;
|
||||
LLVMValueRef lanes[] = {
|
||||
@ -529,14 +503,12 @@ aot_compile_simd_f64x2_convert_i32x4(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_extadd_pairwise(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef in_vector_type,
|
||||
LLVMTypeRef out_vector_type,
|
||||
simd_extadd_pairwise(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef in_vector_type, LLVMTypeRef out_vector_type,
|
||||
bool is_signed)
|
||||
{
|
||||
LLVMValueRef vector, even_mask, odd_mask, sub_vector_even, sub_vector_odd,
|
||||
result;
|
||||
result;
|
||||
|
||||
LLVMValueRef even_element[] = {
|
||||
LLVM_CONST(i32_zero), LLVM_CONST(i32_two), LLVM_CONST(i32_four),
|
||||
@ -554,8 +526,8 @@ simd_extadd_pairwise(AOTCompContext *comp_ctx,
|
||||
/* assumption about i16x8 from i8x16 and i32x4 from i16x8 */
|
||||
uint8 mask_length = V128_i16x8_TYPE == out_vector_type ? 8 : 4;
|
||||
|
||||
if (!(vector = simd_pop_v128_and_bitcast(comp_ctx, func_ctx,
|
||||
in_vector_type, "vector"))) {
|
||||
if (!(vector = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, in_vector_type,
|
||||
"vector"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -567,9 +539,9 @@ simd_extadd_pairwise(AOTCompContext *comp_ctx,
|
||||
|
||||
/* shuffle a <16xi8> vector to two <8xi8> vectors */
|
||||
if (!(sub_vector_even = LLVMBuildShuffleVector(
|
||||
comp_ctx->builder, vector, vector, even_mask, "pick_even"))
|
||||
comp_ctx->builder, vector, vector, even_mask, "pick_even"))
|
||||
|| !(sub_vector_odd = LLVMBuildShuffleVector(
|
||||
comp_ctx->builder, vector, vector, odd_mask, "pick_odd"))) {
|
||||
comp_ctx->builder, vector, vector, odd_mask, "pick_odd"))) {
|
||||
HANDLE_FAILURE("LLVMBuildShuffleVector");
|
||||
return false;
|
||||
}
|
||||
@ -577,22 +549,22 @@ simd_extadd_pairwise(AOTCompContext *comp_ctx,
|
||||
/* sext/zext <8xi8> to <8xi16> */
|
||||
if (is_signed) {
|
||||
if (!(sub_vector_even =
|
||||
LLVMBuildSExt(comp_ctx->builder, sub_vector_even,
|
||||
out_vector_type, "even_sext"))
|
||||
LLVMBuildSExt(comp_ctx->builder, sub_vector_even,
|
||||
out_vector_type, "even_sext"))
|
||||
|| !(sub_vector_odd =
|
||||
LLVMBuildSExt(comp_ctx->builder, sub_vector_odd,
|
||||
out_vector_type, "odd_sext"))) {
|
||||
LLVMBuildSExt(comp_ctx->builder, sub_vector_odd,
|
||||
out_vector_type, "odd_sext"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSExt");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(sub_vector_even =
|
||||
LLVMBuildZExt(comp_ctx->builder, sub_vector_even,
|
||||
out_vector_type, "even_zext"))
|
||||
LLVMBuildZExt(comp_ctx->builder, sub_vector_even,
|
||||
out_vector_type, "even_zext"))
|
||||
|| !(sub_vector_odd =
|
||||
LLVMBuildZExt(comp_ctx->builder, sub_vector_odd,
|
||||
out_vector_type, "odd_zext"))) {
|
||||
LLVMBuildZExt(comp_ctx->builder, sub_vector_odd,
|
||||
out_vector_type, "odd_zext"))) {
|
||||
HANDLE_FAILURE("LLVMBuildZExt");
|
||||
return false;
|
||||
}
|
||||
@ -706,10 +678,8 @@ enum integer_extmul_type {
|
||||
};
|
||||
|
||||
static bool
|
||||
simd_integer_extmul(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
bool is_signed,
|
||||
simd_integer_extmul(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool lower_half, bool is_signed,
|
||||
enum integer_extmul_type itype)
|
||||
{
|
||||
LLVMValueRef vec1, vec2, result;
|
||||
@ -726,8 +696,8 @@ simd_integer_extmul(AOTCompContext *comp_ctx,
|
||||
|
||||
if (!(vec1 = simd_pop_v128_and_bitcast(comp_ctx, func_ctx,
|
||||
in_vector_type[itype], "vec1"))
|
||||
|| !(vec2 = simd_pop_v128_and_bitcast(
|
||||
comp_ctx, func_ctx, in_vector_type[itype], "vec2"))) {
|
||||
|| !(vec2 = simd_pop_v128_and_bitcast(comp_ctx, func_ctx,
|
||||
in_vector_type[itype], "vec2"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -747,8 +717,7 @@ simd_integer_extmul(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_extmul_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
return simd_integer_extmul(comp_ctx, func_ctx, lower_half, is_signed,
|
||||
@ -757,8 +726,7 @@ aot_compile_simd_i16x8_extmul_i8x16(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_extmul_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
return simd_integer_extmul(comp_ctx, func_ctx, lower_half, is_signed,
|
||||
@ -767,8 +735,7 @@ aot_compile_simd_i32x4_extmul_i16x8(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_extmul_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed)
|
||||
{
|
||||
return simd_integer_extmul(comp_ctx, func_ctx, lower_half, is_signed,
|
||||
|
||||
@ -14,35 +14,29 @@ extern "C" {
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_narrow_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed);
|
||||
AOTFuncContext *func_ctx, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed);
|
||||
AOTFuncContext *func_ctx, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_narrow_i64x2(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed);
|
||||
AOTFuncContext *func_ctx, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_extend_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_low,
|
||||
AOTFuncContext *func_ctx, bool is_low,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_extend_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_low,
|
||||
AOTFuncContext *func_ctx, bool is_low,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_extend_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
@ -57,13 +51,11 @@ aot_compile_simd_i32x4_trunc_sat_f64x2(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_convert_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed);
|
||||
AOTFuncContext *func_ctx, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_convert_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_signed);
|
||||
AOTFuncContext *func_ctx, bool is_signed);
|
||||
bool
|
||||
aot_compile_simd_i16x8_extadd_pairwise_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
@ -79,20 +71,17 @@ aot_compile_simd_i16x8_q15mulr_sat(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_extmul_i8x16(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_low,
|
||||
AOTFuncContext *func_ctx, bool is_low,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_extmul_i16x8(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool is_low,
|
||||
AOTFuncContext *func_ctx, bool is_low,
|
||||
bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_extmul_i32x4(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool lower_half,
|
||||
AOTFuncContext *func_ctx, bool lower_half,
|
||||
bool is_signed);
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
|
||||
@ -10,15 +10,13 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
static bool
|
||||
simd_v128_float_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op,
|
||||
LLVMTypeRef vector_type)
|
||||
simd_v128_float_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op, LLVMTypeRef vector_type)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, result = NULL;
|
||||
|
||||
if (!(rhs =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
|| !(lhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type,
|
||||
"lhs"))) {
|
||||
return false;
|
||||
@ -43,7 +41,7 @@ simd_v128_float_arith(AOTCompContext *comp_ctx,
|
||||
|
||||
if (!result) {
|
||||
HANDLE_FAILURE(
|
||||
"LLVMBuildFAdd/LLVMBuildFSub/LLVMBuildFMul/LLVMBuildFDiv");
|
||||
"LLVMBuildFAdd/LLVMBuildFSub/LLVMBuildFMul/LLVMBuildFDiv");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -51,26 +49,21 @@ simd_v128_float_arith(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_f32x4_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op)
|
||||
{
|
||||
return simd_v128_float_arith(comp_ctx, func_ctx, arith_op,
|
||||
V128_f32x4_TYPE);
|
||||
return simd_v128_float_arith(comp_ctx, func_ctx, arith_op, V128_f32x4_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_f64x2_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op)
|
||||
{
|
||||
return simd_v128_float_arith(comp_ctx, func_ctx, arith_op,
|
||||
V128_f64x2_TYPE);
|
||||
return simd_v128_float_arith(comp_ctx, func_ctx, arith_op, V128_f64x2_TYPE);
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_v128_float_neg(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
simd_v128_float_neg(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
@ -101,10 +94,8 @@ aot_compile_simd_f64x2_neg(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_float_intrinsic(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type,
|
||||
const char *intrinsic)
|
||||
simd_float_intrinsic(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type, const char *intrinsic)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
LLVMTypeRef param_types[1] = { vector_type };
|
||||
@ -115,8 +106,8 @@ simd_float_intrinsic(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic, vector_type,
|
||||
param_types, 1, vector))) {
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic,
|
||||
vector_type, param_types, 1, vector))) {
|
||||
HANDLE_FAILURE("LLVMBuildCall");
|
||||
return false;
|
||||
}
|
||||
@ -139,16 +130,14 @@ aot_compile_simd_f64x2_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_round(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_f32x4_round(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_float_intrinsic(comp_ctx, func_ctx, V128_f32x4_TYPE,
|
||||
"llvm.round.v4f32");
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_round(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_f64x2_round(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_float_intrinsic(comp_ctx, func_ctx, V128_f64x2_TYPE,
|
||||
"llvm.round.v2f64");
|
||||
@ -183,32 +172,28 @@ aot_compile_simd_f64x2_ceil(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_floor(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_f32x4_floor(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_float_intrinsic(comp_ctx, func_ctx, V128_f32x4_TYPE,
|
||||
"llvm.floor.v4f32");
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_floor(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_f64x2_floor(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_float_intrinsic(comp_ctx, func_ctx, V128_f64x2_TYPE,
|
||||
"llvm.floor.v2f64");
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_trunc(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_f32x4_trunc(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_float_intrinsic(comp_ctx, func_ctx, V128_f32x4_TYPE,
|
||||
"llvm.trunc.v4f32");
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_trunc(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
aot_compile_simd_f64x2_trunc(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_float_intrinsic(comp_ctx, func_ctx, V128_f64x2_TYPE,
|
||||
"llvm.trunc.v2f64");
|
||||
@ -231,16 +216,14 @@ aot_compile_simd_f64x2_nearest(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_float_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op,
|
||||
LLVMTypeRef vector_type)
|
||||
simd_float_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op, LLVMTypeRef vector_type)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, result;
|
||||
LLVMRealPredicate op = FLOAT_MIN == arith_op ? LLVMRealULT : LLVMRealUGT;
|
||||
|
||||
if (!(rhs =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
|| !(lhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type,
|
||||
"lhs"))) {
|
||||
return false;
|
||||
@ -252,7 +235,7 @@ simd_float_cmp(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildSelect(comp_ctx->builder, result, lhs, rhs, "select"))) {
|
||||
LLVMBuildSelect(comp_ctx->builder, result, lhs, rhs, "select"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSelect");
|
||||
return false;
|
||||
}
|
||||
@ -260,11 +243,11 @@ simd_float_cmp(AOTCompContext *comp_ctx,
|
||||
return simd_bitcast_and_push_v128(comp_ctx, func_ctx, result, "result");
|
||||
}
|
||||
|
||||
/*TODO: sugggest non-IA platforms check with "llvm.minimum.*" and "llvm.maximum.*" firstly */
|
||||
/*TODO: sugggest non-IA platforms check with "llvm.minimum.*" and
|
||||
* "llvm.maximum.*" firstly */
|
||||
bool
|
||||
aot_compile_simd_f32x4_min_max(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min)
|
||||
AOTFuncContext *func_ctx, bool run_min)
|
||||
{
|
||||
return simd_float_cmp(comp_ctx, func_ctx, run_min ? FLOAT_MIN : FLOAT_MAX,
|
||||
V128_f32x4_TYPE);
|
||||
@ -272,18 +255,15 @@ aot_compile_simd_f32x4_min_max(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_min_max(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min)
|
||||
AOTFuncContext *func_ctx, bool run_min)
|
||||
{
|
||||
return simd_float_cmp(comp_ctx, func_ctx, run_min ? FLOAT_MIN : FLOAT_MAX,
|
||||
V128_f64x2_TYPE);
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_float_pmin_max(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type,
|
||||
const char *intrinsic)
|
||||
simd_float_pmin_max(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type, const char *intrinsic)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, result;
|
||||
LLVMTypeRef param_types[2];
|
||||
@ -292,15 +272,15 @@ simd_float_pmin_max(AOTCompContext *comp_ctx,
|
||||
param_types[1] = vector_type;
|
||||
|
||||
if (!(rhs =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
|| !(lhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type,
|
||||
"lhs"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic, vector_type,
|
||||
param_types, 2, lhs, rhs))) {
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic,
|
||||
vector_type, param_types, 2, lhs, rhs))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -309,8 +289,7 @@ simd_float_pmin_max(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_pmin_pmax(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min)
|
||||
AOTFuncContext *func_ctx, bool run_min)
|
||||
{
|
||||
return simd_float_pmin_max(comp_ctx, func_ctx, V128_f32x4_TYPE,
|
||||
run_min ? "llvm.minnum.v4f32"
|
||||
@ -319,8 +298,7 @@ aot_compile_simd_f32x4_pmin_pmax(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_pmin_pmax(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min)
|
||||
AOTFuncContext *func_ctx, bool run_min)
|
||||
{
|
||||
return simd_float_pmin_max(comp_ctx, func_ctx, V128_f64x2_TYPE,
|
||||
run_min ? "llvm.minnum.v2f64"
|
||||
@ -340,8 +318,8 @@ aot_compile_simd_f64x2_demote(AOTCompContext *comp_ctx,
|
||||
|
||||
if (!(elem_0 = LLVMBuildExtractElement(comp_ctx->builder, vector,
|
||||
LLVM_CONST(i32_zero), "elem_0"))
|
||||
|| !(elem_1 = LLVMBuildExtractElement(
|
||||
comp_ctx->builder, vector, LLVM_CONST(i32_one), "elem_1"))) {
|
||||
|| !(elem_1 = LLVMBuildExtractElement(comp_ctx->builder, vector,
|
||||
LLVM_CONST(i32_one), "elem_1"))) {
|
||||
HANDLE_FAILURE("LLVMBuildExtractElement");
|
||||
return false;
|
||||
}
|
||||
@ -355,12 +333,12 @@ aot_compile_simd_f64x2_demote(AOTCompContext *comp_ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(result = LLVMBuildInsertElement(
|
||||
comp_ctx->builder, LLVM_CONST(f32x4_vec_zero), elem_0,
|
||||
LLVM_CONST(i32_zero), "new_vector_0"))
|
||||
if (!(result = LLVMBuildInsertElement(comp_ctx->builder,
|
||||
LLVM_CONST(f32x4_vec_zero), elem_0,
|
||||
LLVM_CONST(i32_zero), "new_vector_0"))
|
||||
|| !(result =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, result, elem_1,
|
||||
LLVM_CONST(i32_one), "new_vector_1"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, result, elem_1,
|
||||
LLVM_CONST(i32_one), "new_vector_1"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
return false;
|
||||
}
|
||||
@ -381,27 +359,27 @@ aot_compile_simd_f32x4_promote(AOTCompContext *comp_ctx,
|
||||
|
||||
if (!(elem_0 = LLVMBuildExtractElement(comp_ctx->builder, vector,
|
||||
LLVM_CONST(i32_zero), "elem_0"))
|
||||
|| !(elem_1 = LLVMBuildExtractElement(
|
||||
comp_ctx->builder, vector, LLVM_CONST(i32_one), "elem_1"))) {
|
||||
|| !(elem_1 = LLVMBuildExtractElement(comp_ctx->builder, vector,
|
||||
LLVM_CONST(i32_one), "elem_1"))) {
|
||||
HANDLE_FAILURE("LLVMBuildExtractElement");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* fpext <f32> elem to <f64> */
|
||||
if (!(elem_0 =
|
||||
LLVMBuildFPExt(comp_ctx->builder, elem_0, F64_TYPE, "elem_0_ext"))
|
||||
LLVMBuildFPExt(comp_ctx->builder, elem_0, F64_TYPE, "elem_0_ext"))
|
||||
|| !(elem_1 = LLVMBuildFPExt(comp_ctx->builder, elem_1, F64_TYPE,
|
||||
"elem_1_ext"))) {
|
||||
HANDLE_FAILURE("LLVMBuildFPExt");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(result = LLVMBuildInsertElement(
|
||||
comp_ctx->builder, LLVM_CONST(f64x2_vec_zero), elem_0,
|
||||
LLVM_CONST(i32_zero), "new_vector_0"))
|
||||
if (!(result = LLVMBuildInsertElement(comp_ctx->builder,
|
||||
LLVM_CONST(f64x2_vec_zero), elem_0,
|
||||
LLVM_CONST(i32_zero), "new_vector_0"))
|
||||
|| !(result =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, result, elem_1,
|
||||
LLVM_CONST(i32_one), "new_vector_1"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, result, elem_1,
|
||||
LLVM_CONST(i32_one), "new_vector_1"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -13,13 +13,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_f32x4_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_f64x2_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
FloatArithmetic arith_op);
|
||||
|
||||
bool
|
||||
@ -43,20 +41,16 @@ aot_compile_simd_f64x2_round(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_sqrt(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx);
|
||||
aot_compile_simd_f32x4_sqrt(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_sqrt(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx);
|
||||
aot_compile_simd_f64x2_sqrt(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_ceil(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx);
|
||||
aot_compile_simd_f32x4_ceil(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_ceil(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx);
|
||||
aot_compile_simd_f64x2_ceil(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_floor(AOTCompContext *comp_ctx,
|
||||
@ -84,23 +78,19 @@ aot_compile_simd_f64x2_nearest(AOTCompContext *comp_ctx,
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_min_max(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min);
|
||||
AOTFuncContext *func_ctx, bool run_min);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_min_max(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min);
|
||||
AOTFuncContext *func_ctx, bool run_min);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f32x4_pmin_pmax(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min);
|
||||
AOTFuncContext *func_ctx, bool run_min);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_pmin_pmax(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
bool run_min);
|
||||
AOTFuncContext *func_ctx, bool run_min);
|
||||
|
||||
bool
|
||||
aot_compile_simd_f64x2_demote(AOTCompContext *comp_ctx,
|
||||
|
||||
@ -9,15 +9,13 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
static bool
|
||||
simd_integer_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
LLVMTypeRef vector_type)
|
||||
simd_integer_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, LLVMTypeRef vector_type)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, result = NULL;
|
||||
|
||||
if (!(rhs =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
|| !(lhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type,
|
||||
"lhs"))) {
|
||||
return false;
|
||||
@ -47,32 +45,28 @@ simd_integer_arith(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i8x16_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op)
|
||||
{
|
||||
return simd_integer_arith(comp_ctx, func_ctx, arith_op, V128_i8x16_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i16x8_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op)
|
||||
{
|
||||
return simd_integer_arith(comp_ctx, func_ctx, arith_op, V128_i16x8_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i32x4_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op)
|
||||
{
|
||||
return simd_integer_arith(comp_ctx, func_ctx, arith_op, V128_i32x4_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i64x2_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op)
|
||||
{
|
||||
return simd_integer_arith(comp_ctx, func_ctx, arith_op, V128_i64x2_TYPE);
|
||||
@ -84,7 +78,7 @@ simd_neg(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMTypeRef type)
|
||||
LLVMValueRef vector, result;
|
||||
|
||||
if (!(vector =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, type, "vector"))) {
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, type, "vector"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -141,17 +135,14 @@ aot_compile_simd_i8x16_popcnt(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
static bool
|
||||
simd_v128_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
simd_v128_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type, V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, result;
|
||||
LLVMIntPredicate op;
|
||||
|
||||
if (!(rhs =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
|| !(lhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type,
|
||||
"lhs"))) {
|
||||
return false;
|
||||
@ -170,7 +161,7 @@ simd_v128_cmp(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildSelect(comp_ctx->builder, result, lhs, rhs, "select"))) {
|
||||
LLVMBuildSelect(comp_ctx->builder, result, lhs, rhs, "select"))) {
|
||||
HANDLE_FAILURE("LLVMBuildSelect");
|
||||
return false;
|
||||
}
|
||||
@ -179,30 +170,24 @@ simd_v128_cmp(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
aot_compile_simd_i8x16_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
return simd_v128_cmp(comp_ctx, func_ctx, V128_i8x16_TYPE, arith_op,
|
||||
is_signed);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
aot_compile_simd_i16x8_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
return simd_v128_cmp(comp_ctx, func_ctx, V128_i16x8_TYPE, arith_op,
|
||||
is_signed);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
aot_compile_simd_i32x4_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
return simd_v128_cmp(comp_ctx, func_ctx, V128_i32x4_TYPE, arith_op,
|
||||
is_signed);
|
||||
@ -210,10 +195,8 @@ aot_compile_simd_i32x4_cmp(AOTCompContext *comp_ctx,
|
||||
|
||||
/* llvm.abs.* */
|
||||
static bool
|
||||
simd_v128_abs(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
char *intrinsic,
|
||||
LLVMTypeRef vector_type)
|
||||
simd_v128_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
char *intrinsic, LLVMTypeRef vector_type)
|
||||
{
|
||||
LLVMValueRef vector, result;
|
||||
LLVMTypeRef param_types[] = { vector_type, INT1_TYPE };
|
||||
@ -236,29 +219,25 @@ simd_v128_abs(AOTCompContext *comp_ctx,
|
||||
bool
|
||||
aot_compile_simd_i8x16_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v16i8",
|
||||
V128_i8x16_TYPE);
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v16i8", V128_i8x16_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v8i16",
|
||||
V128_i16x8_TYPE);
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v8i16", V128_i16x8_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v4i32",
|
||||
V128_i32x4_TYPE);
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v4i32", V128_i32x4_TYPE);
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
{
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v2i64",
|
||||
V128_i64x2_TYPE);
|
||||
return simd_v128_abs(comp_ctx, func_ctx, "llvm.abs.v2i64", V128_i64x2_TYPE);
|
||||
}
|
||||
|
||||
enum integer_avgr_u {
|
||||
@ -270,8 +249,7 @@ enum integer_avgr_u {
|
||||
/* TODO: try int_x86_mmx_pavg_b and int_x86_mmx_pavg_w */
|
||||
/* (v1 + v2 + 1) / 2 */
|
||||
static bool
|
||||
simd_v128_avg(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
simd_v128_avg(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
enum integer_avgr_u itype)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, ones, result;
|
||||
@ -324,8 +302,8 @@ simd_v128_avg(AOTCompContext *comp_ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(result = LLVMBuildTrunc(comp_ctx->builder, result,
|
||||
vector_type[itype], "to_orig_type"))) {
|
||||
if (!(result = LLVMBuildTrunc(comp_ctx->builder, result, vector_type[itype],
|
||||
"to_orig_type"))) {
|
||||
HANDLE_FAILURE("LLVMBuildTrunc");
|
||||
return false;
|
||||
}
|
||||
@ -406,8 +384,8 @@ aot_compile_simd_i32x4_dot_i16x8(AOTCompContext *comp_ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(zero =
|
||||
simd_build_splat_const_integer_vector(comp_ctx, I32_TYPE, 0, 8))) {
|
||||
if (!(zero = simd_build_splat_const_integer_vector(comp_ctx, I32_TYPE, 0,
|
||||
8))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -13,23 +13,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i8x16_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i16x8_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i32x4_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic cond);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i64x2_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
aot_compile_simd_i64x2_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic cond);
|
||||
|
||||
bool
|
||||
@ -49,22 +45,16 @@ aot_compile_simd_i8x16_popcnt(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed);
|
||||
aot_compile_simd_i8x16_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed);
|
||||
aot_compile_simd_i16x8_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_cmp(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed);
|
||||
aot_compile_simd_i32x4_cmp(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i8x16_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||
|
||||
@ -12,12 +12,8 @@
|
||||
|
||||
/* data_length in bytes */
|
||||
static LLVMValueRef
|
||||
simd_load(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint32 align,
|
||||
uint32 offset,
|
||||
uint32 data_length,
|
||||
LLVMTypeRef ptr_type)
|
||||
simd_load(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, uint32 align,
|
||||
uint32 offset, uint32 data_length, LLVMTypeRef ptr_type)
|
||||
{
|
||||
LLVMValueRef maddr, data;
|
||||
|
||||
@ -44,15 +40,13 @@ simd_load(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_load(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint32 align,
|
||||
uint32 offset)
|
||||
aot_compile_simd_v128_load(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint32 align, uint32 offset)
|
||||
{
|
||||
LLVMValueRef result;
|
||||
|
||||
if (!(result =
|
||||
simd_load(comp_ctx, func_ctx, align, offset, 16, V128_PTR_TYPE))) {
|
||||
if (!(result = simd_load(comp_ctx, func_ctx, align, offset, 16,
|
||||
V128_PTR_TYPE))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -64,11 +58,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_extend(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset)
|
||||
aot_compile_simd_load_extend(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset)
|
||||
{
|
||||
LLVMValueRef sub_vector, result;
|
||||
uint32 opcode_index = opcode - SIMD_v128_load8x8_s;
|
||||
@ -119,11 +110,8 @@ aot_compile_simd_load_extend(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_splat(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset)
|
||||
aot_compile_simd_load_splat(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset)
|
||||
{
|
||||
uint32 opcode_index = opcode - SIMD_v128_load8_splat;
|
||||
LLVMValueRef element, result;
|
||||
@ -152,8 +140,8 @@ aot_compile_simd_load_splat(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undefs[opcode_index],
|
||||
element, I32_ZERO, "base"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undefs[opcode_index],
|
||||
element, I32_ZERO, "base"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
return false;
|
||||
}
|
||||
@ -169,11 +157,8 @@ aot_compile_simd_load_splat(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset,
|
||||
aot_compile_simd_load_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset,
|
||||
uint8 lane_id)
|
||||
{
|
||||
LLVMValueRef element, vector;
|
||||
@ -188,7 +173,7 @@ aot_compile_simd_load_lane(AOTCompContext *comp_ctx,
|
||||
bh_assert(opcode_index < 4);
|
||||
|
||||
if (!(vector = simd_pop_v128_and_bitcast(
|
||||
comp_ctx, func_ctx, vector_types[opcode_index], "src"))) {
|
||||
comp_ctx, func_ctx, vector_types[opcode_index], "src"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -208,11 +193,8 @@ aot_compile_simd_load_lane(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_zero(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset)
|
||||
aot_compile_simd_load_zero(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset)
|
||||
{
|
||||
LLVMValueRef element, result, mask;
|
||||
uint32 opcode_index = opcode - SIMD_v128_load32_zero;
|
||||
@ -242,8 +224,8 @@ aot_compile_simd_load_zero(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
if (!(result =
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undef[opcode_index],
|
||||
element, I32_ZERO, "vector"))) {
|
||||
LLVMBuildInsertElement(comp_ctx->builder, undef[opcode_index],
|
||||
element, I32_ZERO, "vector"))) {
|
||||
HANDLE_FAILURE("LLVMBuildInsertElement");
|
||||
return false;
|
||||
}
|
||||
@ -267,12 +249,8 @@ aot_compile_simd_load_zero(AOTCompContext *comp_ctx,
|
||||
|
||||
/* data_length in bytes */
|
||||
static bool
|
||||
simd_store(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint32 align,
|
||||
uint32 offset,
|
||||
uint32 data_length,
|
||||
LLVMValueRef value,
|
||||
simd_store(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, uint32 align,
|
||||
uint32 offset, uint32 data_length, LLVMValueRef value,
|
||||
LLVMTypeRef value_ptr_type)
|
||||
{
|
||||
LLVMValueRef maddr, result;
|
||||
@ -298,10 +276,8 @@ simd_store(AOTCompContext *comp_ctx,
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_store(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint32 align,
|
||||
uint32 offset)
|
||||
aot_compile_simd_v128_store(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint32 align, uint32 offset)
|
||||
{
|
||||
LLVMValueRef value;
|
||||
|
||||
@ -314,11 +290,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_simd_store_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset,
|
||||
aot_compile_simd_store_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset,
|
||||
uint8 lane_id)
|
||||
{
|
||||
LLVMValueRef element, vector;
|
||||
@ -333,7 +306,7 @@ aot_compile_simd_store_lane(AOTCompContext *comp_ctx,
|
||||
bh_assert(opcode_index < 4);
|
||||
|
||||
if (!(vector = simd_pop_v128_and_bitcast(
|
||||
comp_ctx, func_ctx, vector_types[opcode_index], "src"))) {
|
||||
comp_ctx, func_ctx, vector_types[opcode_index], "src"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -13,52 +13,33 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_load(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint32 align,
|
||||
uint32 offset);
|
||||
aot_compile_simd_v128_load(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint32 align, uint32 offset);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_extend(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset);
|
||||
aot_compile_simd_load_extend(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_splat(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset);
|
||||
aot_compile_simd_load_splat(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset,
|
||||
aot_compile_simd_load_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset,
|
||||
uint8 lane_id);
|
||||
|
||||
bool
|
||||
aot_compile_simd_load_zero(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset);
|
||||
aot_compile_simd_load_zero(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset);
|
||||
|
||||
bool
|
||||
aot_compile_simd_v128_store(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint32 align,
|
||||
uint32 offset);
|
||||
aot_compile_simd_v128_store(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint32 align, uint32 offset);
|
||||
|
||||
bool
|
||||
aot_compile_simd_store_lane(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
uint8 opcode,
|
||||
uint32 align,
|
||||
uint32 offset,
|
||||
aot_compile_simd_store_lane(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
uint8 opcode, uint32 align, uint32 offset,
|
||||
uint8 lane_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -9,16 +9,14 @@
|
||||
#include "../../aot/aot_runtime.h"
|
||||
|
||||
static bool
|
||||
simd_sat_int_arith(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type,
|
||||
const char *intrinsics)
|
||||
simd_sat_int_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMTypeRef vector_type, const char *intrinsics)
|
||||
{
|
||||
LLVMValueRef lhs, rhs, result;
|
||||
LLVMTypeRef param_types[2];
|
||||
|
||||
if (!(rhs =
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type, "rhs"))
|
||||
|| !(lhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type,
|
||||
"lhs"))) {
|
||||
return false;
|
||||
@ -28,8 +26,8 @@ simd_sat_int_arith(AOTCompContext *comp_ctx,
|
||||
param_types[1] = vector_type;
|
||||
|
||||
if (!(result =
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsics,
|
||||
vector_type, param_types, 2, lhs, rhs))) {
|
||||
aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsics,
|
||||
vector_type, param_types, 2, lhs, rhs))) {
|
||||
HANDLE_FAILURE("LLVMBuildCall");
|
||||
return false;
|
||||
}
|
||||
@ -40,8 +38,7 @@ simd_sat_int_arith(AOTCompContext *comp_ctx,
|
||||
bool
|
||||
aot_compile_simd_i8x16_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
char *intrinsics[][2] = {
|
||||
{ "llvm.sadd.sat.v16i8", "llvm.uadd.sat.v16i8" },
|
||||
@ -56,8 +53,7 @@ aot_compile_simd_i8x16_saturate(AOTCompContext *comp_ctx,
|
||||
bool
|
||||
aot_compile_simd_i16x8_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
char *intrinsics[][2] = {
|
||||
{ "llvm.sadd.sat.v8i16", "llvm.uadd.sat.v8i16" },
|
||||
@ -72,8 +68,7 @@ aot_compile_simd_i16x8_saturate(AOTCompContext *comp_ctx,
|
||||
bool
|
||||
aot_compile_simd_i32x4_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed)
|
||||
V128Arithmetic arith_op, bool is_signed)
|
||||
{
|
||||
char *intrinsics[][2] = {
|
||||
{ "llvm.sadd.sat.v4i32", "llvm.uadd.sat.v4i32" },
|
||||
|
||||
@ -15,20 +15,17 @@ extern "C" {
|
||||
bool
|
||||
aot_compile_simd_i8x16_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed);
|
||||
V128Arithmetic arith_op, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i16x8_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed);
|
||||
V128Arithmetic arith_op, bool is_signed);
|
||||
|
||||
bool
|
||||
aot_compile_simd_i32x4_saturate(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx,
|
||||
V128Arithmetic arith_op,
|
||||
bool is_signed);
|
||||
V128Arithmetic arith_op, bool is_signed);
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user