Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zero load opcodes #3943

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading