mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 21:26:21 +00:00
Don't use constant float table on arm and riscv (#903)
Don't use constant float table on arm and riscv as LLVM doesn't generate .LPCI/.rodata like relocations on them, the float/double constants are encoded into instructions directly, so no need to lookup them from constant table. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
a9f1c2b64a
commit
a41c1ad85c
|
@ -61,6 +61,8 @@ static const aot_intrinsic g_intrinsic_mapping[] = {
|
||||||
{ "f64_promote_f32", "aot_intrinsic_f32_to_f64", AOT_INTRINSIC_FLAG_F32_TO_F64 },
|
{ "f64_promote_f32", "aot_intrinsic_f32_to_f64", AOT_INTRINSIC_FLAG_F32_TO_F64 },
|
||||||
{ "f32_cmp", "aot_intrinsic_f32_cmp", AOT_INTRINSIC_FLAG_F32_CMP },
|
{ "f32_cmp", "aot_intrinsic_f32_cmp", AOT_INTRINSIC_FLAG_F32_CMP },
|
||||||
{ "f64_cmp", "aot_intrinsic_f64_cmp", AOT_INTRINSIC_FLAG_F64_CMP },
|
{ "f64_cmp", "aot_intrinsic_f64_cmp", AOT_INTRINSIC_FLAG_F64_CMP },
|
||||||
|
{ "f32.const", NULL, AOT_INTRINSIC_FLAG_F32_CONST},
|
||||||
|
{ "f64.const", NULL, AOT_INTRINSIC_FLAG_F64_CONST},
|
||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
|
@ -617,6 +619,13 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
|
||||||
add_f64_common_intrinsics(comp_ctx);
|
add_f64_common_intrinsics(comp_ctx);
|
||||||
add_common_float_integer_convertion(comp_ctx);
|
add_common_float_integer_convertion(comp_ctx);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/*
|
||||||
|
* Use constant value table by default
|
||||||
|
*/
|
||||||
|
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F32_CONST);
|
||||||
|
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F64_CONST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 */
|
#endif /* WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 */
|
||||||
|
|
|
@ -57,6 +57,7 @@ extern "C" {
|
||||||
#define AOT_INTRINSIC_FLAG_F32_TO_U64 AOT_INTRINSIC_FLAG(0, 23)
|
#define AOT_INTRINSIC_FLAG_F32_TO_U64 AOT_INTRINSIC_FLAG(0, 23)
|
||||||
#define AOT_INTRINSIC_FLAG_F32_TO_F64 AOT_INTRINSIC_FLAG(0, 24)
|
#define AOT_INTRINSIC_FLAG_F32_TO_F64 AOT_INTRINSIC_FLAG(0, 24)
|
||||||
#define AOT_INTRINSIC_FLAG_F32_CMP AOT_INTRINSIC_FLAG(0, 25)
|
#define AOT_INTRINSIC_FLAG_F32_CMP AOT_INTRINSIC_FLAG(0, 25)
|
||||||
|
#define AOT_INTRINSIC_FLAG_F32_CONST AOT_INTRINSIC_FLAG(0, 26)
|
||||||
|
|
||||||
#define AOT_INTRINSIC_FLAG_F64_FADD AOT_INTRINSIC_FLAG(1, 0)
|
#define AOT_INTRINSIC_FLAG_F64_FADD AOT_INTRINSIC_FLAG(1, 0)
|
||||||
#define AOT_INTRINSIC_FLAG_F64_FSUB AOT_INTRINSIC_FLAG(1, 1)
|
#define AOT_INTRINSIC_FLAG_F64_FSUB AOT_INTRINSIC_FLAG(1, 1)
|
||||||
|
@ -84,6 +85,7 @@ extern "C" {
|
||||||
#define AOT_INTRINSIC_FLAG_F64_TO_U64 AOT_INTRINSIC_FLAG(1, 23)
|
#define AOT_INTRINSIC_FLAG_F64_TO_U64 AOT_INTRINSIC_FLAG(1, 23)
|
||||||
#define AOT_INTRINSIC_FLAG_F64_TO_F32 AOT_INTRINSIC_FLAG(1, 24)
|
#define AOT_INTRINSIC_FLAG_F64_TO_F32 AOT_INTRINSIC_FLAG(1, 24)
|
||||||
#define AOT_INTRINSIC_FLAG_F64_CMP AOT_INTRINSIC_FLAG(1, 25)
|
#define AOT_INTRINSIC_FLAG_F64_CMP AOT_INTRINSIC_FLAG(1, 25)
|
||||||
|
#define AOT_INTRINSIC_FLAG_F64_CONST AOT_INTRINSIC_FLAG(1, 26)
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
float32
|
float32
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "aot_emit_const.h"
|
#include "aot_emit_const.h"
|
||||||
|
#include "aot_intrinsic.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_compile_op_i32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
aot_compile_op_i32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
|
@ -36,12 +37,8 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
LLVMValueRef alloca, value;
|
LLVMValueRef alloca, value;
|
||||||
|
|
||||||
if (!isnan(f32_const)) {
|
if (!isnan(f32_const)) {
|
||||||
if (!comp_ctx->is_indirect_mode) {
|
if (comp_ctx->is_indirect_mode
|
||||||
value = F32_CONST(f32_const);
|
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
|
||||||
CHECK_LLVM_CONST(value);
|
|
||||||
PUSH_F32(value);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WASMValue wasm_value;
|
WASMValue wasm_value;
|
||||||
memcpy(&wasm_value.f32, &f32_const, sizeof(float32));
|
memcpy(&wasm_value.f32, &f32_const, sizeof(float32));
|
||||||
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
||||||
|
@ -51,6 +48,11 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
}
|
}
|
||||||
PUSH_F32(value);
|
PUSH_F32(value);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
value = F32_CONST(f32_const);
|
||||||
|
CHECK_LLVM_CONST(value);
|
||||||
|
PUSH_F32(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int32 i32_const;
|
int32 i32_const;
|
||||||
|
@ -89,12 +91,8 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
LLVMValueRef alloca, value;
|
LLVMValueRef alloca, value;
|
||||||
|
|
||||||
if (!isnan(f64_const)) {
|
if (!isnan(f64_const)) {
|
||||||
if (!comp_ctx->is_indirect_mode) {
|
if (comp_ctx->is_indirect_mode
|
||||||
value = F64_CONST(f64_const);
|
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
|
||||||
CHECK_LLVM_CONST(value);
|
|
||||||
PUSH_F64(value);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WASMValue wasm_value;
|
WASMValue wasm_value;
|
||||||
memcpy(&wasm_value.f64, &f64_const, sizeof(float64));
|
memcpy(&wasm_value.f64, &f64_const, sizeof(float64));
|
||||||
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
||||||
|
@ -104,6 +102,11 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
}
|
}
|
||||||
PUSH_F64(value);
|
PUSH_F64(value);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
value = F64_CONST(f64_const);
|
||||||
|
CHECK_LLVM_CONST(value);
|
||||||
|
PUSH_F64(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int64 i64_const;
|
int64 i64_const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user