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:
@ -11,24 +11,24 @@
|
||||
|
||||
static bool
|
||||
trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef operand, LLVMTypeRef src_type, LLVMTypeRef dest_type,
|
||||
LLVMValueRef min_value, LLVMValueRef max_value,
|
||||
char *name, bool sign)
|
||||
LLVMValueRef operand, LLVMTypeRef src_type,
|
||||
LLVMTypeRef dest_type, LLVMValueRef min_value,
|
||||
LLVMValueRef max_value, char *name, bool sign)
|
||||
{
|
||||
LLVMBasicBlockRef check_nan_succ, check_overflow_succ;
|
||||
LLVMValueRef is_less, is_greater, res;
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp")) {
|
||||
comp_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp")) {
|
||||
LLVMTypeRef param_types[3];
|
||||
LLVMValueRef opcond = LLVMConstInt(I32_TYPE, FLOAT_UNO, true);
|
||||
param_types[0] = I32_TYPE;
|
||||
param_types[1] = src_type;
|
||||
param_types[2] = src_type;
|
||||
res = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
|
||||
I32_TYPE, param_types, 3, opcond, operand, operand);
|
||||
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
|
||||
I32_TYPE, param_types, 3, opcond, operand, operand);
|
||||
if (!res) {
|
||||
goto fail;
|
||||
}
|
||||
@ -44,10 +44,8 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(check_nan_succ =
|
||||
LLVMAppendBasicBlockInContext(comp_ctx->context,
|
||||
func_ctx->func,
|
||||
"check_nan_succ"))) {
|
||||
if (!(check_nan_succ = LLVMAppendBasicBlockInContext(
|
||||
comp_ctx->context, func_ctx->func, "check_nan_succ"))) {
|
||||
aot_set_last_error("llvm add basic block failed.");
|
||||
goto fail;
|
||||
}
|
||||
@ -55,26 +53,27 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMMoveBasicBlockAfter(check_nan_succ,
|
||||
LLVMGetInsertBlock(comp_ctx->builder));
|
||||
|
||||
if (!(aot_emit_exception(comp_ctx, func_ctx, EXCE_INVALID_CONVERSION_TO_INTEGER,
|
||||
true, res, check_nan_succ)))
|
||||
if (!(aot_emit_exception(comp_ctx, func_ctx,
|
||||
EXCE_INVALID_CONVERSION_TO_INTEGER, true, res,
|
||||
check_nan_succ)))
|
||||
goto fail;
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp")) {
|
||||
comp_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp")) {
|
||||
LLVMTypeRef param_types[3];
|
||||
LLVMValueRef opcond = LLVMConstInt(I32_TYPE, FLOAT_LE, true);
|
||||
param_types[0] = I32_TYPE;
|
||||
param_types[1] = src_type;
|
||||
param_types[2] = src_type;
|
||||
is_less = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
|
||||
I32_TYPE, param_types, 3, opcond, operand, min_value);
|
||||
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
|
||||
I32_TYPE, param_types, 3, opcond, operand, min_value);
|
||||
if (!is_less) {
|
||||
goto fail;
|
||||
}
|
||||
is_less =
|
||||
LLVMBuildIntCast(comp_ctx->builder, is_less, INT1_TYPE, "bit_cast");
|
||||
LLVMBuildIntCast(comp_ctx->builder, is_less, INT1_TYPE, "bit_cast");
|
||||
}
|
||||
else {
|
||||
is_less = LLVMBuildFCmp(comp_ctx->builder, LLVMRealOLE, operand,
|
||||
@ -88,15 +87,15 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp")) {
|
||||
comp_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp")) {
|
||||
LLVMTypeRef param_types[3];
|
||||
LLVMValueRef opcond = LLVMConstInt(I32_TYPE, FLOAT_GE, true);
|
||||
param_types[0] = I32_TYPE;
|
||||
param_types[1] = src_type;
|
||||
param_types[2] = src_type;
|
||||
is_greater = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
|
||||
I32_TYPE, param_types, 3, opcond, operand, max_value);
|
||||
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
|
||||
I32_TYPE, param_types, 3, opcond, operand, max_value);
|
||||
if (!is_greater) {
|
||||
goto fail;
|
||||
}
|
||||
@ -113,16 +112,15 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(res = LLVMBuildOr(comp_ctx->builder, is_less, is_greater, "is_overflow"))) {
|
||||
if (!(res = LLVMBuildOr(comp_ctx->builder, is_less, is_greater,
|
||||
"is_overflow"))) {
|
||||
aot_set_last_error("llvm build logic and failed.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Check if float value out of range */
|
||||
if (!(check_overflow_succ =
|
||||
LLVMAppendBasicBlockInContext(comp_ctx->context,
|
||||
func_ctx->func,
|
||||
"check_overflow_succ"))) {
|
||||
if (!(check_overflow_succ = LLVMAppendBasicBlockInContext(
|
||||
comp_ctx->context, func_ctx->func, "check_overflow_succ"))) {
|
||||
aot_set_last_error("llvm add basic block failed.");
|
||||
goto fail;
|
||||
}
|
||||
@ -130,8 +128,8 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMMoveBasicBlockAfter(check_overflow_succ,
|
||||
LLVMGetInsertBlock(comp_ctx->builder));
|
||||
|
||||
if (!(aot_emit_exception(comp_ctx, func_ctx, EXCE_INTEGER_OVERFLOW,
|
||||
true, res, check_overflow_succ)))
|
||||
if (!(aot_emit_exception(comp_ctx, func_ctx, EXCE_INTEGER_OVERFLOW, true,
|
||||
res, check_overflow_succ)))
|
||||
goto fail;
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
@ -162,22 +160,22 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
#define ADD_BASIC_BLOCK(block, name) do { \
|
||||
if (!(block = LLVMAppendBasicBlockInContext(comp_ctx->context, \
|
||||
func_ctx->func, \
|
||||
name))) { \
|
||||
aot_set_last_error("llvm add basic block failed."); \
|
||||
goto fail; \
|
||||
} \
|
||||
\
|
||||
LLVMMoveBasicBlockAfter(block, LLVMGetInsertBlock(comp_ctx->builder)); \
|
||||
} while (0)
|
||||
#define ADD_BASIC_BLOCK(block, name) \
|
||||
do { \
|
||||
if (!(block = LLVMAppendBasicBlockInContext(comp_ctx->context, \
|
||||
func_ctx->func, name))) { \
|
||||
aot_set_last_error("llvm add basic block failed."); \
|
||||
goto fail; \
|
||||
} \
|
||||
\
|
||||
LLVMMoveBasicBlockAfter(block, LLVMGetInsertBlock(comp_ctx->builder)); \
|
||||
} while (0)
|
||||
|
||||
static bool
|
||||
trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef operand, LLVMTypeRef src_type, LLVMTypeRef dest_type,
|
||||
LLVMValueRef min_value, LLVMValueRef max_value,
|
||||
char *name, bool sign)
|
||||
LLVMValueRef operand, LLVMTypeRef src_type,
|
||||
LLVMTypeRef dest_type, LLVMValueRef min_value,
|
||||
LLVMValueRef max_value, char *name, bool sign)
|
||||
{
|
||||
LLVMBasicBlockRef check_nan_succ, check_less_succ, check_greater_succ;
|
||||
LLVMBasicBlockRef is_nan_block, is_less_block, is_greater_block, res_block;
|
||||
@ -185,8 +183,8 @@ trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef zero = (dest_type == I32_TYPE) ? I32_ZERO : I64_ZERO;
|
||||
LLVMValueRef vmin, vmax;
|
||||
|
||||
if (!(res = LLVMBuildFCmp(comp_ctx->builder, LLVMRealUNO,
|
||||
operand, operand, "fcmp_is_nan"))) {
|
||||
if (!(res = LLVMBuildFCmp(comp_ctx->builder, LLVMRealUNO, operand, operand,
|
||||
"fcmp_is_nan"))) {
|
||||
aot_set_last_error("llvm build fcmp failed.");
|
||||
goto fail;
|
||||
}
|
||||
@ -199,8 +197,8 @@ trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
ADD_BASIC_BLOCK(is_greater_block, "is_greater_block");
|
||||
ADD_BASIC_BLOCK(res_block, "res_block");
|
||||
|
||||
if (!LLVMBuildCondBr(comp_ctx->builder, res,
|
||||
is_nan_block, check_nan_succ)) {
|
||||
if (!LLVMBuildCondBr(comp_ctx->builder, res, is_nan_block,
|
||||
check_nan_succ)) {
|
||||
aot_set_last_error("llvm build cond br failed.");
|
||||
goto fail;
|
||||
}
|
||||
@ -219,8 +217,8 @@ trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
aot_set_last_error("llvm build fcmp failed.");
|
||||
goto fail;
|
||||
}
|
||||
if (!LLVMBuildCondBr(comp_ctx->builder, is_less,
|
||||
is_less_block, check_less_succ)) {
|
||||
if (!LLVMBuildCondBr(comp_ctx->builder, is_less, is_less_block,
|
||||
check_less_succ)) {
|
||||
aot_set_last_error("llvm build cond br failed.");
|
||||
goto fail;
|
||||
}
|
||||
@ -239,8 +237,8 @@ trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
aot_set_last_error("llvm build fcmp failed.");
|
||||
goto fail;
|
||||
}
|
||||
if (!LLVMBuildCondBr(comp_ctx->builder, is_greater,
|
||||
is_greater_block, check_greater_succ)) {
|
||||
if (!LLVMBuildCondBr(comp_ctx->builder, is_greater, is_greater_block,
|
||||
check_greater_succ)) {
|
||||
aot_set_last_error("llvm build cond br failed.");
|
||||
goto fail;
|
||||
}
|
||||
@ -281,8 +279,7 @@ trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
/* Start to translate res_block */
|
||||
LLVMPositionBuilderAtEnd(comp_ctx->builder, res_block);
|
||||
/* Create result phi */
|
||||
if (!(phi = LLVMBuildPhi(comp_ctx->builder,
|
||||
dest_type,
|
||||
if (!(phi = LLVMBuildPhi(comp_ctx->builder, dest_type,
|
||||
"trunc_sat_result_phi"))) {
|
||||
aot_set_last_error("llvm build phi failed.");
|
||||
return false;
|
||||
@ -330,7 +327,8 @@ aot_compile_op_i32_wrap_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
|
||||
POP_I64(value);
|
||||
|
||||
if (!(res = LLVMBuildTrunc(comp_ctx->builder, value, I32_TYPE, "i32_wrap_i64"))) {
|
||||
if (!(res = LLVMBuildTrunc(comp_ctx->builder, value, I32_TYPE,
|
||||
"i32_wrap_i64"))) {
|
||||
aot_set_last_error("llvm build conversion failed.");
|
||||
return false;
|
||||
}
|
||||
@ -360,14 +358,13 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
|
||||
if (!saturating)
|
||||
return trunc_float_to_int(comp_ctx, func_ctx, value,
|
||||
F32_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_f32_s" : "i32_trunc_f32_u", sign);
|
||||
return trunc_float_to_int(
|
||||
comp_ctx, func_ctx, value, F32_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_f32_s" : "i32_trunc_f32_u", sign);
|
||||
else
|
||||
return trunc_sat_float_to_int(comp_ctx, func_ctx, value,
|
||||
F32_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_sat_f32_s" :
|
||||
"i32_trunc_sat_f32_u", sign);
|
||||
return trunc_sat_float_to_int(
|
||||
comp_ctx, func_ctx, value, F32_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_sat_f32_s" : "i32_trunc_sat_f32_u", sign);
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
@ -391,30 +388,31 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
|
||||
if (!saturating)
|
||||
return trunc_float_to_int(comp_ctx, func_ctx, value,
|
||||
F64_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_f64_s" : "i32_trunc_f64_u", sign);
|
||||
return trunc_float_to_int(
|
||||
comp_ctx, func_ctx, value, F64_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_f64_s" : "i32_trunc_f64_u", sign);
|
||||
else
|
||||
return trunc_sat_float_to_int(comp_ctx, func_ctx, value,
|
||||
F64_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_sat_f64_s" :
|
||||
"i32_trunc_sat_f64_u", sign);
|
||||
return trunc_sat_float_to_int(
|
||||
comp_ctx, func_ctx, value, F64_TYPE, I32_TYPE, min_value, max_value,
|
||||
sign ? "i32_trunc_sat_f64_s" : "i32_trunc_sat_f64_u", sign);
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_i64_extend_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool sign)
|
||||
aot_compile_op_i64_extend_i32(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, bool sign)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
POP_I32(value);
|
||||
|
||||
if (sign)
|
||||
res = LLVMBuildSExt(comp_ctx->builder, value, I64_TYPE, "i64_extend_i32_s");
|
||||
res = LLVMBuildSExt(comp_ctx->builder, value, I64_TYPE,
|
||||
"i64_extend_i32_s");
|
||||
else
|
||||
res = LLVMBuildZExt(comp_ctx->builder, value, I64_TYPE, "i64_extend_i32_u");
|
||||
res = LLVMBuildZExt(comp_ctx->builder, value, I64_TYPE,
|
||||
"i64_extend_i32_u");
|
||||
if (!res) {
|
||||
aot_set_last_error("llvm build conversion failed.");
|
||||
return false;
|
||||
@ -427,24 +425,24 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_i64_extend_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
int8 bitwidth)
|
||||
aot_compile_op_i64_extend_i64(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, int8 bitwidth)
|
||||
{
|
||||
LLVMValueRef value, res, cast_value = NULL;
|
||||
|
||||
POP_I64(value);
|
||||
|
||||
if (bitwidth == 8) {
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value,
|
||||
INT8_TYPE, true, "i8_intcast_i64");
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value, INT8_TYPE,
|
||||
true, "i8_intcast_i64");
|
||||
}
|
||||
else if (bitwidth == 16) {
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value,
|
||||
INT16_TYPE, true, "i16_intcast_i64");
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value, INT16_TYPE,
|
||||
true, "i16_intcast_i64");
|
||||
}
|
||||
else if (bitwidth == 32) {
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value,
|
||||
I32_TYPE, true, "i32_intcast_i64");
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value, I32_TYPE, true,
|
||||
"i32_intcast_i64");
|
||||
}
|
||||
|
||||
if (!cast_value) {
|
||||
@ -452,7 +450,8 @@ aot_compile_op_i64_extend_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx
|
||||
return false;
|
||||
}
|
||||
|
||||
res = LLVMBuildSExt(comp_ctx->builder, cast_value, I64_TYPE, "i64_extend_i64_s");
|
||||
res = LLVMBuildSExt(comp_ctx->builder, cast_value, I64_TYPE,
|
||||
"i64_extend_i64_s");
|
||||
|
||||
if (!res) {
|
||||
aot_set_last_error("llvm build conversion failed.");
|
||||
@ -466,20 +465,20 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_i32_extend_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
int8 bitwidth)
|
||||
aot_compile_op_i32_extend_i32(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, int8 bitwidth)
|
||||
{
|
||||
LLVMValueRef value, res, cast_value = NULL;
|
||||
|
||||
POP_I32(value);
|
||||
|
||||
if (bitwidth == 8) {
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value,
|
||||
INT8_TYPE, true, "i8_intcast_i32");
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value, INT8_TYPE,
|
||||
true, "i8_intcast_i32");
|
||||
}
|
||||
else if (bitwidth == 16) {
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value,
|
||||
INT16_TYPE, true, "i16_intcast_i32");
|
||||
cast_value = LLVMBuildIntCast2(comp_ctx->builder, value, INT16_TYPE,
|
||||
true, "i16_intcast_i32");
|
||||
}
|
||||
|
||||
if (!cast_value) {
|
||||
@ -487,7 +486,8 @@ aot_compile_op_i32_extend_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx
|
||||
return false;
|
||||
}
|
||||
|
||||
res = LLVMBuildSExt(comp_ctx->builder, cast_value, I32_TYPE, "i32_extend_i32_s");
|
||||
res = LLVMBuildSExt(comp_ctx->builder, cast_value, I32_TYPE,
|
||||
"i32_extend_i32_s");
|
||||
|
||||
if (!res) {
|
||||
aot_set_last_error("llvm build conversion failed.");
|
||||
@ -519,14 +519,13 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
|
||||
if (!saturating)
|
||||
return trunc_float_to_int(comp_ctx, func_ctx, value,
|
||||
F32_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_f32_s" : "i64_trunc_f32_u", sign);
|
||||
return trunc_float_to_int(
|
||||
comp_ctx, func_ctx, value, F32_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_f32_s" : "i64_trunc_f32_u", sign);
|
||||
else
|
||||
return trunc_sat_float_to_int(comp_ctx, func_ctx, value,
|
||||
F32_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_sat_f32_s" :
|
||||
"i64_trunc_sat_f32_u", sign);
|
||||
return trunc_sat_float_to_int(
|
||||
comp_ctx, func_ctx, value, F32_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_sat_f32_s" : "i64_trunc_sat_f32_u", sign);
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
@ -550,22 +549,21 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
|
||||
if (!saturating)
|
||||
return trunc_float_to_int(comp_ctx, func_ctx, value,
|
||||
F64_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_f64_s" : "i64_trunc_f64_u", sign);
|
||||
return trunc_float_to_int(
|
||||
comp_ctx, func_ctx, value, F64_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_f64_s" : "i64_trunc_f64_u", sign);
|
||||
else
|
||||
return trunc_sat_float_to_int(comp_ctx, func_ctx, value,
|
||||
F64_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_sat_f64_s" :
|
||||
"i64_trunc_sat_f64_u", sign);
|
||||
return trunc_sat_float_to_int(
|
||||
comp_ctx, func_ctx, value, F64_TYPE, I64_TYPE, min_value, max_value,
|
||||
sign ? "i64_trunc_sat_f64_s" : "i64_trunc_sat_f64_u", sign);
|
||||
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_f32_convert_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool sign)
|
||||
aot_compile_op_f32_convert_i32(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, bool sign)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
@ -573,12 +571,13 @@ aot_compile_op_f32_convert_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ct
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, sign ? "f32_convert_i32_s" : "f32_convert_i32_u")) {
|
||||
comp_ctx, sign ? "f32_convert_i32_s" : "f32_convert_i32_u")) {
|
||||
LLVMTypeRef param_types[1];
|
||||
param_types[0] = I32_TYPE;
|
||||
res = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, sign ? "f32_convert_i32_s" : "f32_convert_i32_u",
|
||||
F32_TYPE, param_types, 1, value);
|
||||
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx,
|
||||
sign ? "f32_convert_i32_s"
|
||||
: "f32_convert_i32_u",
|
||||
F32_TYPE, param_types, 1, value);
|
||||
}
|
||||
else {
|
||||
if (sign)
|
||||
@ -600,8 +599,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_f32_convert_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool sign)
|
||||
aot_compile_op_f32_convert_i64(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, bool sign)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
@ -609,12 +608,13 @@ aot_compile_op_f32_convert_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ct
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, sign ? "f32_convert_i64_s" : "f32_convert_i64_u")) {
|
||||
comp_ctx, sign ? "f32_convert_i64_s" : "f32_convert_i64_u")) {
|
||||
LLVMTypeRef param_types[1];
|
||||
param_types[0] = I64_TYPE;
|
||||
res = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, sign ? "f32_convert_i64_s" : "f32_convert_i64_u",
|
||||
F32_TYPE, param_types, 1, value);
|
||||
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx,
|
||||
sign ? "f32_convert_i64_s"
|
||||
: "f32_convert_i64_u",
|
||||
F32_TYPE, param_types, 1, value);
|
||||
}
|
||||
else {
|
||||
if (sign)
|
||||
@ -637,7 +637,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_f32_demote_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
aot_compile_op_f32_demote_f64(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
@ -667,8 +668,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_f64_convert_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool sign)
|
||||
aot_compile_op_f64_convert_i32(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, bool sign)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
@ -676,13 +677,14 @@ aot_compile_op_f64_convert_i32(AOTCompContext *comp_ctx, AOTFuncContext *func_ct
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, sign ? "f64_convert_i32_s" : "f64_convert_i32_u")) {
|
||||
comp_ctx, sign ? "f64_convert_i32_s" : "f64_convert_i32_u")) {
|
||||
LLVMTypeRef param_types[1];
|
||||
param_types[0] = I32_TYPE;
|
||||
|
||||
res = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, sign ? "f64_convert_i32_s" : "f64_convert_i32_u",
|
||||
F64_TYPE, param_types, 1, value);
|
||||
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx,
|
||||
sign ? "f64_convert_i32_s"
|
||||
: "f64_convert_i32_u",
|
||||
F64_TYPE, param_types, 1, value);
|
||||
}
|
||||
else {
|
||||
if (sign)
|
||||
@ -705,8 +707,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_f64_convert_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
bool sign)
|
||||
aot_compile_op_f64_convert_i64(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx, bool sign)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
@ -714,13 +716,14 @@ aot_compile_op_f64_convert_i64(AOTCompContext *comp_ctx, AOTFuncContext *func_ct
|
||||
|
||||
if (comp_ctx->disable_llvm_intrinsics
|
||||
&& aot_intrinsic_check_capability(
|
||||
comp_ctx, sign ? "f64_convert_i64_s" : "f64_convert_i64_u")) {
|
||||
comp_ctx, sign ? "f64_convert_i64_s" : "f64_convert_i64_u")) {
|
||||
LLVMTypeRef param_types[1];
|
||||
param_types[0] = I64_TYPE;
|
||||
|
||||
res = aot_call_llvm_intrinsic(
|
||||
comp_ctx, func_ctx, sign ? "f64_convert_i64_s" : "f64_convert_i64_u",
|
||||
F64_TYPE, param_types, 1, value);
|
||||
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx,
|
||||
sign ? "f64_convert_i64_s"
|
||||
: "f64_convert_i64_u",
|
||||
F64_TYPE, param_types, 1, value);
|
||||
}
|
||||
else {
|
||||
if (sign)
|
||||
@ -743,7 +746,8 @@ fail:
|
||||
}
|
||||
|
||||
bool
|
||||
aot_compile_op_f64_promote_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
aot_compile_op_f64_promote_f32(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
{
|
||||
LLVMValueRef value, res;
|
||||
|
||||
@ -781,8 +785,8 @@ aot_compile_op_i64_reinterpret_f64(AOTCompContext *comp_ctx,
|
||||
{
|
||||
LLVMValueRef value;
|
||||
POP_F64(value);
|
||||
if (!(value = LLVMBuildBitCast(comp_ctx->builder, value,
|
||||
I64_TYPE, "i64"))) {
|
||||
if (!(value =
|
||||
LLVMBuildBitCast(comp_ctx->builder, value, I64_TYPE, "i64"))) {
|
||||
aot_set_last_error("llvm build fp to si failed.");
|
||||
return false;
|
||||
}
|
||||
@ -792,15 +796,14 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
aot_compile_op_i32_reinterpret_f32(AOTCompContext *comp_ctx,
|
||||
AOTFuncContext *func_ctx)
|
||||
{
|
||||
LLVMValueRef value;
|
||||
POP_F32(value);
|
||||
if (!(value = LLVMBuildBitCast(comp_ctx->builder, value,
|
||||
I32_TYPE, "i32"))) {
|
||||
if (!(value =
|
||||
LLVMBuildBitCast(comp_ctx->builder, value, I32_TYPE, "i32"))) {
|
||||
aot_set_last_error("llvm build fp to si failed.");
|
||||
return false;
|
||||
}
|
||||
@ -816,8 +819,8 @@ aot_compile_op_f64_reinterpret_i64(AOTCompContext *comp_ctx,
|
||||
{
|
||||
LLVMValueRef value;
|
||||
POP_I64(value);
|
||||
if (!(value = LLVMBuildBitCast(comp_ctx->builder, value,
|
||||
F64_TYPE, "f64"))) {
|
||||
if (!(value =
|
||||
LLVMBuildBitCast(comp_ctx->builder, value, F64_TYPE, "f64"))) {
|
||||
aot_set_last_error("llvm build si to fp failed.");
|
||||
return false;
|
||||
}
|
||||
@ -833,8 +836,8 @@ aot_compile_op_f32_reinterpret_i32(AOTCompContext *comp_ctx,
|
||||
{
|
||||
LLVMValueRef value;
|
||||
POP_I32(value);
|
||||
if (!(value = LLVMBuildBitCast(comp_ctx->builder, value,
|
||||
F32_TYPE, "f32"))) {
|
||||
if (!(value =
|
||||
LLVMBuildBitCast(comp_ctx->builder, value, F32_TYPE, "f32"))) {
|
||||
aot_set_last_error("llvm build si to fp failed.");
|
||||
return false;
|
||||
}
|
||||
@ -843,4 +846,3 @@ aot_compile_op_f32_reinterpret_i32(AOTCompContext *comp_ctx,
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user