LibWasm: Store opcodes in 32 bits

Wasm opcodes only need one byte plus a 24-bit selector for
prefixed instructions. Store them in u32 instead of u64 and reject
selectors that would not fit. Update the Rust opcode generator to
accept the new integer suffixes used by Opcode.h.
This commit is contained in:
Andreas Kling 2026-05-14 10:16:22 +02:00 committed by Andreas Kling
parent e18d4f7418
commit f22dec54ef
5 changed files with 348 additions and 345 deletions

View file

@ -5881,7 +5881,7 @@ CompiledInstructions try_compile_instructions(Expression const& expression, Span
auto& function = functions[instruction.arguments().get<FunctionIndex>().value()];
if (function.results().size() <= 1 && function.parameters().size() < 4) {
pattern_state = InsnPatternState::Nothing;
OpCode op { Instructions::synthetic_call_00.value() + function.parameters().size() * 2 + function.results().size() };
OpCode op { static_cast<OpCode::Type>(Instructions::synthetic_call_00.value() + function.parameters().size() * 2 + function.results().size()) };
result.extra_instruction_storage.unchecked_append(Instruction(
op,
instruction.arguments()));

View file

@ -746,7 +746,7 @@ static CraneliftInsn serialize_insn(Dispatch const& dispatch, SourcesAndDestinat
out.imm3 = 0;
auto const& args = insn->arguments();
u64 opc = out.opcode;
u32 opc = out.opcode;
if (opc == Instructions::i32_const.value()) {
out.imm1 = static_cast<i64>(args.get<i32>());

View file

@ -10,7 +10,7 @@
namespace Wasm {
AK_TYPEDEF_DISTINCT_ORDERED_ID(u64, OpCode);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u32, OpCode);
namespace Instructions {
@ -208,347 +208,347 @@ namespace Instructions {
M(ref_func, 0xd2, 0, 1)
// These are synthetic opcodes, they are _not_ seen in wasm with these values.
#define ENUMERATE_MULTI_BYTE_WASM_OPCODES(M) \
M(i32_trunc_sat_f32_s, 0xfc00000000000000ull, 1, 1) \
M(i32_trunc_sat_f32_u, 0xfc00000000000001ull, 1, 1) \
M(i32_trunc_sat_f64_s, 0xfc00000000000002ull, 1, 1) \
M(i32_trunc_sat_f64_u, 0xfc00000000000003ull, 1, 1) \
M(i64_trunc_sat_f32_s, 0xfc00000000000004ull, 1, 1) \
M(i64_trunc_sat_f32_u, 0xfc00000000000005ull, 1, 1) \
M(i64_trunc_sat_f64_s, 0xfc00000000000006ull, 1, 1) \
M(i64_trunc_sat_f64_u, 0xfc00000000000007ull, 1, 1) \
M(memory_init, 0xfc00000000000008ull, 3, 0) \
M(data_drop, 0xfc00000000000009ull, 0, 0) \
M(memory_copy, 0xfc0000000000000aull, 3, 0) \
M(memory_fill, 0xfc0000000000000bull, 3, 0) \
M(table_init, 0xfc0000000000000cull, 3, 0) \
M(elem_drop, 0xfc0000000000000dull, 0, 0) \
M(table_copy, 0xfc0000000000000eull, 3, 0) \
M(table_grow, 0xfc0000000000000full, 2, 1) \
M(table_size, 0xfc00000000000010ull, 0, 1) \
M(table_fill, 0xfc00000000000011ull, 3, 0) \
M(v128_load, 0xfd00000000000000ull, 1, 1) \
M(v128_load8x8_s, 0xfd00000000000001ull, 1, 1) \
M(v128_load8x8_u, 0xfd00000000000002ull, 1, 1) \
M(v128_load16x4_s, 0xfd00000000000003ull, 1, 1) \
M(v128_load16x4_u, 0xfd00000000000004ull, 1, 1) \
M(v128_load32x2_s, 0xfd00000000000005ull, 1, 1) \
M(v128_load32x2_u, 0xfd00000000000006ull, 1, 1) \
M(v128_load8_splat, 0xfd00000000000007ull, 1, 1) \
M(v128_load16_splat, 0xfd00000000000008ull, 1, 1) \
M(v128_load32_splat, 0xfd00000000000009ull, 1, 1) \
M(v128_load64_splat, 0xfd0000000000000aull, 1, 1) \
M(v128_store, 0xfd0000000000000bull, 2, 0) \
M(v128_const, 0xfd0000000000000cull, 0, 1) \
M(i8x16_shuffle, 0xfd0000000000000dull, 2, 1) \
M(i8x16_swizzle, 0xfd0000000000000eull, 2, 1) \
M(i8x16_splat, 0xfd0000000000000full, 1, 1) \
M(i16x8_splat, 0xfd00000000000010ull, 1, 1) \
M(i32x4_splat, 0xfd00000000000011ull, 1, 1) \
M(i64x2_splat, 0xfd00000000000012ull, 1, 1) \
M(f32x4_splat, 0xfd00000000000013ull, 1, 1) \
M(f64x2_splat, 0xfd00000000000014ull, 1, 1) \
M(i8x16_extract_lane_s, 0xfd00000000000015ull, 1, 1) \
M(i8x16_extract_lane_u, 0xfd00000000000016ull, 1, 1) \
M(i8x16_replace_lane, 0xfd00000000000017ull, 2, 1) \
M(i16x8_extract_lane_s, 0xfd00000000000018ull, 1, 1) \
M(i16x8_extract_lane_u, 0xfd00000000000019ull, 1, 1) \
M(i16x8_replace_lane, 0xfd0000000000001aull, 2, 1) \
M(i32x4_extract_lane, 0xfd0000000000001bull, 1, 1) \
M(i32x4_replace_lane, 0xfd0000000000001cull, 2, 1) \
M(i64x2_extract_lane, 0xfd0000000000001dull, 1, 1) \
M(i64x2_replace_lane, 0xfd0000000000001eull, 2, 1) \
M(f32x4_extract_lane, 0xfd0000000000001full, 1, 1) \
M(f32x4_replace_lane, 0xfd00000000000020ull, 2, 1) \
M(f64x2_extract_lane, 0xfd00000000000021ull, 1, 1) \
M(f64x2_replace_lane, 0xfd00000000000022ull, 2, 1) \
M(i8x16_eq, 0xfd00000000000023ull, 2, 1) \
M(i8x16_ne, 0xfd00000000000024ull, 2, 1) \
M(i8x16_lt_s, 0xfd00000000000025ull, 2, 1) \
M(i8x16_lt_u, 0xfd00000000000026ull, 2, 1) \
M(i8x16_gt_s, 0xfd00000000000027ull, 2, 1) \
M(i8x16_gt_u, 0xfd00000000000028ull, 2, 1) \
M(i8x16_le_s, 0xfd00000000000029ull, 2, 1) \
M(i8x16_le_u, 0xfd0000000000002aull, 2, 1) \
M(i8x16_ge_s, 0xfd0000000000002bull, 2, 1) \
M(i8x16_ge_u, 0xfd0000000000002cull, 2, 1) \
M(i16x8_eq, 0xfd0000000000002dull, 2, 1) \
M(i16x8_ne, 0xfd0000000000002eull, 2, 1) \
M(i16x8_lt_s, 0xfd0000000000002full, 2, 1) \
M(i16x8_lt_u, 0xfd00000000000030ull, 2, 1) \
M(i16x8_gt_s, 0xfd00000000000031ull, 2, 1) \
M(i16x8_gt_u, 0xfd00000000000032ull, 2, 1) \
M(i16x8_le_s, 0xfd00000000000033ull, 2, 1) \
M(i16x8_le_u, 0xfd00000000000034ull, 2, 1) \
M(i16x8_ge_s, 0xfd00000000000035ull, 2, 1) \
M(i16x8_ge_u, 0xfd00000000000036ull, 2, 1) \
M(i32x4_eq, 0xfd00000000000037ull, 2, 1) \
M(i32x4_ne, 0xfd00000000000038ull, 2, 1) \
M(i32x4_lt_s, 0xfd00000000000039ull, 2, 1) \
M(i32x4_lt_u, 0xfd0000000000003aull, 2, 1) \
M(i32x4_gt_s, 0xfd0000000000003bull, 2, 1) \
M(i32x4_gt_u, 0xfd0000000000003cull, 2, 1) \
M(i32x4_le_s, 0xfd0000000000003dull, 2, 1) \
M(i32x4_le_u, 0xfd0000000000003eull, 2, 1) \
M(i32x4_ge_s, 0xfd0000000000003full, 2, 1) \
M(i32x4_ge_u, 0xfd00000000000040ull, 2, 1) \
M(f32x4_eq, 0xfd00000000000041ull, 2, 1) \
M(f32x4_ne, 0xfd00000000000042ull, 2, 1) \
M(f32x4_lt, 0xfd00000000000043ull, 2, 1) \
M(f32x4_gt, 0xfd00000000000044ull, 2, 1) \
M(f32x4_le, 0xfd00000000000045ull, 2, 1) \
M(f32x4_ge, 0xfd00000000000046ull, 2, 1) \
M(f64x2_eq, 0xfd00000000000047ull, 2, 1) \
M(f64x2_ne, 0xfd00000000000048ull, 2, 1) \
M(f64x2_lt, 0xfd00000000000049ull, 2, 1) \
M(f64x2_gt, 0xfd0000000000004aull, 2, 1) \
M(f64x2_le, 0xfd0000000000004bull, 2, 1) \
M(f64x2_ge, 0xfd0000000000004cull, 2, 1) \
M(v128_not, 0xfd0000000000004dull, 1, 1) \
M(v128_and, 0xfd0000000000004eull, 2, 1) \
M(v128_andnot, 0xfd0000000000004full, 2, 1) \
M(v128_or, 0xfd00000000000050ull, 2, 1) \
M(v128_xor, 0xfd00000000000051ull, 2, 1) \
M(v128_bitselect, 0xfd00000000000052ull, 3, 1) \
M(v128_any_true, 0xfd00000000000053ull, 1, 1) \
M(v128_load8_lane, 0xfd00000000000054ull, 2, 1) \
M(v128_load16_lane, 0xfd00000000000055ull, 2, 1) \
M(v128_load32_lane, 0xfd00000000000056ull, 2, 1) \
M(v128_load64_lane, 0xfd00000000000057ull, 2, 1) \
M(v128_store8_lane, 0xfd00000000000058ull, 2, 0) \
M(v128_store16_lane, 0xfd00000000000059ull, 2, 0) \
M(v128_store32_lane, 0xfd0000000000005aull, 2, 0) \
M(v128_store64_lane, 0xfd0000000000005bull, 2, 0) \
M(v128_load32_zero, 0xfd0000000000005cull, 1, 1) \
M(v128_load64_zero, 0xfd0000000000005dull, 1, 1) \
M(f32x4_demote_f64x2_zero, 0xfd0000000000005eull, 1, 1) \
M(f64x2_promote_low_f32x4, 0xfd0000000000005full, 1, 1) \
M(i8x16_abs, 0xfd00000000000060ull, 1, 1) \
M(i8x16_neg, 0xfd00000000000061ull, 1, 1) \
M(i8x16_popcnt, 0xfd00000000000062ull, 1, 1) \
M(i8x16_all_true, 0xfd00000000000063ull, 1, 1) \
M(i8x16_bitmask, 0xfd00000000000064ull, 1, 1) \
M(i8x16_narrow_i16x8_s, 0xfd00000000000065ull, 2, 1) \
M(i8x16_narrow_i16x8_u, 0xfd00000000000066ull, 2, 1) \
M(f32x4_ceil, 0xfd00000000000067ull, 1, 1) \
M(f32x4_floor, 0xfd00000000000068ull, 1, 1) \
M(f32x4_trunc, 0xfd00000000000069ull, 1, 1) \
M(f32x4_nearest, 0xfd0000000000006aull, 1, 1) \
M(i8x16_shl, 0xfd0000000000006bull, 2, 1) \
M(i8x16_shr_s, 0xfd0000000000006cull, 2, 1) \
M(i8x16_shr_u, 0xfd0000000000006dull, 2, 1) \
M(i8x16_add, 0xfd0000000000006eull, 2, 1) \
M(i8x16_add_sat_s, 0xfd0000000000006full, 2, 1) \
M(i8x16_add_sat_u, 0xfd00000000000070ull, 2, 1) \
M(i8x16_sub, 0xfd00000000000071ull, 2, 1) \
M(i8x16_sub_sat_s, 0xfd00000000000072ull, 2, 1) \
M(i8x16_sub_sat_u, 0xfd00000000000073ull, 2, 1) \
M(f64x2_ceil, 0xfd00000000000074ull, 1, 1) \
M(f64x2_floor, 0xfd00000000000075ull, 1, 1) \
M(i8x16_min_s, 0xfd00000000000076ull, 2, 1) \
M(i8x16_min_u, 0xfd00000000000077ull, 2, 1) \
M(i8x16_max_s, 0xfd00000000000078ull, 2, 1) \
M(i8x16_max_u, 0xfd00000000000079ull, 2, 1) \
M(f64x2_trunc, 0xfd0000000000007aull, 1, 1) \
M(i8x16_avgr_u, 0xfd0000000000007bull, 2, 1) \
M(i16x8_extadd_pairwise_i8x16_s, 0xfd0000000000007cull, 1, 1) \
M(i16x8_extadd_pairwise_i8x16_u, 0xfd0000000000007dull, 1, 1) \
M(i32x4_extadd_pairwise_i16x8_s, 0xfd0000000000007eull, 1, 1) \
M(i32x4_extadd_pairwise_i16x8_u, 0xfd0000000000007full, 1, 1) \
M(i16x8_abs, 0xfd00000000000080ull, 1, 1) \
M(i16x8_neg, 0xfd00000000000081ull, 1, 1) \
M(i16x8_q15mulr_sat_s, 0xfd00000000000082ull, 2, 1) \
M(i16x8_all_true, 0xfd00000000000083ull, 1, 1) \
M(i16x8_bitmask, 0xfd00000000000084ull, 1, 1) \
M(i16x8_narrow_i32x4_s, 0xfd00000000000085ull, 2, 1) \
M(i16x8_narrow_i32x4_u, 0xfd00000000000086ull, 2, 1) \
M(i16x8_extend_low_i8x16_s, 0xfd00000000000087ull, 1, 1) \
M(i16x8_extend_high_i8x16_s, 0xfd00000000000088ull, 1, 1) \
M(i16x8_extend_low_i8x16_u, 0xfd00000000000089ull, 1, 1) \
M(i16x8_extend_high_i8x16_u, 0xfd0000000000008aull, 1, 1) \
M(i16x8_shl, 0xfd0000000000008bull, 2, 1) \
M(i16x8_shr_s, 0xfd0000000000008cull, 2, 1) \
M(i16x8_shr_u, 0xfd0000000000008dull, 2, 1) \
M(i16x8_add, 0xfd0000000000008eull, 2, 1) \
M(i16x8_add_sat_s, 0xfd0000000000008full, 2, 1) \
M(i16x8_add_sat_u, 0xfd00000000000090ull, 2, 1) \
M(i16x8_sub, 0xfd00000000000091ull, 2, 1) \
M(i16x8_sub_sat_s, 0xfd00000000000092ull, 2, 1) \
M(i16x8_sub_sat_u, 0xfd00000000000093ull, 2, 1) \
M(f64x2_nearest, 0xfd00000000000094ull, 1, 1) \
M(i16x8_mul, 0xfd00000000000095ull, 2, 1) \
M(i16x8_min_s, 0xfd00000000000096ull, 2, 1) \
M(i16x8_min_u, 0xfd00000000000097ull, 2, 1) \
M(i16x8_max_s, 0xfd00000000000098ull, 2, 1) \
M(i16x8_max_u, 0xfd00000000000099ull, 2, 1) \
M(i16x8_avgr_u, 0xfd0000000000009bull, 2, 1) \
M(i16x8_extmul_low_i8x16_s, 0xfd0000000000009cull, 2, 1) \
M(i16x8_extmul_high_i8x16_s, 0xfd0000000000009dull, 2, 1) \
M(i16x8_extmul_low_i8x16_u, 0xfd0000000000009eull, 2, 1) \
M(i16x8_extmul_high_i8x16_u, 0xfd0000000000009full, 2, 1) \
M(i32x4_abs, 0xfd000000000000a0ull, 1, 1) \
M(i32x4_neg, 0xfd000000000000a1ull, 1, 1) \
M(i32x4_all_true, 0xfd000000000000a3ull, 1, 1) \
M(i32x4_bitmask, 0xfd000000000000a4ull, 1, 1) \
M(i32x4_extend_low_i16x8_s, 0xfd000000000000a7ull, 1, 1) \
M(i32x4_extend_high_i16x8_s, 0xfd000000000000a8ull, 1, 1) \
M(i32x4_extend_low_i16x8_u, 0xfd000000000000a9ull, 1, 1) \
M(i32x4_extend_high_i16x8_u, 0xfd000000000000aaull, 1, 1) \
M(i32x4_shl, 0xfd000000000000abull, 2, 1) \
M(i32x4_shr_s, 0xfd000000000000acull, 2, 1) \
M(i32x4_shr_u, 0xfd000000000000adull, 2, 1) \
M(i32x4_add, 0xfd000000000000aeull, 2, 1) \
M(i32x4_sub, 0xfd000000000000b1ull, 2, 1) \
M(i32x4_mul, 0xfd000000000000b5ull, 2, 1) \
M(i32x4_min_s, 0xfd000000000000b6ull, 2, 1) \
M(i32x4_min_u, 0xfd000000000000b7ull, 2, 1) \
M(i32x4_max_s, 0xfd000000000000b8ull, 2, 1) \
M(i32x4_max_u, 0xfd000000000000b9ull, 2, 1) \
M(i32x4_dot_i16x8_s, 0xfd000000000000baull, 2, 1) \
M(i32x4_extmul_low_i16x8_s, 0xfd000000000000bcull, 2, 1) \
M(i32x4_extmul_high_i16x8_s, 0xfd000000000000bdull, 2, 1) \
M(i32x4_extmul_low_i16x8_u, 0xfd000000000000beull, 2, 1) \
M(i32x4_extmul_high_i16x8_u, 0xfd000000000000bfull, 2, 1) \
M(i64x2_abs, 0xfd000000000000c0ull, 1, 1) \
M(i64x2_neg, 0xfd000000000000c1ull, 1, 1) \
M(i64x2_all_true, 0xfd000000000000c3ull, 1, 1) \
M(i64x2_bitmask, 0xfd000000000000c4ull, 1, 1) \
M(i64x2_extend_low_i32x4_s, 0xfd000000000000c7ull, 1, 1) \
M(i64x2_extend_high_i32x4_s, 0xfd000000000000c8ull, 1, 1) \
M(i64x2_extend_low_i32x4_u, 0xfd000000000000c9ull, 1, 1) \
M(i64x2_extend_high_i32x4_u, 0xfd000000000000caull, 1, 1) \
M(i64x2_shl, 0xfd000000000000cbull, 2, 1) \
M(i64x2_shr_s, 0xfd000000000000ccull, 2, 1) \
M(i64x2_shr_u, 0xfd000000000000cdull, 2, 1) \
M(i64x2_add, 0xfd000000000000ceull, 2, 1) \
M(i64x2_sub, 0xfd000000000000d1ull, 2, 1) \
M(i64x2_mul, 0xfd000000000000d5ull, 2, 1) \
M(i64x2_eq, 0xfd000000000000d6ull, 2, 1) \
M(i64x2_ne, 0xfd000000000000d7ull, 2, 1) \
M(i64x2_lt_s, 0xfd000000000000d8ull, 2, 1) \
M(i64x2_gt_s, 0xfd000000000000d9ull, 2, 1) \
M(i64x2_le_s, 0xfd000000000000daull, 2, 1) \
M(i64x2_ge_s, 0xfd000000000000dbull, 2, 1) \
M(i64x2_extmul_low_i32x4_s, 0xfd000000000000dcull, 2, 1) \
M(i64x2_extmul_high_i32x4_s, 0xfd000000000000ddull, 2, 1) \
M(i64x2_extmul_low_i32x4_u, 0xfd000000000000deull, 2, 1) \
M(i64x2_extmul_high_i32x4_u, 0xfd000000000000dfull, 2, 1) \
M(f32x4_abs, 0xfd000000000000e0ull, 1, 1) \
M(f32x4_neg, 0xfd000000000000e1ull, 1, 1) \
M(f32x4_sqrt, 0xfd000000000000e3ull, 1, 1) \
M(f32x4_add, 0xfd000000000000e4ull, 2, 1) \
M(f32x4_sub, 0xfd000000000000e5ull, 2, 1) \
M(f32x4_mul, 0xfd000000000000e6ull, 2, 1) \
M(f32x4_div, 0xfd000000000000e7ull, 2, 1) \
M(f32x4_min, 0xfd000000000000e8ull, 2, 1) \
M(f32x4_max, 0xfd000000000000e9ull, 2, 1) \
M(f32x4_pmin, 0xfd000000000000eaull, 2, 1) \
M(f32x4_pmax, 0xfd000000000000ebull, 2, 1) \
M(f64x2_abs, 0xfd000000000000ecull, 1, 1) \
M(f64x2_neg, 0xfd000000000000edull, 1, 1) \
M(f64x2_sqrt, 0xfd000000000000efull, 1, 1) \
M(f64x2_add, 0xfd000000000000f0ull, 2, 1) \
M(f64x2_sub, 0xfd000000000000f1ull, 2, 1) \
M(f64x2_mul, 0xfd000000000000f2ull, 2, 1) \
M(f64x2_div, 0xfd000000000000f3ull, 2, 1) \
M(f64x2_min, 0xfd000000000000f4ull, 2, 1) \
M(f64x2_max, 0xfd000000000000f5ull, 2, 1) \
M(f64x2_pmin, 0xfd000000000000f6ull, 2, 1) \
M(f64x2_pmax, 0xfd000000000000f7ull, 2, 1) \
M(i32x4_trunc_sat_f32x4_s, 0xfd000000000000f8ull, 1, 1) \
M(i32x4_trunc_sat_f32x4_u, 0xfd000000000000f9ull, 1, 1) \
M(f32x4_convert_i32x4_s, 0xfd000000000000faull, 1, 1) \
M(f32x4_convert_i32x4_u, 0xfd000000000000fbull, 1, 1) \
M(i32x4_trunc_sat_f64x2_s_zero, 0xfd000000000000fcull, 1, 1) \
M(i32x4_trunc_sat_f64x2_u_zero, 0xfd000000000000fdull, 1, 1) \
M(f64x2_convert_low_i32x4_s, 0xfd000000000000feull, 1, 1) \
M(f64x2_convert_low_i32x4_u, 0xfd000000000000ffull, 1, 1) \
M(i8x16_relaxed_swizzle, 0xfd00000000000100, 2, 1) \
M(i32x4_relaxed_trunc_f32x4_s, 0xfd00000000000101, 1, 1) \
M(i32x4_relaxed_trunc_f32x4_u, 0xfd00000000000102, 1, 1) \
M(i32x4_relaxed_trunc_f64x2_s_zero, 0xfd00000000000103, 1, 1) \
M(i32x4_relaxed_trunc_f64x2_u_zero, 0xfd00000000000104, 1, 1) \
M(f32x4_relaxed_madd, 0xfd00000000000105, 3, 1) \
M(f32x4_relaxed_nmadd, 0xfd00000000000106, 3, 1) \
M(f64x2_relaxed_madd, 0xfd00000000000107, 3, 1) \
M(f64x2_relaxed_nmadd, 0xfd00000000000108, 3, 1) \
M(i8x16_relaxed_laneselect, 0xfd00000000000109, 3, 1) \
M(i16x8_relaxed_laneselect, 0xfd0000000000010a, 3, 1) \
M(i32x4_relaxed_laneselect, 0xfd0000000000010b, 3, 1) \
M(i64x2_relaxed_laneselect, 0xfd0000000000010c, 3, 1) \
M(f32x4_relaxed_min, 0xfd0000000000010d, 2, 1) \
M(f32x4_relaxed_max, 0xfd0000000000010e, 2, 1) \
M(f64x2_relaxed_min, 0xfd0000000000010f, 2, 1) \
M(f64x2_relaxed_max, 0xfd00000000000110, 2, 1) \
M(i16x8_relaxed_q15mulr_s, 0xfd00000000000111, 2, 1) \
M(i16x8_relaxed_dot_i8x16_i7x16_s, 0xfd00000000000112, 2, 1) \
M(i32x4_relaxed_dot_i8x16_i7x16_add_s, 0xfd00000000000113, 3, 1) \
/* Synthetic fused insns */ \
#define ENUMERATE_MULTI_BYTE_WASM_OPCODES(M) \
M(i32_trunc_sat_f32_s, 0xfc000000u, 1, 1) \
M(i32_trunc_sat_f32_u, 0xfc000001u, 1, 1) \
M(i32_trunc_sat_f64_s, 0xfc000002u, 1, 1) \
M(i32_trunc_sat_f64_u, 0xfc000003u, 1, 1) \
M(i64_trunc_sat_f32_s, 0xfc000004u, 1, 1) \
M(i64_trunc_sat_f32_u, 0xfc000005u, 1, 1) \
M(i64_trunc_sat_f64_s, 0xfc000006u, 1, 1) \
M(i64_trunc_sat_f64_u, 0xfc000007u, 1, 1) \
M(memory_init, 0xfc000008u, 3, 0) \
M(data_drop, 0xfc000009u, 0, 0) \
M(memory_copy, 0xfc00000au, 3, 0) \
M(memory_fill, 0xfc00000bu, 3, 0) \
M(table_init, 0xfc00000cu, 3, 0) \
M(elem_drop, 0xfc00000du, 0, 0) \
M(table_copy, 0xfc00000eu, 3, 0) \
M(table_grow, 0xfc00000fu, 2, 1) \
M(table_size, 0xfc000010u, 0, 1) \
M(table_fill, 0xfc000011u, 3, 0) \
M(v128_load, 0xfd000000u, 1, 1) \
M(v128_load8x8_s, 0xfd000001u, 1, 1) \
M(v128_load8x8_u, 0xfd000002u, 1, 1) \
M(v128_load16x4_s, 0xfd000003u, 1, 1) \
M(v128_load16x4_u, 0xfd000004u, 1, 1) \
M(v128_load32x2_s, 0xfd000005u, 1, 1) \
M(v128_load32x2_u, 0xfd000006u, 1, 1) \
M(v128_load8_splat, 0xfd000007u, 1, 1) \
M(v128_load16_splat, 0xfd000008u, 1, 1) \
M(v128_load32_splat, 0xfd000009u, 1, 1) \
M(v128_load64_splat, 0xfd00000au, 1, 1) \
M(v128_store, 0xfd00000bu, 2, 0) \
M(v128_const, 0xfd00000cu, 0, 1) \
M(i8x16_shuffle, 0xfd00000du, 2, 1) \
M(i8x16_swizzle, 0xfd00000eu, 2, 1) \
M(i8x16_splat, 0xfd00000fu, 1, 1) \
M(i16x8_splat, 0xfd000010u, 1, 1) \
M(i32x4_splat, 0xfd000011u, 1, 1) \
M(i64x2_splat, 0xfd000012u, 1, 1) \
M(f32x4_splat, 0xfd000013u, 1, 1) \
M(f64x2_splat, 0xfd000014u, 1, 1) \
M(i8x16_extract_lane_s, 0xfd000015u, 1, 1) \
M(i8x16_extract_lane_u, 0xfd000016u, 1, 1) \
M(i8x16_replace_lane, 0xfd000017u, 2, 1) \
M(i16x8_extract_lane_s, 0xfd000018u, 1, 1) \
M(i16x8_extract_lane_u, 0xfd000019u, 1, 1) \
M(i16x8_replace_lane, 0xfd00001au, 2, 1) \
M(i32x4_extract_lane, 0xfd00001bu, 1, 1) \
M(i32x4_replace_lane, 0xfd00001cu, 2, 1) \
M(i64x2_extract_lane, 0xfd00001du, 1, 1) \
M(i64x2_replace_lane, 0xfd00001eu, 2, 1) \
M(f32x4_extract_lane, 0xfd00001fu, 1, 1) \
M(f32x4_replace_lane, 0xfd000020u, 2, 1) \
M(f64x2_extract_lane, 0xfd000021u, 1, 1) \
M(f64x2_replace_lane, 0xfd000022u, 2, 1) \
M(i8x16_eq, 0xfd000023u, 2, 1) \
M(i8x16_ne, 0xfd000024u, 2, 1) \
M(i8x16_lt_s, 0xfd000025u, 2, 1) \
M(i8x16_lt_u, 0xfd000026u, 2, 1) \
M(i8x16_gt_s, 0xfd000027u, 2, 1) \
M(i8x16_gt_u, 0xfd000028u, 2, 1) \
M(i8x16_le_s, 0xfd000029u, 2, 1) \
M(i8x16_le_u, 0xfd00002au, 2, 1) \
M(i8x16_ge_s, 0xfd00002bu, 2, 1) \
M(i8x16_ge_u, 0xfd00002cu, 2, 1) \
M(i16x8_eq, 0xfd00002du, 2, 1) \
M(i16x8_ne, 0xfd00002eu, 2, 1) \
M(i16x8_lt_s, 0xfd00002fu, 2, 1) \
M(i16x8_lt_u, 0xfd000030u, 2, 1) \
M(i16x8_gt_s, 0xfd000031u, 2, 1) \
M(i16x8_gt_u, 0xfd000032u, 2, 1) \
M(i16x8_le_s, 0xfd000033u, 2, 1) \
M(i16x8_le_u, 0xfd000034u, 2, 1) \
M(i16x8_ge_s, 0xfd000035u, 2, 1) \
M(i16x8_ge_u, 0xfd000036u, 2, 1) \
M(i32x4_eq, 0xfd000037u, 2, 1) \
M(i32x4_ne, 0xfd000038u, 2, 1) \
M(i32x4_lt_s, 0xfd000039u, 2, 1) \
M(i32x4_lt_u, 0xfd00003au, 2, 1) \
M(i32x4_gt_s, 0xfd00003bu, 2, 1) \
M(i32x4_gt_u, 0xfd00003cu, 2, 1) \
M(i32x4_le_s, 0xfd00003du, 2, 1) \
M(i32x4_le_u, 0xfd00003eu, 2, 1) \
M(i32x4_ge_s, 0xfd00003fu, 2, 1) \
M(i32x4_ge_u, 0xfd000040u, 2, 1) \
M(f32x4_eq, 0xfd000041u, 2, 1) \
M(f32x4_ne, 0xfd000042u, 2, 1) \
M(f32x4_lt, 0xfd000043u, 2, 1) \
M(f32x4_gt, 0xfd000044u, 2, 1) \
M(f32x4_le, 0xfd000045u, 2, 1) \
M(f32x4_ge, 0xfd000046u, 2, 1) \
M(f64x2_eq, 0xfd000047u, 2, 1) \
M(f64x2_ne, 0xfd000048u, 2, 1) \
M(f64x2_lt, 0xfd000049u, 2, 1) \
M(f64x2_gt, 0xfd00004au, 2, 1) \
M(f64x2_le, 0xfd00004bu, 2, 1) \
M(f64x2_ge, 0xfd00004cu, 2, 1) \
M(v128_not, 0xfd00004du, 1, 1) \
M(v128_and, 0xfd00004eu, 2, 1) \
M(v128_andnot, 0xfd00004fu, 2, 1) \
M(v128_or, 0xfd000050u, 2, 1) \
M(v128_xor, 0xfd000051u, 2, 1) \
M(v128_bitselect, 0xfd000052u, 3, 1) \
M(v128_any_true, 0xfd000053u, 1, 1) \
M(v128_load8_lane, 0xfd000054u, 2, 1) \
M(v128_load16_lane, 0xfd000055u, 2, 1) \
M(v128_load32_lane, 0xfd000056u, 2, 1) \
M(v128_load64_lane, 0xfd000057u, 2, 1) \
M(v128_store8_lane, 0xfd000058u, 2, 0) \
M(v128_store16_lane, 0xfd000059u, 2, 0) \
M(v128_store32_lane, 0xfd00005au, 2, 0) \
M(v128_store64_lane, 0xfd00005bu, 2, 0) \
M(v128_load32_zero, 0xfd00005cu, 1, 1) \
M(v128_load64_zero, 0xfd00005du, 1, 1) \
M(f32x4_demote_f64x2_zero, 0xfd00005eu, 1, 1) \
M(f64x2_promote_low_f32x4, 0xfd00005fu, 1, 1) \
M(i8x16_abs, 0xfd000060u, 1, 1) \
M(i8x16_neg, 0xfd000061u, 1, 1) \
M(i8x16_popcnt, 0xfd000062u, 1, 1) \
M(i8x16_all_true, 0xfd000063u, 1, 1) \
M(i8x16_bitmask, 0xfd000064u, 1, 1) \
M(i8x16_narrow_i16x8_s, 0xfd000065u, 2, 1) \
M(i8x16_narrow_i16x8_u, 0xfd000066u, 2, 1) \
M(f32x4_ceil, 0xfd000067u, 1, 1) \
M(f32x4_floor, 0xfd000068u, 1, 1) \
M(f32x4_trunc, 0xfd000069u, 1, 1) \
M(f32x4_nearest, 0xfd00006au, 1, 1) \
M(i8x16_shl, 0xfd00006bu, 2, 1) \
M(i8x16_shr_s, 0xfd00006cu, 2, 1) \
M(i8x16_shr_u, 0xfd00006du, 2, 1) \
M(i8x16_add, 0xfd00006eu, 2, 1) \
M(i8x16_add_sat_s, 0xfd00006fu, 2, 1) \
M(i8x16_add_sat_u, 0xfd000070u, 2, 1) \
M(i8x16_sub, 0xfd000071u, 2, 1) \
M(i8x16_sub_sat_s, 0xfd000072u, 2, 1) \
M(i8x16_sub_sat_u, 0xfd000073u, 2, 1) \
M(f64x2_ceil, 0xfd000074u, 1, 1) \
M(f64x2_floor, 0xfd000075u, 1, 1) \
M(i8x16_min_s, 0xfd000076u, 2, 1) \
M(i8x16_min_u, 0xfd000077u, 2, 1) \
M(i8x16_max_s, 0xfd000078u, 2, 1) \
M(i8x16_max_u, 0xfd000079u, 2, 1) \
M(f64x2_trunc, 0xfd00007au, 1, 1) \
M(i8x16_avgr_u, 0xfd00007bu, 2, 1) \
M(i16x8_extadd_pairwise_i8x16_s, 0xfd00007cu, 1, 1) \
M(i16x8_extadd_pairwise_i8x16_u, 0xfd00007du, 1, 1) \
M(i32x4_extadd_pairwise_i16x8_s, 0xfd00007eu, 1, 1) \
M(i32x4_extadd_pairwise_i16x8_u, 0xfd00007fu, 1, 1) \
M(i16x8_abs, 0xfd000080u, 1, 1) \
M(i16x8_neg, 0xfd000081u, 1, 1) \
M(i16x8_q15mulr_sat_s, 0xfd000082u, 2, 1) \
M(i16x8_all_true, 0xfd000083u, 1, 1) \
M(i16x8_bitmask, 0xfd000084u, 1, 1) \
M(i16x8_narrow_i32x4_s, 0xfd000085u, 2, 1) \
M(i16x8_narrow_i32x4_u, 0xfd000086u, 2, 1) \
M(i16x8_extend_low_i8x16_s, 0xfd000087u, 1, 1) \
M(i16x8_extend_high_i8x16_s, 0xfd000088u, 1, 1) \
M(i16x8_extend_low_i8x16_u, 0xfd000089u, 1, 1) \
M(i16x8_extend_high_i8x16_u, 0xfd00008au, 1, 1) \
M(i16x8_shl, 0xfd00008bu, 2, 1) \
M(i16x8_shr_s, 0xfd00008cu, 2, 1) \
M(i16x8_shr_u, 0xfd00008du, 2, 1) \
M(i16x8_add, 0xfd00008eu, 2, 1) \
M(i16x8_add_sat_s, 0xfd00008fu, 2, 1) \
M(i16x8_add_sat_u, 0xfd000090u, 2, 1) \
M(i16x8_sub, 0xfd000091u, 2, 1) \
M(i16x8_sub_sat_s, 0xfd000092u, 2, 1) \
M(i16x8_sub_sat_u, 0xfd000093u, 2, 1) \
M(f64x2_nearest, 0xfd000094u, 1, 1) \
M(i16x8_mul, 0xfd000095u, 2, 1) \
M(i16x8_min_s, 0xfd000096u, 2, 1) \
M(i16x8_min_u, 0xfd000097u, 2, 1) \
M(i16x8_max_s, 0xfd000098u, 2, 1) \
M(i16x8_max_u, 0xfd000099u, 2, 1) \
M(i16x8_avgr_u, 0xfd00009bu, 2, 1) \
M(i16x8_extmul_low_i8x16_s, 0xfd00009cu, 2, 1) \
M(i16x8_extmul_high_i8x16_s, 0xfd00009du, 2, 1) \
M(i16x8_extmul_low_i8x16_u, 0xfd00009eu, 2, 1) \
M(i16x8_extmul_high_i8x16_u, 0xfd00009fu, 2, 1) \
M(i32x4_abs, 0xfd0000a0u, 1, 1) \
M(i32x4_neg, 0xfd0000a1u, 1, 1) \
M(i32x4_all_true, 0xfd0000a3u, 1, 1) \
M(i32x4_bitmask, 0xfd0000a4u, 1, 1) \
M(i32x4_extend_low_i16x8_s, 0xfd0000a7u, 1, 1) \
M(i32x4_extend_high_i16x8_s, 0xfd0000a8u, 1, 1) \
M(i32x4_extend_low_i16x8_u, 0xfd0000a9u, 1, 1) \
M(i32x4_extend_high_i16x8_u, 0xfd0000aau, 1, 1) \
M(i32x4_shl, 0xfd0000abu, 2, 1) \
M(i32x4_shr_s, 0xfd0000acu, 2, 1) \
M(i32x4_shr_u, 0xfd0000adu, 2, 1) \
M(i32x4_add, 0xfd0000aeu, 2, 1) \
M(i32x4_sub, 0xfd0000b1u, 2, 1) \
M(i32x4_mul, 0xfd0000b5u, 2, 1) \
M(i32x4_min_s, 0xfd0000b6u, 2, 1) \
M(i32x4_min_u, 0xfd0000b7u, 2, 1) \
M(i32x4_max_s, 0xfd0000b8u, 2, 1) \
M(i32x4_max_u, 0xfd0000b9u, 2, 1) \
M(i32x4_dot_i16x8_s, 0xfd0000bau, 2, 1) \
M(i32x4_extmul_low_i16x8_s, 0xfd0000bcu, 2, 1) \
M(i32x4_extmul_high_i16x8_s, 0xfd0000bdu, 2, 1) \
M(i32x4_extmul_low_i16x8_u, 0xfd0000beu, 2, 1) \
M(i32x4_extmul_high_i16x8_u, 0xfd0000bfu, 2, 1) \
M(i64x2_abs, 0xfd0000c0u, 1, 1) \
M(i64x2_neg, 0xfd0000c1u, 1, 1) \
M(i64x2_all_true, 0xfd0000c3u, 1, 1) \
M(i64x2_bitmask, 0xfd0000c4u, 1, 1) \
M(i64x2_extend_low_i32x4_s, 0xfd0000c7u, 1, 1) \
M(i64x2_extend_high_i32x4_s, 0xfd0000c8u, 1, 1) \
M(i64x2_extend_low_i32x4_u, 0xfd0000c9u, 1, 1) \
M(i64x2_extend_high_i32x4_u, 0xfd0000cau, 1, 1) \
M(i64x2_shl, 0xfd0000cbu, 2, 1) \
M(i64x2_shr_s, 0xfd0000ccu, 2, 1) \
M(i64x2_shr_u, 0xfd0000cdu, 2, 1) \
M(i64x2_add, 0xfd0000ceu, 2, 1) \
M(i64x2_sub, 0xfd0000d1u, 2, 1) \
M(i64x2_mul, 0xfd0000d5u, 2, 1) \
M(i64x2_eq, 0xfd0000d6u, 2, 1) \
M(i64x2_ne, 0xfd0000d7u, 2, 1) \
M(i64x2_lt_s, 0xfd0000d8u, 2, 1) \
M(i64x2_gt_s, 0xfd0000d9u, 2, 1) \
M(i64x2_le_s, 0xfd0000dau, 2, 1) \
M(i64x2_ge_s, 0xfd0000dbu, 2, 1) \
M(i64x2_extmul_low_i32x4_s, 0xfd0000dcu, 2, 1) \
M(i64x2_extmul_high_i32x4_s, 0xfd0000ddu, 2, 1) \
M(i64x2_extmul_low_i32x4_u, 0xfd0000deu, 2, 1) \
M(i64x2_extmul_high_i32x4_u, 0xfd0000dfu, 2, 1) \
M(f32x4_abs, 0xfd0000e0u, 1, 1) \
M(f32x4_neg, 0xfd0000e1u, 1, 1) \
M(f32x4_sqrt, 0xfd0000e3u, 1, 1) \
M(f32x4_add, 0xfd0000e4u, 2, 1) \
M(f32x4_sub, 0xfd0000e5u, 2, 1) \
M(f32x4_mul, 0xfd0000e6u, 2, 1) \
M(f32x4_div, 0xfd0000e7u, 2, 1) \
M(f32x4_min, 0xfd0000e8u, 2, 1) \
M(f32x4_max, 0xfd0000e9u, 2, 1) \
M(f32x4_pmin, 0xfd0000eau, 2, 1) \
M(f32x4_pmax, 0xfd0000ebu, 2, 1) \
M(f64x2_abs, 0xfd0000ecu, 1, 1) \
M(f64x2_neg, 0xfd0000edu, 1, 1) \
M(f64x2_sqrt, 0xfd0000efu, 1, 1) \
M(f64x2_add, 0xfd0000f0u, 2, 1) \
M(f64x2_sub, 0xfd0000f1u, 2, 1) \
M(f64x2_mul, 0xfd0000f2u, 2, 1) \
M(f64x2_div, 0xfd0000f3u, 2, 1) \
M(f64x2_min, 0xfd0000f4u, 2, 1) \
M(f64x2_max, 0xfd0000f5u, 2, 1) \
M(f64x2_pmin, 0xfd0000f6u, 2, 1) \
M(f64x2_pmax, 0xfd0000f7u, 2, 1) \
M(i32x4_trunc_sat_f32x4_s, 0xfd0000f8u, 1, 1) \
M(i32x4_trunc_sat_f32x4_u, 0xfd0000f9u, 1, 1) \
M(f32x4_convert_i32x4_s, 0xfd0000fau, 1, 1) \
M(f32x4_convert_i32x4_u, 0xfd0000fbu, 1, 1) \
M(i32x4_trunc_sat_f64x2_s_zero, 0xfd0000fcu, 1, 1) \
M(i32x4_trunc_sat_f64x2_u_zero, 0xfd0000fdu, 1, 1) \
M(f64x2_convert_low_i32x4_s, 0xfd0000feu, 1, 1) \
M(f64x2_convert_low_i32x4_u, 0xfd0000ffu, 1, 1) \
M(i8x16_relaxed_swizzle, 0xfd000100u, 2, 1) \
M(i32x4_relaxed_trunc_f32x4_s, 0xfd000101u, 1, 1) \
M(i32x4_relaxed_trunc_f32x4_u, 0xfd000102u, 1, 1) \
M(i32x4_relaxed_trunc_f64x2_s_zero, 0xfd000103u, 1, 1) \
M(i32x4_relaxed_trunc_f64x2_u_zero, 0xfd000104u, 1, 1) \
M(f32x4_relaxed_madd, 0xfd000105u, 3, 1) \
M(f32x4_relaxed_nmadd, 0xfd000106u, 3, 1) \
M(f64x2_relaxed_madd, 0xfd000107u, 3, 1) \
M(f64x2_relaxed_nmadd, 0xfd000108u, 3, 1) \
M(i8x16_relaxed_laneselect, 0xfd000109u, 3, 1) \
M(i16x8_relaxed_laneselect, 0xfd00010au, 3, 1) \
M(i32x4_relaxed_laneselect, 0xfd00010bu, 3, 1) \
M(i64x2_relaxed_laneselect, 0xfd00010cu, 3, 1) \
M(f32x4_relaxed_min, 0xfd00010du, 2, 1) \
M(f32x4_relaxed_max, 0xfd00010eu, 2, 1) \
M(f64x2_relaxed_min, 0xfd00010fu, 2, 1) \
M(f64x2_relaxed_max, 0xfd000110u, 2, 1) \
M(i16x8_relaxed_q15mulr_s, 0xfd000111u, 2, 1) \
M(i16x8_relaxed_dot_i8x16_i7x16_s, 0xfd000112u, 2, 1) \
M(i32x4_relaxed_dot_i8x16_i7x16_add_s, 0xfd000113u, 3, 1) \
/* Synthetic fused insns */ \
ENUMERATE_SYNTHETIC_INSTRUCTION_OPCODES(M)
#define ENUMERATE_SYNTHETIC_INSTRUCTION_OPCODES(M) \
M(synthetic_i32_add2local, 0xfe00000000000000ull, 0, 1) \
M(synthetic_i32_addconstlocal, 0xfe00000000000001ull, 0, 1) \
M(synthetic_i32_andconstlocal, 0xfe00000000000002ull, 0, 1) \
M(synthetic_i32_storelocal, 0xfe00000000000003ull, 1, 0) \
M(synthetic_local_seti32_const, 0xfe00000000000005ull, 0, 0) \
M(synthetic_call_00, 0xfe00000000000006ull, 0, 0) \
M(synthetic_call_01, 0xfe00000000000007ull, 0, 1) \
M(synthetic_call_10, 0xfe00000000000008ull, 1, 0) \
M(synthetic_call_11, 0xfe00000000000009ull, 1, 1) \
M(synthetic_call_20, 0xfe0000000000000aull, 2, 0) \
M(synthetic_call_21, 0xfe0000000000000bull, 2, 1) \
M(synthetic_call_30, 0xfe0000000000000cull, 3, 0) \
M(synthetic_call_31, 0xfe0000000000000dull, 3, 1) \
M(synthetic_end_expression, 0xfe0000000000000eull, 0, 0) \
M(synthetic_argument_get, 0xfe0000000000000full, 0, 1) \
M(synthetic_argument_set, 0xfe00000000000010ull, 1, 0) \
M(synthetic_argument_tee, 0xfe00000000000011ull, 1, 1) \
M(synthetic_call_with_record_0, 0xfe00000000000012ull, 0, 0) \
M(synthetic_call_with_record_1, 0xfe00000000000013ull, 0, 1) \
M(synthetic_local_get_0, 0xfe00000000000014ull, 0, 1) \
M(synthetic_local_get_1, 0xfe00000000000015ull, 0, 1) \
M(synthetic_local_get_2, 0xfe00000000000016ull, 0, 1) \
M(synthetic_local_get_3, 0xfe00000000000017ull, 0, 1) \
M(synthetic_local_get_4, 0xfe00000000000018ull, 0, 1) \
M(synthetic_local_get_5, 0xfe00000000000019ull, 0, 1) \
M(synthetic_local_get_6, 0xfe0000000000001aull, 0, 1) \
M(synthetic_local_get_7, 0xfe0000000000001bull, 0, 1) \
M(synthetic_br_nostack, 0xfe0000000000001cull, 0, -1) \
M(synthetic_br_if_nostack, 0xfe0000000000001dull, 1, -1) \
M(synthetic_local_set_0, 0xfe0000000000001eull, 1, 0) \
M(synthetic_local_set_1, 0xfe0000000000001full, 1, 0) \
M(synthetic_local_set_2, 0xfe00000000000020ull, 1, 0) \
M(synthetic_local_set_3, 0xfe00000000000021ull, 1, 0) \
M(synthetic_local_set_4, 0xfe00000000000022ull, 1, 0) \
M(synthetic_local_set_5, 0xfe00000000000023ull, 1, 0) \
M(synthetic_local_set_6, 0xfe00000000000024ull, 1, 0) \
M(synthetic_local_set_7, 0xfe00000000000025ull, 1, 0) \
M(synthetic_local_copy, 0xfe00000000000026ull, 0, 0) \
M(synthetic_i32_sub2local, 0xfe00000000000027ull, 0, 1) \
M(synthetic_i32_mul2local, 0xfe00000000000028ull, 0, 1) \
M(synthetic_i32_and2local, 0xfe00000000000029ull, 0, 1) \
M(synthetic_i32_or2local, 0xfe0000000000002aull, 0, 1) \
M(synthetic_i32_xor2local, 0xfe0000000000002bull, 0, 1) \
M(synthetic_i32_shl2local, 0xfe0000000000002cull, 0, 1) \
M(synthetic_i32_shru2local, 0xfe0000000000002dull, 0, 1) \
M(synthetic_i32_shrs2local, 0xfe0000000000002eull, 0, 1) \
M(synthetic_i64_add2local, 0xfe0000000000002full, 0, 1) \
M(synthetic_i64_addconstlocal, 0xfe00000000000030ull, 0, 1) \
M(synthetic_i64_andconstlocal, 0xfe00000000000031ull, 0, 1) \
M(synthetic_i64_storelocal, 0xfe00000000000032ull, 1, 0) \
M(synthetic_i64_sub2local, 0xfe00000000000033ull, 0, 1) \
M(synthetic_i64_mul2local, 0xfe00000000000034ull, 0, 1) \
M(synthetic_i64_and2local, 0xfe00000000000035ull, 0, 1) \
M(synthetic_i64_or2local, 0xfe00000000000036ull, 0, 1) \
M(synthetic_i64_xor2local, 0xfe00000000000037ull, 0, 1) \
M(synthetic_i64_shl2local, 0xfe00000000000038ull, 0, 1) \
M(synthetic_i64_shru2local, 0xfe00000000000039ull, 0, 1) \
M(synthetic_i64_shrs2local, 0xfe0000000000003aull, 0, 1) \
M(synthetic_local_seti64_const, 0xfe0000000000003bull, 0, 0) \
/* Continuation data for br_table with >8 labels. \
* Only consumed by the Cranelift compiler; */ \
M(synthetic_br_table_cont, 0xfe0000000000003cull, 0, 0)
#define ENUMERATE_SYNTHETIC_INSTRUCTION_OPCODES(M) \
M(synthetic_i32_add2local, 0xfe000000u, 0, 1) \
M(synthetic_i32_addconstlocal, 0xfe000001u, 0, 1) \
M(synthetic_i32_andconstlocal, 0xfe000002u, 0, 1) \
M(synthetic_i32_storelocal, 0xfe000003u, 1, 0) \
M(synthetic_local_seti32_const, 0xfe000005u, 0, 0) \
M(synthetic_call_00, 0xfe000006u, 0, 0) \
M(synthetic_call_01, 0xfe000007u, 0, 1) \
M(synthetic_call_10, 0xfe000008u, 1, 0) \
M(synthetic_call_11, 0xfe000009u, 1, 1) \
M(synthetic_call_20, 0xfe00000au, 2, 0) \
M(synthetic_call_21, 0xfe00000bu, 2, 1) \
M(synthetic_call_30, 0xfe00000cu, 3, 0) \
M(synthetic_call_31, 0xfe00000du, 3, 1) \
M(synthetic_end_expression, 0xfe00000eu, 0, 0) \
M(synthetic_argument_get, 0xfe00000fu, 0, 1) \
M(synthetic_argument_set, 0xfe000010u, 1, 0) \
M(synthetic_argument_tee, 0xfe000011u, 1, 1) \
M(synthetic_call_with_record_0, 0xfe000012u, 0, 0) \
M(synthetic_call_with_record_1, 0xfe000013u, 0, 1) \
M(synthetic_local_get_0, 0xfe000014u, 0, 1) \
M(synthetic_local_get_1, 0xfe000015u, 0, 1) \
M(synthetic_local_get_2, 0xfe000016u, 0, 1) \
M(synthetic_local_get_3, 0xfe000017u, 0, 1) \
M(synthetic_local_get_4, 0xfe000018u, 0, 1) \
M(synthetic_local_get_5, 0xfe000019u, 0, 1) \
M(synthetic_local_get_6, 0xfe00001au, 0, 1) \
M(synthetic_local_get_7, 0xfe00001bu, 0, 1) \
M(synthetic_br_nostack, 0xfe00001cu, 0, -1) \
M(synthetic_br_if_nostack, 0xfe00001du, 1, -1) \
M(synthetic_local_set_0, 0xfe00001eu, 1, 0) \
M(synthetic_local_set_1, 0xfe00001fu, 1, 0) \
M(synthetic_local_set_2, 0xfe000020u, 1, 0) \
M(synthetic_local_set_3, 0xfe000021u, 1, 0) \
M(synthetic_local_set_4, 0xfe000022u, 1, 0) \
M(synthetic_local_set_5, 0xfe000023u, 1, 0) \
M(synthetic_local_set_6, 0xfe000024u, 1, 0) \
M(synthetic_local_set_7, 0xfe000025u, 1, 0) \
M(synthetic_local_copy, 0xfe000026u, 0, 0) \
M(synthetic_i32_sub2local, 0xfe000027u, 0, 1) \
M(synthetic_i32_mul2local, 0xfe000028u, 0, 1) \
M(synthetic_i32_and2local, 0xfe000029u, 0, 1) \
M(synthetic_i32_or2local, 0xfe00002au, 0, 1) \
M(synthetic_i32_xor2local, 0xfe00002bu, 0, 1) \
M(synthetic_i32_shl2local, 0xfe00002cu, 0, 1) \
M(synthetic_i32_shru2local, 0xfe00002du, 0, 1) \
M(synthetic_i32_shrs2local, 0xfe00002eu, 0, 1) \
M(synthetic_i64_add2local, 0xfe00002fu, 0, 1) \
M(synthetic_i64_addconstlocal, 0xfe000030u, 0, 1) \
M(synthetic_i64_andconstlocal, 0xfe000031u, 0, 1) \
M(synthetic_i64_storelocal, 0xfe000032u, 1, 0) \
M(synthetic_i64_sub2local, 0xfe000033u, 0, 1) \
M(synthetic_i64_mul2local, 0xfe000034u, 0, 1) \
M(synthetic_i64_and2local, 0xfe000035u, 0, 1) \
M(synthetic_i64_or2local, 0xfe000036u, 0, 1) \
M(synthetic_i64_xor2local, 0xfe000037u, 0, 1) \
M(synthetic_i64_shl2local, 0xfe000038u, 0, 1) \
M(synthetic_i64_shru2local, 0xfe000039u, 0, 1) \
M(synthetic_i64_shrs2local, 0xfe00003au, 0, 1) \
M(synthetic_local_seti64_const, 0xfe00003bu, 0, 0) \
/* Continuation data for br_table with >8 labels. \
* Only consumed by the Cranelift compiler; */ \
M(synthetic_br_table_cont, 0xfe00003cu, 0, 0)
#define ENUMERATE_WASM_OPCODES(M) \
ENUMERATE_SINGLE_BYTE_WASM_OPCODES(M) \
@ -558,7 +558,7 @@ namespace Instructions {
ENUMERATE_WASM_OPCODES(M)
#undef M
static constexpr inline OpCode SyntheticInstructionBase = 0xfe00000000000000ull;
static constexpr inline OpCode SyntheticInstructionBase = 0xfe000000u;
static constexpr inline size_t SyntheticInstructionCount = 61;
}

View file

@ -639,7 +639,10 @@ ParseResult<Instruction> Instruction::parse(ConstrainedStream& stream)
case 0xfd: {
// These are multibyte instructions.
auto selector = TRY_READ(stream, LEB128<u32>, ParseError::InvalidInput);
OpCode full_opcode = static_cast<u64>(opcode.value()) << 56 | selector;
if (selector > 0xffffff)
return ParseError::UnknownInstruction;
OpCode full_opcode = static_cast<u32>(opcode.value()) << 24 | selector;
switch (full_opcode.value()) {
case Instructions::i32_trunc_sat_f32_s.value():

View file

@ -17,7 +17,7 @@ fn generate_opcodes(manifest_dir: &Path, out_dir: &Path) -> Result<(), Box<dyn E
let mut output = String::new();
// Grab name and value from _M(name, value, pops, pushes)_ lines
let re = regex::Regex::new(r"M\(\s*(\w+)\s*,\s*(0x[0-9a-fA-F]+)(?:ull)?\s*,")?;
let re = regex::Regex::new(r"M\(\s*(\w+)\s*,\s*(0x[0-9a-fA-F]+)(?:[uUlL]+)?\s*,")?;
for cap in re.captures_iter(&contents) {
let cpp_name = &cap[1];
let value = &cap[2];