From b0202a73be7401a3720871f6ad473db14c46e962 Mon Sep 17 00:00:00 2001 From: Maks Litskevich Date: Mon, 23 Dec 2024 06:42:41 +0000 Subject: [PATCH] Add zero load opcodes --- core/iwasm/interpreter/wasm_interp_fast.c | 29 ++++++++++++++++++++++- core/iwasm/interpreter/wasm_loader.c | 4 +++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 5744b7ab10..956012d5a5 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -6435,10 +6435,37 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, case SIMD_v128_store16_lane: case SIMD_v128_store32_lane: case SIMD_v128_store64_lane: + { + wasm_set_exception(module, "unsupported SIMD opcode"); + break; + } +#define SIMD_LOAD_ZERO_OP(width) \ + do { \ + uint32 offset, addr; \ + offset = read_uint32(frame_ip); \ + int32 base = POP_I32(); \ + offset += base; \ + addr = GET_OPERAND(uint32, I32, 0); \ + addr_ret = GET_OFFSET(); \ + CHECK_MEMORY_OVERFLOW(width / 8); \ + V128 v = {0}; \ + if (width == 64) { \ + v.i64x2[0] = GET_I64_FROM_ADDR(maddr); \ + } \ + else { \ + v.i32x4[0] = *(uint32_t *)(maddr); \ + } \ + PUT_V128_TO_ADDR(frame_lp + addr_ret, v); \ + } while (0) + case SIMD_v128_load32_zero: + { + SIMD_LOAD_ZERO_OP(32); + break; + } case SIMD_v128_load64_zero: { - wasm_set_exception(module, "unsupported SIMD opcode"); + SIMD_LOAD_ZERO_OP(64); break; } diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 163f086141..a39dff89dc 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -15397,7 +15397,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } read_leb_mem_offset(p, p_end, mem_offset); /* offset */ - +#if WASM_ENABLE_FAST_INTERP != 0 + emit_uint32(loader_ctx, mem_offset); +#endif POP_AND_PUSH(mem_offset_type, VALUE_TYPE_V128); #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true;