srctree

David Zero parent 161c5c0a 384e3556
wasm: Add remaining i32 numeric instructions

inlinesplit
wasm/instructions.cpp added: 782, removed: 18, total 764
@@ -126,14 +126,116 @@ std::optional<std::vector<Instruction>> parse(std::istream &is) {
instructions.emplace_back(I32Const{*value});
break;
}
case I32EqualZero::kOpcode:
instructions.emplace_back(I32EqualZero{});
break;
case I32Equal::kOpcode:
instructions.emplace_back(I32Equal{});
break;
case I32NotEqual::kOpcode:
instructions.emplace_back(I32NotEqual{});
break;
case I32LessThanSigned::kOpcode:
instructions.emplace_back(I32LessThanSigned{});
break;
case I32LessThanUnsigned::kOpcode:
instructions.emplace_back(I32LessThanUnsigned{});
break;
case I32GreaterThanSigned::kOpcode:
instructions.emplace_back(I32GreaterThanSigned{});
break;
case I32GreaterThanUnsigned::kOpcode:
instructions.emplace_back(I32GreaterThanUnsigned{});
break;
case I32LessThanEqualSigned::kOpcode:
instructions.emplace_back(I32LessThanEqualSigned{});
break;
case I32LessThanEqualUnsigned::kOpcode:
instructions.emplace_back(I32LessThanEqualUnsigned{});
break;
case I32GreaterThanEqualSigned::kOpcode:
instructions.emplace_back(I32GreaterThanEqualSigned{});
break;
case I32GreaterThanEqualUnsigned::kOpcode:
instructions.emplace_back(I32GreaterThanEqualUnsigned{});
break;
case I32CountLeadingZeros::kOpcode:
instructions.emplace_back(I32CountLeadingZeros{});
break;
case I32CountTrailingZeros::kOpcode:
instructions.emplace_back(I32CountTrailingZeros{});
break;
case I32PopulationCount::kOpcode:
instructions.emplace_back(I32PopulationCount{});
break;
case I32Add::kOpcode:
instructions.emplace_back(I32Add{});
break;
case I32Sub::kOpcode:
instructions.emplace_back(I32Sub{});
case I32Subtract::kOpcode:
instructions.emplace_back(I32Subtract{});
break;
case I32Multiply::kOpcode:
instructions.emplace_back(I32Multiply{});
break;
case I32DivideSigned::kOpcode:
instructions.emplace_back(I32DivideSigned{});
break;
case I32DivideUnsigned::kOpcode:
instructions.emplace_back(I32DivideUnsigned{});
break;
case I32RemainderSigned::kOpcode:
instructions.emplace_back(I32RemainderSigned{});
break;
case I32RemainderUnsigned::kOpcode:
instructions.emplace_back(I32RemainderUnsigned{});
break;
case I32And::kOpcode:
instructions.emplace_back(I32And{});
break;
case I32Or::kOpcode:
instructions.emplace_back(I32Or{});
break;
case I32ExclusiveOr::kOpcode:
instructions.emplace_back(I32ExclusiveOr{});
break;
case I32ShiftLeft::kOpcode:
instructions.emplace_back(I32ShiftLeft{});
break;
case I32ShiftRightSigned::kOpcode:
instructions.emplace_back(I32ShiftRightSigned{});
break;
case I32ShiftRightUnsigned::kOpcode:
instructions.emplace_back(I32ShiftRightUnsigned{});
break;
case I32RotateLeft::kOpcode:
instructions.emplace_back(I32RotateLeft{});
break;
case I32RotateRight::kOpcode:
instructions.emplace_back(I32RotateRight{});
break;
case I32WrapI64::kOpcode:
instructions.emplace_back(I32WrapI64{});
break;
case I32TruncateF32Signed::kOpcode:
instructions.emplace_back(I32TruncateF32Signed{});
break;
case I32TruncateF32Unsigned::kOpcode:
instructions.emplace_back(I32TruncateF32Unsigned{});
break;
case I32TruncateF64Signed::kOpcode:
instructions.emplace_back(I32TruncateF64Signed{});
break;
case I32TruncateF64Unsigned::kOpcode:
instructions.emplace_back(I32TruncateF64Unsigned{});
break;
case I32ReinterpretF32::kOpcode:
instructions.emplace_back(I32ReinterpretF32{});
break;
case I32Extend8Signed::kOpcode:
instructions.emplace_back(I32Extend8Signed{});
break;
case I32Extend16Signed::kOpcode:
instructions.emplace_back(I32Extend16Signed{});
break;
case LocalGet::kOpcode: {
auto value = wasm::Leb128<std::uint32_t>::decode_from(is);
 
wasm/instructions.h added: 782, removed: 18, total 764
@@ -44,9 +44,43 @@ struct Return;
 
// Numeric instructions
struct I32Const;
struct I32EqualZero;
struct I32Equal;
struct I32NotEqual;
struct I32LessThanSigned;
struct I32LessThanUnsigned;
struct I32GreaterThanSigned;
struct I32GreaterThanUnsigned;
struct I32LessThanEqualSigned;
struct I32LessThanEqualUnsigned;
struct I32GreaterThanEqualSigned;
struct I32GreaterThanEqualUnsigned;
struct I32CountLeadingZeros;
struct I32CountTrailingZeros;
struct I32PopulationCount;
struct I32Add;
struct I32Sub;
struct I32Subtract;
struct I32Multiply;
struct I32DivideSigned;
struct I32DivideUnsigned;
struct I32RemainderSigned;
struct I32RemainderUnsigned;
struct I32And;
struct I32Or;
struct I32ExclusiveOr;
struct I32ShiftLeft;
struct I32ShiftRightSigned;
struct I32ShiftRightUnsigned;
struct I32RotateLeft;
struct I32RotateRight;
struct I32WrapI64;
struct I32TruncateF32Signed;
struct I32TruncateF32Unsigned;
struct I32TruncateF64Signed;
struct I32TruncateF64Unsigned;
struct I32ReinterpretF32;
struct I32Extend8Signed;
struct I32Extend16Signed;
 
// Variable instructions
struct LocalGet;
@@ -61,9 +95,43 @@ using Instruction = std::variant<Block,
BreakIf,
Return,
I32Const,
I32EqualZero,
I32Equal,
I32NotEqual,
I32LessThanSigned,
I32LessThanUnsigned,
I32GreaterThanSigned,
I32GreaterThanUnsigned,
I32LessThanEqualSigned,
I32LessThanEqualUnsigned,
I32GreaterThanEqualSigned,
I32GreaterThanEqualUnsigned,
I32CountLeadingZeros,
I32CountTrailingZeros,
I32PopulationCount,
I32Add,
I32Sub,
I32Subtract,
I32Multiply,
I32DivideSigned,
I32DivideUnsigned,
I32RemainderSigned,
I32RemainderUnsigned,
I32And,
I32Or,
I32ExclusiveOr,
I32ShiftLeft,
I32ShiftRightSigned,
I32ShiftRightUnsigned,
I32RotateLeft,
I32RotateRight,
I32WrapI64,
I32TruncateF32Signed,
I32TruncateF32Unsigned,
I32TruncateF64Signed,
I32TruncateF64Unsigned,
I32ReinterpretF32,
I32Extend8Signed,
I32Extend16Signed,
LocalGet,
LocalSet,
LocalTee,
@@ -113,22 +181,226 @@ struct I32Const {
[[nodiscard]] bool operator==(I32Const const &) const = default;
};
 
struct I32EqualZero {
static constexpr std::uint8_t kOpcode = 0x45;
static constexpr std::string_view kMnemonic = "i32.eqz";
[[nodiscard]] bool operator==(I32EqualZero const &) const = default;
};
 
struct I32Equal {
static constexpr std::uint8_t kOpcode = 0x46;
static constexpr std::string_view kMnemonic = "i32.eq";
[[nodiscard]] bool operator==(I32Equal const &) const = default;
};
 
struct I32NotEqual {
static constexpr std::uint8_t kOpcode = 0x47;
static constexpr std::string_view kMnemonic = "i32.ne";
[[nodiscard]] bool operator==(I32NotEqual const &) const = default;
};
 
struct I32LessThanSigned {
static constexpr std::uint8_t kOpcode = 0x48;
static constexpr std::string_view kMnemonic = "i32.lt_s";
[[nodiscard]] bool operator==(I32LessThanSigned const &) const = default;
};
 
struct I32LessThanUnsigned {
static constexpr std::uint8_t kOpcode = 0x49;
static constexpr std::string_view kMnemonic = "i32.lt_u";
[[nodiscard]] bool operator==(I32LessThanUnsigned const &) const = default;
};
 
struct I32GreaterThanSigned {
static constexpr std::uint8_t kOpcode = 0x4a;
static constexpr std::string_view kMnemonic = "i32.gt_s";
[[nodiscard]] bool operator==(I32GreaterThanSigned const &) const = default;
};
 
struct I32GreaterThanUnsigned {
static constexpr std::uint8_t kOpcode = 0x4b;
static constexpr std::string_view kMnemonic = "i32.gt_u";
[[nodiscard]] bool operator==(I32GreaterThanUnsigned const &) const = default;
};
 
struct I32LessThanEqualSigned {
static constexpr std::uint8_t kOpcode = 0x4c;
static constexpr std::string_view kMnemonic = "i32.le_s";
[[nodiscard]] bool operator==(I32LessThanEqualSigned const &) const = default;
};
 
struct I32LessThanEqualUnsigned {
static constexpr std::uint8_t kOpcode = 0x4d;
static constexpr std::string_view kMnemonic = "i32.le_u";
[[nodiscard]] bool operator==(I32LessThanEqualUnsigned const &) const = default;
};
 
struct I32GreaterThanEqualSigned {
static constexpr std::uint8_t kOpcode = 0x4e;
static constexpr std::string_view kMnemonic = "i32.ge_s";
[[nodiscard]] bool operator==(I32GreaterThanEqualSigned const &) const = default;
};
 
struct I32GreaterThanEqualUnsigned {
static constexpr std::uint8_t kOpcode = 0x4f;
static constexpr std::string_view kMnemonic = "i32.ge_u";
[[nodiscard]] bool operator==(I32GreaterThanEqualUnsigned const &) const = default;
};
 
struct I32CountLeadingZeros {
static constexpr std::uint8_t kOpcode = 0x67;
static constexpr std::string_view kMnemonic = "i32.clz";
[[nodiscard]] bool operator==(I32CountLeadingZeros const &) const = default;
};
 
struct I32CountTrailingZeros {
static constexpr std::uint8_t kOpcode = 0x68;
static constexpr std::string_view kMnemonic = "i32.ctz";
[[nodiscard]] bool operator==(I32CountTrailingZeros const &) const = default;
};
 
struct I32PopulationCount {
static constexpr std::uint8_t kOpcode = 0x69;
static constexpr std::string_view kMnemonic = "i32.popcnt";
[[nodiscard]] bool operator==(I32PopulationCount const &) const = default;
};
 
struct I32Add {
static constexpr std::uint8_t kOpcode = 0x6a;
static constexpr std::string_view kMnemonic = "i32.add";
[[nodiscard]] bool operator==(I32Add const &) const = default;
};
 
struct I32Sub {
struct I32Subtract {
static constexpr std::uint8_t kOpcode = 0x6b;
static constexpr std::string_view kMnemonic = "i32.sub";
[[nodiscard]] bool operator==(I32Sub const &) const = default;
[[nodiscard]] bool operator==(I32Subtract const &) const = default;
};
 
struct I32Multiply {
static constexpr std::uint8_t kOpcode = 0x6c;
static constexpr std::string_view kMnemonic = "i32.mul";
[[nodiscard]] bool operator==(I32Multiply const &) const = default;
};
 
struct I32DivideSigned {
static constexpr std::uint8_t kOpcode = 0x6d;
static constexpr std::string_view kMnemonic = "i32.div_s";
[[nodiscard]] bool operator==(I32DivideSigned const &) const = default;
};
 
struct I32DivideUnsigned {
static constexpr std::uint8_t kOpcode = 0x6e;
static constexpr std::string_view kMnemonic = "i32.div_u";
[[nodiscard]] bool operator==(I32DivideUnsigned const &) const = default;
};
 
struct I32RemainderSigned {
static constexpr std::uint8_t kOpcode = 0x6f;
static constexpr std::string_view kMnemonic = "i32.rem_s";
[[nodiscard]] bool operator==(I32RemainderSigned const &) const = default;
};
 
struct I32RemainderUnsigned {
static constexpr std::uint8_t kOpcode = 0x70;
static constexpr std::string_view kMnemonic = "i32.rem_u";
[[nodiscard]] bool operator==(I32RemainderUnsigned const &) const = default;
};
 
struct I32And {
static constexpr std::uint8_t kOpcode = 0x71;
static constexpr std::string_view kMnemonic = "i32.and";
[[nodiscard]] bool operator==(I32And const &) const = default;
};
 
struct I32Or {
static constexpr std::uint8_t kOpcode = 0x72;
static constexpr std::string_view kMnemonic = "i32.or";
[[nodiscard]] bool operator==(I32Or const &) const = default;
};
 
struct I32ExclusiveOr {
static constexpr std::uint8_t kOpcode = 0x73;
static constexpr std::string_view kMnemonic = "i32.xor";
[[nodiscard]] bool operator==(I32ExclusiveOr const &) const = default;
};
 
struct I32ShiftLeft {
static constexpr std::uint8_t kOpcode = 0x74;
static constexpr std::string_view kMnemonic = "i32.shl";
[[nodiscard]] bool operator==(I32ShiftLeft const &) const = default;
};
 
struct I32ShiftRightSigned {
static constexpr std::uint8_t kOpcode = 0x75;
static constexpr std::string_view kMnemonic = "i32.shr_s";
[[nodiscard]] bool operator==(I32ShiftRightSigned const &) const = default;
};
 
struct I32ShiftRightUnsigned {
static constexpr std::uint8_t kOpcode = 0x76;
static constexpr std::string_view kMnemonic = "i32.shr_u";
[[nodiscard]] bool operator==(I32ShiftRightUnsigned const &) const = default;
};
 
struct I32RotateLeft {
static constexpr std::uint8_t kOpcode = 0x77;
static constexpr std::string_view kMnemonic = "i32.rotl";
[[nodiscard]] bool operator==(I32RotateLeft const &) const = default;
};
 
struct I32RotateRight {
static constexpr std::uint8_t kOpcode = 0x78;
static constexpr std::string_view kMnemonic = "i32.rotr";
[[nodiscard]] bool operator==(I32RotateRight const &) const = default;
};
 
struct I32WrapI64 {
static constexpr std::uint8_t kOpcode = 0xa7;
static constexpr std::string_view kMnemonic = "i32.wrap_i64";
[[nodiscard]] bool operator==(I32WrapI64 const &) const = default;
};
 
struct I32TruncateF32Signed {
static constexpr std::uint8_t kOpcode = 0xa8;
static constexpr std::string_view kMnemonic = "i32.trunc_f32_s";
[[nodiscard]] bool operator==(I32TruncateF32Signed const &) const = default;
};
 
struct I32TruncateF32Unsigned {
static constexpr std::uint8_t kOpcode = 0xa9;
static constexpr std::string_view kMnemonic = "i32.trunc_f32_u";
[[nodiscard]] bool operator==(I32TruncateF32Unsigned const &) const = default;
};
 
struct I32TruncateF64Signed {
static constexpr std::uint8_t kOpcode = 0xaa;
static constexpr std::string_view kMnemonic = "i32.trunc_f64_s";
[[nodiscard]] bool operator==(I32TruncateF64Signed const &) const = default;
};
 
struct I32TruncateF64Unsigned {
static constexpr std::uint8_t kOpcode = 0xab;
static constexpr std::string_view kMnemonic = "i32.trunc_f64_u";
[[nodiscard]] bool operator==(I32TruncateF64Unsigned const &) const = default;
};
 
struct I32ReinterpretF32 {
static constexpr std::uint8_t kOpcode = 0xbc;
static constexpr std::string_view kMnemonic = "i32.reinterpret_f32";
[[nodiscard]] bool operator==(I32ReinterpretF32 const &) const = default;
};
 
struct I32Extend8Signed {
static constexpr std::uint8_t kOpcode = 0xc0;
static constexpr std::string_view kMnemonic = "i32.extend8_s";
[[nodiscard]] bool operator==(I32Extend8Signed const &) const = default;
};
 
struct I32Extend16Signed {
static constexpr std::uint8_t kOpcode = 0xc1;
static constexpr std::string_view kMnemonic = "i32.extend16_s";
[[nodiscard]] bool operator==(I32Extend16Signed const &) const = default;
};
 
// https://webassembly.github.io/spec/core/binary/instructions.html#variable-instructions
 
wasm/instructions_test.cpp added: 782, removed: 18, total 764
@@ -80,16 +80,146 @@ int main() {
a.expect_eq(parse("\x41\x80\x0b"), std::nullopt);
});
 
s.add_test("i32_eqz", [](etest::IActions &a) { a.expect_eq(parse("\x45\x0b"), InsnVec{I32EqualZero{}}); });
 
s.add_test("i32_eq", [](etest::IActions &a) { a.expect_eq(parse("\x46\x0b"), InsnVec{I32Equal{}}); });
 
s.add_test("i32_ne", [](etest::IActions &a) { a.expect_eq(parse("\x47\x0b"), InsnVec{I32NotEqual{}}); });
 
s.add_test("i32_less_than_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x48\x0b"), InsnVec{I32LessThanSigned{}}); //
});
 
