Skip to content

Commit

Permalink
Add zero load opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzzabiyaka committed Dec 23, 2024
1 parent 138faba commit 072960f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 28 additions & 1 deletion core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 072960f

Please sign in to comment.