Skip to content

Commit cfcb946

Browse files
committed
Replace/extract opcodes for fast interp
1 parent 7b704e4 commit cfcb946

File tree

1 file changed

+68
-4
lines changed

1 file changed

+68
-4
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5993,25 +5993,89 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
59935993
SIMD_SPLAT_OP_F64(simde_wasm_f64x2_splat);
59945994
break;
59955995
}
5996-
5997-
// TODO:
5998-
/* Lane */
5996+
#define SIMD_EXTRACT_LANE_OP(register, return_type, push_elem) \
5997+
do { \
5998+
uint8 lane = *frame_ip++; \
5999+
V128 v = POP_V128(); \
6000+
push_elem((return_type)(v.register[lane])); \
6001+
} while (0)
6002+
#define SIMD_REPLACE_LANE_OP(register, return_type, pop_elem) \
6003+
do { \
6004+
uint8 lane = *frame_ip++; \
6005+
return_type replacement = pop_elem(); \
6006+
V128 v = POP_V128(); \
6007+
v.register[lane] = replacement; \
6008+
addr_ret = GET_OFFSET(); \
6009+
PUT_V128_TO_ADDR(frame_lp + addr_ret, v); \
6010+
} while (0)
59996011
case SIMD_i8x16_extract_lane_s:
6012+
{
6013+
SIMD_EXTRACT_LANE_OP(i8x16, int8, PUSH_I32);
6014+
break;
6015+
}
60006016
case SIMD_i8x16_extract_lane_u:
6017+
{
6018+
SIMD_EXTRACT_LANE_OP(i8x16, uint8, PUSH_I32);
6019+
break;
6020+
}
60016021
case SIMD_i8x16_replace_lane:
6022+
{
6023+
SIMD_REPLACE_LANE_OP(i8x16, int8, POP_I32);
6024+
break;
6025+
}
60026026
case SIMD_i16x8_extract_lane_s:
6027+
{
6028+
SIMD_EXTRACT_LANE_OP(i16x8, int16, PUSH_I32);
6029+
break;
6030+
}
60036031
case SIMD_i16x8_extract_lane_u:
6032+
{
6033+
SIMD_EXTRACT_LANE_OP(i16x8, uint16, PUSH_I32);
6034+
break;
6035+
}
60046036
case SIMD_i16x8_replace_lane:
6037+
{
6038+
SIMD_REPLACE_LANE_OP(i16x8, int16, POP_I32);
6039+
break;
6040+
}
60056041
case SIMD_i32x4_extract_lane:
6042+
{
6043+
SIMD_EXTRACT_LANE_OP(i32x4, int32, PUSH_I32);
6044+
break;
6045+
}
60066046
case SIMD_i32x4_replace_lane:
6047+
{
6048+
SIMD_REPLACE_LANE_OP(i32x4, int32, POP_I32);
6049+
break;
6050+
}
60076051
case SIMD_i64x2_extract_lane:
6052+
{
6053+
SIMD_EXTRACT_LANE_OP(i64x2, int64, PUSH_I64);
6054+
break;
6055+
}
60086056
case SIMD_i64x2_replace_lane:
6057+
{
6058+
SIMD_REPLACE_LANE_OP(i64x2, int64, POP_I64);
6059+
break;
6060+
}
60096061
case SIMD_f32x4_extract_lane:
6062+
{
6063+
SIMD_EXTRACT_LANE_OP(f32x4, float32, PUSH_F32);
6064+
break;
6065+
}
60106066
case SIMD_f32x4_replace_lane:
6067+
{
6068+
SIMD_REPLACE_LANE_OP(f32x4, float32, POP_F32);
6069+
break;
6070+
}
60116071
case SIMD_f64x2_extract_lane:
6072+
{
6073+
SIMD_EXTRACT_LANE_OP(f64x2, float64, PUSH_F64);
6074+
break;
6075+
}
60126076
case SIMD_f64x2_replace_lane:
60136077
{
6014-
wasm_set_exception(module, "unsupported SIMD opcode");
6078+
SIMD_REPLACE_LANE_OP(f64x2, float64, POP_F64);
60156079
break;
60166080
}
60176081

0 commit comments

Comments
 (0)