s.add_test("i32_less_than_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x49\x0b"), InsnVec{I32LessThanUnsigned{}}); //
});
 
s.add_test("i32_greater_than_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x4a\x0b"), InsnVec{I32GreaterThanSigned{}}); //
});
 
s.add_test("i32_greater_than_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x4b\x0b"), InsnVec{I32GreaterThanUnsigned{}}); //
});
 
s.add_test("i32_less_than_equal_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x4c\x0b"), InsnVec{I32LessThanEqualSigned{}}); //
});
 
s.add_test("i32_less_than_equal_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x4d\x0b"), InsnVec{I32LessThanEqualUnsigned{}}); //
});
 
s.add_test("i32_greater_than_equal_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x4e\x0b"), InsnVec{I32GreaterThanEqualSigned{}}); //
});
 
s.add_test("i32_greater_than_equal_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x4f\x0b"), InsnVec{I32GreaterThanEqualUnsigned{}}); //
});
 
s.add_test("i32_count_leading_zeros", [](etest::IActions &a) {
a.expect_eq(parse("\x67\x0b"), InsnVec{I32CountLeadingZeros{}}); //
});
 
s.add_test("i32_count_trailing_zeros", [](etest::IActions &a) {
a.expect_eq(parse("\x68\x0b"), InsnVec{I32CountTrailingZeros{}}); //
});
 
s.add_test("i32_population_count", [](etest::IActions &a) {
a.expect_eq(parse("\x69\x0b"), InsnVec{I32PopulationCount{}}); //
});
 
s.add_test("i32_add", [](etest::IActions &a) {
a.expect_eq(parse("\x6a\x0b"), InsnVec{I32Add{}}); //
});
 
s.add_test("i32_sub", [](etest::IActions &a) {
a.expect_eq(parse("\x6b\x0b"), InsnVec{I32Sub{}}); //
s.add_test("i32_subtract", [](etest::IActions &a) {
a.expect_eq(parse("\x6b\x0b"), InsnVec{I32Subtract{}}); //
});
 
s.add_test("i32_multiply", [](etest::IActions &a) {
a.expect_eq(parse("\x6c\x0b"), InsnVec{I32Multiply{}}); //
});
 
s.add_test("i32_divide_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x6d\x0b"), InsnVec{I32DivideSigned{}}); //
});
 
s.add_test("i32_divide_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x6e\x0b"), InsnVec{I32DivideUnsigned{}}); //
});
 
s.add_test("i32_remainder_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x6f\x0b"), InsnVec{I32RemainderSigned{}}); //
});
 
s.add_test("i32_remainder_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x70\x0b"), InsnVec{I32RemainderUnsigned{}}); //
});
 
