Skip to content

Commit 441440f

Browse files
jammar1James Marsh
andauthored
Implement final SIMD opcodes: store lane (#4001)
Co-authored-by: James Marsh <mrshnja@amazon.co.uk>
1 parent dea195f commit 441440f

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6436,12 +6436,46 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
64366436
SIMD_LOAD_LANE_OP(i64x2, 64);
64376437
break;
64386438
}
6439+
#define SIMD_STORE_LANE_OP(register, width) \
6440+
do { \
6441+
uint32 offset, addr; \
6442+
offset = read_uint32(frame_ip); \
6443+
V128 vec = POP_V128(); \
6444+
int32 base = POP_I32(); \
6445+
offset += base; \
6446+
int lane = *frame_ip++; \
6447+
addr = GET_OPERAND(uint32, I32, 0); \
6448+
addr_ret = GET_OFFSET(); \
6449+
CHECK_MEMORY_OVERFLOW(width / 8); \
6450+
if (width == 64) { \
6451+
STORE_I64(maddr, vec.register[lane]); \
6452+
} \
6453+
else { \
6454+
*(uint##width *)(maddr) = vec.register[lane]; \
6455+
} \
6456+
} while (0)
6457+
64396458
case SIMD_v128_store8_lane:
6459+
{
6460+
SIMD_STORE_LANE_OP(i8x16, 8);
6461+
break;
6462+
}
6463+
64406464
case SIMD_v128_store16_lane:
6465+
{
6466+
SIMD_STORE_LANE_OP(i16x8, 16);
6467+
break;
6468+
}
6469+
64416470
case SIMD_v128_store32_lane:
6471+
{
6472+
SIMD_STORE_LANE_OP(i32x4, 32);
6473+
break;
6474+
}
6475+
64426476
case SIMD_v128_store64_lane:
64436477
{
6444-
wasm_set_exception(module, "unsupported SIMD opcode");
6478+
SIMD_STORE_LANE_OP(i64x2, 64);
64456479
break;
64466480
}
64476481
#define SIMD_LOAD_ZERO_OP(register, width) \

core/iwasm/interpreter/wasm_loader.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15362,6 +15362,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1536215362

1536315363
read_leb_mem_offset(p, p_end, mem_offset); /* offset */
1536415364

15365+
#if WASM_ENABLE_FAST_INTERP != 0
15366+
emit_uint32(loader_ctx, mem_offset);
15367+
#endif
15368+
1536515369
CHECK_BUF(p, p_end, 1);
1536615370
lane = read_uint8(p);
1536715371
if (!check_simd_access_lane(opcode1, lane, error_buf,

0 commit comments

Comments
 (0)