Implement xtensa XIP (#1202)
Lookup table for i32.const and i64.const for xtensa XIP Lookup const offset from table for load/store opcodes for xtensa XIP Fill capability flags for xtensa XIP Enable lower switch pass for xtensa XIP
This commit is contained in:
@ -2742,8 +2742,9 @@ aot_require_lower_switch_pass(AOTCompContext *comp_ctx)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
/* IR switch/case will cause .rodata relocation on riscv */
|
||||
if (!strncmp(comp_ctx->target_arch, "riscv", 5)) {
|
||||
/* IR switch/case will cause .rodata relocation on riscv/xtensa */
|
||||
if (!strncmp(comp_ctx->target_arch, "riscv", 5)
|
||||
|| !strncmp(comp_ctx->target_arch, "xtensa", 6)) {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
|
||||
@ -10,8 +10,23 @@ bool
|
||||
aot_compile_op_i32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
int32 i32_const)
|
||||
{
|
||||
LLVMValueRef value = I32_CONST((uint32)i32_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
LLVMValueRef value;
|
||||
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "i32.const")) {
|
||||
WASMValue wasm_value;
|
||||
wasm_value.i32 = i32_const;
|
||||
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
||||
&wasm_value, VALUE_TYPE_I32);
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = I32_CONST((uint32)i32_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
}
|
||||
|
||||
PUSH_I32(value);
|
||||
return true;
|
||||
fail:
|
||||
@ -22,8 +37,23 @@ bool
|
||||
aot_compile_op_i64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
int64 i64_const)
|
||||
{
|
||||
LLVMValueRef value = I64_CONST((uint64)i64_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
LLVMValueRef value;
|
||||
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "i64.const")) {
|
||||
WASMValue wasm_value;
|
||||
wasm_value.i64 = i64_const;
|
||||
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
||||
&wasm_value, VALUE_TYPE_I64);
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = I64_CONST((uint64)i64_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
}
|
||||
|
||||
PUSH_I64(value);
|
||||
return true;
|
||||
fail:
|
||||
|
||||
@ -97,7 +97,19 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
|
||||
is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false;
|
||||
|
||||
CHECK_LLVM_CONST(offset_const);
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "i32.const")) {
|
||||
WASMValue wasm_value;
|
||||
wasm_value.i32 = offset;
|
||||
offset_const = aot_load_const_from_table(
|
||||
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_I32);
|
||||
if (!offset_const) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
CHECK_LLVM_CONST(offset_const);
|
||||
}
|
||||
|
||||
/* Get memory base address and memory data size */
|
||||
if (func_ctx->mem_space_unchanged
|
||||
|
||||
@ -800,9 +800,10 @@ is_targeting_soft_float(AOTCompContext *comp_ctx, bool is_f32)
|
||||
* so user must specify '--cpu-features=+soft-float' to wamrc if the target
|
||||
* doesn't have or enable FPU on arm, x86 or mips. */
|
||||
if (is_target_arm(comp_ctx) || is_target_x86(comp_ctx)
|
||||
|| is_target_mips(comp_ctx))
|
||||
|| is_target_mips(comp_ctx)) {
|
||||
ret = strstr(feature_string, "+soft-float") ? true : false;
|
||||
else if (is_target_xtensa(comp_ctx))
|
||||
}
|
||||
else if (is_target_xtensa(comp_ctx)) {
|
||||
/* Note:
|
||||
* 1. The Floating-Point Coprocessor Option of xtensa only support
|
||||
* single-precision floating-point operations, so must use soft-float
|
||||
@ -811,7 +812,11 @@ is_targeting_soft_float(AOTCompContext *comp_ctx, bool is_f32)
|
||||
* so user must specify '--cpu-features=-fp' to wamrc if the target
|
||||
* doesn't have or enable Floating-Point Coprocessor Option on xtensa.
|
||||
*/
|
||||
ret = (!is_f32 || strstr(feature_string, "-fp")) ? true : false;
|
||||
if (comp_ctx->disable_llvm_intrinsics)
|
||||
ret = false;
|
||||
else
|
||||
ret = (!is_f32 || strstr(feature_string, "-fp")) ? true : false;
|
||||
}
|
||||
else if (is_target_riscv(comp_ctx)) {
|
||||
/*
|
||||
* Note: Use builtin intrinsics since hardware float operation
|
||||
@ -823,8 +828,9 @@ is_targeting_soft_float(AOTCompContext *comp_ctx, bool is_f32)
|
||||
else
|
||||
ret = !strstr(feature_string, "+d") ? true : false;
|
||||
}
|
||||
else
|
||||
else {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
LLVMDisposeMessage(feature_string);
|
||||
return ret;
|
||||
|
||||
@ -2731,6 +2731,16 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
|
||||
int32 index;
|
||||
|
||||
switch (value_type) {
|
||||
case VALUE_TYPE_I32:
|
||||
/* Store the raw int bits of i32 const as a hex string */
|
||||
snprintf(buf, sizeof(buf), "i32#%08" PRIX32, value->i32);
|
||||
const_ptr_type = INT32_PTR_TYPE;
|
||||
break;
|
||||
case VALUE_TYPE_I64:
|
||||
/* Store the raw int bits of i64 const as a hex string */
|
||||
snprintf(buf, sizeof(buf), "i64#%016" PRIX64, value->i64);
|
||||
const_ptr_type = INT64_PTR_TYPE;
|
||||
break;
|
||||
case VALUE_TYPE_F32:
|
||||
/* Store the raw int bits of f32 const as a hex string */
|
||||
snprintf(buf, sizeof(buf), "f32#%08" PRIX32, value->i32);
|
||||
|
||||
Reference in New Issue
Block a user