s.add_test("i32_and", [](etest::IActions &a) {
a.expect_eq(parse("\x71\x0b"), InsnVec{I32And{}}); //
});
 
s.add_test("i32_or", [](etest::IActions &a) {
a.expect_eq(parse("\x72\x0b"), InsnVec{I32Or{}}); //
});
 
s.add_test("i32_exclusive_or", [](etest::IActions &a) {
a.expect_eq(parse("\x73\x0b"), InsnVec{I32ExclusiveOr{}}); //
});
 
s.add_test("i32_shift_left", [](etest::IActions &a) {
a.expect_eq(parse("\x74\x0b"), InsnVec{I32ShiftLeft{}}); //
});
 
s.add_test("i32_shift_right_signed", [](etest::IActions &a) {
a.expect_eq(parse("\x75\x0b"), InsnVec{I32ShiftRightSigned{}}); //
});
 
s.add_test("i32_shift_right_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\x76\x0b"), InsnVec{I32ShiftRightUnsigned{}}); //
});
 
s.add_test("i32_rotate_left", [](etest::IActions &a) {
a.expect_eq(parse("\x77\x0b"), InsnVec{I32RotateLeft{}}); //
});
 
s.add_test("i32_rotate_right", [](etest::IActions &a) {
a.expect_eq(parse("\x78\x0b"), InsnVec{I32RotateRight{}}); //
});
 
s.add_test("i32_wrap_i64", [](etest::IActions &a) {
a.expect_eq(parse("\xa7\x0b"), InsnVec{I32WrapI64{}}); //
});
 
s.add_test("i32_truncate_f32_signed", [](etest::IActions &a) {
a.expect_eq(parse("\xa8\x0b"), InsnVec{I32TruncateF32Signed{}}); //
});
 
s.add_test("i32_truncate_f32_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\xa9\x0b"), InsnVec{I32TruncateF32Unsigned{}}); //
});
 
s.add_test("i32_truncate_f64_signed", [](etest::IActions &a) {
a.expect_eq(parse("\xaa\x0b"), InsnVec{I32TruncateF64Signed{}}); //
});
 
s.add_test("i32_truncate_f64_unsigned", [](etest::IActions &a) {
a.expect_eq(parse("\xab\x0b"), InsnVec{I32TruncateF64Unsigned{}}); //
});
 
s.add_test("i32_reinterpret_f32", [](etest::IActions &a) {
a.expect_eq(parse("\xbc\x0b"), InsnVec{I32ReinterpretF32{}}); //
});
 
s.add_test("i32_extend8_signed", [](etest::IActions &a) {
a.expect_eq(parse("\xc0\x0b"), InsnVec{I32Extend8Signed{}}); //
});
 
