diff options
Diffstat (limited to 'externals/biscuit/tests/src')
25 files changed, 13372 insertions, 0 deletions
diff --git a/externals/biscuit/tests/src/assembler_bfloat_tests.cpp b/externals/biscuit/tests/src/assembler_bfloat_tests.cpp new file mode 100644 index 00000000..3f0df44f --- /dev/null +++ b/externals/biscuit/tests/src/assembler_bfloat_tests.cpp @@ -0,0 +1,95 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("FCVT.BF16.S", "[Zfbfmin]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_BF16_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x44838FD3); + + as.RewindBuffer(); + + as.FCVT_BF16_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x4483CFD3); + + as.RewindBuffer(); + + as.FCVT_BF16_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x4483FFD3); +} + +TEST_CASE("FCVT.S.BF16", "[Zfbfmin]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_S_BF16(f31, f7, RMode::RNE); + REQUIRE(value == 0x40638FD3); + + as.RewindBuffer(); + + as.FCVT_S_BF16(f31, f7, RMode::RMM); + REQUIRE(value == 0x4063CFD3); + + as.RewindBuffer(); + + as.FCVT_S_BF16(f31, f7, RMode::DYN); + REQUIRE(value == 0x4063FFD3); +} + +TEST_CASE("VFNCVTBF16.F.F.W", "[Zvfbfmin]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.VFNCVTBF16_F_F_W(v31, v7, VecMask::Yes); + REQUIRE(value == 0x487E9FD7); + + as.RewindBuffer(); + + as.VFNCVTBF16_F_F_W(v31, v7, VecMask::No); + REQUIRE(value == 0x4A7E9FD7); +} + +TEST_CASE("VFWCVTBF16.F.F.V", "[Zvfbfmin]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.VFWCVTBF16_F_F_V(v31, v7, VecMask::Yes); + REQUIRE(value == 0x48769FD7); + + as.RewindBuffer(); + + as.VFWCVTBF16_F_F_V(v31, v7, VecMask::No); + REQUIRE(value == 0x4A769FD7); +} + +TEST_CASE("VFWMACCBF16.VF", "[Zvfbfwma]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.VFWMACCBF16(v31, f7, v20, VecMask::Yes); + REQUIRE(value == 0xED43DFD7); + + as.RewindBuffer(); + + as.VFWMACCBF16(v31, f7, v20, VecMask::No); + REQUIRE(value == 0xEF43DFD7); +} + +TEST_CASE("VFWMACCBF16.VV", "[Zvfbfwma]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.VFWMACCBF16(v31, v7, v20, VecMask::Yes); + REQUIRE(value == 0xED439FD7); + + as.RewindBuffer(); + + as.VFWMACCBF16(v31, v7, v20, VecMask::No); + REQUIRE(value == 0xEF439FD7); +} diff --git a/externals/biscuit/tests/src/assembler_branch_tests.cpp b/externals/biscuit/tests/src/assembler_branch_tests.cpp new file mode 100644 index 00000000..ed0c7f23 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_branch_tests.cpp @@ -0,0 +1,105 @@ +#include <catch/catch.hpp> + +#include <array> +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("Branch to Self", "[branch]") { + uint32_t data; + auto as = MakeAssembler32(data); + + // Simple branch to self with a jump instruction. + { + Label label; + as.Bind(&label); + as.J(&label); + REQUIRE(data == 0x0000006F); + } + + as.RewindBuffer(); + + // Simple branch to self with a compressed jump instruction. + { + Label label; + as.Bind(&label); + as.C_J(&label); + REQUIRE((data & 0xFFFF) == 0xA001); + } + + as.RewindBuffer(); + + // Simple branch to self with a conditional branch instruction. + { + Label label; + as.Bind(&label); + as.BNE(x3, x4, &label); + REQUIRE(data == 0x00419063); + } + + as.RewindBuffer(); + + // Simple branch to self with a compressed branch instruction. + { + Label label; + as.Bind(&label); + as.C_BNEZ(x15, &label); + REQUIRE((data & 0xFFFF) == 0xE381); + } +} + +TEST_CASE("Branch with Instructions Between", "[branch]") { + std::array<uint32_t, 20> data{}; + auto as = MakeAssembler32(data); + + // Simple branch backward + { + Label label; + as.Bind(&label); + as.ADD(x1, x2, x3); + as.SUB(x2, x4, x3); + as.J(&label); + REQUIRE(data[2] == 0xFF9FF06F); + } + + as.RewindBuffer(); + data.fill(0); + + // Simple branch forward + { + Label label; + as.J(&label); + as.ADD(x1, x2, x3); + as.SUB(x2, x4, x3); + as.Bind(&label); + REQUIRE(data[0] == 0x00C0006F); + } + + as.RewindBuffer(); + data.fill(0); + + // Simple branch backward (compressed) + { + Label label; + as.Bind(&label); + as.ADD(x1, x2, x3); + as.SUB(x2, x4, x3); + as.C_J(&label); + REQUIRE((data[2] & 0xFFFF) == 0xBFC5); + } + + as.RewindBuffer(); + data.fill(0); + + // Simple branch forward (compressed) + { + Label label; + as.C_J(&label); + as.ADD(x1, x2, x3); + as.SUB(x2, x4, x3); + as.Bind(&label); + REQUIRE((data[0] & 0xFFFF) == 0xA0A1); + } +} diff --git a/externals/biscuit/tests/src/assembler_cmo_tests.cpp b/externals/biscuit/tests/src/assembler_cmo_tests.cpp new file mode 100644 index 00000000..0b4cffdc --- /dev/null +++ b/externals/biscuit/tests/src/assembler_cmo_tests.cpp @@ -0,0 +1,113 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("CBO.CLEAN", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CBO_CLEAN(x0); + REQUIRE(value == 0x0010200F); + + as.RewindBuffer(); + + as.CBO_CLEAN(x31); + REQUIRE(value == 0x001FA00F); +} + +TEST_CASE("CBO.FLUSH", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CBO_FLUSH(x0); + REQUIRE(value == 0x0020200F); + + as.RewindBuffer(); + + as.CBO_FLUSH(x31); + REQUIRE(value == 0x002FA00F); +} + +TEST_CASE("CBO.INVAL", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CBO_INVAL(x0); + REQUIRE(value == 0x0000200F); + + as.RewindBuffer(); + + as.CBO_INVAL(x31); + REQUIRE(value == 0x000FA00F); +} + +TEST_CASE("CBO.ZERO", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CBO_ZERO(x0); + REQUIRE(value == 0x0040200F); + + as.RewindBuffer(); + + as.CBO_ZERO(x31); + REQUIRE(value == 0x004FA00F); +} + +TEST_CASE("PREFETCH.I", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.PREFETCH_I(x0); + REQUIRE(value == 0x00006013); + + as.RewindBuffer(); + + as.PREFETCH_I(x31, 2016); + REQUIRE(value == 0x7E0FE013); + + as.RewindBuffer(); + + as.PREFETCH_I(x31, -2016); + REQUIRE(value == 0x820FE013); +} + +TEST_CASE("PREFETCH.R", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.PREFETCH_R(x0); + REQUIRE(value == 0x00106013); + + as.RewindBuffer(); + + as.PREFETCH_R(x31, 2016); + REQUIRE(value == 0x7E1FE013); + + as.RewindBuffer(); + + as.PREFETCH_R(x31, -2016); + REQUIRE(value == 0x821FE013); +} + +TEST_CASE("PREFETCH.W", "[cmo]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.PREFETCH_W(x0); + REQUIRE(value == 0x00306013); + + as.RewindBuffer(); + + as.PREFETCH_W(x31, 2016); + REQUIRE(value == 0x7E3FE013); + + as.RewindBuffer(); + + as.PREFETCH_W(x31, -2016); + REQUIRE(value == 0x823FE013); +} diff --git a/externals/biscuit/tests/src/assembler_privileged_tests.cpp b/externals/biscuit/tests/src/assembler_privileged_tests.cpp new file mode 100644 index 00000000..0f7d8129 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_privileged_tests.cpp @@ -0,0 +1,302 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("HFENCE.VVMA", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HFENCE_VVMA(x0, x0); + REQUIRE(value == 0x22000073); + + as.RewindBuffer(); + + as.HFENCE_VVMA(x15, x15); + REQUIRE(value == 0x22F78073); +} + +TEST_CASE("HFENCE.GVMA", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HFENCE_GVMA(x0, x0); + REQUIRE(value == 0x62000073); + + as.RewindBuffer(); + + as.HFENCE_GVMA(x15, x15); + REQUIRE(value == 0x62F78073); +} + +TEST_CASE("HINVAL.VVMA", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HINVAL_VVMA(x0, x0); + REQUIRE(value == 0x26000073); + + as.RewindBuffer(); + + as.HINVAL_VVMA(x15, x15); + REQUIRE(value == 0x26F78073); +} + +TEST_CASE("HINVAL.GVMA", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HINVAL_GVMA(x0, x0); + REQUIRE(value == 0x66000073); + + as.RewindBuffer(); + + as.HINVAL_GVMA(x15, x15); + REQUIRE(value == 0x66F78073); +} + +TEST_CASE("HLV.B", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLV_B(x0, x0); + REQUIRE(value == 0x60004073); + + as.RewindBuffer(); + + as.HLV_B(x15, x14); + REQUIRE(value == 0x600747F3); +} + +TEST_CASE("HLV.BU", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLV_BU(x0, x0); + REQUIRE(value == 0x60104073); + + as.RewindBuffer(); + + as.HLV_BU(x15, x14); + REQUIRE(value == 0x601747F3); +} + +TEST_CASE("HLV.D", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.HLV_D(x0, x0); + REQUIRE(value == 0x6C004073); + + as.RewindBuffer(); + + as.HLV_D(x15, x14); + REQUIRE(value == 0x6C0747F3); +} + +TEST_CASE("HLV.H", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLV_H(x0, x0); + REQUIRE(value == 0x64004073); + + as.RewindBuffer(); + + as.HLV_H(x15, x14); + REQUIRE(value == 0x640747F3); +} + +TEST_CASE("HLV.HU", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLV_HU(x0, x0); + REQUIRE(value == 0x64104073); + + as.RewindBuffer(); + + as.HLV_HU(x15, x14); + REQUIRE(value == 0x641747F3); +} + +TEST_CASE("HLV.W", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLV_W(x0, x0); + REQUIRE(value == 0x68004073); + + as.RewindBuffer(); + + as.HLV_W(x15, x14); + REQUIRE(value == 0x680747F3); +} + +TEST_CASE("HLV.WU", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.HLV_WU(x0, x0); + REQUIRE(value == 0x68104073); + + as.RewindBuffer(); + + as.HLV_WU(x15, x14); + REQUIRE(value == 0x681747F3); +} + +TEST_CASE("HLVX.HU", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLVX_HU(x0, x0); + REQUIRE(value == 0x64304073); + + as.RewindBuffer(); + + as.HLVX_HU(x15, x14); + REQUIRE(value == 0x643747F3); +} + +TEST_CASE("HLVX.WU", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HLVX_WU(x0, x0); + REQUIRE(value == 0x68304073); + + as.RewindBuffer(); + + as.HLVX_WU(x15, x14); + REQUIRE(value == 0x683747F3); +} + +TEST_CASE("HSV.B", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HSV_B(x0, x0); + REQUIRE(value == 0x62004073); + + as.RewindBuffer(); + + as.HSV_B(x15, x14); + REQUIRE(value == 0x62F74073); +} + +TEST_CASE("HSV.D", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.HSV_D(x0, x0); + REQUIRE(value == 0x6E004073); + + as.RewindBuffer(); + + as.HSV_D(x15, x14); + REQUIRE(value == 0x6EF74073); +} + +TEST_CASE("HSV.H", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HSV_H(x0, x0); + REQUIRE(value == 0x66004073); + + as.RewindBuffer(); + + as.HSV_H(x15, x14); + REQUIRE(value == 0x66F74073); +} + +TEST_CASE("HSV.W", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.HSV_W(x0, x0); + REQUIRE(value == 0x6A004073); + + as.RewindBuffer(); + + as.HSV_W(x15, x14); + REQUIRE(value == 0x6AF74073); +} + +TEST_CASE("MRET", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MRET(); + REQUIRE(value == 0x30200073); +} + +TEST_CASE("SFENCE.INVAL.IR", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SFENCE_INVAL_IR(); + REQUIRE(value == 0x18100073); +} + +TEST_CASE("SFENCE.VMA", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SFENCE_VMA(x0, x0); + REQUIRE(value == 0x12000073); + + as.RewindBuffer(); + + as.SFENCE_VMA(x15, x15); + REQUIRE(value == 0x12F78073); +} + +TEST_CASE("SFENCE.W.INVAL", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SFENCE_W_INVAL(); + REQUIRE(value == 0x18000073); +} + +TEST_CASE("SINVAL.VMA", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SINVAL_VMA(x0, x0); + REQUIRE(value == 0x16000073); + + as.RewindBuffer(); + + as.SINVAL_VMA(x15, x15); + REQUIRE(value == 0x16F78073); +} + +TEST_CASE("SRET", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SRET(); + REQUIRE(value == 0x10200073); +} + +TEST_CASE("URET", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.URET(); + REQUIRE(value == 0x00200073); +} + +TEST_CASE("WFI", "[rvpriv]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.WFI(); + REQUIRE(value == 0x10500073); +} diff --git a/externals/biscuit/tests/src/assembler_rv32i_tests.cpp b/externals/biscuit/tests/src/assembler_rv32i_tests.cpp new file mode 100644 index 00000000..a3dec818 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rv32i_tests.cpp @@ -0,0 +1,769 @@ +#include <catch/catch.hpp> + +#include <array> +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("ADD", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ADD(x7, x15, x31); + REQUIRE(value == 0x01F783B3); + + as.RewindBuffer(); + + as.ADD(x31, x31, x31); + REQUIRE(value == 0x01FF8FB3); + + as.RewindBuffer(); + + as.ADD(x0, x0, x0); + REQUIRE(value == 0x00000033); +} + +TEST_CASE("ADDI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ADDI(x15, x31, 1024); + REQUIRE(value == 0x400F8793); + + as.RewindBuffer(); + + as.ADDI(x15, x31, 2048); + REQUIRE(value == 0x800F8793); + + as.RewindBuffer(); + + as.ADDI(x15, x31, 4095); + REQUIRE(value == 0xFFFF8793); +} + +TEST_CASE("AND", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AND(x7, x15, x31); + REQUIRE(value == 0x01F7F3B3); + + as.RewindBuffer(); + + as.AND(x31, x31, x31); + REQUIRE(value == 0x01FFFFB3); + + as.RewindBuffer(); + + as.AND(x0, x0, x0); + REQUIRE(value == 0x00007033); +} + +TEST_CASE("ANDI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ANDI(x15, x31, 1024); + REQUIRE(value == 0x400FF793); + + as.RewindBuffer(); + + as.ANDI(x15, x31, 2048); + REQUIRE(value == 0x800FF793); + + as.RewindBuffer(); + + as.ANDI(x15, x31, 4095); + REQUIRE(value == 0xFFFFF793); +} + +TEST_CASE("AUIPC", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AUIPC(x31, -1); + REQUIRE(value == 0xFFFFFF97); + + as.RewindBuffer(); + + as.AUIPC(x31, 0); + REQUIRE(value == 0x00000F97); + + as.RewindBuffer(); + + as.AUIPC(x31, 0x00FF00FF); + REQUIRE(value == 0xF00FFF97); +} + +TEST_CASE("BEQ", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BEQ(x15, x31, 2000); + REQUIRE(value == 0x7DF78863); + + as.RewindBuffer(); + + as.BEQ(x15, x31, -2); + REQUIRE(value == 0xFFF78FE3); +} + +TEST_CASE("BGE", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BGE(x15, x31, 2000); + REQUIRE(value == 0x7DF7D863); + + as.RewindBuffer(); + + as.BGE(x15, x31, -2); + REQUIRE(value == 0xFFF7DFE3); +} + +TEST_CASE("BGEU", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BGEU(x15, x31, 2000); + REQUIRE(value == 0x7DF7F863); + + as.RewindBuffer(); + + as.BGEU(x15, x31, -2); + REQUIRE(value == 0xFFF7FFE3); +} + +TEST_CASE("BNE", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BNE(x15, x31, 2000); + REQUIRE(value == 0x7DF79863); + + as.RewindBuffer(); + + as.BNE(x15, x31, -2); + REQUIRE(value == 0xFFF79FE3); +} + +TEST_CASE("BLT", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BLT(x15, x31, 2000); + REQUIRE(value == 0x7DF7C863); + + as.RewindBuffer(); + + as.BLT(x15, x31, -2); + REQUIRE(value == 0xFFF7CFE3); +} + +TEST_CASE("BLTU", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BLTU(x15, x31, 2000); + REQUIRE(value == 0x7DF7E863); + + as.RewindBuffer(); + + as.BLTU(x15, x31, -2); + REQUIRE(value == 0xFFF7EFE3); +} + +TEST_CASE("CALL", "[rv32i]") { + std::array<uint32_t, 2> vals{}; + auto as = MakeAssembler32(vals); + + const auto compare_vals = [&vals](uint32_t val_1, uint32_t val_2) { + REQUIRE(vals[0] == val_1); + REQUIRE(vals[1] == val_2); + }; + + as.CALL(-1); + compare_vals(0x00000097, 0xFFF080E7); +} + +TEST_CASE("EBREAK", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.EBREAK(); + REQUIRE(value == 0x00100073); +} + +TEST_CASE("ECALL", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ECALL(); + REQUIRE(value == 0x00000073); +} + +TEST_CASE("FENCE", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FENCE(FenceOrder::IORW, FenceOrder::IORW); + REQUIRE(value == 0x0FF0000F); + + as.RewindBuffer(); + + as.FENCETSO(); + REQUIRE(value == 0x8330000F); + + as.RewindBuffer(); + + as.FENCEI(); + REQUIRE(value == 0x0000100F); +} + +TEST_CASE("JAL", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.JAL(x31, 0xFFFFFFFF); + REQUIRE(value == 0xFFFFFFEF); + + as.RewindBuffer(); + + as.JAL(x31, 2000); + REQUIRE(value == 0x7D000FEF); + + as.RewindBuffer(); + + as.JAL(x31, 100000); + REQUIRE(value == 0x6A018FEF); +} + +TEST_CASE("JALR", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.JALR(x15, 1024, x31); + REQUIRE(value == 0x400F87E7); + + as.RewindBuffer(); + + as.JALR(x15, 1536, x31); + REQUIRE(value == 0x600F87E7); + + as.RewindBuffer(); + + as.JALR(x15, -1, x31); + REQUIRE(value == 0xFFFF87E7); +} + +TEST_CASE("LB", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LB(x15, 1024, x31); + REQUIRE(value == 0x400F8783); + + as.RewindBuffer(); + + as.LB(x15, 1536, x31); + REQUIRE(value == 0x600F8783); + + as.RewindBuffer(); + + as.LB(x15, -1, x31); + REQUIRE(value == 0xFFFF8783); +} + +TEST_CASE("LBU", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LBU(x15, 1024, x31); + REQUIRE(value == 0x400FC783); + + as.RewindBuffer(); + + as.LBU(x15, 1536, x31); + REQUIRE(value == 0x600FC783); + + as.RewindBuffer(); + + as.LBU(x15, -1, x31); + REQUIRE(value == 0xFFFFC783); +} + +TEST_CASE("LH", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LH(x15, 1024, x31); + REQUIRE(value == 0x400F9783); + + as.RewindBuffer(); + + as.LH(x15, 1536, x31); + REQUIRE(value == 0x600F9783); + + as.RewindBuffer(); + + as.LH(x15, -1, x31); + REQUIRE(value == 0xFFFF9783); +} + +TEST_CASE("LHU", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LHU(x15, 1024, x31); + REQUIRE(value == 0x400FD783); + + as.RewindBuffer(); + + as.LHU(x15, 1536, x31); + REQUIRE(value == 0x600FD783); + + as.RewindBuffer(); + + as.LHU(x15, -1, x31); + REQUIRE(value == 0xFFFFD783); +} + +TEST_CASE("LI", "[rv32i]") { + std::array<uint32_t, 2> vals{}; + auto as = MakeAssembler32(vals); + + const auto compare_vals = [&vals](uint32_t val_1, uint32_t val_2) { + REQUIRE(vals[0] == val_1); + REQUIRE(vals[1] == val_2); + }; + + ///////// Single ADDI cases + + as.LI(x1, 0); + // addi x1, x0, 0 + compare_vals(0x00000093, 0x00000000); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, -1); + // addi x1, x0, -1 + compare_vals(0xFFF00093, 0x00000000); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, 42); + // addi x1, x0, 42 + compare_vals(0x02A00093, 0x000000000); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, 0x7ff); + // addi x1, x0, 2047 + compare_vals(0x7FF00093, 0x00000000); + as.RewindBuffer(); + vals = {}; + + ///////// Single LUI cases + + as.LI(x1, 0x2A000); + // lui x1, 42 + compare_vals(0x0002A0B7, 0x00000000); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, ~0xFFF); + // lui x1, -1 + compare_vals(0xFFFFF0B7, 0x00000000); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, INT32_MIN); + // lui x1, -524288 + compare_vals(0x800000B7, 0x00000000); + as.RewindBuffer(); + vals = {}; + + ///////// Full LUI+ADDI cases + + as.LI(x1, 0x11111111); + // lui x1, 69905 + // addi x1, x1, 273 + compare_vals(0x111110B7, 0x11108093); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, INT32_MAX); + // lui x1, -524288 + // addi x1, x1, -1 + compare_vals(0x800000B7, 0xFFF08093); +} + +TEST_CASE("LUI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LUI(x10, 0xFFFFFFFF); + REQUIRE(value == 0xFFFFF537); + + as.RewindBuffer(); + + as.LUI(x10, 0xFFF7FFFF); + REQUIRE(value == 0x7FFFF537); + + as.RewindBuffer(); + + as.LUI(x31, 0xFFFFFFFF); + REQUIRE(value == 0xFFFFFFB7); +} + +TEST_CASE("LW", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LW(x15, 1024, x31); + REQUIRE(value == 0x400FA783); + + as.RewindBuffer(); + + as.LW(x15, 1536, x31); + REQUIRE(value == 0x600FA783); + + as.RewindBuffer(); + + as.LW(x15, -1, x31); + REQUIRE(value == 0xFFFFA783); +} + +TEST_CASE("OR", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.OR(x7, x15, x31); + REQUIRE(value == 0x01F7E3B3); + + as.RewindBuffer(); + + as.OR(x31, x31, x31); + REQUIRE(value == 0x01FFEFB3); + + as.RewindBuffer(); + + as.OR(x0, x0, x0); + REQUIRE(value == 0x00006033); +} + +TEST_CASE("ORI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ORI(x15, x31, 1024); + REQUIRE(value == 0x400FE793); + + as.RewindBuffer(); + + as.ORI(x15, x31, 2048); + REQUIRE(value == 0x800FE793); + + as.RewindBuffer(); + + as.ORI(x15, x31, 4095); + REQUIRE(value == 0xFFFFE793); +} + +TEST_CASE("PAUSE", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.PAUSE(); + REQUIRE(value == 0x0100000F); +} + +TEST_CASE("SB", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SB(x31, 1024, x15); + REQUIRE(value == 0x41F78023); + + as.RewindBuffer(); + + as.SB(x31, 1536, x15); + REQUIRE(value == 0x61F78023); + + as.RewindBuffer(); + + as.SB(x31, -1, x15); + REQUIRE(value == 0xFFF78FA3); +} + +TEST_CASE("SH", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SH(x31, 1024, x15); + REQUIRE(value == 0x41F79023); + + as.RewindBuffer(); + + as.SH(x31, 1536, x15); + REQUIRE(value == 0x61F79023); + + as.RewindBuffer(); + + as.SH(x31, -1, x15); + REQUIRE(value == 0xFFF79FA3); +} + +TEST_CASE("SLL", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SLL(x7, x15, x31); + REQUIRE(value == 0x01F793B3); + + as.RewindBuffer(); + + as.SLL(x31, x31, x31); + REQUIRE(value == 0x01FF9FB3); + + as.RewindBuffer(); + + as.SLL(x0, x0, x0); + REQUIRE(value == 0x00001033); +} + +TEST_CASE("SLLI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SLLI(x31, x15, 10); + REQUIRE(value == 0x00A79F93); + + as.RewindBuffer(); + + as.SLLI(x31, x15, 20); + REQUIRE(value == 0x01479F93); + + as.RewindBuffer(); + + as.SLLI(x31, x15, 31); + REQUIRE(value == 0x01F79F93); +} + +TEST_CASE("SLT", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SLT(x7, x15, x31); + REQUIRE(value == 0x01F7A3B3); + + as.RewindBuffer(); + + as.SLT(x31, x31, x31); + REQUIRE(value == 0x01FFAFB3); + + as.RewindBuffer(); + + as.SLT(x0, x0, x0); + REQUIRE(value == 0x00002033); +} + +TEST_CASE("SLTI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SLTI(x15, x31, 1024); + REQUIRE(value == 0x400FA793); + + as.RewindBuffer(); + + as.SLTI(x15, x31, -2048); + REQUIRE(value == 0x800FA793); + + as.RewindBuffer(); + + as.SLTI(x15, x31, -1); + REQUIRE(value == 0xFFFFA793); +} + +TEST_CASE("SLTIU", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SLTIU(x15, x31, 1024); + REQUIRE(value == 0x400FB793); + + as.RewindBuffer(); + + as.SLTIU(x15, x31, -2048); + REQUIRE(value == 0x800FB793); + + as.RewindBuffer(); + + as.SLTIU(x15, x31, -1); + REQUIRE(value == 0xFFFFB793); +} + +TEST_CASE("SLTU", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SLTU(x7, x15, x31); + REQUIRE(value == 0x01F7B3B3); + + as.RewindBuffer(); + + as.SLTU(x31, x31, x31); + REQUIRE(value == 0x01FFBFB3); + + as.RewindBuffer(); + + as.SLTU(x0, x0, x0); + REQUIRE(value == 0x00003033); +} + +TEST_CASE("SRA", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SRA(x7, x15, x31); + REQUIRE(value == 0x41F7D3B3); + + as.RewindBuffer(); + + as.SRA(x31, x31, x31); + REQUIRE(value == 0x41FFDFB3); + + as.RewindBuffer(); + + as.SRA(x0, x0, x0); + REQUIRE(value == 0x40005033); +} + +TEST_CASE("SRAI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SRAI(x31, x15, 10); + REQUIRE(value == 0x40A7DF93); + + as.RewindBuffer(); + + as.SRAI(x31, x15, 20); + REQUIRE(value == 0x4147DF93); + + as.RewindBuffer(); + + as.SRAI(x31, x15, 31); + REQUIRE(value == 0x41F7DF93); +} + +TEST_CASE("SRL", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SRL(x7, x15, x31); + REQUIRE(value == 0x01F7D3B3); + + as.RewindBuffer(); + + as.SRL(x31, x31, x31); + REQUIRE(value == 0x01FFDFB3); + + as.RewindBuffer(); + + as.SRL(x0, x0, x0); + REQUIRE(value == 0x00005033); +} + +TEST_CASE("SRLI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SRLI(x31, x15, 10); + REQUIRE(value == 0x00A7DF93); + + as.RewindBuffer(); + + as.SRLI(x31, x15, 20); + REQUIRE(value == 0x0147DF93); + + as.RewindBuffer(); + + as.SRLI(x31, x15, 31); + REQUIRE(value == 0x01F7DF93); +} + +TEST_CASE("SUB", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SUB(x7, x15, x31); + REQUIRE(value == 0x41F783B3); + + as.RewindBuffer(); + + as.SUB(x31, x31, x31); + REQUIRE(value == 0x41FF8FB3); + + as.RewindBuffer(); + + as.SUB(x0, x0, x0); + REQUIRE(value == 0x40000033); +} + +TEST_CASE("SW", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SW(x31, 1024, x15); + REQUIRE(value == 0x41F7A023); + + as.RewindBuffer(); + + as.SW(x31, 1536, x15); + REQUIRE(value == 0x61F7A023); + + as.RewindBuffer(); + + as.SW(x31, -1, x15); + REQUIRE(value == 0xFFF7AFA3); +} + +TEST_CASE("XOR", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.XOR(x7, x15, x31); + REQUIRE(value == 0x01F7C3B3); + + as.RewindBuffer(); + + as.XOR(x31, x31, x31); + REQUIRE(value == 0x01FFCFB3); + + as.RewindBuffer(); + + as.XOR(x0, x0, x0); + REQUIRE(value == 0x00004033); +} + +TEST_CASE("XORI", "[rv32i]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.XORI(x15, x31, 1024); + REQUIRE(value == 0x400FC793); + + as.RewindBuffer(); + + as.XORI(x15, x31, 2048); + REQUIRE(value == 0x800FC793); + + as.RewindBuffer(); + + as.XORI(x15, x31, 4095); + REQUIRE(value == 0xFFFFC793); +} diff --git a/externals/biscuit/tests/src/assembler_rv64i_tests.cpp b/externals/biscuit/tests/src/assembler_rv64i_tests.cpp new file mode 100644 index 00000000..e019873b --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rv64i_tests.cpp @@ -0,0 +1,436 @@ +#include <catch/catch.hpp> + +#include <array> +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("ADDIW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.ADDIW(x31, x15, 1024); + REQUIRE(value == 0x40078F9B); + + as.RewindBuffer(); + + as.ADDIW(x31, x15, 2048); + REQUIRE(value == 0x80078F9B); + + as.RewindBuffer(); + + as.ADDIW(x31, x15, 4095); + REQUIRE(value == 0xFFF78F9B); +} + +TEST_CASE("ADDW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.ADDW(x7, x15, x31); + REQUIRE(value == 0x01F783BB); + + as.RewindBuffer(); + + as.ADDW(x31, x31, x31); + REQUIRE(value == 0x01FF8FBB); + + as.RewindBuffer(); + + as.ADDW(x0, x0, x0); + REQUIRE(value == 0x0000003B); +} + +TEST_CASE("LWU", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.LWU(x15, 1024, x31); + REQUIRE(value == 0x400FE783); + + as.RewindBuffer(); + + as.LWU(x15, 1536, x31); + REQUIRE(value == 0x600FE783); + + as.RewindBuffer(); + + as.LWU(x15, -1, x31); + REQUIRE(value == 0xFFFFE783); +} + +TEST_CASE("LD", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.LD(x15, 1024, x31); + REQUIRE(value == 0x400FB783); + + as.RewindBuffer(); + + as.LD(x15, 1536, x31); + REQUIRE(value == 0x600FB783); + + as.RewindBuffer(); + + as.LD(x15, -1, x31); + REQUIRE(value == 0xFFFFB783); +} + +TEST_CASE("LI (RV64)", "[rv64i]") { + // Up to 8 instructions can be generated + std::array<uint32_t, 8> vals{}; + auto as = MakeAssembler64(vals); + + const auto compare_vals = [&vals]<typename... Args>(const Args&... args) { + static_assert(sizeof...(args) <= vals.size()); + + size_t i = 0; + for (const auto arg : {args...}) { + REQUIRE(vals[i] == arg); + i++; + } + }; + + ///////// Single ADDIW cases + + as.LI(x1, 0); + // addiw x1, x0, 0 + compare_vals(0x0000009BU, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, -1); + // addiw x1, x0, -1 + compare_vals(0xFFF0009BU, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, 42); + // addiw x1, x0, 42 + compare_vals(0x02A0009BU, 0x000000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, 0x7ff); + // addiw x1, x0, 2047 + compare_vals(0x7FF0009BU, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + ///////// Single LUI cases + + as.LI(x1, 0x2A000); + // lui x1, 42 + compare_vals(0x0002A0B7U, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, ~0xFFF); + // lui x1, -1 + compare_vals(0xFFFFF0B7U, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, INT32_MIN); + // lui x1, -524288 + compare_vals(0x800000B7U, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + ///////// LUI+ADDIW cases + + as.LI(x1, 0x11111111); + // lui x1, 69905 + // addiw x1, x1, 273 + compare_vals(0x111110B7U, 0x1110809BU, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, INT32_MAX); + // lui x1, -524288 + // addiw x1, x1, -1 + compare_vals(0x800000B7U, 0xFFF0809BU, 0x00000000U); + as.RewindBuffer(); + vals = {}; + + ///////// ADDIW+SLLI cases + + as.LI(x1, 0x7FF0000000ULL); + // addiw x1, x0, 2047 + // slli x1, x1, 28 + compare_vals(0x7FF0009BU, 0x01C09093U, 0x000000000U); + as.RewindBuffer(); + vals = {}; + + as.LI(x1, 0xABC00000ULL); + // addiw x1, x0, 687 + // slli x1, x1, 22 + compare_vals(0x2AF0009BU, 0x01609093U, 0x000000000U); + as.RewindBuffer(); + vals = {}; + + ///////// LUI+ADDIW+SLLI cases + + as.LI(x1, 0x7FFFFFFF0000ULL); + // lui x1, -524288 + // addiw x1, x1, -1 + // slli x1, x1, 16 + compare_vals(0x800000B7U, 0xFFF0809BU, 0x01009093U, 0x000000000U); + as.RewindBuffer(); + vals = {}; + + ///////// LUI+ADDIW+SLLI+ADDI cases + + as.LI(x1, 0x7FFFFFFF0123); + // lui x1, -524288 + // addiw x1, x1, -1 + // slli x1, x1, 16 + // addi x1, x1, 291 + compare_vals(0x800000B7U, 0xfff0809BU, 0x01009093U, 0x12308093U, + 0x000000000U); + as.RewindBuffer(); + vals = {}; + + ///////// ADDIW+SLLI+ADDI+SLLI+ADDI cases + + as.LI(x1, 0x8000000080000001ULL); + // addiw x1, x0, -1 + // slli x1, x1, 32 + // addi x1, x1, 1 + // slli x1, x1, 31 + // addi x1, x1, 1 + compare_vals(0xFFF0009BU, 0x02009093U, 0x00108093U, 0x01F09093U, + 0x00108093U, 0x000000000U); + as.RewindBuffer(); + vals = {}; + + ///////// Full LUI+ADDIW+SLLI+ADDI+SLLI+ADDI+SLLI+ADDI cases + + as.LI(x1, 0x80808000808080F1ULL); + // lui x1, -16 + // addiw x1, x1, 257 + // slli x1, x1, 16 + // addi x1, x1, 1 + // slli x1, x1, 16 + // addi x1, x1, 257 + // slli x1, x1, 15 + // addi x1, x1, 241 + compare_vals(0xFFFF00B7U, 0x1010809BU, 0x01009093U, 0x00108093U, + 0x01009093U, 0x10108093U, 0x00F09093U, 0x0F108093U); +} + +TEST_CASE("SD", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SD(x15, 1024, x31); + REQUIRE(value == 0x40FFB023); + + as.RewindBuffer(); + + as.SD(x15, 1536, x31); + REQUIRE(value == 0x60FFB023); + + as.RewindBuffer(); + + as.SD(x15, -1, x31); + REQUIRE(value == 0xFEFFBFA3); +} + +TEST_CASE("SLLI (RV64)", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SLLI(x31, x15, 10); + REQUIRE(value == 0x00A79F93); + + as.RewindBuffer(); + + as.SLLI(x31, x15, 20); + REQUIRE(value == 0x01479F93); + + as.RewindBuffer(); + + as.SLLI(x31, x15, 31); + REQUIRE(value == 0x01F79F93); + + as.RewindBuffer(); + + as.SLLI(x31, x15, 63); + REQUIRE(value == 0x03F79F93); +} + +TEST_CASE("SLLIW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SLLIW(x31, x15, 10); + REQUIRE(value == 0x00A79F9B); + + as.RewindBuffer(); + + as.SLLIW(x31, x15, 20); + REQUIRE(value == 0x01479F9B); + + as.RewindBuffer(); + + as.SLLIW(x31, x15, 31); + REQUIRE(value == 0x01F79F9B); +} + +TEST_CASE("SLLW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SLLW(x7, x15, x31); + REQUIRE(value == 0x01F793BB); + + as.RewindBuffer(); + + as.SLLW(x31, x31, x31); + REQUIRE(value == 0x01FF9FBB); + + as.RewindBuffer(); + + as.SLLW(x0, x0, x0); + REQUIRE(value == 0x0000103B); +} + +TEST_CASE("SRAI (RV64)", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SRAI(x31, x15, 10); + REQUIRE(value == 0x40A7DF93); + + as.RewindBuffer(); + + as.SRAI(x31, x15, 20); + REQUIRE(value == 0x4147DF93); + + as.RewindBuffer(); + + as.SRAI(x31, x15, 31); + REQUIRE(value == 0x41F7DF93); + + as.RewindBuffer(); + + as.SRAI(x31, x15, 63); + REQUIRE(value == 0x43F7DF93); +} + +TEST_CASE("SRAIW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SRAIW(x31, x15, 10); + REQUIRE(value == 0x40A7DF9B); + + as.RewindBuffer(); + + as.SRAIW(x31, x15, 20); + REQUIRE(value == 0x4147DF9B); + + as.RewindBuffer(); + + as.SRAIW(x31, x15, 31); + REQUIRE(value == 0x41F7DF9B); +} + +TEST_CASE("SRAW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SRAW(x7, x15, x31); + REQUIRE(value == 0x41F7D3BB); + + as.RewindBuffer(); + + as.SRAW(x31, x31, x31); + REQUIRE(value == 0x41FFDFBB); + + as.RewindBuffer(); + + as.SRAW(x0, x0, x0); + REQUIRE(value == 0x4000503B); +} + +TEST_CASE("SRLI (RV64)", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SRLI(x31, x15, 10); + REQUIRE(value == 0x00A7DF93); + + as.RewindBuffer(); + + as.SRLI(x31, x15, 20); + REQUIRE(value == 0x0147DF93); + + as.RewindBuffer(); + + as.SRLI(x31, x15, 31); + REQUIRE(value == 0x01F7DF93); + + as.RewindBuffer(); + + as.SRLI(x31, x15, 63); + REQUIRE(value == 0x03F7DF93); +} + +TEST_CASE("SRLIW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SRLIW(x31, x15, 10); + REQUIRE(value == 0x00A7DF9B); + + as.RewindBuffer(); + + as.SRLIW(x31, x15, 20); + REQUIRE(value == 0x0147DF9B); + + as.RewindBuffer(); + + as.SRLIW(x31, x15, 31); + REQUIRE(value == 0x01F7DF9B); +} + +TEST_CASE("SRLW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SRLW(x7, x15, x31); + REQUIRE(value == 0x01F7D3BB); + + as.RewindBuffer(); + + as.SRLW(x31, x31, x31); + REQUIRE(value == 0x01FFDFBB); + + as.RewindBuffer(); + + as.SRLW(x0, x0, x0); + REQUIRE(value == 0x0000503B); +} + +TEST_CASE("SUBW", "[rv64i]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SUBW(x7, x15, x31); + REQUIRE(value == 0x41F783BB); + + as.RewindBuffer(); + + as.SUBW(x31, x31, x31); + REQUIRE(value == 0x41FF8FBB); + + as.RewindBuffer(); + + as.SUBW(x0, x0, x0); + REQUIRE(value == 0x4000003B); +} diff --git a/externals/biscuit/tests/src/assembler_rva_tests.cpp b/externals/biscuit/tests/src/assembler_rva_tests.cpp new file mode 100644 index 00000000..b972a666 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rva_tests.cpp @@ -0,0 +1,513 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("AMOADD.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOADD_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x0077BFAF); + + as.RewindBuffer(); + + as.AMOADD_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x0477BFAF); + + as.RewindBuffer(); + + as.AMOADD_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x0277BFAF); + + as.RewindBuffer(); + + as.AMOADD_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x0677BFAF); +} + +TEST_CASE("AMOADD.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOADD_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x0077AFAF); + + as.RewindBuffer(); + + as.AMOADD_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x0477AFAF); + + as.RewindBuffer(); + + as.AMOADD_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x0277AFAF); + + as.RewindBuffer(); + + as.AMOADD_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x0677AFAF); +} + +TEST_CASE("AMOAND.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOAND_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x6077BFAF); + + as.RewindBuffer(); + + as.AMOAND_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x6477BFAF); + + as.RewindBuffer(); + + as.AMOAND_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x6277BFAF); + + as.RewindBuffer(); + + as.AMOAND_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x6677BFAF); +} + +TEST_CASE("AMOAND.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOAND_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x6077AFAF); + + as.RewindBuffer(); + + as.AMOAND_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x6477AFAF); + + as.RewindBuffer(); + + as.AMOAND_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x6277AFAF); + + as.RewindBuffer(); + + as.AMOAND_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x6677AFAF); +} + +TEST_CASE("AMOMAX.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOMAX_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0xA077BFAF); + + as.RewindBuffer(); + + as.AMOMAX_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0xA477BFAF); + + as.RewindBuffer(); + + as.AMOMAX_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0xA277BFAF); + + as.RewindBuffer(); + + as.AMOMAX_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0xA677BFAF); +} + +TEST_CASE("AMOMAX.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOMAX_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0xA077AFAF); + + as.RewindBuffer(); + + as.AMOMAX_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0xA477AFAF); + + as.RewindBuffer(); + + as.AMOMAX_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0xA277AFAF); + + as.RewindBuffer(); + + as.AMOMAX_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0xA677AFAF); +} + +TEST_CASE("AMOMAXU.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOMAXU_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0xE077BFAF); + + as.RewindBuffer(); + + as.AMOMAXU_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0xE477BFAF); + + as.RewindBuffer(); + + as.AMOMAXU_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0xE277BFAF); + + as.RewindBuffer(); + + as.AMOMAXU_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0xE677BFAF); +} + +TEST_CASE("AMOMAXU.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOMAXU_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0xE077AFAF); + + as.RewindBuffer(); + + as.AMOMAXU_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0xE477AFAF); + + as.RewindBuffer(); + + as.AMOMAXU_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0xE277AFAF); + + as.RewindBuffer(); + + as.AMOMAXU_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0xE677AFAF); +} + +TEST_CASE("AMOMIN.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOMIN_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x8077BFAF); + + as.RewindBuffer(); + + as.AMOMIN_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x8477BFAF); + + as.RewindBuffer(); + + as.AMOMIN_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x8277BFAF); + + as.RewindBuffer(); + + as.AMOMIN_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x8677BFAF); +} + +TEST_CASE("AMOMIN.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOMIN_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x8077AFAF); + + as.RewindBuffer(); + + as.AMOMIN_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x8477AFAF); + + as.RewindBuffer(); + + as.AMOMIN_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x8277AFAF); + + as.RewindBuffer(); + + as.AMOMIN_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x8677AFAF); +} + +TEST_CASE("AMOMINU.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOMINU_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0xC077BFAF); + + as.RewindBuffer(); + + as.AMOMINU_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0xC477BFAF); + + as.RewindBuffer(); + + as.AMOMINU_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0xC277BFAF); + + as.RewindBuffer(); + + as.AMOMINU_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0xC677BFAF); +} + +TEST_CASE("AMOMINU.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOMINU_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0xC077AFAF); + + as.RewindBuffer(); + + as.AMOMINU_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0xC477AFAF); + + as.RewindBuffer(); + + as.AMOMINU_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0xC277AFAF); + + as.RewindBuffer(); + + as.AMOMINU_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0xC677AFAF); +} + +TEST_CASE("AMOOR.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOOR_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x4077BFAF); + + as.RewindBuffer(); + + as.AMOOR_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x4477BFAF); + + as.RewindBuffer(); + + as.AMOOR_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x4277BFAF); + + as.RewindBuffer(); + + as.AMOOR_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x4677BFAF); +} + +TEST_CASE("AMOOR.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOOR_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x4077AFAF); + + as.RewindBuffer(); + + as.AMOOR_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x4477AFAF); + + as.RewindBuffer(); + + as.AMOOR_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x4277AFAF); + + as.RewindBuffer(); + + as.AMOOR_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x4677AFAF); +} + +TEST_CASE("AMOSWAP.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOSWAP_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x0877BFAF); + + as.RewindBuffer(); + + as.AMOSWAP_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x0C77BFAF); + + as.RewindBuffer(); + + as.AMOSWAP_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x0A77BFAF); + + as.RewindBuffer(); + + as.AMOSWAP_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x0E77BFAF); +} + +TEST_CASE("AMOSWAP.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOSWAP_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x0877AFAF); + + as.RewindBuffer(); + + as.AMOSWAP_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x0C77AFAF); + + as.RewindBuffer(); + + as.AMOSWAP_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x0A77AFAF); + + as.RewindBuffer(); + + as.AMOSWAP_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x0E77AFAF); +} + +TEST_CASE("AMOXOR.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOXOR_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x2077BFAF); + + as.RewindBuffer(); + + as.AMOXOR_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x2477BFAF); + + as.RewindBuffer(); + + as.AMOXOR_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x2277BFAF); + + as.RewindBuffer(); + + as.AMOXOR_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x2677BFAF); +} + +TEST_CASE("AMOXOR.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AMOXOR_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x2077AFAF); + + as.RewindBuffer(); + + as.AMOXOR_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x2477AFAF); + + as.RewindBuffer(); + + as.AMOXOR_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x2277AFAF); + + as.RewindBuffer(); + + as.AMOXOR_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x2677AFAF); +} + +TEST_CASE("LR.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.LR_D(Ordering::None, x31, x15); + REQUIRE(value == 0x1007BFAF); + + as.RewindBuffer(); + + as.LR_D(Ordering::AQ, x31, x15); + REQUIRE(value == 0x1407BFAF); + + as.RewindBuffer(); + + as.LR_D(Ordering::RL, x31, x15); + REQUIRE(value == 0x1207BFAF); + + as.RewindBuffer(); + + as.LR_D(Ordering::AQRL, x31, x15); + REQUIRE(value == 0x1607BFAF); +} + +TEST_CASE("LR.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.LR_W(Ordering::None, x31, x15); + REQUIRE(value == 0x1007AFAF); + + as.RewindBuffer(); + + as.LR_W(Ordering::AQ, x31, x15); + REQUIRE(value == 0x1407AFAF); + + as.RewindBuffer(); + + as.LR_W(Ordering::RL, x31, x15); + REQUIRE(value == 0x1207AFAF); + + as.RewindBuffer(); + + as.LR_W(Ordering::AQRL, x31, x15); + REQUIRE(value == 0x1607AFAF); +} + +TEST_CASE("SC.D", "[rv64a]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SC_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x1877BFAF); + + as.RewindBuffer(); + + as.SC_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x1C77BFAF); + + as.RewindBuffer(); + + as.SC_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x1A77BFAF); + + as.RewindBuffer(); + + as.SC_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x1E77BFAF); +} + +TEST_CASE("SC.W", "[rv32a]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SC_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x1877AFAF); + + as.RewindBuffer(); + + as.SC_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x1C77AFAF); + + as.RewindBuffer(); + + as.SC_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x1A77AFAF); + + as.RewindBuffer(); + + as.SC_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x1E77AFAF); +} diff --git a/externals/biscuit/tests/src/assembler_rvb_tests.cpp b/externals/biscuit/tests/src/assembler_rvb_tests.cpp new file mode 100644 index 00000000..ba39f002 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvb_tests.cpp @@ -0,0 +1,610 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("ADD.UW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.ADDUW(x31, x7, x15); + REQUIRE(value == 0x08F38FBB); + + as.RewindBuffer(); + + // Pseudo instruction + + as.ZEXTW(x31, x7); + REQUIRE(value == 0x08038FBB); +} + +TEST_CASE("ANDN", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ANDN(x31, x7, x15); + REQUIRE(value == 0x40F3FFB3); +} + +TEST_CASE("BCLR", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BCLR(x31, x7, x15); + REQUIRE(value == 0x48F39FB3); +} + +TEST_CASE("BCLRI", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BCLRI(x31, x7, 0); + REQUIRE(value == 0x48039F93); + + as.RewindBuffer(); + + as.BCLRI(x31, x7, 15); + REQUIRE(value == 0x48F39F93); + + as.RewindBuffer(); + + as.BCLRI(x31, x7, 31); + REQUIRE(value == 0x49F39F93); +} + +TEST_CASE("BCLRI (RV64)", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.BCLRI(x31, x7, 0); + REQUIRE(value == 0x48039F93); + + as.RewindBuffer(); + + as.BCLRI(x31, x7, 15); + REQUIRE(value == 0x48F39F93); + + as.RewindBuffer(); + + as.BCLRI(x31, x7, 31); + REQUIRE(value == 0x49F39F93); + + as.RewindBuffer(); + + as.BCLRI(x31, x7, 63); + REQUIRE(value == 0x4BF39F93); +} + +TEST_CASE("BEXT", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BEXT(x31, x7, x15); + REQUIRE(value == 0x48F3DFB3); +} + +TEST_CASE("BEXTI", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BEXTI(x31, x7, 0); + REQUIRE(value == 0x4803DF93); + + as.RewindBuffer(); + + as.BEXTI(x31, x7, 15); + REQUIRE(value == 0x48F3DF93); + + as.RewindBuffer(); + + as.BEXTI(x31, x7, 31); + REQUIRE(value == 0x49F3DF93); +} + +TEST_CASE("BEXTI (RV64)", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.BEXTI(x31, x7, 0); + REQUIRE(value == 0x4803DF93); + + as.RewindBuffer(); + + as.BEXTI(x31, x7, 15); + REQUIRE(value == 0x48F3DF93); + + as.RewindBuffer(); + + as.BEXTI(x31, x7, 31); + REQUIRE(value == 0x49F3DF93); + + as.RewindBuffer(); + + as.BEXTI(x31, x7, 63); + REQUIRE(value == 0x4BF3DF93); +} + +TEST_CASE("BINV", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BINV(x31, x7, x15); + REQUIRE(value == 0x68F39FB3); +} + +TEST_CASE("BINVI", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BINVI(x31, x7, 0); + REQUIRE(value == 0x68039F93); + + as.RewindBuffer(); + + as.BINVI(x31, x7, 15); + REQUIRE(value == 0x68F39F93); + + as.RewindBuffer(); + + as.BINVI(x31, x7, 31); + REQUIRE(value == 0x69F39F93); +} + +TEST_CASE("BINVI (RV64)", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.BINVI(x31, x7, 0); + REQUIRE(value == 0x68039F93); + + as.RewindBuffer(); + + as.BINVI(x31, x7, 15); + REQUIRE(value == 0x68F39F93); + + as.RewindBuffer(); + + as.BINVI(x31, x7, 31); + REQUIRE(value == 0x69F39F93); + + as.RewindBuffer(); + + as.BINVI(x31, x7, 63); + REQUIRE(value == 0x6BF39F93); +} + +TEST_CASE("BREV8", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BREV8(x31, x31); + REQUIRE(value == 0x687FDF93); + + as.RewindBuffer(); + + as.BREV8(x1, x2); + REQUIRE(value == 0x68715093); +} + +TEST_CASE("BSET", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BSET(x31, x7, x15); + REQUIRE(value == 0x28F39FB3); +} + +TEST_CASE("BSETI", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.BSETI(x31, x7, 0); + REQUIRE(value == 0x28039FB3); + + as.RewindBuffer(); + + as.BSETI(x31, x7, 15); + REQUIRE(value == 0x28F39FB3); + + as.RewindBuffer(); + + as.BSETI(x31, x7, 31); + REQUIRE(value == 0x29F39FB3); +} + +TEST_CASE("BSETI (RV64)", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.BSETI(x31, x7, 0); + REQUIRE(value == 0x28039FB3); + + as.RewindBuffer(); + + as.BSETI(x31, x7, 15); + REQUIRE(value == 0x28F39FB3); + + as.RewindBuffer(); + + as.BSETI(x31, x7, 31); + REQUIRE(value == 0x29F39FB3); + + as.RewindBuffer(); + + as.BSETI(x31, x7, 63); + REQUIRE(value == 0x2BF39FB3); +} + +TEST_CASE("CLMUL", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CLMUL(x31, x7, x15); + REQUIRE(value == 0x0AF39FB3); +} + +TEST_CASE("CLMULH", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CLMULH(x31, x7, x15); + REQUIRE(value == 0x0AF3BFB3); +} + +TEST_CASE("CLMULR", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CLMULR(x31, x7, x15); + REQUIRE(value == 0x0AF3AFB3); +} + +TEST_CASE("CLZ", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CLZ(x31, x7); + REQUIRE(value == 0x60039F93); +} + +TEST_CASE("CLZW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CLZW(x31, x7); + REQUIRE(value == 0x60039F9B); +} + +TEST_CASE("CPOP", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CPOP(x31, x7); + REQUIRE(value == 0x60239F93); +} + +TEST_CASE("CPOPW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CPOPW(x31, x7); + REQUIRE(value == 0x60239F9B); +} + +TEST_CASE("CTZ", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CTZ(x31, x7); + REQUIRE(value == 0x60139F93); +} + +TEST_CASE("CTZW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CTZW(x31, x7); + REQUIRE(value == 0x60139F9B); +} + +TEST_CASE("MAX", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MAX(x31, x7, x15); + REQUIRE(value == 0x0AF3EFB3); +} + +TEST_CASE("MAXU", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MAXU(x31, x7, x15); + REQUIRE(value == 0x0AF3FFB3); +} + +TEST_CASE("MIN", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MIN(x31, x7, x15); + REQUIRE(value == 0x0AF3CFB3); +} + +TEST_CASE("MINU", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MINU(x31, x7, x15); + REQUIRE(value == 0x0AF3DFB3); +} + +TEST_CASE("ORC.B", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ORCB(x31, x7); + REQUIRE(value == 0x2873DF93); +} + +TEST_CASE("ORN", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ORN(x31, x7, x15); + REQUIRE(value == 0x40F3EFB3); +} + +TEST_CASE("PACK", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.PACK(x31, x7, x2); + REQUIRE(value == 0x0823CFB3); +} + +TEST_CASE("PACKH", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.PACKH(x31, x7, x2); + REQUIRE(value == 0x0823FFB3); +} + +TEST_CASE("PACKW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.PACKW(x31, x7, x2); + REQUIRE(value == 0x0823CFBB); +} + +TEST_CASE("REV8", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.REV8(x31, x7); + REQUIRE(value == 0x6983DF93); +} + +TEST_CASE("REV8 (RV64)", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.REV8(x31, x7); + REQUIRE(value == 0x6B83DF93); +} + +TEST_CASE("ROL", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ROL(x31, x7, x15); + REQUIRE(value == 0x60F39FB3); +} + +TEST_CASE("ROLW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.ROLW(x31, x7, x15); + REQUIRE(value == 0x60F39FBB); +} + +TEST_CASE("ROR", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ROR(x31, x7, x15); + REQUIRE(value == 0x60F3DFB3); +} + +TEST_CASE("RORW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.RORW(x31, x7, x15); + REQUIRE(value == 0x60F3DFBB); +} + +TEST_CASE("RORI", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.RORI(x31, x7, 0); + REQUIRE(value == 0x6003DF93); + + as.RewindBuffer(); + + as.RORI(x31, x7, 63); + REQUIRE(value == 0x63F3DF93); +} + +TEST_CASE("RORIW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.RORIW(x31, x7, 0); + REQUIRE(value == 0x6003DF9B); + + as.RewindBuffer(); + + as.RORIW(x31, x7, 63); + REQUIRE(value == 0x63F3DF9B); +} + +TEST_CASE("SEXT.B", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SEXTB(x31, x7); + REQUIRE(value == 0x60439F93); +} + +TEST_CASE("SEXT.H", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SEXTH(x31, x7); + REQUIRE(value == 0x60539F93); +} + +TEST_CASE("SH1ADD", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SH1ADD(x31, x7, x15); + REQUIRE(value == 0x20F3AFB3); +} + +TEST_CASE("SH1ADD.UW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SH1ADDUW(x31, x7, x15); + REQUIRE(value == 0x20F3AFBB); +} + +TEST_CASE("SH2ADD", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SH2ADD(x31, x7, x15); + REQUIRE(value == 0x20F3CFB3); +} + +TEST_CASE("SH2ADD.UW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SH2ADDUW(x31, x7, x15); + REQUIRE(value == 0x20F3CFBB); +} + +TEST_CASE("SH3ADD", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SH3ADD(x31, x7, x15); + REQUIRE(value == 0x20F3EFB3); +} + +TEST_CASE("SH3ADD.UW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SH3ADDUW(x31, x7, x15); + REQUIRE(value == 0x20F3EFBB); +} + +TEST_CASE("SLLI.UW", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SLLIUW(x31, x7, 0); + REQUIRE(value == 0x08039F9B); + + as.RewindBuffer(); + + as.SLLIUW(x31, x7, 63); + REQUIRE(value == 0x0BF39F9B); +} + +TEST_CASE("UNZIP", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.UNZIP(x31, x31); + REQUIRE(value == 0x09FFDF93); + + as.RewindBuffer(); + + as.UNZIP(x1, x2); + REQUIRE(value == 0x09F15093); +} + +TEST_CASE("XNOR", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.XNOR(x31, x7, x15); + REQUIRE(value == 0x40F3CFB3); +} + +TEST_CASE("XPERM4", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.XPERM4(x31, x31, x31); + REQUIRE(value == 0x29FFAFB3); + + as.RewindBuffer(); + + as.XPERM4(x1, x2, x3); + REQUIRE(value == 0x283120B3); +} + +TEST_CASE("XPERM8", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.XPERM8(x31, x31, x31); + REQUIRE(value == 0x29FFCFB3); + + as.RewindBuffer(); + + as.XPERM8(x1, x2, x3); + REQUIRE(value == 0x283140B3); +} + +TEST_CASE("ZEXT.H", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ZEXTH(x31, x7); + REQUIRE(value == 0x0803CFB3); +} + +TEST_CASE("ZEXT.H (RV64)", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.ZEXTH(x31, x7); + REQUIRE(value == 0x0803CFBB); +} + +TEST_CASE("ZIP", "[rvb]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.ZIP(x31, x31); + REQUIRE(value == 0x09EF9F93); + + as.RewindBuffer(); + + as.ZIP(x1, x2); + REQUIRE(value == 0x09E11093); +} diff --git a/externals/biscuit/tests/src/assembler_rvc_tests.cpp b/externals/biscuit/tests/src/assembler_rvc_tests.cpp new file mode 100644 index 00000000..da2b0c00 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvc_tests.cpp @@ -0,0 +1,595 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("C.ADD", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_ADD(x31, x31); + REQUIRE(value == 0x9FFE); + + as.RewindBuffer(); + + as.C_ADD(x15, x8); + REQUIRE(value == 0x97A2); +} + +TEST_CASE("C.ADDI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_ADDI(x15, -1); + REQUIRE(value == 0x17FD); + + as.RewindBuffer(); + + as.C_ADDI(x15, -32); + REQUIRE(value == 0x1781); + + as.RewindBuffer(); + + as.C_ADDI(x15, 31); + REQUIRE(value == 0x07FD); +} + +TEST_CASE("C.ADDIW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_ADDIW(x15, -1); + REQUIRE(value == 0x37FD); + + as.RewindBuffer(); + + as.C_ADDIW(x15, -32); + REQUIRE(value == 0x3781); + + as.RewindBuffer(); + + as.C_ADDIW(x15, 31); + REQUIRE(value == 0x27FD); +} + +TEST_CASE("C.ADDI4SPN", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_ADDI4SPN(x15, 252); + REQUIRE(value == 0x19FC); + + as.RewindBuffer(); + + as.C_ADDI4SPN(x8, 1020); + REQUIRE(value == 0x1FE0); + + as.RewindBuffer(); + + as.C_ADDI4SPN(x15, 1020); + REQUIRE(value == 0x1FFC); +} + +TEST_CASE("C.ADDI16SP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_ADDI16SP(16); + REQUIRE(value == 0x6141); + + as.RewindBuffer(); + + as.C_ADDI16SP(64); + REQUIRE(value == 0x6121); +} + +TEST_CASE("C.ADDW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_ADDW(x15, x15); + REQUIRE(value == 0x9FBD); + + as.RewindBuffer(); + + as.C_ADDW(x15, x8); + REQUIRE(value == 0x9FA1); +} + +TEST_CASE("C.AND", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_AND(x15, x15); + REQUIRE(value == 0x8FFD); + + as.RewindBuffer(); + + as.C_AND(x15, x8); + REQUIRE(value == 0x8FE1); +} + +TEST_CASE("C.ANDI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_ANDI(x15, 16); + REQUIRE(value == 0x8BC1); + + as.RewindBuffer(); + + as.C_ANDI(x15, 31); + REQUIRE(value == 0x8BFD); +} + +TEST_CASE("C.EBREAK", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_EBREAK(); + REQUIRE(value == 0x9002); +} + +TEST_CASE("C.FLD", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FLD(f15, 8, x15); + REQUIRE(value == 0x279C); + + as.RewindBuffer(); + + as.C_FLD(f15, 24, x15); + REQUIRE(value == 0x2F9C); +} + +TEST_CASE("C.FLDSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FLDSP(f15, 8); + REQUIRE(value == 0x27A2); + + as.RewindBuffer(); + + as.C_FLDSP(f15, 24); + REQUIRE(value == 0x27E2); +} + +TEST_CASE("C.FLW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FLW(f15, 16, x15); + REQUIRE(value == 0x6B9C); + + as.RewindBuffer(); + + as.C_FLW(f15, 24, x15); + REQUIRE(value == 0x6F9C); +} + +TEST_CASE("C.FLWSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FLWSP(f15, 16); + REQUIRE(value == 0x67C2); + + as.RewindBuffer(); + + as.C_FLWSP(f15, 24); + REQUIRE(value == 0x67E2); +} + +TEST_CASE("C.FSD", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FSD(f15, 8, x15); + REQUIRE(value == 0xA79C); + + as.RewindBuffer(); + + as.C_FSD(f15, 24, x15); + REQUIRE(value == 0xAF9C); +} + +TEST_CASE("C.FSDSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FSDSP(f15, 8); + REQUIRE(value == 0xA43E); + + as.RewindBuffer(); + + as.C_FSDSP(f15, 24); + REQUIRE(value == 0xAC3E); +} + +TEST_CASE("C.FSW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FSW(f15, 16, x15); + REQUIRE(value == 0xEB9C); + + as.RewindBuffer(); + + as.C_FSW(f15, 24, x15); + REQUIRE(value == 0xEF9C); +} + +TEST_CASE("C.FSWSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_FSWSP(f15, 16); + REQUIRE(value == 0xE83E); + + as.RewindBuffer(); + + as.C_FSWSP(f15, 24); + REQUIRE(value == 0xEC3E); +} + +TEST_CASE("C.JALR", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_JALR(x31); + REQUIRE(value == 0x9F82); + + as.RewindBuffer(); + + as.C_JALR(x15); + REQUIRE(value == 0x9782); +} + +TEST_CASE("C.JR", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_JR(x31); + REQUIRE(value == 0x8F82); + + as.RewindBuffer(); + + as.C_JR(x15); + REQUIRE(value == 0x8782); +} + +TEST_CASE("C.LD", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_LD(x15, 8, x15); + REQUIRE(value == 0x679C); + + as.RewindBuffer(); + + as.C_LD(x15, 24, x15); + REQUIRE(value == 0x6F9C); +} + +TEST_CASE("C.LDSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_LDSP(x15, 8); + REQUIRE(value == 0x67A2); + + as.RewindBuffer(); + + as.C_LDSP(x15, 24); + REQUIRE(value == 0x67E2); +} + +TEST_CASE("C.LI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_LI(x15, -1); + REQUIRE(value == 0x57FD); + + as.RewindBuffer(); + + as.C_LI(x15, -32); + REQUIRE(value == 0x5781); + + as.RewindBuffer(); + + as.C_LI(x15, 31); + REQUIRE(value == 0x47FD); +} + +TEST_CASE("C.LQ", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_LQ(x15, 16, x15); + REQUIRE(value == 0x2B9C); + + as.RewindBuffer(); + + as.C_LQ(x15, 256, x15); + REQUIRE(value == 0x279C); +} + +TEST_CASE("C.LQSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_LQSP(x15, 16); + REQUIRE(value == 0x27C2); + + as.RewindBuffer(); + + as.C_LQSP(x15, 256); + REQUIRE(value == 0x2792); +} + +TEST_CASE("C.LUI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_LUI(x15, 0x3F000); + REQUIRE(value == 0x77FD); + + as.RewindBuffer(); + + as.C_LUI(x15, 0x0F000); + REQUIRE(value == 0x67BD); +} + +TEST_CASE("C.LW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_LW(x15, 16, x15); + REQUIRE(value == 0x4B9C); + + as.RewindBuffer(); + + as.C_LW(x15, 24, x15); + REQUIRE(value == 0x4F9C); +} + +TEST_CASE("C.LWSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_LWSP(x15, 16); + REQUIRE(value == 0x47C2); + + as.RewindBuffer(); + + as.C_LWSP(x15, 24); + REQUIRE(value == 0x47E2); +} + +TEST_CASE("C.MV", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_MV(x31, x31); + REQUIRE(value == 0x8FFE); + + as.RewindBuffer(); + + as.C_MV(x15, x8); + REQUIRE(value == 0x87A2); +} + +TEST_CASE("C.NOP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_NOP(); + REQUIRE(value == 0x0001); +} + +TEST_CASE("C.OR", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_OR(x15, x15); + REQUIRE(value == 0x8FDD); + + as.RewindBuffer(); + + as.C_OR(x15, x8); + REQUIRE(value == 0x8FC1); +} + +TEST_CASE("C.SD", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SD(x15, 8, x15); + REQUIRE(value == 0xE79C); + + as.RewindBuffer(); + + as.C_SD(x15, 24, x15); + REQUIRE(value == 0xEF9C); +} + +TEST_CASE("C.SDSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SDSP(x15, 8); + REQUIRE(value == 0xE43E); + + as.RewindBuffer(); + + as.C_SDSP(x15, 24); + REQUIRE(value == 0xEC3E); +} + +TEST_CASE("C.SLLI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_SLLI(x15, 15); + REQUIRE(value == 0x07BE); + + as.RewindBuffer(); + + as.C_SLLI(x15, 31); + REQUIRE(value == 0x07FE); +} + +TEST_CASE("C.SLLI (RV128)", "[rv128c]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_SLLI(x15, 64); + REQUIRE(value == 0x0782); +} + +TEST_CASE("C.SQ", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_SQ(x15, 16, x15); + REQUIRE(value == 0xAB9C); + + as.RewindBuffer(); + + as.C_SQ(x15, 256, x15); + REQUIRE(value == 0xA79C); +} + +TEST_CASE("C.SQSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_SQSP(x15, 16); + REQUIRE(value == 0xA83E); + + as.RewindBuffer(); + + as.C_SQSP(x15, 256); + REQUIRE(value == 0xA23E); +} + +TEST_CASE("C.SRAI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_SRAI(x15, 16); + REQUIRE(value == 0x87C1); + + as.RewindBuffer(); + + as.C_SRAI(x15, 31); + REQUIRE(value == 0x87FD); +} + +TEST_CASE("C.SRAI (RV128)", "[rv128c]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_SRAI(x15, 64); + REQUIRE(value == 0x8781); +} + +TEST_CASE("C.SRLI", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_SRLI(x15, 16); + REQUIRE(value == 0x83C1); + + as.RewindBuffer(); + + as.C_SRLI(x15, 31); + REQUIRE(value == 0x83FD); +} + +TEST_CASE("C.SRLI (RV128)", "[rv128c]") { + uint32_t value = 0; + auto as = MakeAssembler128(value); + + as.C_SRLI(x15, 64); + REQUIRE(value == 0x8381); +} + +TEST_CASE("C.SUB", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_SUB(x15, x15); + REQUIRE(value == 0x8F9D); + + as.RewindBuffer(); + + as.C_SUB(x15, x8); + REQUIRE(value == 0x8F81); +} + +TEST_CASE("C.SUBW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SUBW(x15, x15); + REQUIRE(value == 0x9F9D); + + as.RewindBuffer(); + + as.C_SUBW(x15, x8); + REQUIRE(value == 0x9F81); +} + +TEST_CASE("C.SW", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_SW(x15, 16, x15); + REQUIRE(value == 0xCB9C); + + as.RewindBuffer(); + + as.C_SW(x15, 24, x15); + REQUIRE(value == 0xCF9C); +} + +TEST_CASE("C.SWSP", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_SWSP(x15, 16); + REQUIRE(value == 0xC83E); + + as.RewindBuffer(); + + as.C_SWSP(x15, 24); + REQUIRE(value == 0xCC3E); +} + +TEST_CASE("C.UNDEF", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_UNDEF(); + REQUIRE(value == 0); +} + +TEST_CASE("C.XOR", "[rvc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.C_XOR(x15, x15); + REQUIRE(value == 0x8FBD); + + as.RewindBuffer(); + + as.C_XOR(x15, x8); + REQUIRE(value == 0x8FA1); +} diff --git a/externals/biscuit/tests/src/assembler_rvd_tests.cpp b/externals/biscuit/tests/src/assembler_rvd_tests.cpp new file mode 100644 index 00000000..789df61d --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvd_tests.cpp @@ -0,0 +1,528 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("FADD.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FADD_D(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x03A38FD3); + + as.RewindBuffer(); + + as.FADD_D(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x03A3CFD3); + + as.RewindBuffer(); + + as.FADD_D(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x03A3FFD3); +} + +TEST_CASE("FCLASS.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCLASS_D(x31, f7); + REQUIRE(value == 0xE2039FD3); + + as.RewindBuffer(); + + as.FCLASS_D(x7, f31); + REQUIRE(value == 0xE20F93D3); +} + +TEST_CASE("FCVT.D.S", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_D_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x42038FD3); + + as.RewindBuffer(); + + as.FCVT_D_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x4203CFD3); + + as.RewindBuffer(); + + as.FCVT_D_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x4203FFD3); +} + +TEST_CASE("FCVT.D.W", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_D_W(f31, x7, RMode::RNE); + REQUIRE(value == 0xD2038FD3); + + as.RewindBuffer(); + + as.FCVT_D_W(f31, x7, RMode::RMM); + REQUIRE(value == 0xD203CFD3); + + as.RewindBuffer(); + + as.FCVT_D_W(f31, x7, RMode::DYN); + REQUIRE(value == 0xD203FFD3); +} + +TEST_CASE("FCVT.D.WU", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_D_WU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD2138FD3); + + as.RewindBuffer(); + + as.FCVT_D_WU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD213CFD3); + + as.RewindBuffer(); + + as.FCVT_D_WU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD213FFD3); +} + +TEST_CASE("FCVT.L.D", "[rv64d]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_L_D(x31, f7, RMode::RNE); + REQUIRE(value == 0xC2238FD3); + + as.RewindBuffer(); + + as.FCVT_L_D(x31, f7, RMode::RMM); + REQUIRE(value == 0xC223CFD3); + + as.RewindBuffer(); + + as.FCVT_L_D(x31, f7, RMode::DYN); + REQUIRE(value == 0xC223FFD3); +} + +TEST_CASE("FCVT.LU.D", "[rv64d]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_LU_D(x31, f7, RMode::RNE); + REQUIRE(value == 0xC2338FD3); + + as.RewindBuffer(); + + as.FCVT_LU_D(x31, f7, RMode::RMM); + REQUIRE(value == 0xC233CFD3); + + as.RewindBuffer(); + + as.FCVT_LU_D(x31, f7, RMode::DYN); + REQUIRE(value == 0xC233FFD3); +} + +TEST_CASE("FCVT.D.L", "[rv64d]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_D_L(f31, x7, RMode::RNE); + REQUIRE(value == 0xD2238FD3); + + as.RewindBuffer(); + + as.FCVT_D_L(f31, x7, RMode::RMM); + REQUIRE(value == 0xD223CFD3); + + as.RewindBuffer(); + + as.FCVT_D_L(f31, x7, RMode::DYN); + REQUIRE(value == 0xD223FFD3); +} + +TEST_CASE("FCVT.D.LU", "[rv64d]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_D_LU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD2338FD3); + + as.RewindBuffer(); + + as.FCVT_D_LU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD233CFD3); + + as.RewindBuffer(); + + as.FCVT_D_LU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD233FFD3); +} + +TEST_CASE("FCVT.W.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_W_D(x31, f7, RMode::RNE); + REQUIRE(value == 0xC2038FD3); + + as.RewindBuffer(); + + as.FCVT_W_D(x31, f7, RMode::RMM); + REQUIRE(value == 0xC203CFD3); + + as.RewindBuffer(); + + as.FCVT_W_D(x31, f7, RMode::DYN); + REQUIRE(value == 0xC203FFD3); +} + +TEST_CASE("FCVT.WU.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_WU_D(x31, f7, RMode::RNE); + REQUIRE(value == 0xC2138FD3); + + as.RewindBuffer(); + + as.FCVT_WU_D(x31, f7, RMode::RMM); + REQUIRE(value == 0xC213CFD3); + + as.RewindBuffer(); + + as.FCVT_WU_D(x31, f7, RMode::DYN); + REQUIRE(value == 0xC213FFD3); +} + +TEST_CASE("FCVT.S.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_S_D(f31, f7, RMode::RNE); + REQUIRE(value == 0x40138FD3); + + as.RewindBuffer(); + + as.FCVT_S_D(f31, f7, RMode::RMM); + REQUIRE(value == 0x4013CFD3); + + as.RewindBuffer(); + + as.FCVT_S_D(f31, f7, RMode::DYN); + REQUIRE(value == 0x4013FFD3); +} + +TEST_CASE("FDIV.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FDIV_D(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x1BA38FD3); + + as.RewindBuffer(); + + as.FDIV_D(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x1BA3CFD3); + + as.RewindBuffer(); + + as.FDIV_D(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x1BA3FFD3); +} + +TEST_CASE("FEQ.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FEQ_D(x31, f7, f26); + REQUIRE(value == 0xA3A3AFD3); + + as.RewindBuffer(); + + as.FEQ_D(x31, f26, f7); + REQUIRE(value == 0xA27D2FD3); +} + +TEST_CASE("FLE.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLE_D(x31, f7, f26); + REQUIRE(value == 0xA3A38FD3); + + as.RewindBuffer(); + + as.FLE_D(x31, f26, f7); + REQUIRE(value == 0xA27D0FD3); +} + +TEST_CASE("FLT.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLT_D(x31, f7, f26); + REQUIRE(value == 0xA3A39FD3); + + as.RewindBuffer(); + + as.FLT_D(x31, f26, f7); + REQUIRE(value == 0xA27D1FD3); +} + +TEST_CASE("FLD", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLD(f15, 1024, x31); + REQUIRE(value == 0x400FB787); + + as.RewindBuffer(); + + as.FLD(f15, 1536, x31); + REQUIRE(value == 0x600FB787); + + as.RewindBuffer(); + + as.FLD(f15, -1, x31); + REQUIRE(value == 0xFFFFB787); +} + +TEST_CASE("FMADD.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMADD_D(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD27F87C3); + + as.RewindBuffer(); + + as.FMADD_D(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD27FC7C3); + + as.RewindBuffer(); + + as.FMADD_D(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD27FF7C3); +} + +TEST_CASE("FMAX.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMAX_D(f31, f7, f26); + REQUIRE(value == 0x2BA39FD3); + + as.RewindBuffer(); + + as.FMAX_D(f31, f31, f31); + REQUIRE(value == 0x2BFF9FD3); +} + +TEST_CASE("FMIN.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMIN_D(f31, f7, f26); + REQUIRE(value == 0x2BA38FD3); + + as.RewindBuffer(); + + as.FMIN_D(f31, f31, f31); + REQUIRE(value == 0x2BFF8FD3); +} + +TEST_CASE("FMSUB.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMSUB_D(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD27F87C7); + + as.RewindBuffer(); + + as.FMSUB_D(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD27FC7C7); + + as.RewindBuffer(); + + as.FMSUB_D(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD27FF7C7); +} + +TEST_CASE("FMUL.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMUL_D(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x13A38FD3); + + as.RewindBuffer(); + + as.FMUL_D(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x13A3CFD3); + + as.RewindBuffer(); + + as.FMUL_D(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x13A3FFD3); +} + +TEST_CASE("FMV.D.X", "[rv64d]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMV_D_X(f31, x7); + REQUIRE(value == 0xF2038FD3); + + as.RewindBuffer(); + + as.FMV_D_X(f7, x31); + REQUIRE(value == 0xF20F83D3); +} + +TEST_CASE("FMV.X.D", "[rv64d]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMV_X_D(x31, f7); + REQUIRE(value == 0xE2038FD3); + + as.RewindBuffer(); + + as.FMV_X_D(x7, f31); + REQUIRE(value == 0xE20F83D3); +} + +TEST_CASE("FNMADD.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMADD_D(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD27F87CF); + + as.RewindBuffer(); + + as.FNMADD_D(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD27FC7CF); + + as.RewindBuffer(); + + as.FNMADD_D(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD27FF7CF); +} + +TEST_CASE("FNMSUB.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMSUB_D(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD27F87CB); + + as.RewindBuffer(); + + as.FNMSUB_D(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD27FC7CB); + + as.RewindBuffer(); + + as.FNMSUB_D(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD27FF7CB); +} + +TEST_CASE("FSGNJ.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJ_D(f31, f7, f26); + REQUIRE(value == 0x23A38FD3); + + as.RewindBuffer(); + + as.FSGNJ_D(f31, f31, f31); + REQUIRE(value == 0x23FF8FD3); +} + +TEST_CASE("FSGNJN.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJN_D(f31, f7, f26); + REQUIRE(value == 0x23A39FD3); + + as.RewindBuffer(); + + as.FSGNJN_D(f31, f31, f31); + REQUIRE(value == 0x23FF9FD3); +} + +TEST_CASE("FSGNJX.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJX_D(f31, f7, f26); + REQUIRE(value == 0x23A3AFD3); + + as.RewindBuffer(); + + as.FSGNJX_D(f31, f31, f31); + REQUIRE(value == 0x23FFAFD3); +} + +TEST_CASE("FSQRT.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSQRT_D(f31, f7, RMode::RNE); + REQUIRE(value == 0x5A038FD3); + + as.RewindBuffer(); + + as.FSQRT_D(f31, f7, RMode::RMM); + REQUIRE(value == 0x5A03CFD3); + + as.RewindBuffer(); + + as.FSQRT_D(f31, f7, RMode::DYN); + REQUIRE(value == 0x5A03FFD3); +} + +TEST_CASE("FSUB.D", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSUB_D(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x0BA38FD3); + + as.RewindBuffer(); + + as.FSUB_D(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x0BA3CFD3); + + as.RewindBuffer(); + + as.FSUB_D(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x0BA3FFD3); +} + +TEST_CASE("FSD", "[rv32d]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSD(f31, 1024, x15); + REQUIRE(value == 0x41F7B027); + + as.RewindBuffer(); + + as.FSD(f31, 1536, x15); + REQUIRE(value == 0x61F7B027); + + as.RewindBuffer(); + + as.FSD(f31, -1, x15); + REQUIRE(value == 0xFFF7BFA7); +} diff --git a/externals/biscuit/tests/src/assembler_rvf_tests.cpp b/externals/biscuit/tests/src/assembler_rvf_tests.cpp new file mode 100644 index 00000000..1fe177a8 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvf_tests.cpp @@ -0,0 +1,1085 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("FADD.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FADD_H(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x05A38FD3); + + as.RewindBuffer(); + + as.FADD_H(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x05A3CFD3); + + as.RewindBuffer(); + + as.FADD_H(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x05A3FFD3); +} + +TEST_CASE("FADD.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FADD_S(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x01A38FD3); + + as.RewindBuffer(); + + as.FADD_S(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x01A3CFD3); + + as.RewindBuffer(); + + as.FADD_S(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x01A3FFD3); +} + +TEST_CASE("FCLASS.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCLASS_H(x31, f7); + REQUIRE(value == 0xE4039FD3); + + as.RewindBuffer(); + + as.FCLASS_H(x7, f31); + REQUIRE(value == 0xE40F93D3); +} + +TEST_CASE("FCLASS.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCLASS_S(x31, f7); + REQUIRE(value == 0xE0039FD3); + + as.RewindBuffer(); + + as.FCLASS_S(x7, f31); + REQUIRE(value == 0xE00F93D3); +} + +TEST_CASE("FCVT.D.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_D_H(f31, f7, RMode::RNE); + REQUIRE(value == 0x42238FD3); + + as.RewindBuffer(); + + as.FCVT_D_H(f31, f7, RMode::RMM); + REQUIRE(value == 0x4223CFD3); + + as.RewindBuffer(); + + as.FCVT_D_H(f31, f7, RMode::DYN); + REQUIRE(value == 0x4223FFD3); +} + +TEST_CASE("FCVT.H.D", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_H_D(f31, f7, RMode::RNE); + REQUIRE(value == 0x44138FD3); + + as.RewindBuffer(); + + as.FCVT_H_D(f31, f7, RMode::RMM); + REQUIRE(value == 0x4413CFD3); + + as.RewindBuffer(); + + as.FCVT_H_D(f31, f7, RMode::DYN); + REQUIRE(value == 0x4413FFD3); +} + +TEST_CASE("FCVT.H.Q", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_H_Q(f31, f7, RMode::RNE); + REQUIRE(value == 0x44338FD3); + + as.RewindBuffer(); + + as.FCVT_H_Q(f31, f7, RMode::RMM); + REQUIRE(value == 0x4433CFD3); + + as.RewindBuffer(); + + as.FCVT_H_Q(f31, f7, RMode::DYN); + REQUIRE(value == 0x4433FFD3); +} + +TEST_CASE("FCVT.H.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_H_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x44038FD3); + + as.RewindBuffer(); + + as.FCVT_H_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x4403CFD3); + + as.RewindBuffer(); + + as.FCVT_H_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x4403FFD3); +} + +TEST_CASE("FCVT.Q.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_Q_H(f31, f7, RMode::RNE); + REQUIRE(value == 0x46238FD3); + + as.RewindBuffer(); + + as.FCVT_Q_H(f31, f7, RMode::RMM); + REQUIRE(value == 0x4623CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_H(f31, f7, RMode::DYN); + REQUIRE(value == 0x4623FFD3); +} + +TEST_CASE("FCVT.S.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_S_H(f31, f7, RMode::RNE); + REQUIRE(value == 0x40238FD3); + + as.RewindBuffer(); + + as.FCVT_S_H(f31, f7, RMode::RMM); + REQUIRE(value == 0x4023CFD3); + + as.RewindBuffer(); + + as.FCVT_S_H(f31, f7, RMode::DYN); + REQUIRE(value == 0x4023FFD3); +} + +TEST_CASE("FCVT.H.W", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_H_W(f31, x7, RMode::RNE); + REQUIRE(value == 0xD4038FD3); + + as.RewindBuffer(); + + as.FCVT_H_W(f31, x7, RMode::RMM); + REQUIRE(value == 0xD403CFD3); + + as.RewindBuffer(); + + as.FCVT_H_W(f31, x7, RMode::DYN); + REQUIRE(value == 0xD403FFD3); +} + +TEST_CASE("FCVT.S.W", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_S_W(f31, x7, RMode::RNE); + REQUIRE(value == 0xD0038FD3); + + as.RewindBuffer(); + + as.FCVT_S_W(f31, x7, RMode::RMM); + REQUIRE(value == 0xD003CFD3); + + as.RewindBuffer(); + + as.FCVT_S_W(f31, x7, RMode::DYN); + REQUIRE(value == 0xD003FFD3); +} + +TEST_CASE("FCVT.H.WU", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_H_WU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD4138FD3); + + as.RewindBuffer(); + + as.FCVT_H_WU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD413CFD3); + + as.RewindBuffer(); + + as.FCVT_H_WU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD413FFD3); +} + +TEST_CASE("FCVT.S.WU", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_S_WU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD0138FD3); + + as.RewindBuffer(); + + as.FCVT_S_WU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD013CFD3); + + as.RewindBuffer(); + + as.FCVT_S_WU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD013FFD3); +} + +TEST_CASE("FCVT.L.H", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_L_H(x31, f7, RMode::RNE); + REQUIRE(value == 0xC4238FD3); + + as.RewindBuffer(); + + as.FCVT_L_H(x31, f7, RMode::RMM); + REQUIRE(value == 0xC423CFD3); + + as.RewindBuffer(); + + as.FCVT_L_H(x31, f7, RMode::DYN); + REQUIRE(value == 0xC423FFD3); +} + +TEST_CASE("FCVT.L.S", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_L_S(x31, f7, RMode::RNE); + REQUIRE(value == 0xC0238FD3); + + as.RewindBuffer(); + + as.FCVT_L_S(x31, f7, RMode::RMM); + REQUIRE(value == 0xC023CFD3); + + as.RewindBuffer(); + + as.FCVT_L_S(x31, f7, RMode::DYN); + REQUIRE(value == 0xC023FFD3); +} + +TEST_CASE("FCVT.LU.H", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_LU_H(x31, f7, RMode::RNE); + REQUIRE(value == 0xC4338FD3); + + as.RewindBuffer(); + + as.FCVT_LU_H(x31, f7, RMode::RMM); + REQUIRE(value == 0xC433CFD3); + + as.RewindBuffer(); + + as.FCVT_LU_H(x31, f7, RMode::DYN); + REQUIRE(value == 0xC433FFD3); +} + +TEST_CASE("FCVT.LU.S", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_LU_S(x31, f7, RMode::RNE); + REQUIRE(value == 0xC0338FD3); + + as.RewindBuffer(); + + as.FCVT_LU_S(x31, f7, RMode::RMM); + REQUIRE(value == 0xC033CFD3); + + as.RewindBuffer(); + + as.FCVT_LU_S(x31, f7, RMode::DYN); + REQUIRE(value == 0xC033FFD3); +} + +TEST_CASE("FCVT.H.L", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_H_L(f31, x7, RMode::RNE); + REQUIRE(value == 0xD4238FD3); + + as.RewindBuffer(); + + as.FCVT_H_L(f31, x7, RMode::RMM); + REQUIRE(value == 0xD423CFD3); + + as.RewindBuffer(); + + as.FCVT_H_L(f31, x7, RMode::DYN); + REQUIRE(value == 0xD423FFD3); +} + +TEST_CASE("FCVT.S.L", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_S_L(f31, x7, RMode::RNE); + REQUIRE(value == 0xD0238FD3); + + as.RewindBuffer(); + + as.FCVT_S_L(f31, x7, RMode::RMM); + REQUIRE(value == 0xD023CFD3); + + as.RewindBuffer(); + + as.FCVT_S_L(f31, x7, RMode::DYN); + REQUIRE(value == 0xD023FFD3); +} + +TEST_CASE("FCVT.H.LU", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_H_LU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD4338FD3); + + as.RewindBuffer(); + + as.FCVT_H_LU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD433CFD3); + + as.RewindBuffer(); + + as.FCVT_H_LU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD433FFD3); +} + +TEST_CASE("FCVT.S.LU", "[rv64f]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_S_LU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD0338FD3); + + as.RewindBuffer(); + + as.FCVT_S_LU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD033CFD3); + + as.RewindBuffer(); + + as.FCVT_S_LU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD033FFD3); +} + +TEST_CASE("FCVT.W.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_W_H(x31, f7, RMode::RNE); + REQUIRE(value == 0xC4038FD3); + + as.RewindBuffer(); + + as.FCVT_W_H(x31, f7, RMode::RMM); + REQUIRE(value == 0xC403CFD3); + + as.RewindBuffer(); + + as.FCVT_W_H(x31, f7, RMode::DYN); + REQUIRE(value == 0xC403FFD3); +} + +TEST_CASE("FCVT.W.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_W_S(x31, f7, RMode::RNE); + REQUIRE(value == 0xC0038FD3); + + as.RewindBuffer(); + + as.FCVT_W_S(x31, f7, RMode::RMM); + REQUIRE(value == 0xC003CFD3); + + as.RewindBuffer(); + + as.FCVT_W_S(x31, f7, RMode::DYN); + REQUIRE(value == 0xC003FFD3); +} + +TEST_CASE("FCVT.WU.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_WU_H(x31, f7, RMode::RNE); + REQUIRE(value == 0xC4138FD3); + + as.RewindBuffer(); + + as.FCVT_WU_H(x31, f7, RMode::RMM); + REQUIRE(value == 0xC413CFD3); + + as.RewindBuffer(); + + as.FCVT_WU_H(x31, f7, RMode::DYN); + REQUIRE(value == 0xC413FFD3); +} + +TEST_CASE("FCVT.WU.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_WU_S(x31, f7, RMode::RNE); + REQUIRE(value == 0xC0138FD3); + + as.RewindBuffer(); + + as.FCVT_WU_S(x31, f7, RMode::RMM); + REQUIRE(value == 0xC013CFD3); + + as.RewindBuffer(); + + as.FCVT_WU_S(x31, f7, RMode::DYN); + REQUIRE(value == 0xC013FFD3); +} + +TEST_CASE("FDIV.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FDIV_H(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x1DA38FD3); + + as.RewindBuffer(); + + as.FDIV_H(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x1DA3CFD3); + + as.RewindBuffer(); + + as.FDIV_H(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x1DA3FFD3); +} + +TEST_CASE("FDIV.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FDIV_S(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x19A38FD3); + + as.RewindBuffer(); + + as.FDIV_S(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x19A3CFD3); + + as.RewindBuffer(); + + as.FDIV_S(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x19A3FFD3); +} + +TEST_CASE("FEQ.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FEQ_H(x31, f7, f26); + REQUIRE(value == 0xA5A3AFD3); + + as.RewindBuffer(); + + as.FEQ_H(x31, f26, f7); + REQUIRE(value == 0xA47D2FD3); +} + +TEST_CASE("FEQ.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FEQ_S(x31, f7, f26); + REQUIRE(value == 0xA1A3AFD3); + + as.RewindBuffer(); + + as.FEQ_S(x31, f26, f7); + REQUIRE(value == 0xA07D2FD3); +} + +TEST_CASE("FLE.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLE_H(x31, f7, f26); + REQUIRE(value == 0xA5A38FD3); + + as.RewindBuffer(); + + as.FLE_H(x31, f26, f7); + REQUIRE(value == 0xA47D0FD3); +} + +TEST_CASE("FLE.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLE_S(x31, f7, f26); + REQUIRE(value == 0xA1A38FD3); + + as.RewindBuffer(); + + as.FLE_S(x31, f26, f7); + REQUIRE(value == 0xA07D0FD3); +} + +TEST_CASE("FLH", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLH(f15, 1024, x31); + REQUIRE(value == 0x400F9787); + + as.RewindBuffer(); + + as.FLH(f15, 1536, x31); + REQUIRE(value == 0x600F9787); + + as.RewindBuffer(); + + as.FLH(f15, -1, x31); + REQUIRE(value == 0xFFFF9787); +} + +TEST_CASE("FLT.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLT_H(x31, f7, f26); + REQUIRE(value == 0xA5A39FD3); + + as.RewindBuffer(); + + as.FLT_H(x31, f26, f7); + REQUIRE(value == 0xA47D1FD3); +} + +TEST_CASE("FLT.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLT_S(x31, f7, f26); + REQUIRE(value == 0xA1A39FD3); + + as.RewindBuffer(); + + as.FLT_S(x31, f26, f7); + REQUIRE(value == 0xA07D1FD3); +} + +TEST_CASE("FLW", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLW(f15, 1024, x31); + REQUIRE(value == 0x400FA787); + + as.RewindBuffer(); + + as.FLW(f15, 1536, x31); + REQUIRE(value == 0x600FA787); + + as.RewindBuffer(); + + as.FLW(f15, -1, x31); + REQUIRE(value == 0xFFFFA787); +} + +TEST_CASE("FMADD.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMADD_H(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD47F87C3); + + as.RewindBuffer(); + + as.FMADD_H(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD47FC7C3); + + as.RewindBuffer(); + + as.FMADD_H(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD47FF7C3); +} + +TEST_CASE("FMADD.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMADD_S(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD07F87C3); + + as.RewindBuffer(); + + as.FMADD_S(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD07FC7C3); + + as.RewindBuffer(); + + as.FMADD_S(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD07FF7C3); +} + +TEST_CASE("FMAX.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMAX_H(f31, f7, f26); + REQUIRE(value == 0x2DA39FD3); + + as.RewindBuffer(); + + as.FMAX_H(f31, f31, f31); + REQUIRE(value == 0x2DFF9FD3); +} + +TEST_CASE("FMAX.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMAX_S(f31, f7, f26); + REQUIRE(value == 0x29A39FD3); + + as.RewindBuffer(); + + as.FMAX_S(f31, f31, f31); + REQUIRE(value == 0x29FF9FD3); +} + +TEST_CASE("FMIN.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMIN_H(f31, f7, f26); + REQUIRE(value == 0x2DA38FD3); + + as.RewindBuffer(); + + as.FMIN_H(f31, f31, f31); + REQUIRE(value == 0x2DFF8FD3); +} + +TEST_CASE("FMIN.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMIN_S(f31, f7, f26); + REQUIRE(value == 0x29A38FD3); + + as.RewindBuffer(); + + as.FMIN_S(f31, f31, f31); + REQUIRE(value == 0x29FF8FD3); +} + +TEST_CASE("FMSUB.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMSUB_H(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD47F87C7); + + as.RewindBuffer(); + + as.FMSUB_H(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD47FC7C7); + + as.RewindBuffer(); + + as.FMSUB_H(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD47FF7C7); +} + +TEST_CASE("FMSUB.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMSUB_S(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD07F87C7); + + as.RewindBuffer(); + + as.FMSUB_S(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD07FC7C7); + + as.RewindBuffer(); + + as.FMSUB_S(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD07FF7C7); +} + +TEST_CASE("FMUL.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMUL_H(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x15A38FD3); + + as.RewindBuffer(); + + as.FMUL_H(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x15A3CFD3); + + as.RewindBuffer(); + + as.FMUL_H(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x15A3FFD3); +} + +TEST_CASE("FMUL.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMUL_S(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x11A38FD3); + + as.RewindBuffer(); + + as.FMUL_S(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x11A3CFD3); + + as.RewindBuffer(); + + as.FMUL_S(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x11A3FFD3); +} + +TEST_CASE("FMV.H.X", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMV_H_X(f31, x7); + REQUIRE(value == 0xF4038FD3); + + as.RewindBuffer(); + + as.FMV_H_X(f7, x31); + REQUIRE(value == 0xF40F83D3); +} + +TEST_CASE("FMV.W.X", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMV_W_X(f31, x7); + REQUIRE(value == 0xF0038FD3); + + as.RewindBuffer(); + + as.FMV_W_X(f7, x31); + REQUIRE(value == 0xF00F83D3); +} + +TEST_CASE("FMV.X.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMV_X_H(x31, f7); + REQUIRE(value == 0xE4038FD3); + + as.RewindBuffer(); + + as.FMV_X_H(x7, f31); + REQUIRE(value == 0xE40F83D3); +} + +TEST_CASE("FMV.X.W", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMV_X_W(x31, f7); + REQUIRE(value == 0xE0038FD3); + + as.RewindBuffer(); + + as.FMV_X_W(x7, f31); + REQUIRE(value == 0xE00F83D3); +} + +TEST_CASE("FNMADD.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMADD_H(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD47F87CF); + + as.RewindBuffer(); + + as.FNMADD_H(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD47FC7CF); + + as.RewindBuffer(); + + as.FNMADD_H(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD47FF7CF); +} + +TEST_CASE("FNMADD.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMADD_S(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD07F87CF); + + as.RewindBuffer(); + + as.FNMADD_S(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD07FC7CF); + + as.RewindBuffer(); + + as.FNMADD_S(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD07FF7CF); +} + +TEST_CASE("FNMSUB.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMSUB_H(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD47F87CB); + + as.RewindBuffer(); + + as.FNMSUB_H(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD47FC7CB); + + as.RewindBuffer(); + + as.FNMSUB_H(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD47FF7CB); +} + +TEST_CASE("FNMSUB.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMSUB_S(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD07F87CB); + + as.RewindBuffer(); + + as.FNMSUB_S(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD07FC7CB); + + as.RewindBuffer(); + + as.FNMSUB_S(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD07FF7CB); +} + +TEST_CASE("FSGNJ.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJ_H(f31, f7, f26); + REQUIRE(value == 0x25A38FD3); + + as.RewindBuffer(); + + as.FSGNJ_H(f31, f31, f31); + REQUIRE(value == 0x25FF8FD3); +} + +TEST_CASE("FSGNJ.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJ_S(f31, f7, f26); + REQUIRE(value == 0x21A38FD3); + + as.RewindBuffer(); + + as.FSGNJ_S(f31, f31, f31); + REQUIRE(value == 0x21FF8FD3); +} + +TEST_CASE("FSGNJN.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJN_H(f31, f7, f26); + REQUIRE(value == 0x25A39FD3); + + as.RewindBuffer(); + + as.FSGNJN_H(f31, f31, f31); + REQUIRE(value == 0x25FF9FD3); +} + +TEST_CASE("FSGNJN.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJN_S(f31, f7, f26); + REQUIRE(value == 0x21A39FD3); + + as.RewindBuffer(); + + as.FSGNJN_S(f31, f31, f31); + REQUIRE(value == 0x21FF9FD3); +} + +TEST_CASE("FSGNJX.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJX_H(f31, f7, f26); + REQUIRE(value == 0x25A3AFD3); + + as.RewindBuffer(); + + as.FSGNJX_H(f31, f31, f31); + REQUIRE(value == 0x25FFAFD3); +} + +TEST_CASE("FSGNJX.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJX_S(f31, f7, f26); + REQUIRE(value == 0x21A3AFD3); + + as.RewindBuffer(); + + as.FSGNJX_S(f31, f31, f31); + REQUIRE(value == 0x21FFAFD3); +} + +TEST_CASE("FSH", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSH(f31, 1024, x15); + REQUIRE(value == 0x41F79027); + + as.RewindBuffer(); + + as.FSH(f31, 1536, x15); + REQUIRE(value == 0x61F79027); + + as.RewindBuffer(); + + as.FSH(f31, -1, x15); + REQUIRE(value == 0xFFF79FA7); +} + +TEST_CASE("FSQRT.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSQRT_H(f31, f7, RMode::RNE); + REQUIRE(value == 0x5C038FD3); + + as.RewindBuffer(); + + as.FSQRT_H(f31, f7, RMode::RMM); + REQUIRE(value == 0x5C03CFD3); + + as.RewindBuffer(); + + as.FSQRT_H(f31, f7, RMode::DYN); + REQUIRE(value == 0x5C03FFD3); +} + +TEST_CASE("FSQRT.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSQRT_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x58038FD3); + + as.RewindBuffer(); + + as.FSQRT_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x5803CFD3); + + as.RewindBuffer(); + + as.FSQRT_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x5803FFD3); +} + +TEST_CASE("FSUB.H", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSUB_H(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x0DA38FD3); + + as.RewindBuffer(); + + as.FSUB_H(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x0DA3CFD3); + + as.RewindBuffer(); + + as.FSUB_H(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x0DA3FFD3); +} + +TEST_CASE("FSUB.S", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSUB_S(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x09A38FD3); + + as.RewindBuffer(); + + as.FSUB_S(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x09A3CFD3); + + as.RewindBuffer(); + + as.FSUB_S(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x09A3FFD3); +} + +TEST_CASE("FSW", "[rv32f]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSW(f31, 1024, x15); + REQUIRE(value == 0x41F7A027); + + as.RewindBuffer(); + + as.FSW(f31, 1536, x15); + REQUIRE(value == 0x61F7A027); + + as.RewindBuffer(); + + as.FSW(f31, -1, x15); + REQUIRE(value == 0xFFF7AFA7); +} diff --git a/externals/biscuit/tests/src/assembler_rvk_tests.cpp b/externals/biscuit/tests/src/assembler_rvk_tests.cpp new file mode 100644 index 00000000..ccb8c2bd --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvk_tests.cpp @@ -0,0 +1,384 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("AES32DSI", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AES32DSI(x31, x31, x31, 0b11); + REQUIRE(value == 0xEBFF8FB3); + + as.RewindBuffer(); + + as.AES32DSI(x1, x2, x3, 0b10); + REQUIRE(value == 0xAA3100B3); +} + +TEST_CASE("AES32DSMI", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AES32DSMI(x31, x31, x31, 0b11); + REQUIRE(value == 0xEFFF8FB3); + + as.RewindBuffer(); + + as.AES32DSMI(x1, x2, x3, 0b10); + REQUIRE(value == 0xAE3100B3); +} + +TEST_CASE("AES32ESI", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AES32ESI(x31, x31, x31, 0b11); + REQUIRE(value == 0xE3FF8FB3); + + as.RewindBuffer(); + + as.AES32ESI(x1, x2, x3, 0b10); + REQUIRE(value == 0xA23100B3); +} + +TEST_CASE("AES32ESMI", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.AES32ESMI(x31, x31, x31, 0b11); + REQUIRE(value == 0xE7FF8FB3); + + as.RewindBuffer(); + + as.AES32ESMI(x1, x2, x3, 0b10); + REQUIRE(value == 0xA63100B3); +} + +TEST_CASE("AES64DS", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64DS(x31, x31, x31); + REQUIRE(value == 0x3BFF8FB3); + + as.RewindBuffer(); + + as.AES64DS(x1, x2, x3); + REQUIRE(value == 0x3A3100B3); +} + +TEST_CASE("AES64DSM", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64DSM(x31, x31, x31); + REQUIRE(value == 0x3FFF8FB3); + + as.RewindBuffer(); + + as.AES64DSM(x1, x2, x3); + REQUIRE(value == 0x3E3100B3); +} + +TEST_CASE("AES64ES", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64ES(x31, x31, x31); + REQUIRE(value == 0x33FF8FB3); + + as.RewindBuffer(); + + as.AES64ES(x1, x2, x3); + REQUIRE(value == 0x323100B3); +} + +TEST_CASE("AES64ESM", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64ESM(x31, x31, x31); + REQUIRE(value == 0x37FF8FB3); + + as.RewindBuffer(); + + as.AES64ESM(x1, x2, x3); + REQUIRE(value == 0x363100B3); +} + +TEST_CASE("AES64IM", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64IM(x31, x31); + REQUIRE(value == 0x300F9F93); + + as.RewindBuffer(); + + as.AES64IM(x1, x2); + REQUIRE(value == 0x30011093); +} + +TEST_CASE("AES64KS1I", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64KS1I(x31, x31, 0xA); + REQUIRE(value == 0x31AF9F93); + + as.RewindBuffer(); + + as.AES64KS1I(x1, x2, 0x5); + REQUIRE(value == 0x31511093); +} + +TEST_CASE("AES64KS2", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AES64KS2(x31, x31, x31); + REQUIRE(value == 0x7FFF8FB3); + + as.RewindBuffer(); + + as.AES64KS2(x1, x2, x3); + REQUIRE(value == 0x7E3100B3); +} + +TEST_CASE("SHA256SIG0", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA256SIG0(x31, x31); + REQUIRE(value == 0x102F9F93); + + as.RewindBuffer(); + + as.SHA256SIG0(x1, x2); + REQUIRE(value == 0x10211093); +} + +TEST_CASE("SHA256SIG1", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA256SIG1(x31, x31); + REQUIRE(value == 0x103F9F93); + + as.RewindBuffer(); + + as.SHA256SIG1(x1, x2); + REQUIRE(value == 0x10311093); +} + +TEST_CASE("SHA256SUM0", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA256SUM0(x31, x31); + REQUIRE(value == 0x100F9F93); + + as.RewindBuffer(); + + as.SHA256SUM0(x1, x2); + REQUIRE(value == 0x10011093); +} + +TEST_CASE("SHA256SUM1", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA256SUM1(x31, x31); + REQUIRE(value == 0x101F9F93); + + as.RewindBuffer(); + + as.SHA256SUM1(x1, x2); + REQUIRE(value == 0x10111093); +} + +TEST_CASE("SHA512SIG0", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA512SIG0(x31, x31); + REQUIRE(value == 0x106F9F93); + + as.RewindBuffer(); + + as.SHA512SIG0(x1, x2); + REQUIRE(value == 0x10611093); +} + +TEST_CASE("SHA512SIG0H", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SHA512SIG0H(x31, x31, x31); + REQUIRE(value == 0x5DFF8FB3); + + as.RewindBuffer(); + + as.SHA512SIG0H(x1, x2, x3); + REQUIRE(value == 0x5C3100B3); +} + +TEST_CASE("SHA512SIG0L", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SHA512SIG0L(x31, x31, x31); + REQUIRE(value == 0x55FF8FB3); + + as.RewindBuffer(); + + as.SHA512SIG0L(x1, x2, x3); + REQUIRE(value == 0x543100B3); +} + +TEST_CASE("SHA512SIG1", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA512SIG1(x31, x31); + REQUIRE(value == 0x107F9F93); + + as.RewindBuffer(); + + as.SHA512SIG1(x1, x2); + REQUIRE(value == 0x10711093); +} + +TEST_CASE("SHA512SIG1H", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SHA512SIG1H(x31, x31, x31); + REQUIRE(value == 0x5FFF8FB3); + + as.RewindBuffer(); + + as.SHA512SIG1H(x1, x2, x3); + REQUIRE(value == 0x5E3100B3); +} + +TEST_CASE("SHA512SIG1L", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SHA512SIG1L(x31, x31, x31); + REQUIRE(value == 0x57FF8FB3); + + as.RewindBuffer(); + + as.SHA512SIG1L(x1, x2, x3); + REQUIRE(value == 0x563100B3); +} + +TEST_CASE("SHA512SUM0", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA512SUM0(x31, x31); + REQUIRE(value == 0x104F9F93); + + as.RewindBuffer(); + + as.SHA512SUM0(x1, x2); + REQUIRE(value == 0x10411093); +} + +TEST_CASE("SHA512SUM0R", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SHA512SUM0R(x31, x31, x31); + REQUIRE(value == 0x51FF8FB3); + + as.RewindBuffer(); + + as.SHA512SUM0R(x1, x2, x3); + REQUIRE(value == 0x503100B3); +} + +TEST_CASE("SHA512SUM1", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SHA512SUM1(x31, x31); + REQUIRE(value == 0x105F9F93); + + as.RewindBuffer(); + + as.SHA512SUM1(x1, x2); + REQUIRE(value == 0x10511093); +} + +TEST_CASE("SHA512SUM1R", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.SHA512SUM1R(x31, x31, x31); + REQUIRE(value == 0x53FF8FB3); + + as.RewindBuffer(); + + as.SHA512SUM1R(x1, x2, x3); + REQUIRE(value == 0x523100B3); +} + +TEST_CASE("SM3P0", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SM3P0(x31, x31); + REQUIRE(value == 0x108F9F93); + + as.RewindBuffer(); + + as.SM3P0(x1, x2); + REQUIRE(value == 0x10811093); +} + +TEST_CASE("SM3P1", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SM3P1(x31, x31); + REQUIRE(value == 0x109F9F93); + + as.RewindBuffer(); + + as.SM3P1(x1, x2); + REQUIRE(value == 0x10911093); +} + +TEST_CASE("SM4ED", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SM4ED(x31, x31, x31, 0b11); + REQUIRE(value == 0xF1FF8FB3); + + as.RewindBuffer(); + + as.SM4ED(x1, x2, x3, 0b10); + REQUIRE(value == 0xB03100B3); +} + +TEST_CASE("SM4KS", "[rvk]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.SM4KS(x31, x31, x31, 0b11); + REQUIRE(value == 0xF5FF8FB3); + + as.RewindBuffer(); + + as.SM4KS(x1, x2, x3, 0b10); + REQUIRE(value == 0xB43100B3); +} diff --git a/externals/biscuit/tests/src/assembler_rvm_tests.cpp b/externals/biscuit/tests/src/assembler_rvm_tests.cpp new file mode 100644 index 00000000..ba9ad32d --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvm_tests.cpp @@ -0,0 +1,241 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("DIV", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.DIV(x31, x15, x20); + REQUIRE(value == 0x0347CFB3); + + as.RewindBuffer(); + + as.DIV(x31, x20, x15); + REQUIRE(value == 0x02FA4FB3); + + as.RewindBuffer(); + + as.DIV(x20, x31, x15); + REQUIRE(value == 0x02FFCA33); +} + +TEST_CASE("DIVW", "[rv64m]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.DIVW(x31, x15, x20); + REQUIRE(value == 0x0347CFBB); + + as.RewindBuffer(); + + as.DIVW(x31, x20, x15); + REQUIRE(value == 0x02FA4FBB); + + as.RewindBuffer(); + + as.DIVW(x20, x31, x15); + REQUIRE(value == 0x02FFCA3B); +} + +TEST_CASE("DIVU", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.DIVU(x31, x15, x20); + REQUIRE(value == 0x0347DFB3); + + as.RewindBuffer(); + + as.DIVU(x31, x20, x15); + REQUIRE(value == 0x02FA5FB3); + + as.RewindBuffer(); + + as.DIVU(x20, x31, x15); + REQUIRE(value == 0x02FFDA33); +} + +TEST_CASE("DIVUW", "[rv64m]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.DIVUW(x31, x15, x20); + REQUIRE(value == 0x0347DFBB); + + as.RewindBuffer(); + + as.DIVUW(x31, x20, x15); + REQUIRE(value == 0x02FA5FBB); + + as.RewindBuffer(); + + as.DIVUW(x20, x31, x15); + REQUIRE(value == 0x02FFDA3B); +} + +TEST_CASE("MUL", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MUL(x31, x15, x20); + REQUIRE(value == 0x03478FB3); + + as.RewindBuffer(); + + as.MUL(x31, x20, x15); + REQUIRE(value == 0x02FA0FB3); + + as.RewindBuffer(); + + as.MUL(x20, x31, x15); + REQUIRE(value == 0x02FF8A33); +} + +TEST_CASE("MULH", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MULH(x31, x15, x20); + REQUIRE(value == 0x03479FB3); + + as.RewindBuffer(); + + as.MULH(x31, x20, x15); + REQUIRE(value == 0x02FA1FB3); + + as.RewindBuffer(); + + as.MULH(x20, x31, x15); + REQUIRE(value == 0x02FF9A33); +} + +TEST_CASE("MULW", "[rv64m]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.MULW(x31, x15, x20); + REQUIRE(value == 0x03478FBB); + + as.RewindBuffer(); + + as.MULW(x31, x20, x15); + REQUIRE(value == 0x02FA0FBB); + + as.RewindBuffer(); + + as.MULW(x20, x31, x15); + REQUIRE(value == 0x02FF8A3B); +} + +TEST_CASE("MULHSU", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MULHSU(x31, x15, x20); + REQUIRE(value == 0x0347AFB3); + + as.RewindBuffer(); + + as.MULHSU(x31, x20, x15); + REQUIRE(value == 0x02FA2FB3); + + as.RewindBuffer(); + + as.MULHSU(x20, x31, x15); + REQUIRE(value == 0x02FFAA33); +} + +TEST_CASE("MULHU", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.MULHU(x31, x15, x20); + REQUIRE(value == 0x0347BFB3); + + as.RewindBuffer(); + + as.MULHU(x31, x20, x15); + REQUIRE(value == 0x02FA3FB3); + + as.RewindBuffer(); + + as.MULHU(x20, x31, x15); + REQUIRE(value == 0x02FFBA33); +} + +TEST_CASE("REM", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.REM(x31, x15, x20); + REQUIRE(value == 0x0347EFB3); + + as.RewindBuffer(); + + as.REM(x31, x20, x15); + REQUIRE(value == 0x02FA6FB3); + + as.RewindBuffer(); + + as.REM(x20, x31, x15); + REQUIRE(value == 0x02FFEA33); +} + +TEST_CASE("REMW", "[rv64m]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.REMW(x31, x15, x20); + REQUIRE(value == 0x0347EFBB); + + as.RewindBuffer(); + + as.REMW(x31, x20, x15); + REQUIRE(value == 0x02FA6FBB); + + as.RewindBuffer(); + + as.REMW(x20, x31, x15); + REQUIRE(value == 0x02FFEA3B); +} + +TEST_CASE("REMU", "[rv32m]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.REMU(x31, x15, x20); + REQUIRE(value == 0x0347FFB3); + + as.RewindBuffer(); + + as.REMU(x31, x20, x15); + REQUIRE(value == 0x02FA7FB3); + + as.RewindBuffer(); + + as.REMU(x20, x31, x15); + REQUIRE(value == 0x02FFFA33); +} + +TEST_CASE("REMUW", "[rv64m]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.REMUW(x31, x15, x20); + REQUIRE(value == 0x0347FFBB); + + as.RewindBuffer(); + + as.REMUW(x31, x20, x15); + REQUIRE(value == 0x02FA7FBB); + + as.RewindBuffer(); + + as.REMUW(x20, x31, x15); + REQUIRE(value == 0x02FFFA3B); +} diff --git a/externals/biscuit/tests/src/assembler_rvq_tests.cpp b/externals/biscuit/tests/src/assembler_rvq_tests.cpp new file mode 100644 index 00000000..2c2e8bd3 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvq_tests.cpp @@ -0,0 +1,538 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("FADD.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FADD_Q(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x07A38FD3); + + as.RewindBuffer(); + + as.FADD_Q(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x07A3CFD3); + + as.RewindBuffer(); + + as.FADD_Q(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x07A3FFD3); +} + +TEST_CASE("FCLASS.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCLASS_Q(x31, f7); + REQUIRE(value == 0xE6039FD3); + + as.RewindBuffer(); + + as.FCLASS_Q(x7, f31); + REQUIRE(value == 0xE60F93D3); +} + +TEST_CASE("FCVT.Q.D", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_Q_D(f31, f7, RMode::RNE); + REQUIRE(value == 0x46138FD3); + + as.RewindBuffer(); + + as.FCVT_Q_D(f31, f7, RMode::RMM); + REQUIRE(value == 0x4613CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_D(f31, f7, RMode::DYN); + REQUIRE(value == 0x4613FFD3); +} + +TEST_CASE("FCVT.Q.S", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_Q_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x46038FD3); + + as.RewindBuffer(); + + as.FCVT_Q_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x4603CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x4603FFD3); +} + +TEST_CASE("FCVT.Q.W", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_Q_W(f31, x7, RMode::RNE); + REQUIRE(value == 0xD6038FD3); + + as.RewindBuffer(); + + as.FCVT_Q_W(f31, x7, RMode::RMM); + REQUIRE(value == 0xD603CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_W(f31, x7, RMode::DYN); + REQUIRE(value == 0xD603FFD3); +} + +TEST_CASE("FCVT.Q.WU", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_Q_WU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD6138FD3); + + as.RewindBuffer(); + + as.FCVT_Q_WU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD613CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_WU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD613FFD3); +} + +TEST_CASE("FCVT.L.Q", "[rv64q]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_L_Q(x31, f7, RMode::RNE); + REQUIRE(value == 0xC6238FD3); + + as.RewindBuffer(); + + as.FCVT_L_Q(x31, f7, RMode::RMM); + REQUIRE(value == 0xC623CFD3); + + as.RewindBuffer(); + + as.FCVT_L_Q(x31, f7, RMode::DYN); + REQUIRE(value == 0xC623FFD3); +} + +TEST_CASE("FCVT.LU.Q", "[rv64q]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_LU_Q(x31, f7, RMode::RNE); + REQUIRE(value == 0xC6338FD3); + + as.RewindBuffer(); + + as.FCVT_LU_Q(x31, f7, RMode::RMM); + REQUIRE(value == 0xC633CFD3); + + as.RewindBuffer(); + + as.FCVT_LU_Q(x31, f7, RMode::DYN); + REQUIRE(value == 0xC633FFD3); +} + +TEST_CASE("FCVT.Q.L", "[rv64q]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_Q_L(f31, x7, RMode::RNE); + REQUIRE(value == 0xD6238FD3); + + as.RewindBuffer(); + + as.FCVT_Q_L(f31, x7, RMode::RMM); + REQUIRE(value == 0xD623CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_L(f31, x7, RMode::DYN); + REQUIRE(value == 0xD623FFD3); +} + +TEST_CASE("FCVT.Q.LU", "[rv64q]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVT_Q_LU(f31, x7, RMode::RNE); + REQUIRE(value == 0xD6338FD3); + + as.RewindBuffer(); + + as.FCVT_Q_LU(f31, x7, RMode::RMM); + REQUIRE(value == 0xD633CFD3); + + as.RewindBuffer(); + + as.FCVT_Q_LU(f31, x7, RMode::DYN); + REQUIRE(value == 0xD633FFD3); +} + +TEST_CASE("FCVT.W.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_W_Q(x31, f7, RMode::RNE); + REQUIRE(value == 0xC6038FD3); + + as.RewindBuffer(); + + as.FCVT_W_Q(x31, f7, RMode::RMM); + REQUIRE(value == 0xC603CFD3); + + as.RewindBuffer(); + + as.FCVT_W_Q(x31, f7, RMode::DYN); + REQUIRE(value == 0xC603FFD3); +} + +TEST_CASE("FCVT.WU.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_WU_Q(x31, f7, RMode::RNE); + REQUIRE(value == 0xC6138FD3); + + as.RewindBuffer(); + + as.FCVT_WU_Q(x31, f7, RMode::RMM); + REQUIRE(value == 0xC613CFD3); + + as.RewindBuffer(); + + as.FCVT_WU_Q(x31, f7, RMode::DYN); + REQUIRE(value == 0xC613FFD3); +} + +TEST_CASE("FCVT.D.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_D_Q(f31, f7, RMode::RNE); + REQUIRE(value == 0x42338FD3); + + as.RewindBuffer(); + + as.FCVT_D_Q(f31, f7, RMode::RMM); + REQUIRE(value == 0x4233CFD3); + + as.RewindBuffer(); + + as.FCVT_D_Q(f31, f7, RMode::DYN); + REQUIRE(value == 0x4233FFD3); +} + +TEST_CASE("FCVT.S.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FCVT_S_Q(f31, f7, RMode::RNE); + REQUIRE(value == 0x40338FD3); + + as.RewindBuffer(); + + as.FCVT_S_Q(f31, f7, RMode::RMM); + REQUIRE(value == 0x4033CFD3); + + as.RewindBuffer(); + + as.FCVT_S_Q(f31, f7, RMode::DYN); + REQUIRE(value == 0x4033FFD3); +} + +TEST_CASE("FDIV.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FDIV_Q(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x1FA38FD3); + + as.RewindBuffer(); + + as.FDIV_Q(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x1FA3CFD3); + + as.RewindBuffer(); + + as.FDIV_Q(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x1FA3FFD3); +} + +TEST_CASE("FEQ.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FEQ_Q(x31, f7, f26); + REQUIRE(value == 0xA7A3AFD3); + + as.RewindBuffer(); + + as.FEQ_Q(x31, f26, f7); + REQUIRE(value == 0xA67D2FD3); +} + +TEST_CASE("FLE.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLE_Q(x31, f7, f26); + REQUIRE(value == 0xA7A38FD3); + + as.RewindBuffer(); + + as.FLE_Q(x31, f26, f7); + REQUIRE(value == 0xA67D0FD3); +} + +TEST_CASE("FLT.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLT_Q(x31, f7, f26); + REQUIRE(value == 0xA7A39FD3); + + as.RewindBuffer(); + + as.FLT_Q(x31, f26, f7); + REQUIRE(value == 0xA67D1FD3); +} + +TEST_CASE("FLQ", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FLQ(f15, 1024, x31); + REQUIRE(value == 0x400FC787); + + as.RewindBuffer(); + + as.FLQ(f15, 1536, x31); + REQUIRE(value == 0x600FC787); + + as.RewindBuffer(); + + as.FLQ(f15, -1, x31); + REQUIRE(value == 0xFFFFC787); +} + +TEST_CASE("FMADD.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMADD_Q(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD67F87C3); + + as.RewindBuffer(); + + as.FMADD_Q(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD67FC7C3); + + as.RewindBuffer(); + + as.FMADD_Q(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD67FF7C3); +} + +TEST_CASE("FMAX.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMAX_Q(f31, f7, f26); + REQUIRE(value == 0x2FA39FD3); + + as.RewindBuffer(); + + as.FMAX_Q(f31, f31, f31); + REQUIRE(value == 0x2FFF9FD3); +} + +TEST_CASE("FMIN.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMIN_Q(f31, f7, f26); + REQUIRE(value == 0x2FA38FD3); + + as.RewindBuffer(); + + as.FMIN_Q(f31, f31, f31); + REQUIRE(value == 0x2FFF8FD3); +} + +TEST_CASE("FMSUB.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMSUB_Q(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD67F87C7); + + as.RewindBuffer(); + + as.FMSUB_Q(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD67FC7C7); + + as.RewindBuffer(); + + as.FMSUB_Q(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD67FF7C7); +} + +TEST_CASE("FMUL.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMUL_Q(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x17A38FD3); + + as.RewindBuffer(); + + as.FMUL_Q(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x17A3CFD3); + + as.RewindBuffer(); + + as.FMUL_Q(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x17A3FFD3); +} + +TEST_CASE("FNMADD.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMADD_Q(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD67F87CF); + + as.RewindBuffer(); + + as.FNMADD_Q(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD67FC7CF); + + as.RewindBuffer(); + + as.FNMADD_Q(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD67FF7CF); +} + +TEST_CASE("FNMSUB.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FNMSUB_Q(f15, f31, f7, f26, RMode::RNE); + REQUIRE(value == 0xD67F87CB); + + as.RewindBuffer(); + + as.FNMSUB_Q(f15, f31, f7, f26, RMode::RMM); + REQUIRE(value == 0xD67FC7CB); + + as.RewindBuffer(); + + as.FNMSUB_Q(f15, f31, f7, f26, RMode::DYN); + REQUIRE(value == 0xD67FF7CB); +} + +TEST_CASE("FSGNJ.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJ_Q(f31, f7, f26); + REQUIRE(value == 0x27A38FD3); + + as.RewindBuffer(); + + as.FSGNJ_Q(f31, f31, f31); + REQUIRE(value == 0x27FF8FD3); +} + +TEST_CASE("FSGNJN.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJN_Q(f31, f7, f26); + REQUIRE(value == 0x27A39FD3); + + as.RewindBuffer(); + + as.FSGNJN_Q(f31, f31, f31); + REQUIRE(value == 0x27FF9FD3); +} + +TEST_CASE("FSGNJX.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSGNJX_Q(f31, f7, f26); + REQUIRE(value == 0x27A3AFD3); + + as.RewindBuffer(); + + as.FSGNJX_Q(f31, f31, f31); + REQUIRE(value == 0x27FFAFD3); +} + +TEST_CASE("FSQRT.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSQRT_Q(f31, f7, RMode::RNE); + REQUIRE(value == 0x5E038FD3); + + as.RewindBuffer(); + + as.FSQRT_Q(f31, f7, RMode::RMM); + REQUIRE(value == 0x5E03CFD3); + + as.RewindBuffer(); + + as.FSQRT_Q(f31, f7, RMode::DYN); + REQUIRE(value == 0x5E03FFD3); +} + +TEST_CASE("FSUB.Q", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSUB_Q(f31, f7, f26, RMode::RNE); + REQUIRE(value == 0x0FA38FD3); + + as.RewindBuffer(); + + as.FSUB_Q(f31, f7, f26, RMode::RMM); + REQUIRE(value == 0x0FA3CFD3); + + as.RewindBuffer(); + + as.FSUB_Q(f31, f7, f26, RMode::DYN); + REQUIRE(value == 0x0FA3FFD3); +} + +TEST_CASE("FSQ", "[rv32q]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FSQ(f31, 1024, x15); + REQUIRE(value == 0x41F7C027); + + as.RewindBuffer(); + + as.FSQ(f31, 1536, x15); + REQUIRE(value == 0x61F7C027); + + as.RewindBuffer(); + + as.FSQ(f31, -1, x15); + REQUIRE(value == 0xFFF7CFA7); +} diff --git a/externals/biscuit/tests/src/assembler_rvv_tests.cpp b/externals/biscuit/tests/src/assembler_rvv_tests.cpp new file mode 100644 index 00000000..eb3508af --- /dev/null +++ b/externals/biscuit/tests/src/assembler_rvv_tests.cpp @@ -0,0 +1,5334 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("VAADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAADD(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x26862257); + + as.RewindBuffer(); + + as.VAADD(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x24862257); +} + +TEST_CASE("VAADD.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAADD(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2685E257); + + as.RewindBuffer(); + + as.VAADD(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2485E257); +} + +TEST_CASE("VAADDU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAADDU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x22862257); + + as.RewindBuffer(); + + as.VAADDU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x20862257); +} + +TEST_CASE("VAADDU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAADDU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2285E257); + + as.RewindBuffer(); + + as.VAADDU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2085E257); +} + +TEST_CASE("VADC.VVM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VADC(v4, v8, v12); + REQUIRE(value == 0x40860257); +} + +TEST_CASE("VADC.VXM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VADC(v4, v8, x11); + REQUIRE(value == 0x4085C257); +} + +TEST_CASE("VADC.VIM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VADC(v4, v8, 15); + REQUIRE(value == 0x4087B257); + + as.RewindBuffer(); + + as.VADC(v4, v8, -16); + REQUIRE(value == 0x40883257); +} + +TEST_CASE("VADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VADD(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x02860257); + + as.RewindBuffer(); + + as.VADD(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x00860257); +} + +TEST_CASE("VADD.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VADD(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x0285C257); + + as.RewindBuffer(); + + as.VADD(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x0085C257); +} + +TEST_CASE("VADD.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VADD(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x0287B257); + + as.RewindBuffer(); + + as.VADD(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x02883257); + + as.RewindBuffer(); + + as.VADD(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x0087B257); + + as.RewindBuffer(); + + as.VADD(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x00883257); +} + +TEST_CASE("VAND.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAND(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x26860257); + + as.RewindBuffer(); + + as.VAND(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x24860257); +} + +TEST_CASE("VAND.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAND(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2685C257); + + as.RewindBuffer(); + + as.VAND(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2485C257); +} + +TEST_CASE("VAND.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAND(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x2687B257); + + as.RewindBuffer(); + + as.VAND(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x26883257); + + as.RewindBuffer(); + + as.VAND(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x2487B257); + + as.RewindBuffer(); + + as.VAND(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x24883257); +} + +TEST_CASE("VASUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VASUB(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x2E862257); + + as.RewindBuffer(); + + as.VASUB(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x2C862257); +} + +TEST_CASE("VASUB.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VASUB(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2E85E257); + + as.RewindBuffer(); + + as.VASUB(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2C85E257); +} + +TEST_CASE("VASUBU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VASUBU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x2A862257); + + as.RewindBuffer(); + + as.VASUBU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x28862257); +} + +TEST_CASE("VASUBU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VASUBU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2A85E257); + + as.RewindBuffer(); + + as.VASUBU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2885E257); +} + +TEST_CASE("VCOMPRESS.VM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCOMPRESS(v4, v8, v12); + REQUIRE(value == 0x5E862257); +} + +TEST_CASE("VDIV.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VDIV(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x86862257); + + as.RewindBuffer(); + + as.VDIV(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x84862257); +} + +TEST_CASE("VDIV.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VDIV(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8685E257); + + as.RewindBuffer(); + + as.VDIV(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8485E257); +} + +TEST_CASE("VDIVU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VDIVU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x82862257); + + as.RewindBuffer(); + + as.VDIVU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x80862257); +} + +TEST_CASE("VDIVU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VDIVU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8285E257); + + as.RewindBuffer(); + + as.VDIVU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8085E257); +} + +TEST_CASE("VFADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFADD(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x02861257); + + as.RewindBuffer(); + + as.VFADD(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x00861257); +} + +TEST_CASE("VFADD.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFADD(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x02865257); + + as.RewindBuffer(); + + as.VFADD(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x00865257); +} + +TEST_CASE("VFCLASS.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCLASS(v4, v8, VecMask::No); + REQUIRE(value == 0x4E881257); + + as.RewindBuffer(); + + as.VFCLASS(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4C881257); +} + +TEST_CASE("VFCVT.F.X.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCVT_F_X(v4, v8, VecMask::No); + REQUIRE(value == 0x4A819257); + + as.RewindBuffer(); + + as.VFCVT_F_X(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48819257); +} + +TEST_CASE("VFCVT.F.XU.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCVT_F_XU(v4, v8, VecMask::No); + REQUIRE(value == 0x4A811257); + + as.RewindBuffer(); + + as.VFCVT_F_XU(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48811257); +} + +TEST_CASE("VFCVT.RTZ.X.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCVT_RTZ_X_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A839257); + + as.RewindBuffer(); + + as.VFCVT_RTZ_X_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48839257); +} + +TEST_CASE("VFCVT.RTZ.XU.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCVT_RTZ_XU_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A831257); + + as.RewindBuffer(); + + as.VFCVT_RTZ_XU_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48831257); +} + +TEST_CASE("VFCVT.X.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCVT_X_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A809257); + + as.RewindBuffer(); + + as.VFCVT_X_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48809257); +} + +TEST_CASE("VFCVT.XU.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFCVT_XU_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A801257); + + as.RewindBuffer(); + + as.VFCVT_XU_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48801257); +} + +TEST_CASE("VFNCVT.F.F.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_F_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A8A1257); + + as.RewindBuffer(); + + as.VFNCVT_F_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x488A1257); +} + +TEST_CASE("VFNCVT.F.X.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_F_X(v4, v8, VecMask::No); + REQUIRE(value == 0x4A899257); + + as.RewindBuffer(); + + as.VFNCVT_F_X(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48899257); +} + +TEST_CASE("VFNCVT.F.XU.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_F_XU(v4, v8, VecMask::No); + REQUIRE(value == 0x4A891257); + + as.RewindBuffer(); + + as.VFNCVT_F_XU(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48891257); +} + +TEST_CASE("VFNCVT.ROD.F.F.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_ROD_F_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A8A9257); + + as.RewindBuffer(); + + as.VFNCVT_ROD_F_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x488A9257); +} + +TEST_CASE("VFNCVT.RTZ.X.F.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_RTZ_X_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A8B9257); + + as.RewindBuffer(); + + as.VFNCVT_RTZ_X_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x488B9257); +} + +TEST_CASE("VFNCVT.RTZ.XU.F.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_RTZ_XU_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A8B1257); + + as.RewindBuffer(); + + as.VFNCVT_RTZ_XU_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x488B1257); +} + +TEST_CASE("VFNCVT.X.F.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_X_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A889257); + + as.RewindBuffer(); + + as.VFNCVT_X_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48889257); +} + +TEST_CASE("VFNCVT.XU.F.W", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNCVT_XU_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A881257); + + as.RewindBuffer(); + + as.VFNCVT_XU_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48881257); +} + +TEST_CASE("VFWCVT.F.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_F_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A861257); + + as.RewindBuffer(); + + as.VFWCVT_F_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48861257); +} + +TEST_CASE("VFWCVT.F.X.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_F_X(v4, v8, VecMask::No); + REQUIRE(value == 0x4A859257); + + as.RewindBuffer(); + + as.VFWCVT_F_X(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48859257); +} + +TEST_CASE("VFWCVT.F.XU.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_F_XU(v4, v8, VecMask::No); + REQUIRE(value == 0x4A851257); + + as.RewindBuffer(); + + as.VFWCVT_F_XU(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48851257); +} + +TEST_CASE("VFWCVT.RTZ.X.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_RTZ_X_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A879257); + + as.RewindBuffer(); + + as.VFWCVT_RTZ_X_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48879257); +} + +TEST_CASE("VFWCVT.RTZ.XU.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_RTZ_XU_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A871257); + + as.RewindBuffer(); + + as.VFWCVT_RTZ_XU_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48871257); +} + +TEST_CASE("VFWCVT.X.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_X_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A849257); + + as.RewindBuffer(); + + as.VFWCVT_X_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48849257); +} + +TEST_CASE("VFWCVT.XU.F.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWCVT_XU_F(v4, v8, VecMask::No); + REQUIRE(value == 0x4A841257); + + as.RewindBuffer(); + + as.VFWCVT_XU_F(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48841257); +} + +TEST_CASE("VFDIV.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFDIV(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x82861257); + + as.RewindBuffer(); + + as.VFDIV(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x80861257); +} + +TEST_CASE("VFDIV.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFDIV(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x82865257); + + as.RewindBuffer(); + + as.VFDIV(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x80865257); +} + +TEST_CASE("VFRDIV.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFRDIV(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x86865257); + + as.RewindBuffer(); + + as.VFRDIV(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x84865257); +} + +TEST_CASE("VFIRST.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFIRST(x10, v12, VecMask::No); + REQUIRE(value == 0x42C8A557); + + as.RewindBuffer(); + + as.VFIRST(x10, v12, VecMask::Yes); + REQUIRE(value == 0x40C8A557); +} + +TEST_CASE("VFREDMAX.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFREDMAX(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x1E861257); + + as.RewindBuffer(); + + as.VFREDMAX(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x1C861257); +} + +TEST_CASE("VFREDMIN.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFREDMIN(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x16861257); + + as.RewindBuffer(); + + as.VFREDMIN(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x14861257); +} + +TEST_CASE("VFREDSUM.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFREDSUM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x06861257); + + as.RewindBuffer(); + + as.VFREDSUM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x04861257); +} + +TEST_CASE("VFREDOSUM.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFREDOSUM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x0E861257); + + as.RewindBuffer(); + + as.VFREDOSUM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x0C861257); +} + +TEST_CASE("VFMACC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMACC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xB2861257); + + as.RewindBuffer(); + + as.VFMACC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xB0861257); +} + +TEST_CASE("VFMACC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMACC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xB2865257); + + as.RewindBuffer(); + + as.VFMACC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xB0865257); +} + +TEST_CASE("VFMADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMADD(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xA2861257); + + as.RewindBuffer(); + + as.VFMADD(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xA0861257); +} + +TEST_CASE("VFMADD.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMADD(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xA2865257); + + as.RewindBuffer(); + + as.VFMADD(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xA0865257); +} + +TEST_CASE("VFMAX.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMAX(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x1A861257); + + as.RewindBuffer(); + + as.VFMAX(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x18861257); +} + +TEST_CASE("VFMAX.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMAX(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x1A865257); + + as.RewindBuffer(); + + as.VFMAX(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x18865257); +} + +TEST_CASE("VFMERGE.VFM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMERGE(v4, v8, f12); + REQUIRE(value == 0x5C865257); +} + +TEST_CASE("VFMIN.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMIN(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x12861257); + + as.RewindBuffer(); + + as.VFMIN(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x10861257); +} + +TEST_CASE("VFMIN.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMIN(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x12865257); + + as.RewindBuffer(); + + as.VFMIN(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x10865257); +} + +TEST_CASE("VFMSAC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMSAC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xBA861257); + + as.RewindBuffer(); + + as.VFMSAC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xB8861257); +} + +TEST_CASE("VFMSAC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMSAC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xBA865257); + + as.RewindBuffer(); + + as.VFMSAC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xB8865257); +} + +TEST_CASE("VFMSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMSUB(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xAA861257); + + as.RewindBuffer(); + + as.VFMSUB(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xA8861257); +} + +TEST_CASE("VFMSUB.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMSUB(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xAA865257); + + as.RewindBuffer(); + + as.VFMSUB(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xA8865257); +} + +TEST_CASE("VFMUL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMUL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x92861257); + + as.RewindBuffer(); + + as.VFMUL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x90861257); +} + +TEST_CASE("VFMUL.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMUL(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x92865257); + + as.RewindBuffer(); + + as.VFMUL(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x90865257); +} + +TEST_CASE("VFMV.F.S", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMV_FS(f10, v8); + REQUIRE(value == 0x42801557); +} + +TEST_CASE("VFMV.S.F", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMV_SF(v4, f11); + REQUIRE(value == 0x4205D257); +} + +TEST_CASE("VFMV.V.F", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFMV(v4, f11); + REQUIRE(value == 0x5E05D257); +} + +TEST_CASE("VFNMACC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMACC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xB6861257); + + as.RewindBuffer(); + + as.VFNMACC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xB4861257); +} + +TEST_CASE("VFNMACC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMACC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xB6865257); + + as.RewindBuffer(); + + as.VFNMACC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xB4865257); +} + +TEST_CASE("VFNMADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMADD(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xA6861257); + + as.RewindBuffer(); + + as.VFNMADD(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xA4861257); +} + +TEST_CASE("VFNMADD.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMADD(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xA6865257); + + as.RewindBuffer(); + + as.VFNMADD(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xA4865257); +} + +TEST_CASE("VFNMSAC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMSAC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xBE861257); + + as.RewindBuffer(); + + as.VFNMSAC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xBC861257); +} + +TEST_CASE("VFNMSAC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMSAC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xBE865257); + + as.RewindBuffer(); + + as.VFNMSAC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xBC865257); +} + +TEST_CASE("VFNMSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMSUB(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xAE861257); + + as.RewindBuffer(); + + as.VFNMSUB(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xAC861257); +} + +TEST_CASE("VFNMSUB.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFNMSUB(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xAE865257); + + as.RewindBuffer(); + + as.VFNMSUB(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xAC865257); +} + +TEST_CASE("VFREC7.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFREC7(v4, v8, VecMask::No); + REQUIRE(value == 0x4E829257); + + as.RewindBuffer(); + + as.VFREC7(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4C829257); +} + +TEST_CASE("VFSGNJ.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSGNJ(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x22861257); + + as.RewindBuffer(); + + as.VFSGNJ(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x20861257); +} + +TEST_CASE("VFSGNJ.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSGNJ(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x22865257); + + as.RewindBuffer(); + + as.VFSGNJ(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x20865257); +} + +TEST_CASE("VFSGNJN.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSGNJN(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x26861257); + + as.RewindBuffer(); + + as.VFSGNJN(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x24861257); +} + +TEST_CASE("VFSGNJN.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSGNJN(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x26865257); + + as.RewindBuffer(); + + as.VFSGNJN(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x24865257); +} + +TEST_CASE("VFSGNJX.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSGNJX(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x2A861257); + + as.RewindBuffer(); + + as.VFSGNJX(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x28861257); +} + +TEST_CASE("VFSGNJX.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSGNJX(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x2A865257); + + as.RewindBuffer(); + + as.VFSGNJX(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x28865257); +} + +TEST_CASE("VFSQRT.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSQRT(v4, v8, VecMask::No); + REQUIRE(value == 0x4E801257); + + as.RewindBuffer(); + + as.VFSQRT(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4C801257); +} + +TEST_CASE("VFRSQRT7.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFRSQRT7(v4, v8, VecMask::No); + REQUIRE(value == 0x4E821257); + + as.RewindBuffer(); + + as.VFRSQRT7(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4C821257); +} + +TEST_CASE("VFSLIDE1DOWN.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSLIDE1DOWN(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x3E865257); + + as.RewindBuffer(); + + as.VFSLIDE1DOWN(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x3C865257); +} + +TEST_CASE("VFSLIDE1UP.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSLIDE1UP(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x3A865257); + + as.RewindBuffer(); + + as.VFSLIDE1UP(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x38865257); +} + +TEST_CASE("VFSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSUB(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x0A861257); + + as.RewindBuffer(); + + as.VFSUB(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x08861257); +} + +TEST_CASE("VFSUB.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFSUB(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x0A865257); + + as.RewindBuffer(); + + as.VFSUB(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x08865257); +} + +TEST_CASE("VFRSUB.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFRSUB(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x9E865257); + + as.RewindBuffer(); + + as.VFRSUB(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x9C865257); +} + +TEST_CASE("VFWADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWADD(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xC2861257); + + as.RewindBuffer(); + + as.VFWADD(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC0861257); +} + +TEST_CASE("VFWADD.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWADD(v4, v8, f12, VecMask::No); + REQUIRE(value == 0xC2865257); + + as.RewindBuffer(); + + as.VFWADD(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0xC0865257); +} + +TEST_CASE("VFWADD.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWADDW(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xD2861257); + + as.RewindBuffer(); + + as.VFWADDW(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xD0861257); +} + +TEST_CASE("VFWADD.WF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWADDW(v4, v8, f12, VecMask::No); + REQUIRE(value == 0xD2865257); + + as.RewindBuffer(); + + as.VFWADDW(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0xD0865257); +} + +TEST_CASE("VFWMACC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWMACC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xF2861257); + + as.RewindBuffer(); + + as.VFWMACC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xF0861257); +} + +TEST_CASE("VFWMACC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWMACC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xF2865257); + + as.RewindBuffer(); + + as.VFWMACC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xF0865257); +} + +TEST_CASE("VFWMUL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWMUL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xE2861257); + + as.RewindBuffer(); + + as.VFWMUL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xE0861257); +} + +TEST_CASE("VFWMUL.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWMUL(v4, v8, f12, VecMask::No); + REQUIRE(value == 0xE2865257); + + as.RewindBuffer(); + + as.VFWMUL(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0xE0865257); +} + +TEST_CASE("VFWNMACC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWNMACC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xF6861257); + + as.RewindBuffer(); + + as.VFWNMACC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xF4861257); +} + +TEST_CASE("VFWNMACC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWNMACC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xF6865257); + + as.RewindBuffer(); + + as.VFWNMACC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xF4865257); +} + +TEST_CASE("VFWNMSAC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWNMSAC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xFE861257); + + as.RewindBuffer(); + + as.VFWNMSAC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xFC861257); +} + +TEST_CASE("VFWNMSAC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWNMSAC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xFE865257); + + as.RewindBuffer(); + + as.VFWNMSAC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xFC865257); +} + +TEST_CASE("VFWREDSUM.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWREDSUM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xC6861257); + + as.RewindBuffer(); + + as.VFWREDSUM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC4861257); +} + +TEST_CASE("VFWREDOSUM.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWREDOSUM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xCE861257); + + as.RewindBuffer(); + + as.VFWREDOSUM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xCC861257); +} + +TEST_CASE("VFWMSAC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWMSAC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xFA861257); + + as.RewindBuffer(); + + as.VFWMSAC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xF8861257); +} + +TEST_CASE("VFWMSAC.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWMSAC(v4, f12, v8, VecMask::No); + REQUIRE(value == 0xFA865257); + + as.RewindBuffer(); + + as.VFWMSAC(v4, f12, v8, VecMask::Yes); + REQUIRE(value == 0xF8865257); +} + +TEST_CASE("VFWSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWSUB(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xCA861257); + + as.RewindBuffer(); + + as.VFWSUB(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC8861257); +} + +TEST_CASE("VFWSUB.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWSUB(v4, v8, f12, VecMask::No); + REQUIRE(value == 0xCA865257); + + as.RewindBuffer(); + + as.VFWSUB(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0xC8865257); +} + +TEST_CASE("VFWSUB.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWSUBW(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xDA861257); + + as.RewindBuffer(); + + as.VFWSUBW(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xD8861257); +} + +TEST_CASE("VFWSUB.WF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VFWSUBW(v4, v8, f12, VecMask::No); + REQUIRE(value == 0xDA865257); + + as.RewindBuffer(); + + as.VFWSUBW(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0xD8865257); +} + +TEST_CASE("VID.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VID(v4, VecMask::No); + REQUIRE(value == 0x5208A257); + + as.RewindBuffer(); + + as.VID(v4, VecMask::Yes); + REQUIRE(value == 0x5008A257); +} + +TEST_CASE("VIOTA.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VIOTA(v4, v8, VecMask::No); + REQUIRE(value == 0x52882257); + + as.RewindBuffer(); + + as.VIOTA(v4, v8, VecMask::Yes); + REQUIRE(value == 0x50882257); +} + +TEST_CASE("VMACC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMACC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xB6862257); + + as.RewindBuffer(); + + as.VMACC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xB4862257); +} + +TEST_CASE("VMACC.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMACC(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xB685E257); + + as.RewindBuffer(); + + as.VMACC(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xB485E257); +} + +TEST_CASE("VMADC.VV(M)", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMADC(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x46860257); + + as.RewindBuffer(); + + as.VMADC(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x44860257); +} + +TEST_CASE("VMADC.VX(M)", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMADC(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x4685C257); + + as.RewindBuffer(); + + as.VMADC(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x4485C257); +} + +TEST_CASE("VMADC.VI(M)", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMADC(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x4687B257); + + as.RewindBuffer(); + + as.VMADC(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x46883257); + + as.RewindBuffer(); + + as.VMADC(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x4487B257); + + as.RewindBuffer(); + + as.VMADC(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x44883257); +} + +TEST_CASE("VMADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMADD(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xA6862257); + + as.RewindBuffer(); + + as.VMADD(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xA4862257); +} + +TEST_CASE("VMADD.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMADD(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xA685E257); + + as.RewindBuffer(); + + as.VMADD(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xA485E257); +} + +TEST_CASE("VMAND.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMAND(v4, v8, v12); + REQUIRE(value == 0x66862257); +} + +TEST_CASE("VMANDNOT.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMANDNOT(v4, v8, v12); + REQUIRE(value == 0x62862257); +} + +TEST_CASE("VMFEQ.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFEQ(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x62861257); + + as.RewindBuffer(); + + as.VMFEQ(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x60861257); +} + +TEST_CASE("VMFEQ.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFEQ(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x62865257); + + as.RewindBuffer(); + + as.VMFEQ(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x60865257); +} + +TEST_CASE("VMFGE.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFGE(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x7E865257); + + as.RewindBuffer(); + + as.VMFGE(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x7C865257); +} + +TEST_CASE("VMFGT.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFGT(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x76865257); + + as.RewindBuffer(); + + as.VMFGT(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x74865257); +} + +TEST_CASE("VMFLE.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFLE(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x66861257); + + as.RewindBuffer(); + + as.VMFLE(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x64861257); +} + +TEST_CASE("VMFLE.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFLE(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x66865257); + + as.RewindBuffer(); + + as.VMFLE(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x64865257); +} + +TEST_CASE("VMFLT.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFLT(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x6E861257); + + as.RewindBuffer(); + + as.VMFLT(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x6C861257); +} + +TEST_CASE("VMFLT.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFLT(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x6E865257); + + as.RewindBuffer(); + + as.VMFLT(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x6C865257); +} + +TEST_CASE("VMFNE.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFNE(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x72861257); + + as.RewindBuffer(); + + as.VMFNE(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x70861257); +} + +TEST_CASE("VMFNE.VF", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMFNE(v4, v8, f12, VecMask::No); + REQUIRE(value == 0x72865257); + + as.RewindBuffer(); + + as.VMFNE(v4, v8, f12, VecMask::Yes); + REQUIRE(value == 0x70865257); +} + +TEST_CASE("VMNAND.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMNAND(v4, v8, v12); + REQUIRE(value == 0x76862257); +} + +TEST_CASE("VMNOR.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMNOR(v4, v8, v12); + REQUIRE(value == 0x7A862257); +} + +TEST_CASE("VMOR.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMOR(v4, v8, v12); + REQUIRE(value == 0x6A862257); +} + +TEST_CASE("VMORNOT.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMORNOT(v4, v8, v12); + REQUIRE(value == 0x72862257); +} + +TEST_CASE("VMXNOR.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMXNOR(v4, v8, v12); + REQUIRE(value == 0x7E862257); +} + +TEST_CASE("VMXOR.MM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMXOR(v4, v8, v12); + REQUIRE(value == 0x6E862257); +} + +TEST_CASE("VMAX.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMAX(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x1E860257); + + as.RewindBuffer(); + + as.VMAX(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x1C860257); +} + +TEST_CASE("VMAX.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMAX(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x1E85C257); + + as.RewindBuffer(); + + as.VMAX(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x1C85C257); +} + +TEST_CASE("VMAXU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMAXU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x1A860257); + + as.RewindBuffer(); + + as.VMAXU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x18860257); +} + +TEST_CASE("VMAXU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMAXU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x1A85C257); + + as.RewindBuffer(); + + as.VMAXU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x1885C257); +} + +TEST_CASE("VMERGE.VVM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMERGE(v4, v8, v12); + REQUIRE(value == 0x5C860257); +} + +TEST_CASE("VMERGE.VXM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMERGE(v4, v8, x11); + REQUIRE(value == 0x5C85C257); +} + +TEST_CASE("VMERGE.VIM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMERGE(v4, v8, 15); + REQUIRE(value == 0x5C87B257); + + as.RewindBuffer(); + + as.VMERGE(v4, v8, -16); + REQUIRE(value == 0x5C883257); +} + +TEST_CASE("VMIN.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMIN(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x16860257); + + as.RewindBuffer(); + + as.VMIN(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x14860257); +} + +TEST_CASE("VMIN.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMIN(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x1685C257); + + as.RewindBuffer(); + + as.VMIN(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x1485C257); +} + +TEST_CASE("VMINU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMINU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x12860257); + + as.RewindBuffer(); + + as.VMINU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x10860257); +} + +TEST_CASE("VMINU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMINU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x1285C257); + + as.RewindBuffer(); + + as.VMINU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x1085C257); +} + +TEST_CASE("VMSBC.VV(M)", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSBC(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x4E860257); + + as.RewindBuffer(); + + as.VMSBC(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x4C860257); +} + +TEST_CASE("VMSBC.VX(M)", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSBC(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x4E85C257); + + as.RewindBuffer(); + + as.VMSBC(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x4C85C257); +} + +TEST_CASE("VMSBF.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSBF(v4, v8, VecMask::No); + REQUIRE(value == 0x5280A257); + + as.RewindBuffer(); + + as.VMSBF(v4, v8, VecMask::Yes); + REQUIRE(value == 0x5080A257); +} + +TEST_CASE("VMSIF.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSIF(v4, v8, VecMask::No); + REQUIRE(value == 0x5281A257); + + as.RewindBuffer(); + + as.VMSIF(v4, v8, VecMask::Yes); + REQUIRE(value == 0x5081A257); +} + +TEST_CASE("VMSOF.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSOF(v4, v8, VecMask::No); + REQUIRE(value == 0x52812257); + + as.RewindBuffer(); + + as.VMSOF(v4, v8, VecMask::Yes); + REQUIRE(value == 0x50812257); +} + +TEST_CASE("VMSEQ.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSEQ(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x62860257); + + as.RewindBuffer(); + + as.VMSEQ(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x60860257); +} + +TEST_CASE("VMSEQ.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSEQ(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x6285C257); + + as.RewindBuffer(); + + as.VMSEQ(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x6085C257); +} + +TEST_CASE("VMSEQ.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSEQ(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x6287B257); + + as.RewindBuffer(); + + as.VMSEQ(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x62883257); + + as.RewindBuffer(); + + as.VMSEQ(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x6087B257); + + as.RewindBuffer(); + + as.VMSEQ(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x60883257); +} + +TEST_CASE("VMSGT.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSGT(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x7E85C257); + + as.RewindBuffer(); + + as.VMSGT(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x7C85C257); +} + +TEST_CASE("VMSGT.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSGT(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x7E87B257); + + as.RewindBuffer(); + + as.VMSGT(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x7E883257); + + as.RewindBuffer(); + + as.VMSGT(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x7C87B257); + + as.RewindBuffer(); + + as.VMSGT(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x7C883257); +} + +TEST_CASE("VMSGTU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSGTU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x7A85C257); + + as.RewindBuffer(); + + as.VMSGTU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x7885C257); +} + +TEST_CASE("VMSGTU.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSGTU(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x7A87B257); + + as.RewindBuffer(); + + as.VMSGTU(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x7A883257); + + as.RewindBuffer(); + + as.VMSGTU(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x7887B257); + + as.RewindBuffer(); + + as.VMSGTU(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x78883257); +} + +TEST_CASE("VMSLE.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLE(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x76860257); + + as.RewindBuffer(); + + as.VMSLE(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x74860257); +} + +TEST_CASE("VMSLE.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLE(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x7685C257); + + as.RewindBuffer(); + + as.VMSLE(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x7485C257); +} + +TEST_CASE("VMSLE.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLE(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x7687B257); + + as.RewindBuffer(); + + as.VMSLE(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x76883257); + + as.RewindBuffer(); + + as.VMSLE(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x7487B257); + + as.RewindBuffer(); + + as.VMSLE(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x74883257); +} + +TEST_CASE("VMSLEU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLEU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x72860257); + + as.RewindBuffer(); + + as.VMSLEU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x70860257); +} + +TEST_CASE("VMSLEU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLEU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x7285C257); + + as.RewindBuffer(); + + as.VMSLEU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x7085C257); +} + +TEST_CASE("VMSLEU.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLEU(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x7287B257); + + as.RewindBuffer(); + + as.VMSLEU(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x72883257); + + as.RewindBuffer(); + + as.VMSLEU(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x7087B257); + + as.RewindBuffer(); + + as.VMSLEU(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x70883257); +} + +TEST_CASE("VMSLT.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLT(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x6E860257); + + as.RewindBuffer(); + + as.VMSLT(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x6C860257); +} + +TEST_CASE("VMSLT.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLT(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x6E85C257); + + as.RewindBuffer(); + + as.VMSLT(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x6C85C257); +} + +TEST_CASE("VMSLTU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLTU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x6A860257); + + as.RewindBuffer(); + + as.VMSLTU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x68860257); +} + +TEST_CASE("VMSLTU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSLTU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x6A85C257); + + as.RewindBuffer(); + + as.VMSLTU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x6885C257); +} + +TEST_CASE("VMSNE.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSNE(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x66860257); + + as.RewindBuffer(); + + as.VMSNE(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x64860257); +} + +TEST_CASE("VMSNE.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSNE(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x6685C257); + + as.RewindBuffer(); + + as.VMSNE(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x6485C257); +} + +TEST_CASE("VMSNE.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMSNE(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x6687B257); + + as.RewindBuffer(); + + as.VMSNE(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x66883257); + + as.RewindBuffer(); + + as.VMSNE(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x6487B257); + + as.RewindBuffer(); + + as.VMSNE(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x64883257); +} + +TEST_CASE("VMUL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMUL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x96862257); + + as.RewindBuffer(); + + as.VMUL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x94862257); +} + +TEST_CASE("VMUL.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMUL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x9685E257); + + as.RewindBuffer(); + + as.VMUL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x9485E257); +} + +TEST_CASE("VMULH.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMULH(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x9E862257); + + as.RewindBuffer(); + + as.VMULH(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x9C862257); +} + +TEST_CASE("VMULH.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMULH(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x9E85E257); + + as.RewindBuffer(); + + as.VMULH(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x9C85E257); +} + +TEST_CASE("VMULHSU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMULHSU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x9A862257); + + as.RewindBuffer(); + + as.VMULHSU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x98862257); +} + +TEST_CASE("VMULHSU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMULHSU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x9A85E257); + + as.RewindBuffer(); + + as.VMULHSU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x9885E257); +} + +TEST_CASE("VMULHU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMULHU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x92862257); + + as.RewindBuffer(); + + as.VMULHU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x90862257); +} + +TEST_CASE("VMULHU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMULHU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x9285E257); + + as.RewindBuffer(); + + as.VMULHU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x9085E257); +} + +TEST_CASE("VMV.S.X", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV_SX(v4, x10); + REQUIRE(value == 0x42056257); +} + +TEST_CASE("VMV.X.S", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV_XS(x10, v12); + REQUIRE(value == 0x42C02557); +} + +TEST_CASE("VMV.V.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV(v8, v12); + REQUIRE(value == 0x5E060457); +} + +TEST_CASE("VMV.V.X", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV(v8, x11); + REQUIRE(value == 0x5E05C457); +} + +TEST_CASE("VMV.V.I", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV(v8, 15); + REQUIRE(value == 0x5E07B457); + + as.RewindBuffer(); + + as.VMV(v8, -16); + REQUIRE(value == 0x5E083457); +} + +TEST_CASE("VMV1R.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV1R(v1, v2); + REQUIRE(value == 0x9E2030D7); +} + +TEST_CASE("VMV2R.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV2R(v2, v4); + REQUIRE(value == 0x9E40B157); +} + +TEST_CASE("VMV4R.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV4R(v4, v8); + REQUIRE(value == 0x9E81B257); +} + +TEST_CASE("VMV8R.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VMV8R(v0, v8); + REQUIRE(value == 0x9E83B057); +} + +TEST_CASE("VNCLIP.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNCLIP(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xBE860257); + + as.RewindBuffer(); + + as.VNCLIP(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xBC860257); +} + +TEST_CASE("VNCLIP.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNCLIP(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xBE85C257); + + as.RewindBuffer(); + + as.VNCLIP(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xBC85C257); +} + +TEST_CASE("VNCLIP.WI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNCLIP(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xBE80B257); + + as.RewindBuffer(); + + as.VNCLIP(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xBE8FB257); + + as.RewindBuffer(); + + as.VNCLIP(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xBC80B257); + + as.RewindBuffer(); + + as.VNCLIP(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xBC8FB257); +} + +TEST_CASE("VNCLIPU.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNCLIPU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xBA860257); + + as.RewindBuffer(); + + as.VNCLIPU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xB8860257); +} + +TEST_CASE("VNCLIPU.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNCLIPU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xBA85C257); + + as.RewindBuffer(); + + as.VNCLIPU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xB885C257); +} + +TEST_CASE("VNCLIPU.WI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNCLIPU(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xBA80B257); + + as.RewindBuffer(); + + as.VNCLIPU(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xBA8FB257); + + as.RewindBuffer(); + + as.VNCLIPU(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xB880B257); + + as.RewindBuffer(); + + as.VNCLIPU(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xB88FB257); +} + +TEST_CASE("VNMSAC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNMSAC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xBE862257); + + as.RewindBuffer(); + + as.VNMSAC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xBC862257); +} + +TEST_CASE("VNMSAC.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNMSAC(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xBE85E257); + + as.RewindBuffer(); + + as.VNMSAC(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xBC85E257); +} + +TEST_CASE("VNMSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNMSUB(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xAE862257); + + as.RewindBuffer(); + + as.VNMSUB(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xAC862257); +} + +TEST_CASE("VNMSUB.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNMSUB(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xAE85E257); + + as.RewindBuffer(); + + as.VNMSUB(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xAC85E257); +} + +TEST_CASE("VNSRA.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNSRA(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xB6860257); + + as.RewindBuffer(); + + as.VNSRA(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xB4860257); +} + +TEST_CASE("VNSRA.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNSRA(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xB685C257); + + as.RewindBuffer(); + + as.VNSRA(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xB485C257); +} + +TEST_CASE("VNSRA.WI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNSRA(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xB680B257); + + as.RewindBuffer(); + + as.VNSRA(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xB68FB257); + + as.RewindBuffer(); + + as.VNSRA(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xB480B257); + + as.RewindBuffer(); + + as.VNSRA(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xB48FB257); +} + +TEST_CASE("VNSRL.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNSRL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xB2860257); + + as.RewindBuffer(); + + as.VNSRL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xB0860257); +} + +TEST_CASE("VNSRL.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNSRL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xB285C257); + + as.RewindBuffer(); + + as.VNSRL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xB085C257); +} + +TEST_CASE("VNSRL.WI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VNSRL(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xB280B257); + + as.RewindBuffer(); + + as.VNSRL(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xB28FB257); + + as.RewindBuffer(); + + as.VNSRL(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xB080B257); + + as.RewindBuffer(); + + as.VNSRL(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xB08FB257); +} + +TEST_CASE("VOR.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VOR(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x2A860257); + + as.RewindBuffer(); + + as.VOR(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x28860257); +} + +TEST_CASE("VOR.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VOR(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2A85C257); + + as.RewindBuffer(); + + as.VOR(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2885C257); +} + +TEST_CASE("VOR.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VOR(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x2A87B257); + + as.RewindBuffer(); + + as.VOR(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x2A883257); + + as.RewindBuffer(); + + as.VOR(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x2887B257); + + as.RewindBuffer(); + + as.VOR(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x28883257); +} + +TEST_CASE("VPOPC.M", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VPOPC(x10, v12, VecMask::No); + REQUIRE(value == 0x42C82557); + + as.RewindBuffer(); + + as.VPOPC(x10, v12, VecMask::Yes); + REQUIRE(value == 0x40C82557); +} + +TEST_CASE("VREDAND.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDAND(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x06862257); + + as.RewindBuffer(); + + as.VREDAND(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x04862257); +} + +TEST_CASE("VREDMAX.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDMAX(v4, v8, v8, VecMask::No); + REQUIRE(value == 0x1E842257); + + as.RewindBuffer(); + + as.VREDMAX(v4, v8, v8, VecMask::Yes); + REQUIRE(value == 0x1C842257); +} + +TEST_CASE("VREDMAXU.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDMAXU(v4, v8, v8, VecMask::No); + REQUIRE(value == 0x1A842257); + + as.RewindBuffer(); + + as.VREDMAXU(v4, v8, v8, VecMask::Yes); + REQUIRE(value == 0x18842257); +} + +TEST_CASE("VREDMIN.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDMIN(v4, v8, v8, VecMask::No); + REQUIRE(value == 0x16842257); + + as.RewindBuffer(); + + as.VREDMIN(v4, v8, v8, VecMask::Yes); + REQUIRE(value == 0x14842257); +} + +TEST_CASE("VREDMINU.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDMINU(v4, v8, v8, VecMask::No); + REQUIRE(value == 0x12842257); + + as.RewindBuffer(); + + as.VREDMINU(v4, v8, v8, VecMask::Yes); + REQUIRE(value == 0x10842257); +} + +TEST_CASE("VREDOR.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDOR(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x0A862257); + + as.RewindBuffer(); + + as.VREDOR(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x08862257); +} + +TEST_CASE("VREDSUM.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDSUM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x02862257); + + as.RewindBuffer(); + + as.VREDSUM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x00862257); +} + +TEST_CASE("VREDXOR.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREDXOR(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x0E862257); + + as.RewindBuffer(); + + as.VREDXOR(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x0C862257); +} + +TEST_CASE("VREM.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x8E862257); + + as.RewindBuffer(); + + as.VREM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x8C862257); +} + +TEST_CASE("VREM.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREM(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8E85E257); + + as.RewindBuffer(); + + as.VREM(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8C85E257); +} + +TEST_CASE("VREMU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREMU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x8A862257); + + as.RewindBuffer(); + + as.VREMU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x88862257); +} + +TEST_CASE("VREMU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREMU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8A85E257); + + as.RewindBuffer(); + + as.VREMU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8885E257); +} + +TEST_CASE("VRGATHER.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VRGATHER(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x32860257); + + as.RewindBuffer(); + + as.VRGATHER(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x30860257); +} + +TEST_CASE("VRGATHER.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VRGATHER(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x3285C257); + + as.RewindBuffer(); + + as.VRGATHER(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x3085C257); +} + +TEST_CASE("VRGATHER.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VRGATHER(v4, v8, 0, VecMask::No); + REQUIRE(value == 0x32803257); + + as.RewindBuffer(); + + as.VRGATHER(v4, v8, 31, VecMask::No); + REQUIRE(value == 0x328FB257); + + as.RewindBuffer(); + + as.VRGATHER(v4, v8, 0, VecMask::Yes); + REQUIRE(value == 0x30803257); + + as.RewindBuffer(); + + as.VRGATHER(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0x308FB257); +} + +TEST_CASE("VRGATHEREI16.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VRGATHEREI16(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x3A860257); + + as.RewindBuffer(); + + as.VRGATHEREI16(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x38860257); +} + +TEST_CASE("VRSUB.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VRSUB(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x0E85C257); + + as.RewindBuffer(); + + as.VRSUB(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x0C85C257); +} + +TEST_CASE("VRSUB.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VRSUB(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x0E87B257); + + as.RewindBuffer(); + + as.VRSUB(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x0E883257); + + as.RewindBuffer(); + + as.VRSUB(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x0C87B257); + + as.RewindBuffer(); + + as.VRSUB(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x0C883257); +} + +TEST_CASE("VSADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSADD(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x86860257); + + as.RewindBuffer(); + + as.VSADD(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x84860257); +} + +TEST_CASE("VSADD.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSADD(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8685C257); + + as.RewindBuffer(); + + as.VSADD(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8485C257); +} + +TEST_CASE("VSADD.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSADD(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x8687B257); + + as.RewindBuffer(); + + as.VSADD(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x86883257); + + as.RewindBuffer(); + + as.VSADD(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x8487B257); + + as.RewindBuffer(); + + as.VSADD(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x84883257); +} + +TEST_CASE("VSADDU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSADDU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x82860257); + + as.RewindBuffer(); + + as.VSADDU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x80860257); +} + +TEST_CASE("VSADDU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSADDU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8285C257); + + as.RewindBuffer(); + + as.VSADDU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8085C257); +} + +TEST_CASE("VSADDU.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSADDU(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x8287B257); + + as.RewindBuffer(); + + as.VSADDU(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x82883257); + + as.RewindBuffer(); + + as.VSADDU(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x8087B257); + + as.RewindBuffer(); + + as.VSADDU(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x80883257); +} + +TEST_CASE("VSBC.VVM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSBC(v4, v8, v12); + REQUIRE(value == 0x48860257); +} + +TEST_CASE("VSBC.VXM", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSBC(v4, v8, x11); + REQUIRE(value == 0x4885C257); +} + +TEST_CASE("VSEXT.VF2", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSEXTVF2(v4, v8, VecMask::No); + REQUIRE(value == 0x4A83A257); + + as.RewindBuffer(); + + as.VSEXTVF2(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4883A257); +} + +TEST_CASE("VSEXT.VF4", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSEXTVF4(v4, v8, VecMask::No); + REQUIRE(value == 0x4A82A257); + + as.RewindBuffer(); + + as.VSEXTVF4(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4882A257); +} + +TEST_CASE("VSEXT.VF8", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSEXTVF8(v4, v8, VecMask::No); + REQUIRE(value == 0x4A81A257); + + as.RewindBuffer(); + + as.VSEXTVF8(v4, v8, VecMask::Yes); + REQUIRE(value == 0x4881A257); +} + +TEST_CASE("VSLIDE1DOWN.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLIDE1DOWN(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x3E85E257); + + as.RewindBuffer(); + + as.VSLIDE1DOWN(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x3C85E257); +} + +TEST_CASE("VSLIDEDOWN.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLIDEDOWN(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x3E85C257); + + as.RewindBuffer(); + + as.VSLIDEDOWN(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x3C85C257); +} + +TEST_CASE("VSLIDEDOWN.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLIDEDOWN(v4, v8, 0, VecMask::No); + REQUIRE(value == 0x3E803257); + + as.RewindBuffer(); + + as.VSLIDEDOWN(v4, v8, 31, VecMask::No); + REQUIRE(value == 0x3E8FB257); + + as.RewindBuffer(); + + as.VSLIDEDOWN(v4, v8, 0, VecMask::Yes); + REQUIRE(value == 0x3C803257); + + as.RewindBuffer(); + + as.VSLIDEDOWN(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0x3C8FB257); +} + +TEST_CASE("VSLIDE1UP.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLIDE1UP(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x3A85E257); + + as.RewindBuffer(); + + as.VSLIDE1UP(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x3885E257); +} + +TEST_CASE("VSLIDEUP.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLIDEUP(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x3A85C257); + + as.RewindBuffer(); + + as.VSLIDEUP(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x3885C257); +} + +TEST_CASE("VSLIDEUP.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLIDEUP(v4, v8, 0, VecMask::No); + REQUIRE(value == 0x3A803257); + + as.RewindBuffer(); + + as.VSLIDEUP(v4, v8, 31, VecMask::No); + REQUIRE(value == 0x3A8FB257); + + as.RewindBuffer(); + + as.VSLIDEUP(v4, v8, 0, VecMask::Yes); + REQUIRE(value == 0x38803257); + + as.RewindBuffer(); + + as.VSLIDEUP(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0x388FB257); +} + +TEST_CASE("VSLL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x96860257); + + as.RewindBuffer(); + + as.VSLL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x94860257); +} + +TEST_CASE("VSLL.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x9685C257); + + as.RewindBuffer(); + + as.VSLL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x9485C257); +} + +TEST_CASE("VSLL.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSLL(v4, v8, 1, VecMask::No); + REQUIRE(value == 0x9680B257); + + as.RewindBuffer(); + + as.VSLL(v4, v8, 31, VecMask::No); + REQUIRE(value == 0x968FB257); + + as.RewindBuffer(); + + as.VSLL(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0x9480B257); + + as.RewindBuffer(); + + as.VSLL(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0x948FB257); +} + +TEST_CASE("VSMUL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSMUL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x9E860257); + + as.RewindBuffer(); + + as.VSMUL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x9C860257); +} + +TEST_CASE("VSMUL.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSMUL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x9E85C257); + + as.RewindBuffer(); + + as.VSMUL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x9C85C257); +} + +TEST_CASE("VSRA.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSRA(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xA6860257); + + as.RewindBuffer(); + + as.VSRA(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xA4860257); +} + +TEST_CASE("VSRA.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSRA(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xA685C257); + + as.RewindBuffer(); + + as.VSRA(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xA485C257); +} + +TEST_CASE("VSRA.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSRA(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xA680B257); + + as.RewindBuffer(); + + as.VSRA(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xA68FB257); + + as.RewindBuffer(); + + as.VSRA(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xA480B257); + + as.RewindBuffer(); + + as.VSRA(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xA48FB257); +} + +TEST_CASE("VSRL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSRL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xA2860257); + + as.RewindBuffer(); + + as.VSRL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xA0860257); +} + +TEST_CASE("VSRL.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSRL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xA285C257); + + as.RewindBuffer(); + + as.VSRL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xA085C257); +} + +TEST_CASE("VSRL.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSRL(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xA280B257); + + as.RewindBuffer(); + + as.VSRL(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xA28FB257); + + as.RewindBuffer(); + + as.VSRL(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xA080B257); + + as.RewindBuffer(); + + as.VSRL(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xA08FB257); +} + +TEST_CASE("VSSRA.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSRA(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xAE860257); + + as.RewindBuffer(); + + as.VSSRA(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xAC860257); +} + +TEST_CASE("VSSRA.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSRA(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xAE85C257); + + as.RewindBuffer(); + + as.VSSRA(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xAC85C257); +} + +TEST_CASE("VSSRA.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSRA(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xAE80B257); + + as.RewindBuffer(); + + as.VSSRA(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xAE8FB257); + + as.RewindBuffer(); + + as.VSSRA(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xAC80B257); + + as.RewindBuffer(); + + as.VSSRA(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xAC8FB257); +} + +TEST_CASE("VSSRL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSRL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xAA860257); + + as.RewindBuffer(); + + as.VSSRL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xA8860257); +} + +TEST_CASE("VSSRL.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSRL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xAA85C257); + + as.RewindBuffer(); + + as.VSSRL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xA885C257); +} + +TEST_CASE("VSSRL.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSRL(v4, v8, 1, VecMask::No); + REQUIRE(value == 0xAA80B257); + + as.RewindBuffer(); + + as.VSSRL(v4, v8, 31, VecMask::No); + REQUIRE(value == 0xAA8FB257); + + as.RewindBuffer(); + + as.VSSRL(v4, v8, 1, VecMask::Yes); + REQUIRE(value == 0xA880B257); + + as.RewindBuffer(); + + as.VSSRL(v4, v8, 31, VecMask::Yes); + REQUIRE(value == 0xA88FB257); +} + +TEST_CASE("VSSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSUB(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x8E860257); + + as.RewindBuffer(); + + as.VSSUB(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x8C860257); +} + +TEST_CASE("VSSUB.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSUB(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8E85C257); + + as.RewindBuffer(); + + as.VSSUB(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8C85C257); +} + +TEST_CASE("VSSUBU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSUBU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x8A860257); + + as.RewindBuffer(); + + as.VSSUBU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x88860257); +} + +TEST_CASE("VSSUBU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSUBU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x8A85C257); + + as.RewindBuffer(); + + as.VSSUBU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x8885C257); +} + +TEST_CASE("VSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSUB(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x0A860257); + + as.RewindBuffer(); + + as.VSUB(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x08860257); +} + +TEST_CASE("VSUB.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSUB(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x0A85C257); + + as.RewindBuffer(); + + as.VSUB(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x0885C257); +} + +TEST_CASE("VWADD.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADD(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xC6862257); + + as.RewindBuffer(); + + as.VWADD(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC4862257); +} + +TEST_CASE("VWADD.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADD(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xC685E257); + + as.RewindBuffer(); + + as.VWADD(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xC485E257); +} + +TEST_CASE("VWADD.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADDW(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xD6862257); + + as.RewindBuffer(); + + as.VWADDW(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xD4862257); +} + +TEST_CASE("VWADD.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADDW(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xD685E257); + + as.RewindBuffer(); + + as.VWADDW(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xD485E257); +} + +TEST_CASE("VWADDU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADDU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xC2862257); + + as.RewindBuffer(); + + as.VWADDU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC0862257); +} + +TEST_CASE("VWADDU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADDU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xC285E257); + + as.RewindBuffer(); + + as.VWADDU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xC085E257); +} + +TEST_CASE("VWADDU.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADDUW(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xD2862257); + + as.RewindBuffer(); + + as.VWADDUW(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xD0862257); +} + +TEST_CASE("VWADDU.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWADDUW(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xD285E257); + + as.RewindBuffer(); + + as.VWADDUW(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xD085E257); +} + +TEST_CASE("VWMACC.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACC(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xF6862257); + + as.RewindBuffer(); + + as.VWMACC(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xF4862257); +} + +TEST_CASE("VWMACC.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACC(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xF685E257); + + as.RewindBuffer(); + + as.VWMACC(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xF485E257); +} + +TEST_CASE("VWMACCSU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACCSU(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xFE862257); + + as.RewindBuffer(); + + as.VWMACCSU(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xFC862257); +} + +TEST_CASE("VWMACCSU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACCSU(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xFE85E257); + + as.RewindBuffer(); + + as.VWMACCSU(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xFC85E257); +} + +TEST_CASE("VWMACCU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACCU(v4, v12, v8, VecMask::No); + REQUIRE(value == 0xF2862257); + + as.RewindBuffer(); + + as.VWMACCU(v4, v12, v8, VecMask::Yes); + REQUIRE(value == 0xF0862257); +} + +TEST_CASE("VWMACCU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACCU(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xF285E257); + + as.RewindBuffer(); + + as.VWMACCU(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xF085E257); +} + +TEST_CASE("VWMACCUS.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMACCUS(v4, x11, v8, VecMask::No); + REQUIRE(value == 0xFA85E257); + + as.RewindBuffer(); + + as.VWMACCUS(v4, x11, v8, VecMask::Yes); + REQUIRE(value == 0xF885E257); +} + +TEST_CASE("VWMUL.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMUL(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xEE862257); + + as.RewindBuffer(); + + as.VWMUL(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xEC862257); +} + +TEST_CASE("VWMUL.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMUL(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xEE85E257); + + as.RewindBuffer(); + + as.VWMUL(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xEC85E257); +} + +TEST_CASE("VWMULSU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMULSU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xEA862257); + + as.RewindBuffer(); + + as.VWMULSU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xE8862257); +} + +TEST_CASE("VWMULSU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMULSU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xEA85E257); + + as.RewindBuffer(); + + as.VWMULSU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xE885E257); +} + +TEST_CASE("VWMULU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMULU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xE2862257); + + as.RewindBuffer(); + + as.VWMULU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xE0862257); +} + +TEST_CASE("VWMULU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWMULU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xE285E257); + + as.RewindBuffer(); + + as.VWMULU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xE085E257); +} + +TEST_CASE("VWREDSUM.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWREDSUM(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xC6860257); + + as.RewindBuffer(); + + as.VWREDSUM(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC4860257); +} + +TEST_CASE("VWREDSUMU.VS", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWREDSUMU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xC2860257); + + as.RewindBuffer(); + + as.VWREDSUMU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC0860257); +} + +TEST_CASE("VWSUB.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUB(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xCE862257); + + as.RewindBuffer(); + + as.VWSUB(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xCC862257); +} + +TEST_CASE("VWSUB.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUB(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xCE85E257); + + as.RewindBuffer(); + + as.VWSUB(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xCC85E257); +} + +TEST_CASE("VWSUB.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUBW(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xDE862257); + + as.RewindBuffer(); + + as.VWSUBW(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xDC862257); +} + +TEST_CASE("VWSUB.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUBW(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xDE85E257); + + as.RewindBuffer(); + + as.VWSUBW(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xDC85E257); +} + +TEST_CASE("VWSUBU.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUBU(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xCA862257); + + as.RewindBuffer(); + + as.VWSUBU(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xC8862257); +} + +TEST_CASE("VWSUBU.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUBU(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xCA85E257); + + as.RewindBuffer(); + + as.VWSUBU(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xC885E257); +} + +TEST_CASE("VWSUBU.WV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUBUW(v4, v8, v12, VecMask::No); + REQUIRE(value == 0xDA862257); + + as.RewindBuffer(); + + as.VWSUBUW(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0xD8862257); +} + +TEST_CASE("VWSUBU.WX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSUBUW(v4, v8, x11, VecMask::No); + REQUIRE(value == 0xDA85E257); + + as.RewindBuffer(); + + as.VWSUBUW(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0xD885E257); +} + +TEST_CASE("VXOR.VV", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VXOR(v4, v8, v12, VecMask::No); + REQUIRE(value == 0x2E860257); + + as.RewindBuffer(); + + as.VXOR(v4, v8, v12, VecMask::Yes); + REQUIRE(value == 0x2C860257); +} + +TEST_CASE("VXOR.VX", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VXOR(v4, v8, x11, VecMask::No); + REQUIRE(value == 0x2E85C257); + + as.RewindBuffer(); + + as.VXOR(v4, v8, x11, VecMask::Yes); + REQUIRE(value == 0x2C85C257); +} + +TEST_CASE("VXOR.VI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VXOR(v4, v8, 15, VecMask::No); + REQUIRE(value == 0x2E87B257); + + as.RewindBuffer(); + + as.VXOR(v4, v8, -16, VecMask::No); + REQUIRE(value == 0x2E883257); + + as.RewindBuffer(); + + as.VXOR(v4, v8, 15, VecMask::Yes); + REQUIRE(value == 0x2C87B257); + + as.RewindBuffer(); + + as.VXOR(v4, v8, -16, VecMask::Yes); + REQUIRE(value == 0x2C883257); +} + +TEST_CASE("VZEXT.VF2", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VZEXTVF2(v4, v8, VecMask::No); + REQUIRE(value == 0x4A832257); + + as.RewindBuffer(); + + as.VZEXTVF2(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48832257); +} + +TEST_CASE("VZEXT.VF4", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VZEXTVF4(v4, v8, VecMask::No); + REQUIRE(value == 0x4A822257); + + as.RewindBuffer(); + + as.VZEXTVF4(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48822257); +} + +TEST_CASE("VZEXT.VF8", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VZEXTVF8(v4, v8, VecMask::No); + REQUIRE(value == 0x4A812257); + + as.RewindBuffer(); + + as.VZEXTVF8(v4, v8, VecMask::Yes); + REQUIRE(value == 0x48812257); +} + +TEST_CASE("VLE8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE8(v0, x11, VecMask::No); + REQUIRE(value == 0x02058007); + + as.RewindBuffer(); + + as.VLE8(v0, x11, VecMask::Yes); + REQUIRE(value == 0x00058007); +} + +TEST_CASE("VLE16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE16(v0, x11, VecMask::No); + REQUIRE(value == 0x0205D007); + + as.RewindBuffer(); + + as.VLE16(v0, x11, VecMask::Yes); + REQUIRE(value == 0x0005D007); +} + +TEST_CASE("VLE32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE32(v0, x11, VecMask::No); + REQUIRE(value == 0x0205E007); + + as.RewindBuffer(); + + as.VLE32(v0, x11, VecMask::Yes); + REQUIRE(value == 0x0005E007); +} + +TEST_CASE("VLE64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE64(v0, x11, VecMask::No); + REQUIRE(value == 0x0205F007); + + as.RewindBuffer(); + + as.VLE64(v0, x11, VecMask::Yes); + REQUIRE(value == 0x0005F007); +} + +TEST_CASE("VLM.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLM(v0, x11); + REQUIRE(value == 0x02B58007); +} + +TEST_CASE("VLSE8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLSE8(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB50207); + + as.RewindBuffer(); + + as.VLSE8(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B50207); +} + +TEST_CASE("VLSE16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLSE16(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB55207); + + as.RewindBuffer(); + + as.VLSE16(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B55207); +} + +TEST_CASE("VLSE32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLSE32(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB56207); + + as.RewindBuffer(); + + as.VLSE32(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B56207); +} + +TEST_CASE("VLSE64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLSE64(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB57207); + + as.RewindBuffer(); + + as.VLSE64(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B57207); +} + +TEST_CASE("VLOXEI8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLOXEI8(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC50207); + + as.RewindBuffer(); + + as.VLOXEI8(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC50207); +} + +TEST_CASE("VLOXEI16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLOXEI16(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC55207); + + as.RewindBuffer(); + + as.VLOXEI16(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC55207); +} + +TEST_CASE("VLOXEI32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLOXEI32(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC56207); + + as.RewindBuffer(); + + as.VLOXEI32(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC56207); +} + +TEST_CASE("VLOXEI64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLOXEI64(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC57207); + + as.RewindBuffer(); + + as.VLOXEI64(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC57207); +} + +TEST_CASE("VLUXEI8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLUXEI8(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C50207); + + as.RewindBuffer(); + + as.VLUXEI8(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C50207); +} + +TEST_CASE("VLUXEI16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLUXEI16(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C55207); + + as.RewindBuffer(); + + as.VLUXEI16(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C55207); +} + +TEST_CASE("VLUXEI32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLUXEI32(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C56207); + + as.RewindBuffer(); + + as.VLUXEI32(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C56207); +} + +TEST_CASE("VLUXEI64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLUXEI64(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C57207); + + as.RewindBuffer(); + + as.VLUXEI64(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C57207); +} + +TEST_CASE("VLE8FF.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE8FF(v4, x10, VecMask::No); + REQUIRE(value == 0x03050207); + + as.RewindBuffer(); + + as.VLE8FF(v4, x10, VecMask::Yes); + REQUIRE(value == 0x01050207); +} + +TEST_CASE("VLE16FF.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE16FF(v4, x10, VecMask::No); + REQUIRE(value == 0x03055207); + + as.RewindBuffer(); + + as.VLE16FF(v4, x10, VecMask::Yes); + REQUIRE(value == 0x01055207); +} + +TEST_CASE("VLE32FF.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE32FF(v4, x10, VecMask::No); + REQUIRE(value == 0x03056207); + + as.RewindBuffer(); + + as.VLE32FF(v4, x10, VecMask::Yes); + REQUIRE(value == 0x01056207); +} + +TEST_CASE("VLE64FF.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLE64FF(v4, x10, VecMask::No); + REQUIRE(value == 0x03057207); + + as.RewindBuffer(); + + as.VLE64FF(v4, x10, VecMask::Yes); + REQUIRE(value == 0x01057207); +} + +TEST_CASE("8-bit segmented unit-stride loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSEGE8(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02050207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSEGE8(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00050207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit segmented unit-stride loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSEGE16(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02055207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSEGE16(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00055207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit segmented unit-stride loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSEGE32(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02056207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSEGE32(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00056207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit segmented unit-stride loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSEGE64(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02057207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSEGE64(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00057207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit segmented strided loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSSEGE8(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB50207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSSEGE8(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B50207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit segmented strided loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSSEGE16(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB55207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSSEGE16(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B55207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit segmented strided loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSSEGE32(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB56207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSSEGE32(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B56207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit segmented strided loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLSSEGE64(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB57207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLSSEGE64(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B57207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit vector indexed-ordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLOXSEGEI8(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC50207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLOXSEGEI8(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC50207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit vector indexed-ordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLOXSEGEI16(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC55207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLOXSEGEI16(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC55207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit vector indexed-ordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLOXSEGEI32(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC56207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLOXSEGEI32(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC56207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit vector indexed-ordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLOXSEGEI64(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC57207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLOXSEGEI64(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC57207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit vector indexed-unordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLUXSEGEI8(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C50207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLUXSEGEI8(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C50207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit vector indexed-unordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLUXSEGEI16(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C55207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLUXSEGEI16(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C55207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit vector indexed-unordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLUXSEGEI32(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C56207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLUXSEGEI32(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C56207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit vector indexed-unordered segment loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VLUXSEGEI64(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C57207 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VLUXSEGEI64(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C57207 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit vector whole register loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLRE8(1, v3, x10); + REQUIRE(value == 0x02850187); + as.RewindBuffer(); + + as.VLRE8(2, v2, x10); + REQUIRE(value == 0x22850107); + as.RewindBuffer(); + + as.VLRE8(4, v4, x10); + REQUIRE(value == 0x62850207); + as.RewindBuffer(); + + as.VLRE8(8, v8, x10); + REQUIRE(value == 0xE2850407); +} + +TEST_CASE("16-bit vector whole register loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLRE16(1, v3, x10); + REQUIRE(value == 0x02855187); + as.RewindBuffer(); + + as.VLRE16(2, v2, x10); + REQUIRE(value == 0x22855107); + as.RewindBuffer(); + + as.VLRE16(4, v4, x10); + REQUIRE(value == 0x62855207); + as.RewindBuffer(); + + as.VLRE16(8, v8, x10); + REQUIRE(value == 0xE2855407); +} + +TEST_CASE("32-bit vector whole register loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLRE32(1, v3, x10); + REQUIRE(value == 0x02856187); + as.RewindBuffer(); + + as.VLRE32(2, v2, x10); + REQUIRE(value == 0x22856107); + as.RewindBuffer(); + + as.VLRE32(4, v4, x10); + REQUIRE(value == 0x62856207); + as.RewindBuffer(); + + as.VLRE32(8, v8, x10); + REQUIRE(value == 0xE2856407); +} + +TEST_CASE("64-bit vector whole register loads", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VLRE64(1, v3, x10); + REQUIRE(value == 0x02857187); + as.RewindBuffer(); + + as.VLRE64(2, v2, x10); + REQUIRE(value == 0x22857107); + as.RewindBuffer(); + + as.VLRE64(4, v4, x10); + REQUIRE(value == 0x62857207); + as.RewindBuffer(); + + as.VLRE64(8, v8, x10); + REQUIRE(value == 0xE2857407); +} + +TEST_CASE("VSE8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSE8(v0, x13, VecMask::No); + REQUIRE(value == 0x02068027); + + as.RewindBuffer(); + + as.VSE8(v0, x13, VecMask::Yes); + REQUIRE(value == 0x00068027); +} + +TEST_CASE("VSE16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSE16(v0, x13, VecMask::No); + REQUIRE(value == 0x0206D027); + + as.RewindBuffer(); + + as.VSE16(v0, x13, VecMask::Yes); + REQUIRE(value == 0x0006D027); +} + +TEST_CASE("VSE32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSE32(v0, x13, VecMask::No); + REQUIRE(value == 0x0206E027); + + as.RewindBuffer(); + + as.VSE32(v0, x13, VecMask::Yes); + REQUIRE(value == 0x0006E027); +} + +TEST_CASE("VSE64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSE64(v0, x13, VecMask::No); + REQUIRE(value == 0x0206F027); + + as.RewindBuffer(); + + as.VSE64(v0, x13, VecMask::Yes); + REQUIRE(value == 0x0006F027); +} + +TEST_CASE("VSM.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSM(v0, x13); + REQUIRE(value == 0x02B68027); +} + +TEST_CASE("VSSE8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSE8(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB50227); + + as.RewindBuffer(); + + as.VSSE8(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B50227); +} + +TEST_CASE("VSSE16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSE16(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB55227); + + as.RewindBuffer(); + + as.VSSE16(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B55227); +} + +TEST_CASE("VSSE32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSE32(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB56227); + + as.RewindBuffer(); + + as.VSSE32(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B56227); +} + +TEST_CASE("VSSE64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSSE64(v4, x10, x11, VecMask::No); + REQUIRE(value == 0x0AB57227); + + as.RewindBuffer(); + + as.VSSE64(v4, x10, x11, VecMask::Yes); + REQUIRE(value == 0x08B57227); +} + +TEST_CASE("VSOXEI8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSOXEI8(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC50227); + + as.RewindBuffer(); + + as.VSOXEI8(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC50227); +} + +TEST_CASE("VSOXEI16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSOXEI16(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC55227); + + as.RewindBuffer(); + + as.VSOXEI16(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC55227); +} + +TEST_CASE("VSOXEI32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSOXEI32(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC56227); + + as.RewindBuffer(); + + as.VSOXEI32(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC56227); +} + +TEST_CASE("VSOXEI64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSOXEI64(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x0EC57227); + + as.RewindBuffer(); + + as.VSOXEI64(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x0CC57227); +} + +TEST_CASE("VSUXEI8.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSUXEI8(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C50227); + + as.RewindBuffer(); + + as.VSUXEI8(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C50227); +} + +TEST_CASE("VSUXEI16.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSUXEI16(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C55227); + + as.RewindBuffer(); + + as.VSUXEI16(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C55227); +} + +TEST_CASE("VSUXEI32.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSUXEI32(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C56227); + + as.RewindBuffer(); + + as.VSUXEI32(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C56227); +} + +TEST_CASE("VSUXEI64.V", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSUXEI64(v4, x10, v12, VecMask::No); + REQUIRE(value == 0x06C57227); + + as.RewindBuffer(); + + as.VSUXEI64(v4, x10, v12, VecMask::Yes); + REQUIRE(value == 0x04C57227); +} + +TEST_CASE("8-bit segmented unit-stride stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSEGE8(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02050227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSEGE8(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00050227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit segmented unit-stride stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSEGE16(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02055227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSEGE16(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00055227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit segmented unit-stride stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSEGE32(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02056227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSEGE32(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00056227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit segmented unit-stride stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSEGE64(i, v4, x10, VecMask::No); + REQUIRE(value == (0x02057227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSEGE64(i, v4, x10, VecMask::Yes); + REQUIRE(value == (0x00057227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit segmented strided stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSSEGE8(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB50227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSSEGE8(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B50227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit segmented strided stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSSEGE16(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB55227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSSEGE16(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B55227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit segmented strided stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSSEGE32(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB56227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSSEGE32(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B56227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit segmented strided stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSSSEGE64(i, v4, x10, x11, VecMask::No); + REQUIRE(value == (0x0AB57227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSSSEGE64(i, v4, x10, x11, VecMask::Yes); + REQUIRE(value == (0x08B57227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit segmented vector indexed-ordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSOXSEGEI8(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC50227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSOXSEGEI8(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC50227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit segmented vector indexed-ordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSOXSEGEI16(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC55227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSOXSEGEI16(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC55227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit segmented vector indexed-ordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSOXSEGEI32(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC56227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSOXSEGEI32(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC56227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit segmented vector indexed-ordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSOXSEGEI64(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x0EC57227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSOXSEGEI64(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x0CC57227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("8-bit segmented vector indexed-unordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSUXSEGEI8(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C50227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSUXSEGEI8(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C50227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("16-bit segmented vector indexed-unordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSUXSEGEI16(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C55227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSUXSEGEI16(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C55227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("32-bit segmented vector indexed-unordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSUXSEGEI32(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C56227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSUXSEGEI32(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C56227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("64-bit segmented vector indexed-unordered stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 2; i <= 8; i++) { + as.VSUXSEGEI64(i, v4, x10, v12, VecMask::No); + REQUIRE(value == (0x06C57227 | ((i - 1) << 29))); + + as.RewindBuffer(); + + as.VSUXSEGEI64(i, v4, x10, v12, VecMask::Yes); + REQUIRE(value == (0x04C57227 | ((i - 1) << 29))); + + as.RewindBuffer(); + } +} + +TEST_CASE("Vector whole register stores", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSR(1, v3, x11); + REQUIRE(value == 0x028581A7); + + as.RewindBuffer(); + + as.VSR(2, v2, x11); + REQUIRE(value == 0x22858127); + + as.RewindBuffer(); + + as.VSR(4, v4, x11); + REQUIRE(value == 0x62858227); + + as.RewindBuffer(); + + as.VSR(8, v8, x11); + REQUIRE(value == 0xE2858427); +} + +TEST_CASE("VSETIVLI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSETIVLI(x10, 11, SEW::E8, LMUL::M1, VTA::No, VMA::No); + REQUIRE(value == 0xC005F557); + + as.RewindBuffer(); + + as.VSETIVLI(x10, 11, SEW::E16, LMUL::M2, VTA::No, VMA::No); + REQUIRE(value == 0xC095F557); + + as.RewindBuffer(); + + as.VSETIVLI(x10, 11, SEW::E256, LMUL::M2, VTA::Yes, VMA::No); + REQUIRE(value == 0xC695F557); + + as.RewindBuffer(); + + as.VSETIVLI(x10, 11, SEW::E256, LMUL::M2, VTA::Yes, VMA::Yes); + REQUIRE(value == 0xCE95F557); +} + +TEST_CASE("VSETVL", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSETVL(x10, x11, x12); + REQUIRE(value == 0x80C5F557); +} + +TEST_CASE("VSETVLI", "[rvv]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSETVLI(x31, x6, SEW::E64, LMUL::MF2, VTA::Yes, VMA::Yes); + REQUIRE(value == 0x0DF37FD7); + + as.RewindBuffer(); + + as.VSETVLI(x31, x6, SEW::E64, LMUL::MF2, VTA::No, VMA::No); + REQUIRE(value == 0x01F37FD7); + + as.RewindBuffer(); + + as.VSETVLI(x12, x18, SEW::E8, LMUL::M1, VTA::No, VMA::No); + REQUIRE(value == 0x00097657); + + as.RewindBuffer(); + + as.VSETVLI(x15, x12, SEW::E32, LMUL::M4, VTA::No, VMA::No); + REQUIRE(value == 0x012677D7); +} diff --git a/externals/biscuit/tests/src/assembler_test_utils.hpp b/externals/biscuit/tests/src/assembler_test_utils.hpp new file mode 100644 index 00000000..a20737dc --- /dev/null +++ b/externals/biscuit/tests/src/assembler_test_utils.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include <biscuit/assembler.hpp> +#include <cstdint> + +namespace biscuit { + +template <typename T> +inline Assembler MakeAssembler32(T& buffer) { + return Assembler{reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer), ArchFeature::RV32}; +} + +template <typename T> +inline Assembler MakeAssembler64(T& buffer) { + return Assembler{reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer), ArchFeature::RV64}; +} + +template <typename T> +inline Assembler MakeAssembler128(T& buffer) { + return Assembler{reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer), ArchFeature::RV128}; +} + +} // namespace biscuit diff --git a/externals/biscuit/tests/src/assembler_vector_crypto_tests.cpp b/externals/biscuit/tests/src/assembler_vector_crypto_tests.cpp new file mode 100644 index 00000000..fbfe0fa1 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_vector_crypto_tests.cpp @@ -0,0 +1,495 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("VANDN.VV", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VANDN(v20, v12, v10, VecMask::Yes); + REQUIRE(value == 0x04C50A57); + + as.RewindBuffer(); + + as.VANDN(v20, v12, v10, VecMask::No); + REQUIRE(value == 0x06C50A57); +} + +TEST_CASE("VANDN.VX", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VANDN(v20, v12, x10, VecMask::Yes); + REQUIRE(value == 0x04C54A57); + + as.RewindBuffer(); + + as.VANDN(v20, v12, x10, VecMask::No); + REQUIRE(value == 0x06C54A57); +} + +TEST_CASE("VBREV.V", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VBREV(v20, v12, VecMask::Yes); + REQUIRE(value == 0x48C52A57); + + as.RewindBuffer(); + + as.VBREV(v20, v12, VecMask::No); + REQUIRE(value == 0x4AC52A57); +} + +TEST_CASE("VBREV8.V", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VBREV8(v20, v12, VecMask::Yes); + REQUIRE(value == 0x48C42A57); + + as.RewindBuffer(); + + as.VBREV8(v20, v12, VecMask::No); + REQUIRE(value == 0x4AC42A57); +} + +TEST_CASE("VREV8.V", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VREV8(v20, v12, VecMask::Yes); + REQUIRE(value == 0x48C4AA57); + + as.RewindBuffer(); + + as.VREV8(v20, v12, VecMask::No); + REQUIRE(value == 0x4AC4AA57); +} + +TEST_CASE("VCLZ.V", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCLZ(v20, v12, VecMask::Yes); + REQUIRE(value == 0x48C62A57); + + as.RewindBuffer(); + + as.VCLZ(v20, v12, VecMask::No); + REQUIRE(value == 0x4AC62A57); +} + +TEST_CASE("VCTZ.V", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCTZ(v20, v12, VecMask::Yes); + REQUIRE(value == 0x48C6AA57); + + as.RewindBuffer(); + + as.VCTZ(v20, v12, VecMask::No); + REQUIRE(value == 0x4AC6AA57); +} + +TEST_CASE("VCPOP.V", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCPOP(v20, v12, VecMask::Yes); + REQUIRE(value == 0x48C72A57); + + as.RewindBuffer(); + + as.VCPOP(v20, v12, VecMask::No); + REQUIRE(value == 0x4AC72A57); +} + +TEST_CASE("VROL.VV", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VROL(v20, v12, v10, VecMask::Yes); + REQUIRE(value == 0x54C50A57); + + as.RewindBuffer(); + + as.VROL(v20, v12, v10, VecMask::No); + REQUIRE(value == 0x56C50A57); +} + +TEST_CASE("VROL.VX", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VROL(v20, v12, x10, VecMask::Yes); + REQUIRE(value == 0x54C54A57); + + as.RewindBuffer(); + + as.VROL(v20, v12, x10, VecMask::No); + REQUIRE(value == 0x56C54A57); +} + +TEST_CASE("VROR.VV", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VROR(v20, v12, v10, VecMask::Yes); + REQUIRE(value == 0x50C50A57); + + as.RewindBuffer(); + + as.VROR(v20, v12, v10, VecMask::No); + REQUIRE(value == 0x52C50A57); +} + +TEST_CASE("VROR.VX", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VROR(v20, v12, x10, VecMask::Yes); + REQUIRE(value == 0x50C54A57); + + as.RewindBuffer(); + + as.VROR(v20, v12, x10, VecMask::No); + REQUIRE(value == 0x52C54A57); +} + +TEST_CASE("VROR.VI", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VROR(v20, v12, 63, VecMask::Yes); + REQUIRE(value == 0x54CFBA57); + + as.RewindBuffer(); + + as.VROR(v20, v12, 31, VecMask::Yes); + REQUIRE(value == 0x50CFBA57); + + as.RewindBuffer(); + + as.VROR(v20, v12, 63, VecMask::No); + REQUIRE(value == 0x56CFBA57); + + as.RewindBuffer(); + + as.VROR(v20, v12, 31, VecMask::No); + REQUIRE(value == 0x52CFBA57); +} + +TEST_CASE("VWSLL.VV", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSLL(v20, v12, v10, VecMask::Yes); + REQUIRE(value == 0xD4C50A57); + + as.RewindBuffer(); + + as.VWSLL(v20, v12, v10, VecMask::No); + REQUIRE(value == 0xD6C50A57); +} + +TEST_CASE("VWSLL.VX", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSLL(v20, v12, x10, VecMask::Yes); + REQUIRE(value == 0xD4C54A57); + + as.RewindBuffer(); + + as.VWSLL(v20, v12, x10, VecMask::No); + REQUIRE(value == 0xD6C54A57); +} + +TEST_CASE("VWSLL.VI", "[Zvbb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VWSLL(v20, v12, 31, VecMask::Yes); + REQUIRE(value == 0xD4CFBA57); + + as.RewindBuffer(); + + as.VWSLL(v20, v12, 15, VecMask::Yes); + REQUIRE(value == 0xD4C7BA57); + + as.RewindBuffer(); + + as.VWSLL(v20, v12, 31, VecMask::No); + REQUIRE(value == 0xD6CFBA57); + + as.RewindBuffer(); + + as.VWSLL(v20, v12, 15, VecMask::No); + REQUIRE(value == 0xD6C7BA57); +} + +TEST_CASE("VCLMUL.VV", "[Zvbc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCLMUL(v20, v12, v10, VecMask::Yes); + REQUIRE(value == 0x30C52A57); + + as.RewindBuffer(); + + as.VCLMUL(v20, v12, v10, VecMask::No); + REQUIRE(value == 0x32C52A57); +} + +TEST_CASE("VCLMUL.VX", "[Zvbc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCLMUL(v20, v12, x10, VecMask::Yes); + REQUIRE(value == 0x30C56A57); + + as.RewindBuffer(); + + as.VCLMUL(v20, v12, x10, VecMask::No); + REQUIRE(value == 0x32C56A57); +} + +TEST_CASE("VCLMULH.VV", "[Zvbc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCLMULH(v20, v12, v10, VecMask::Yes); + REQUIRE(value == 0x34C52A57); + + as.RewindBuffer(); + + as.VCLMULH(v20, v12, v10, VecMask::No); + REQUIRE(value == 0x36C52A57); +} + +TEST_CASE("VCLMULH.VX", "[Zvbc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VCLMULH(v20, v12, x10, VecMask::Yes); + REQUIRE(value == 0x34C56A57); + + as.RewindBuffer(); + + as.VCLMULH(v20, v12, x10, VecMask::No); + REQUIRE(value == 0x36C56A57); +} + +TEST_CASE("VGHSH.VV", "[Zvkg]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VGHSH(v20, v12, v10); + REQUIRE(value == 0xB2C52A77); +} + +TEST_CASE("VGMUL.VV", "[Zvkg]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VGMUL(v20, v12); + REQUIRE(value == 0xA2C8AA77); +} + +TEST_CASE("VAESDF.VV", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESDF_VV(v20, v12); + REQUIRE(value == 0xA2C0AA77); +} + +TEST_CASE("VAESDF.VS", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESDF_VS(v20, v12); + REQUIRE(value == 0xA6C0AA77); +} + +TEST_CASE("VAESDM.VV", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESDM_VV(v20, v12); + REQUIRE(value == 0xA2C02A77); +} + +TEST_CASE("VAESDM.VS", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESDM_VS(v20, v12); + REQUIRE(value == 0xA6C02A77); +} + +TEST_CASE("VAESEF.VV", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESEF_VV(v20, v12); + REQUIRE(value == 0xA2C1AA77); +} + +TEST_CASE("VAESEF.VS", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESEF_VS(v20, v12); + REQUIRE(value == 0xA6C1AA77); +} + +TEST_CASE("VAESEM.VV", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESEM_VV(v20, v12); + REQUIRE(value == 0xA2C12A77); +} + +TEST_CASE("VAESEM.VS", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESEM_VS(v20, v12); + REQUIRE(value == 0xA6C12A77); +} + +TEST_CASE("VAESKF1.VI", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + // Test mapping of out of range indices + for (const uint32_t idx : {0U, 11U, 12U, 13U, 14U, 15U}) { + as.VAESKF1(v20, v12, idx); + + const auto op_base = 0x8AC02A77U; + const auto inverted_b3 = idx ^ 0b1000; + const auto verify = op_base | (inverted_b3 << 15); + + REQUIRE(value == verify); + + as.RewindBuffer(); + } + + as.VAESKF1(v20, v12, 8); + REQUIRE(value == 0x8AC42A77); +} + +TEST_CASE("VAESKF2.VI", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + // Test mapping of out of range indices + for (const uint32_t idx : {0U, 1U, 15U}) { + as.VAESKF2(v20, v12, idx); + + const auto op_base = 0xAAC02A77; + const auto inverted_b3 = idx ^ 0b1000; + const auto verify = op_base | (inverted_b3 << 15); + + REQUIRE(value == verify); + + as.RewindBuffer(); + } + + as.VAESKF2(v20, v12, 8); + REQUIRE(value == 0xAAC42A77); +} + +TEST_CASE("VAESZ.VS", "[Zvkned]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VAESZ(v20, v12); + REQUIRE(value == 0xA6C3AA77); +} + +TEST_CASE("VSHA2MS.VV", "[Zvknhb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSHA2MS(v20, v12, v10); + REQUIRE(value == 0xB6C52A77); +} + +TEST_CASE("VSHA2CH.VV", "[Zvknhb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSHA2CH(v20, v12, v10); + REQUIRE(value == 0xBAC52A77); +} + +TEST_CASE("VSHA2CL.VV", "[Zvknhb]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSHA2CL(v20, v12, v10); + REQUIRE(value == 0xBEC52A77); +} + +TEST_CASE("VSM4K.VI", "[Zvksed]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 0; i <= 7; i++) { + as.VSM4K(v20, v12, i); + + const auto op_base = 0x86C02A77U; + const auto verify = op_base | (i << 15); + REQUIRE(value == verify); + + as.RewindBuffer(); + } +} + +TEST_CASE("VSM4R.VV", "[Zvksed]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSM4R_VV(v20, v12); + REQUIRE(value == 0xA2C82A77); +} + +TEST_CASE("VSM4R.VS", "[Zvksed]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSM4R_VS(v20, v12); + REQUIRE(value == 0xA6C82A77); +} + +TEST_CASE("VSM3C.VI", "[Zvksh]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 0; i <= 31; i++) { + as.VSM3C(v20, v12, i); + + const auto op_base = 0xAEC02A77U; + const auto verify = op_base | (i << 15); + REQUIRE(value == verify); + + as.RewindBuffer(); + } +} + +TEST_CASE("VSM3ME.VV", "[Zvksh]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.VSM3ME(v20, v12, v10); + REQUIRE(value == 0x82C52A77); +} diff --git a/externals/biscuit/tests/src/assembler_zacas_tests.cpp b/externals/biscuit/tests/src/assembler_zacas_tests.cpp new file mode 100644 index 00000000..f0891fba --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zacas_tests.cpp @@ -0,0 +1,76 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("AMOCAS.D", "[Zacas]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOCAS_D(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x2877BFAF); + + as.RewindBuffer(); + + as.AMOCAS_D(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x2C77BFAF); + + as.RewindBuffer(); + + as.AMOCAS_D(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x2A77BFAF); + + as.RewindBuffer(); + + as.AMOCAS_D(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x2E77BFAF); +} + +TEST_CASE("AMOCAS.Q", "[Zacas]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOCAS_Q(Ordering::None, x30, x6, x14); + REQUIRE(value == 0x28674F2F); + + as.RewindBuffer(); + + as.AMOCAS_Q(Ordering::AQ, x30, x6, x14); + REQUIRE(value == 0x2C674F2F); + + as.RewindBuffer(); + + as.AMOCAS_Q(Ordering::RL, x30, x6, x14); + REQUIRE(value == 0x2A674F2F); + + as.RewindBuffer(); + + as.AMOCAS_Q(Ordering::AQRL, x30, x6, x14); + REQUIRE(value == 0x2E674F2F); +} + +TEST_CASE("AMOCAS.W", "[Zacas]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.AMOCAS_W(Ordering::None, x31, x7, x15); + REQUIRE(value == 0x2877AFAF); + + as.RewindBuffer(); + + as.AMOCAS_W(Ordering::AQ, x31, x7, x15); + REQUIRE(value == 0x2C77AFAF); + + as.RewindBuffer(); + + as.AMOCAS_W(Ordering::RL, x31, x7, x15); + REQUIRE(value == 0x2A77AFAF); + + as.RewindBuffer(); + + as.AMOCAS_W(Ordering::AQRL, x31, x7, x15); + REQUIRE(value == 0x2E77AFAF); +} diff --git a/externals/biscuit/tests/src/assembler_zawrs_tests.cpp b/externals/biscuit/tests/src/assembler_zawrs_tests.cpp new file mode 100644 index 00000000..ed49bfe5 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zawrs_tests.cpp @@ -0,0 +1,23 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("WRS.NTO", "[Zawrs]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.WRS_NTO(); + REQUIRE(value == 0x00D00073); +} + +TEST_CASE("WRS.STO", "[Zawrs]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.WRS_STO(); + REQUIRE(value == 0x01D00073); +} diff --git a/externals/biscuit/tests/src/assembler_zc_tests.cpp b/externals/biscuit/tests/src/assembler_zc_tests.cpp new file mode 100644 index 00000000..1c7d9d95 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zc_tests.cpp @@ -0,0 +1,457 @@ +#include <catch/catch.hpp> + +#include <array> +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("C.LBU", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_LBU(x12, 0, x15); + REQUIRE(value == 0x8390U); + + as.RewindBuffer(); + + as.C_LBU(x12, 1, x15); + REQUIRE(value == 0x83D0U); + + as.RewindBuffer(); + + as.C_LBU(x12, 2, x15); + REQUIRE(value == 0x83B0U); + + as.RewindBuffer(); + + as.C_LBU(x12, 3, x15); + REQUIRE(value == 0x83F0U); +} + +TEST_CASE("C.LH", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_LH(x12, 0, x15); + REQUIRE(value == 0x87D0U); + + as.RewindBuffer(); + + as.C_LH(x12, 2, x15); + REQUIRE(value == 0x87F0U); +} + +TEST_CASE("C.LHU", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_LHU(x12, 0, x15); + REQUIRE(value == 0x8790U); + + as.RewindBuffer(); + + as.C_LHU(x12, 2, x15); + REQUIRE(value == 0x87B0U); +} + +TEST_CASE("C.SB", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SB(x12, 0, x15); + REQUIRE(value == 0x8B90U); + + as.RewindBuffer(); + + as.C_SB(x12, 1, x15); + REQUIRE(value == 0x8BD0U); + + as.RewindBuffer(); + + as.C_SB(x12, 2, x15); + REQUIRE(value == 0x8BB0U); + + as.RewindBuffer(); + + as.C_SB(x12, 3, x15); + REQUIRE(value == 0x8BF0U); +} + +TEST_CASE("C.SH", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SH(x12, 0, x15); + REQUIRE(value == 0x8F90U); + + as.RewindBuffer(); + + as.C_SH(x12, 2, x15); + REQUIRE(value == 0x8FB0U); +} + +TEST_CASE("C.SEXT.B", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SEXT_B(x12); + REQUIRE(value == 0x9E65); + + as.RewindBuffer(); + + as.C_SEXT_B(x15); + REQUIRE(value == 0x9FE5); +} + +TEST_CASE("C.SEXT.H", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_SEXT_H(x12); + REQUIRE(value == 0x9E6D); + + as.RewindBuffer(); + + as.C_SEXT_H(x15); + REQUIRE(value == 0x9FED); +} + +TEST_CASE("C.ZEXT.B", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_ZEXT_B(x12); + REQUIRE(value == 0x9E61); + + as.RewindBuffer(); + + as.C_ZEXT_B(x15); + REQUIRE(value == 0x9FE1); +} + +TEST_CASE("C.ZEXT.H", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_ZEXT_H(x12); + REQUIRE(value == 0x9E69); + + as.RewindBuffer(); + + as.C_ZEXT_H(x15); + REQUIRE(value == 0x9FE9); +} + +TEST_CASE("C.ZEXT.W", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_ZEXT_W(x12); + REQUIRE(value == 0x9E71); + + as.RewindBuffer(); + + as.C_ZEXT_W(x15); + REQUIRE(value == 0x9FF1); +} + +TEST_CASE("C.MUL", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_MUL(x12, x15); + REQUIRE(value == 0x9E5D); + + as.RewindBuffer(); + + as.C_MUL(x15, x12); + REQUIRE(value == 0x9FD1); +} + +TEST_CASE("C.NOT", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_NOT(x12); + REQUIRE(value == 0x9E75); + + as.RewindBuffer(); + + as.C_NOT(x15); + REQUIRE(value == 0x9FF5); +} + +TEST_CASE("CM.MVA01S", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CM_MVA01S(s7, s6); + REQUIRE(value == 0xAFFA); + + as.RewindBuffer(); + + as.CM_MVA01S(s3, s4); + REQUIRE(value == 0xADF2); +} + +TEST_CASE("CM.MVSA01", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CM_MVSA01(s7, s6); + REQUIRE(value == 0xAFBA); + + as.RewindBuffer(); + + as.CM_MVSA01(s3, s4); + REQUIRE(value == 0xADB2); +} + +TEST_CASE("CM.JALT", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 32; i <= 255; i++) { + const uint32_t op_base = 0xA002; + const uint32_t op = op_base | (i << 2); + + as.CM_JALT(i); + REQUIRE(value == op); + + as.RewindBuffer(); + } +} + +TEST_CASE("CM.JT", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (uint32_t i = 0; i <= 31; i++) { + const uint32_t op_base = 0xA002; + const uint32_t op = op_base | (i << 2); + + as.CM_JT(i); + REQUIRE(value == op); + + as.RewindBuffer(); + } +} + +constexpr std::array stack_adj_bases_rv32{ + 0, 0, 0, 0, 16, 16, 16, 16, + 32, 32, 32, 32, 48, 48, 48, 64, +}; +constexpr std::array stack_adj_bases_rv64{ + 0, 0, 0, 0, 16, 16, 32, 32, + 48, 48, 64, 64, 80, 80, 96, 112, +}; + +TEST_CASE("CM.POP", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CM_POP({ra}, 16); + REQUIRE(value == 0xBA42); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xBA02U; + const auto stack_adj_base = stack_adj_bases_rv64[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_POP({ra, {s0, sreg}}, stack_adj_base + (16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.POP (RV32)", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CM_POP({ra}, 16); + REQUIRE(value == 0xBA42); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xBA02U; + const auto stack_adj_base = stack_adj_bases_rv32[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_POP({ra, {s0, sreg}}, stack_adj_base + (16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.POPRET", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CM_POPRET({ra}, 16); + REQUIRE(value == 0xBE42); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xBE02U; + const auto stack_adj_base = stack_adj_bases_rv64[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_POPRET({ra, {s0, sreg}}, stack_adj_base + (16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.POPRET (RV32)", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CM_POPRET({ra}, 16); + REQUIRE(value == 0xBE42); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xBE02U; + const auto stack_adj_base = stack_adj_bases_rv32[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_POPRET({ra, {s0, sreg}}, stack_adj_base + (16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.POPRETZ", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CM_POPRETZ({ra}, 16); + REQUIRE(value == 0xBC42); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xBC02U; + const auto stack_adj_base = stack_adj_bases_rv64[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_POPRETZ({ra, {s0, sreg}}, stack_adj_base + (16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.POPRETZ (RV32)", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CM_POPRETZ({ra}, 16); + REQUIRE(value == 0xBC42); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xBC02U; + const auto stack_adj_base = stack_adj_bases_rv32[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_POPRETZ({ra, {s0, sreg}}, stack_adj_base + (16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.PUSH", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CM_PUSH({ra}, -16); + REQUIRE(value == 0xB842); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xB802U; + const auto stack_adj_base = stack_adj_bases_rv64[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_PUSH({ra, {s0, sreg}}, -stack_adj_base + (-16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} + +TEST_CASE("CM.PUSH (RV32)", "[Zc]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.CM_PUSH({ra}, -16); + REQUIRE(value == 0xB842); + as.RewindBuffer(); + + // s10 intentionally omitted, since no direct encoding for it exists. + uint32_t rlist = 5; + for (const GPR sreg : {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s11}) { + const auto op_base = 0xB802U; + const auto stack_adj_base = stack_adj_bases_rv32[rlist]; + + for (int32_t i = 0; i <= 3; i++) { + const auto op = op_base | (rlist << 4) | uint32_t(i) << 2; + + as.CM_PUSH({ra, {s0, sreg}}, -stack_adj_base + (-16 * i)); + REQUIRE(value == op); + as.RewindBuffer(); + } + + rlist++; + } +} diff --git a/externals/biscuit/tests/src/assembler_zfa_tests.cpp b/externals/biscuit/tests/src/assembler_zfa_tests.cpp new file mode 100644 index 00000000..d73297d4 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zfa_tests.cpp @@ -0,0 +1,414 @@ +#include <catch/catch.hpp> + +#include <array> +#include <cstring> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +static constexpr std::array fli_constants{ + 0xBFF0000000000000ULL, // -1.0 + 0x0010000000000000ULL, // Minimum positive normal + 0x3EF0000000000000ULL, // 1.0 * 2^-16 + 0x3F00000000000000ULL, // 1.0 * 2^-15 + 0x3F70000000000000ULL, // 1.0 * 2^-8 + 0x3F80000000000000ULL, // 1.0 * 2^-7 + 0x3FB0000000000000ULL, // 1.0 * 2^-4 + 0x3FC0000000000000ULL, // 1.0 * 2^-3 + 0x3FD0000000000000ULL, // 0.25 + 0x3FD4000000000000ULL, // 0.3125 + 0x3FD8000000000000ULL, // 0.375 + 0x3FDC000000000000ULL, // 0.4375 + 0x3FE0000000000000ULL, // 0.5 + 0x3FE4000000000000ULL, // 0.625 + 0x3FE8000000000000ULL, // 0.75 + 0x3FEC000000000000ULL, // 0.875 + 0x3FF0000000000000ULL, // 1.0 + 0x3FF4000000000000ULL, // 1.25 + 0x3FF8000000000000ULL, // 1.5 + 0x3FFC000000000000ULL, // 1.75 + 0x4000000000000000ULL, // 2.0 + 0x4004000000000000ULL, // 2.5 + 0x4008000000000000ULL, // 3 + 0x4010000000000000ULL, // 4 + 0x4020000000000000ULL, // 8 + 0x4030000000000000ULL, // 16 + 0x4060000000000000ULL, // 2^7 + 0x4070000000000000ULL, // 2^8 + 0x40E0000000000000ULL, // 2^15 + 0x40F0000000000000ULL, // 2^16 + 0x7FF0000000000000ULL, // +inf + 0x7FF8000000000000ULL, // Canonical NaN +}; + +TEST_CASE("FLI.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (size_t i = 0; i < fli_constants.size(); i++) { + const auto constant = fli_constants[i]; + double fconstant{}; + std::memcpy(&fconstant, &constant, sizeof(fconstant)); + + as.FLI_D(f10, fconstant); + + const auto op_base = 0xF2100553; + const auto verify = op_base | (i << 15); + REQUIRE(value == verify); + + as.RewindBuffer(); + } +} + +TEST_CASE("FLI.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (size_t i = 0; i < fli_constants.size(); i++) { + const auto constant = fli_constants[i]; + double fconstant{}; + std::memcpy(&fconstant, &constant, sizeof(fconstant)); + + as.FLI_H(f10, fconstant); + + const auto op_base = 0xF4100553; + const auto verify = op_base | (i << 15); + REQUIRE(value == verify); + + as.RewindBuffer(); + } +} + +TEST_CASE("FLI.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + for (size_t i = 0; i < fli_constants.size(); i++) { + const auto constant = fli_constants[i]; + double fconstant{}; + std::memcpy(&fconstant, &constant, sizeof(fconstant)); + + as.FLI_S(f10, fconstant); + + const auto op_base = 0xF0100553; + const auto verify = op_base | (i << 15); + REQUIRE(value == verify); + + as.RewindBuffer(); + } +} + +TEST_CASE("FMINM.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMINM_D(f20, f12, f10); + REQUIRE(value == 0x2AA62A53); +} + +TEST_CASE("FMINM.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMINM_H(f20, f12, f10); + REQUIRE(value == 0x2CA62A53); +} + +TEST_CASE("FMINM.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMINM_Q(f20, f12, f10); + REQUIRE(value == 0x2EA62A53); +} + +TEST_CASE("FMINM.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMINM_S(f20, f12, f10); + REQUIRE(value == 0x28A62A53); +} + +TEST_CASE("FMAXM.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMAXM_D(f20, f12, f10); + REQUIRE(value == 0x2AA63A53); +} + +TEST_CASE("FMAXM.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMAXM_H(f20, f12, f10); + REQUIRE(value == 0x2CA63A53); +} + +TEST_CASE("FMAXM.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMAXM_Q(f20, f12, f10); + REQUIRE(value == 0x2EA63A53); +} + +TEST_CASE("FMAXM.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMAXM_S(f20, f12, f10); + REQUIRE(value == 0x28A63A53); +} + +TEST_CASE("FROUND.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUND_D(f31, f7, RMode::RNE); + REQUIRE(value == 0x42438FD3); + + as.RewindBuffer(); + + as.FROUND_D(f31, f7, RMode::RMM); + REQUIRE(value == 0x4243CFD3); + + as.RewindBuffer(); + + as.FROUND_D(f31, f7, RMode::DYN); + REQUIRE(value == 0x4243FFD3); +} + +TEST_CASE("FROUND.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUND_H(f31, f7, RMode::RNE); + REQUIRE(value == 0x44438FD3); + + as.RewindBuffer(); + + as.FROUND_H(f31, f7, RMode::RMM); + REQUIRE(value == 0x4443CFD3); + + as.RewindBuffer(); + + as.FROUND_H(f31, f7, RMode::DYN); + REQUIRE(value == 0x4443FFD3); +} + +TEST_CASE("FROUND.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUND_Q(f31, f7, RMode::RNE); + REQUIRE(value == 0x46438FD3); + + as.RewindBuffer(); + + as.FROUND_Q(f31, f7, RMode::RMM); + REQUIRE(value == 0x4643CFD3); + + as.RewindBuffer(); + + as.FROUND_Q(f31, f7, RMode::DYN); + REQUIRE(value == 0x4643FFD3); +} + +TEST_CASE("FROUND.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUND_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x40438FD3); + + as.RewindBuffer(); + + as.FROUND_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x4043CFD3); + + as.RewindBuffer(); + + as.FROUND_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x4043FFD3); +} + +TEST_CASE("FROUNDNX.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUNDNX_D(f31, f7, RMode::RNE); + REQUIRE(value == 0x42538FD3); + + as.RewindBuffer(); + + as.FROUNDNX_D(f31, f7, RMode::RMM); + REQUIRE(value == 0x4253CFD3); + + as.RewindBuffer(); + + as.FROUNDNX_D(f31, f7, RMode::DYN); + REQUIRE(value == 0x4253FFD3); +} + +TEST_CASE("FROUNDNX.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUNDNX_H(f31, f7, RMode::RNE); + REQUIRE(value == 0x44538FD3); + + as.RewindBuffer(); + + as.FROUNDNX_H(f31, f7, RMode::RMM); + REQUIRE(value == 0x4453CFD3); + + as.RewindBuffer(); + + as.FROUNDNX_H(f31, f7, RMode::DYN); + REQUIRE(value == 0x4453FFD3); +} + +TEST_CASE("FROUNDNX.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUNDNX_Q(f31, f7, RMode::RNE); + REQUIRE(value == 0x46538FD3); + + as.RewindBuffer(); + + as.FROUNDNX_Q(f31, f7, RMode::RMM); + REQUIRE(value == 0x4653CFD3); + + as.RewindBuffer(); + + as.FROUNDNX_Q(f31, f7, RMode::DYN); + REQUIRE(value == 0x4653FFD3); +} + +TEST_CASE("FROUNDNX.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FROUNDNX_S(f31, f7, RMode::RNE); + REQUIRE(value == 0x40538FD3); + + as.RewindBuffer(); + + as.FROUNDNX_S(f31, f7, RMode::RMM); + REQUIRE(value == 0x4053CFD3); + + as.RewindBuffer(); + + as.FROUNDNX_S(f31, f7, RMode::DYN); + REQUIRE(value == 0x4053FFD3); +} + +TEST_CASE("FCVTMOD.W.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FCVTMOD_W_D(x31, f7); + REQUIRE(value == 0xC2839FD3); +} + +TEST_CASE("FMVH.X.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMVH_X_D(x31, f7); + REQUIRE(value == 0xE2138FD3); +} + +TEST_CASE("FMVH.X.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMVH_X_Q(x31, f7); + REQUIRE(value == 0xE6138FD3); +} + +TEST_CASE("FMVP.D.X", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler32(value); + + as.FMVP_D_X(f31, x7, x8); + REQUIRE(value == 0xB2838FD3); +} + +TEST_CASE("FMVP.Q.X", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FMVP_Q_X(f31, x7, x8); + REQUIRE(value == 0xB6838FD3); +} + +TEST_CASE("FLEQ.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLEQ_D(x31, f7, f15); + REQUIRE(value == 0xA2F3CFD3); +} + +TEST_CASE("FLTQ.D", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLTQ_D(x31, f7, f15); + REQUIRE(value == 0xA2F3DFD3); +} + +TEST_CASE("FLEQ.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLEQ_H(x31, f7, f15); + REQUIRE(value == 0xA4F3CFD3); +} + +TEST_CASE("FLTQ.H", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLTQ_H(x31, f7, f15); + REQUIRE(value == 0xA4F3DFD3); +} + +TEST_CASE("FLEQ.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLEQ_Q(x31, f7, f15); + REQUIRE(value == 0xA6F3CFD3); +} + +TEST_CASE("FLTQ.Q", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLTQ_Q(x31, f7, f15); + REQUIRE(value == 0xA6F3DFD3); +} + +TEST_CASE("FLEQ.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLEQ_S(x31, f7, f15); + REQUIRE(value == 0xA0F3CFD3); +} + +TEST_CASE("FLTQ.S", "[Zfa]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.FLTQ_S(x31, f7, f15); + REQUIRE(value == 0xA0F3DFD3); +} diff --git a/externals/biscuit/tests/src/assembler_zicond_tests.cpp b/externals/biscuit/tests/src/assembler_zicond_tests.cpp new file mode 100644 index 00000000..68dc11b9 --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zicond_tests.cpp @@ -0,0 +1,33 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("CZERO.EQZ", "[Zicond]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CZERO_EQZ(x31, x30, x29); + REQUIRE(value == 0x0FDF5FB3); + + as.RewindBuffer(); + + as.CZERO_EQZ(x1, x2, x3); + REQUIRE(value == 0x0E3150B3); +} + +TEST_CASE("CZERO.NEZ", "[Zicond]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CZERO_NEZ(x31, x30, x29); + REQUIRE(value == 0x0FDF7FB3); + + as.RewindBuffer(); + + as.CZERO_NEZ(x1, x2, x3); + REQUIRE(value == 0x0E3170B3); +} diff --git a/externals/biscuit/tests/src/assembler_zicsr_tests.cpp b/externals/biscuit/tests/src/assembler_zicsr_tests.cpp new file mode 100644 index 00000000..b3f5ad6d --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zicsr_tests.cpp @@ -0,0 +1,130 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("CSRRC", "[Zicsr]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CSRRC(x31, CSR::Cycle, x15); + REQUIRE(value == 0xC007BFF3); + + as.RewindBuffer(); + + as.CSRRC(x31, CSR::FFlags, x15); + REQUIRE(value == 0x0017BFF3); + + as.RewindBuffer(); + + as.CSRRC(x31, CSR::FRM, x15); + REQUIRE(value == 0x0027BFF3); + + as.RewindBuffer(); + + as.CSRRC(x31, CSR::FCSR, x15); + REQUIRE(value == 0x0037BFF3); +} + +TEST_CASE("CSRRCI", "[Zicsr]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CSRRCI(x31, CSR::Cycle, 0); + REQUIRE(value == 0xC0007FF3); + + as.RewindBuffer(); + + as.CSRRCI(x31, CSR::FFlags, 0x1F); + REQUIRE(value == 0x001FFFF3); + + as.RewindBuffer(); + + as.CSRRCI(x31, CSR::FRM, 0x7); + REQUIRE(value == 0x0023FFF3); +} + +TEST_CASE("CSRRS", "[Zicsr]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CSRRS(x31, CSR::Cycle, x15); + REQUIRE(value == 0xC007AFF3); + + as.RewindBuffer(); + + as.CSRRS(x31, CSR::FFlags, x15); + REQUIRE(value == 0x0017AFF3); + + as.RewindBuffer(); + + as.CSRRS(x31, CSR::FRM, x15); + REQUIRE(value == 0x0027AFF3); + + as.RewindBuffer(); + + as.CSRRS(x31, CSR::FCSR, x15); + REQUIRE(value == 0x0037AFF3); +} + +TEST_CASE("CSRRSI", "[Zicsr]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CSRRSI(x31, CSR::Cycle, 0); + REQUIRE(value == 0xC0006FF3); + + as.RewindBuffer(); + + as.CSRRSI(x31, CSR::FFlags, 0x1F); + REQUIRE(value == 0x001FEFF3); + + as.RewindBuffer(); + + as.CSRRSI(x31, CSR::FRM, 0x7); + REQUIRE(value == 0x0023EFF3); +} + +TEST_CASE("CSRRW", "[Zicsr]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CSRRW(x31, CSR::Cycle, x15); + REQUIRE(value == 0xC0079FF3); + + as.RewindBuffer(); + + as.CSRRW(x31, CSR::FFlags, x15); + REQUIRE(value == 0x00179FF3); + + as.RewindBuffer(); + + as.CSRRW(x31, CSR::FRM, x15); + REQUIRE(value == 0x00279FF3); + + as.RewindBuffer(); + + as.CSRRW(x31, CSR::FCSR, x15); + REQUIRE(value == 0x00379FF3); +} + +TEST_CASE("CSRRWI", "[Zicsr]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.CSRRWI(x31, CSR::Cycle, 0); + REQUIRE(value == 0xC0005FF3); + + as.RewindBuffer(); + + as.CSRRWI(x31, CSR::FFlags, 0x1F); + REQUIRE(value == 0x001FDFF3); + + as.RewindBuffer(); + + as.CSRRWI(x31, CSR::FRM, 0x7); + REQUIRE(value == 0x0023DFF3); +} diff --git a/externals/biscuit/tests/src/assembler_zihintntl_tests.cpp b/externals/biscuit/tests/src/assembler_zihintntl_tests.cpp new file mode 100644 index 00000000..5e81fb8c --- /dev/null +++ b/externals/biscuit/tests/src/assembler_zihintntl_tests.cpp @@ -0,0 +1,71 @@ +#include <catch/catch.hpp> + +#include <biscuit/assembler.hpp> + +#include "assembler_test_utils.hpp" + +using namespace biscuit; + +TEST_CASE("C.NTL.ALL", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_NTL_ALL(); + REQUIRE(value == 0x9016); +} + +TEST_CASE("C.NTL.S1", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_NTL_S1(); + REQUIRE(value == 0x9012); +} + +TEST_CASE("C.NTL.P1", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_NTL_P1(); + REQUIRE(value == 0x900A); +} + +TEST_CASE("C.NTL.PALL", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.C_NTL_PALL(); + REQUIRE(value == 0x900E); +} + +TEST_CASE("NTL.ALL", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.NTL_ALL(); + REQUIRE(value == 0x00500033); +} + +TEST_CASE("NTL.S1", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.NTL_S1(); + REQUIRE(value == 0x00400033); +} + +TEST_CASE("NTL.P1", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.NTL_P1(); + REQUIRE(value == 0x00200033); +} + +TEST_CASE("NTL.PALL", "[Zihintntl]") { + uint32_t value = 0; + auto as = MakeAssembler64(value); + + as.NTL_PALL(); + REQUIRE(value == 0x00300033); +} diff --git a/externals/biscuit/tests/src/main.cpp b/externals/biscuit/tests/src/main.cpp new file mode 100644 index 00000000..4c506ba0 --- /dev/null +++ b/externals/biscuit/tests/src/main.cpp @@ -0,0 +1,2 @@ +#define CATCH_CONFIG_MAIN +#include <catch/catch.hpp> |