Skip to content

Commit 072960f

Browse files
committed
Add zero load opcodes
1 parent 138faba commit 072960f

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6435,10 +6435,37 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
64356435
case SIMD_v128_store16_lane:
64366436
case SIMD_v128_store32_lane:
64376437
case SIMD_v128_store64_lane:
6438+
{
6439+
wasm_set_exception(module, "unsupported SIMD opcode");
6440+
break;
6441+
}
6442+
#define SIMD_LOAD_ZERO_OP(width) \
6443+
do { \
6444+
uint32 offset, addr; \
6445+
offset = read_uint32(frame_ip); \
6446+
int32 base = POP_I32(); \
6447+
offset += base; \
6448+
addr = GET_OPERAND(uint32, I32, 0); \
6449+
addr_ret = GET_OFFSET(); \
6450+
CHECK_MEMORY_OVERFLOW(width / 8); \
6451+
V128 v = { 0 }; \
6452+
if (width == 64) { \
6453+
v.i64x2[0] = GET_I64_FROM_ADDR(maddr); \
6454+
} \
6455+
else { \
6456+
v.i32x4[0] = *(uint32_t *)(maddr); \
6457+
} \
6458+
PUT_V128_TO_ADDR(frame_lp + addr_ret, v); \
6459+
} while (0)
6460+
64386461
case SIMD_v128_load32_zero:
6462+
{
6463+
SIMD_LOAD_ZERO_OP(32);
6464+
break;
6465+
}
64396466
case SIMD_v128_load64_zero:
64406467
{
6441-
wasm_set_exception(module, "unsupported SIMD opcode");
6468+
SIMD_LOAD_ZERO_OP(64);
64426469
break;
64436470
}
64446471

core/iwasm/interpreter/wasm_loader.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15397,7 +15397,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1539715397
}
1539815398

1539915399
read_leb_mem_offset(p, p_end, mem_offset); /* offset */
15400-
15400+
#if WASM_ENABLE_FAST_INTERP != 0
15401+
emit_uint32(loader_ctx, mem_offset);
15402+
#endif
1540115403
POP_AND_PUSH(mem_offset_type, VALUE_TYPE_V128);
1540215404
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
1540315405
func->has_memory_operations = true;

0 commit comments

Comments
 (0)