s.add_test("i32_extend16_signed", [](etest::IActions &a) {
a.expect_eq(parse("\xc1\x0b"), InsnVec{I32Extend16Signed{}}); //
});
 
s.add_test("local_get", [](etest::IActions &a) {
 
wasm/serialize.cpp added: 782, removed: 18, total 764
@@ -82,16 +82,152 @@ void InstructionStringifyVisitor::operator()(I32Const const &t) {
out += std::to_string(t.value);
}
 
void InstructionStringifyVisitor::operator()(I32EqualZero const &) {
out += I32EqualZero::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Equal const &) {
out += I32Equal::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32NotEqual const &) {
out += I32NotEqual::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32LessThanSigned const &) {
out += I32LessThanSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32LessThanUnsigned const &) {
out += I32LessThanUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32GreaterThanSigned const &) {
out += I32GreaterThanSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32GreaterThanUnsigned const &) {
out += I32GreaterThanUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32LessThanEqualSigned const &) {
out += I32LessThanEqualSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32LessThanEqualUnsigned const &) {
out += I32LessThanEqualUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32GreaterThanEqualSigned const &) {
out += I32GreaterThanEqualSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32GreaterThanEqualUnsigned const &) {
out += I32GreaterThanEqualUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32CountLeadingZeros const &) {
out += I32CountLeadingZeros::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32CountTrailingZeros const &) {
out += I32CountTrailingZeros::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32PopulationCount const &) {
out += I32PopulationCount::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Add const &) {
out += I32Add::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Sub const &) {
out += I32Sub::kMnemonic;
void InstructionStringifyVisitor::operator()(I32Subtract const &) {
out += I32Subtract::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Multiply const &) {
out += I32Multiply::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32DivideSigned const &) {
out += I32DivideSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32DivideUnsigned const &) {
out += I32DivideUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32RemainderSigned const &) {
out += I32RemainderSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32RemainderUnsigned const &) {
out += I32RemainderUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32And const &) {
out += I32And::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Or const &) {
out += I32Or::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32ExclusiveOr const &) {
out += I32ExclusiveOr::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32ShiftLeft const &) {
out += I32ShiftLeft::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32ShiftRightSigned const &) {
out += I32ShiftRightSigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32ShiftRightUnsigned const &) {
out += I32ShiftRightUnsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32RotateLeft const &) {
out += I32RotateLeft::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32RotateRight const &) {
out += I32RotateRight::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32WrapI64 const &) {
out += I32WrapI64::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32TruncateF32Signed const &) {
out += I32TruncateF32Signed::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32TruncateF32Unsigned const &) {
out += I32TruncateF32Unsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32TruncateF64Signed const &) {
out += I32TruncateF64Signed::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32TruncateF64Unsigned const &) {
out += I32TruncateF64Unsigned::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32ReinterpretF32 const &) {
out += I32ReinterpretF32::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Extend8Signed const &) {
out += I32Extend8Signed::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(I32Extend16Signed const &) {
out += I32Extend16Signed::kMnemonic;
}
 
void InstructionStringifyVisitor::operator()(LocalGet const &t) {
 
wasm/serialize.h added: 782, removed: 18, total 764
@@ -96,9 +96,43 @@ struct InstructionStringifyVisitor {
void operator()(BreakIf const &t);
void operator()(Return const &);
void operator()(I32Const const &t);
void operator()(I32EqualZero const &);
void operator()(I32Equal const &);
void operator()(I32NotEqual const &);
void operator()(I32LessThanSigned const &);
void operator()(I32LessThanUnsigned const &);
void operator()(I32GreaterThanSigned const &);
void operator()(I32GreaterThanUnsigned const &);
void operator()(I32LessThanEqualSigned const &);
void operator()(I32LessThanEqualUnsigned const &);
void operator()(I32GreaterThanEqualSigned const &);
void operator()(I32GreaterThanEqualUnsigned const &);
void operator()(I32CountLeadingZeros const &);
void operator()(I32CountTrailingZeros const &);
void operator()(I32PopulationCount const &);
void operator()(I32Add const &);
void operator()(I32Sub const &);
void operator()(I32Subtract const &);
void operator()(I32Multiply const &);
void operator()(I32DivideSigned const &);
void operator()(I32DivideUnsigned const &);
void operator()(I32RemainderSigned const &);
void operator()(I32RemainderUnsigned const &);
void operator()(I32And const &);
void operator()(I32Or const &);
void operator()(I32ExclusiveOr const &);
void operator()(I32ShiftLeft const &);
void operator()(I32ShiftRightSigned const &);
void operator()(I32ShiftRightUnsigned const &);
void operator()(I32RotateLeft const &);
void operator()(I32RotateRight const &);
void operator()(I32WrapI64 const &);
void operator()(I32TruncateF32Signed const &);
void operator()(I32TruncateF32Unsigned const &);
void operator()(I32TruncateF64Signed const &);
void operator()(I32TruncateF64Unsigned const &);
void operator()(I32ReinterpretF32 const &);
void operator()(I32Extend8Signed const &);
void operator()(I32Extend16Signed const &);
void operator()(LocalGet const &t);
void operator()(LocalSet const &t);
void operator()(LocalTee const &t);
 
wasm/serialize_test.cpp added: 782, removed: 18, total 764
@@ -49,12 +49,102 @@ int main() {
 
s.add_test("i32_const", [](etest::IActions &a) { a.expect_eq(to_string(I32Const{}), "i32.const 0"); });
 
s.add_test("i32_eqz", [](etest::IActions &a) { a.expect_eq(to_string(I32EqualZero{}), "i32.eqz"); });
 
s.add_test("i32_eq", [](etest::IActions &a) { a.expect_eq(to_string(I32Equal{}), "i32.eq"); });
 
s.add_test("i32_ne", [](etest::IActions &a) { a.expect_eq(to_string(I32NotEqual{}), "i32.ne"); });
 
s.add_test("i32_less_than_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32LessThanSigned{}), "i32.lt_s"); });
 
s.add_test("i32_less_than_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32LessThanUnsigned{}), "i32.lt_u"); });
 
s.add_test("i32_greater_than_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32GreaterThanSigned{}), "i32.gt_s"); });
 
s.add_test("i32_greater_than_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32GreaterThanUnsigned{}), "i32.gt_u"); });
 
s.add_test("i32_less_than_equal_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32LessThanEqualSigned{}), "i32.le_s"); });
 
s.add_test("i32_less_than_equal_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32LessThanEqualUnsigned{}), "i32.le_u"); });
 
s.add_test("i32_greater_than_equal_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32GreaterThanEqualSigned{}), "i32.ge_s"); });
 
s.add_test("i32_greater_than_equal_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32GreaterThanEqualUnsigned{}), "i32.ge_u"); });
 
s.add_test("i32_count_leading_zeros",
[](etest::IActions &a) { a.expect_eq(to_string(I32CountLeadingZeros{}), "i32.clz"); });
 
s.add_test("i32_count_trailing_zeros",
[](etest::IActions &a) { a.expect_eq(to_string(I32CountTrailingZeros{}), "i32.ctz"); });
 
s.add_test("i32_population_count",
[](etest::IActions &a) { a.expect_eq(to_string(I32PopulationCount{}), "i32.popcnt"); });
 
s.add_test("i32_add", [](etest::IActions &a) { a.expect_eq(to_string(I32Add{}), "i32.add"); });
 
s.add_test("i32_sub", [](etest::IActions &a) { a.expect_eq(to_string(I32Sub{}), "i32.sub"); });
s.add_test("i32_subtract", [](etest::IActions &a) { a.expect_eq(to_string(I32Subtract{}), "i32.sub"); });
 
s.add_test("i32_multiply", [](etest::IActions &a) { a.expect_eq(to_string(I32Multiply{}), "i32.mul"); });
 
s.add_test("i32_divide_signed", [](etest::IActions &a) { a.expect_eq(to_string(I32DivideSigned{}), "i32.div_s"); });
 
s.add_test("i32_divide_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32DivideUnsigned{}), "i32.div_u"); });
 
s.add_test("i32_remainder_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32RemainderSigned{}), "i32.rem_s"); });
 
s.add_test("i32_remainder_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32RemainderUnsigned{}), "i32.rem_u"); });
 
s.add_test("i32_and", [](etest::IActions &a) { a.expect_eq(to_string(I32And{}), "i32.and"); });
 
s.add_test("i32_or", [](etest::IActions &a) { a.expect_eq(to_string(I32Or{}), "i32.or"); });
 
s.add_test("i32_exlusive_or", [](etest::IActions &a) { a.expect_eq(to_string(I32ExclusiveOr{}), "i32.xor"); });
 
s.add_test("i32_shift_left", [](etest::IActions &a) { a.expect_eq(to_string(I32ShiftLeft{}), "i32.shl"); });
 
s.add_test("i32_shift_right_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32ShiftRightSigned{}), "i32.shr_s"); });
 
s.add_test("i32_shift_right_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32ShiftRightUnsigned{}), "i32.shr_u"); });
 
s.add_test("i32_rotate_left", [](etest::IActions &a) { a.expect_eq(to_string(I32RotateLeft{}), "i32.rotl"); });
 
s.add_test("i32_rotate_right", [](etest::IActions &a) { a.expect_eq(to_string(I32RotateRight{}), "i32.rotr"); });
 
s.add_test("i32_wrap_i64", [](etest::IActions &a) { a.expect_eq(to_string(I32WrapI64{}), "i32.wrap_i64"); });
 
s.add_test("i32_truncate_f32_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32TruncateF32Signed{}), "i32.trunc_f32_s"); });
 
s.add_test("i32_truncate_f32_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32TruncateF32Unsigned{}), "i32.trunc_f32_u"); });
 
s.add_test("i32_truncate_f64_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32TruncateF64Signed{}), "i32.trunc_f64_s"); });
 
s.add_test("i32_truncate_f64_unsigned",
[](etest::IActions &a) { a.expect_eq(to_string(I32TruncateF64Unsigned{}), "i32.trunc_f64_u"); });
 
s.add_test("i32_reinterpret_f32",
[](etest::IActions &a) { a.expect_eq(to_string(I32ReinterpretF32{}), "i32.reinterpret_f32"); });
 
s.add_test("i32_extend8_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32Extend8Signed{}), "i32.extend8_s"); });
 
s.add_test("i32_extend16_signed",
[](etest::IActions &a) { a.expect_eq(to_string(I32Extend16Signed{}), "i32.extend16_s"); });
 
s.add_test("local_get", [](etest::IActions &a) { a.expect_eq(to_string(LocalGet{}), "local.get 0"); });