Skip to content

Commit

Permalink
Merge pull request #3943 from Zzzabiyaka/makslit/load_opcodes
Browse files Browse the repository at this point in the history
Add zero load opcodes
  • Loading branch information
loganek authored Dec 23, 2024
2 parents 138faba + 4cb9b1b commit dea195f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
40 changes: 32 additions & 8 deletions core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -6391,14 +6391,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
break;
}

#define SIMD_LOAD_LANE_OP(register, width) \
#define SIMD_LOAD_LANE_COMMON(vec, register, lane, width) \
do { \
uint32 offset, addr; \
offset = read_uint32(frame_ip); \
V128 vec = POP_V128(); \
int32 base = POP_I32(); \
offset += base; \
int lane = *frame_ip++; \
addr = GET_OPERAND(uint32, I32, 0); \
addr_ret = GET_OFFSET(); \
CHECK_MEMORY_OVERFLOW(width / 8); \
Expand All @@ -6411,6 +6405,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
PUT_V128_TO_ADDR(frame_lp + addr_ret, vec); \
} while (0)

#define SIMD_LOAD_LANE_OP(register, width) \
do { \
uint32 offset, addr; \
offset = read_uint32(frame_ip); \
V128 vec = POP_V128(); \
int32 base = POP_I32(); \
offset += base; \
int lane = *frame_ip++; \
SIMD_LOAD_LANE_COMMON(vec, register, lane, width); \
} while (0)

case SIMD_v128_load8_lane:
{
SIMD_LOAD_LANE_OP(i8x16, 8);
Expand All @@ -6435,10 +6440,29 @@ 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(register, width) \
do { \
uint32 offset, addr; \
offset = read_uint32(frame_ip); \
int32 base = POP_I32(); \
offset += base; \
int32 lane = 0; \
V128 vec = { 0 }; \
SIMD_LOAD_LANE_COMMON(vec, register, lane, width); \
} while (0)

case SIMD_v128_load32_zero:
{
SIMD_LOAD_ZERO_OP(i32x4, 32);
break;
}
case SIMD_v128_load64_zero:
{
wasm_set_exception(module, "unsupported SIMD opcode");
SIMD_LOAD_ZERO_OP(i64x2, 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 dea195f

Please sign in to comment.