Skip to content

Commit

Permalink
Add some loads, stores, more eqs
Browse files Browse the repository at this point in the history
  • Loading branch information
James Marsh committed Oct 21, 2024
1 parent 78c9a5e commit 71d129f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
38 changes: 37 additions & 1 deletion core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -5668,6 +5668,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
switch (opcode) {
/* Memory */
case SIMD_v128_load:
{
uint32 offset, addr;
offset = read_uint32(
frame_ip); // TODO: Check with an offset!
addr = GET_OPERAND(uint32, I32, 0);
frame_ip += 2;
addr_ret = GET_OFFSET();
CHECK_MEMORY_OVERFLOW(16);
PUT_V128_TO_ADDR(frame_lp + addr_ret, LOAD_V128(maddr));
break;
}
case SIMD_v128_load8x8_s:
case SIMD_v128_load8x8_u:
case SIMD_v128_load16x4_s:
Expand All @@ -5680,7 +5691,16 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
case SIMD_v128_load64_splat:
case SIMD_v128_store:
{
wasm_set_exception(module, "unsupported SIMD opcode");
uint32 offset, addr;
offset = read_uint32(frame_ip);
addr = GET_OPERAND(uint32, I32, 2);

V128 data;
data = POP_V128();
frame_ip += 2;

CHECK_MEMORY_OVERFLOW(16);
STORE_V128(maddr, data);
break;
}

Expand Down Expand Up @@ -5751,6 +5771,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
/* i8x16 comparison operations */
case SIMD_i8x16_eq:
{
// TODO: Use simde
V128 v1 = POP_V128();
V128 v2 = POP_V128();
int i;
Expand Down Expand Up @@ -5780,6 +5801,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

/* i16x8 comparison operations */
case SIMD_i16x8_eq:
{
// TODO: Use simde
V128 v1 = POP_V128();
V128 v2 = POP_V128();
int i;
addr_ret = GET_OFFSET();

V128 result;
for (i = 0; i < 8; i++) {
result.i16x8[i] =
v1.i16x8[i] == v2.i16x8[i] ? 0xffff : 0;
}
PUT_V128_TO_ADDR(frame_lp + addr_ret, result);
break;
}
case SIMD_i16x8_ne:
case SIMD_i16x8_lt_s:
case SIMD_i16x8_lt_u:
Expand Down
8 changes: 8 additions & 0 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -14934,6 +14934,10 @@ 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 All @@ -14953,6 +14957,10 @@ 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_V128();
POP_MEM_OFFSET();
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
Expand Down

0 comments on commit 71d129f

Please sign in to comment.