mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-06 22:48:25 +01:00
Squashed 'externals/biscuit/' content from commit 1d53c9e6
git-subtree-dir: externals/biscuit git-subtree-split: 1d53c9e6cfe56544982200a5bac15a5de064936b
This commit is contained in:
commit
e4a733d5b2
55 changed files with 40248 additions and 0 deletions
76
tests/CMakeLists.txt
Normal file
76
tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
project(biscuit_tests)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/assembler_bfloat_tests.cpp
|
||||
src/assembler_branch_tests.cpp
|
||||
src/assembler_cmo_tests.cpp
|
||||
src/assembler_privileged_tests.cpp
|
||||
src/assembler_rv32i_tests.cpp
|
||||
src/assembler_rv64i_tests.cpp
|
||||
src/assembler_rva_tests.cpp
|
||||
src/assembler_rvb_tests.cpp
|
||||
src/assembler_rvc_tests.cpp
|
||||
src/assembler_rvd_tests.cpp
|
||||
src/assembler_rvf_tests.cpp
|
||||
src/assembler_rvk_tests.cpp
|
||||
src/assembler_rvm_tests.cpp
|
||||
src/assembler_rvq_tests.cpp
|
||||
src/assembler_rvv_tests.cpp
|
||||
src/assembler_vector_crypto_tests.cpp
|
||||
src/assembler_zacas_tests.cpp
|
||||
src/assembler_zawrs_tests.cpp
|
||||
src/assembler_zc_tests.cpp
|
||||
src/assembler_zfa_tests.cpp
|
||||
src/assembler_zicond_tests.cpp
|
||||
src/assembler_zicsr_tests.cpp
|
||||
src/assembler_zihintntl_tests.cpp
|
||||
src/main.cpp
|
||||
|
||||
src/assembler_test_utils.hpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
externals/
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
biscuit
|
||||
)
|
||||
|
||||
target_compile_features(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
cxx_std_20
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
/MP
|
||||
/Zi
|
||||
/Zo
|
||||
/permissive-
|
||||
/EHsc
|
||||
/utf-8
|
||||
/volatile:iso
|
||||
/Zc:externConstexpr
|
||||
/Zc:inline
|
||||
/Zc:throwingNew
|
||||
|
||||
# Warnings
|
||||
/W4
|
||||
/we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled
|
||||
/we4101 # 'identifier': unreferenced local variable
|
||||
/we4265 # 'class': class has virtual functions, but destructor is not virtual
|
||||
/we4388 # signed/unsigned mismatch
|
||||
/we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect
|
||||
/we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
|
||||
/we4555 # Expression has no effect; expected expression with side-effect
|
||||
/we4715 # 'function': not all control paths return a value
|
||||
/we4834 # Discarding return value of function with 'nodiscard' attribute
|
||||
/we5038 # data member 'member1' will be initialized after data member 'member2'
|
||||
)
|
||||
endif()
|
||||
|
||||
add_test(biscuit_tests_ctest ${PROJECT_NAME})
|
||||
17976
tests/externals/catch/catch.hpp
vendored
Normal file
17976
tests/externals/catch/catch.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
95
tests/src/assembler_bfloat_tests.cpp
Normal file
95
tests/src/assembler_bfloat_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
105
tests/src/assembler_branch_tests.cpp
Normal file
105
tests/src/assembler_branch_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
113
tests/src/assembler_cmo_tests.cpp
Normal file
113
tests/src/assembler_cmo_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
302
tests/src/assembler_privileged_tests.cpp
Normal file
302
tests/src/assembler_privileged_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
769
tests/src/assembler_rv32i_tests.cpp
Normal file
769
tests/src/assembler_rv32i_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
436
tests/src/assembler_rv64i_tests.cpp
Normal file
436
tests/src/assembler_rv64i_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
513
tests/src/assembler_rva_tests.cpp
Normal file
513
tests/src/assembler_rva_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
610
tests/src/assembler_rvb_tests.cpp
Normal file
610
tests/src/assembler_rvb_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
595
tests/src/assembler_rvc_tests.cpp
Normal file
595
tests/src/assembler_rvc_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
528
tests/src/assembler_rvd_tests.cpp
Normal file
528
tests/src/assembler_rvd_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
1085
tests/src/assembler_rvf_tests.cpp
Normal file
1085
tests/src/assembler_rvf_tests.cpp
Normal file
File diff suppressed because it is too large
Load diff
384
tests/src/assembler_rvk_tests.cpp
Normal file
384
tests/src/assembler_rvk_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
241
tests/src/assembler_rvm_tests.cpp
Normal file
241
tests/src/assembler_rvm_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
538
tests/src/assembler_rvq_tests.cpp
Normal file
538
tests/src/assembler_rvq_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
5334
tests/src/assembler_rvv_tests.cpp
Normal file
5334
tests/src/assembler_rvv_tests.cpp
Normal file
File diff suppressed because it is too large
Load diff
23
tests/src/assembler_test_utils.hpp
Normal file
23
tests/src/assembler_test_utils.hpp
Normal file
|
|
@ -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
|
||||
495
tests/src/assembler_vector_crypto_tests.cpp
Normal file
495
tests/src/assembler_vector_crypto_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
76
tests/src/assembler_zacas_tests.cpp
Normal file
76
tests/src/assembler_zacas_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
23
tests/src/assembler_zawrs_tests.cpp
Normal file
23
tests/src/assembler_zawrs_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
457
tests/src/assembler_zc_tests.cpp
Normal file
457
tests/src/assembler_zc_tests.cpp
Normal file
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
414
tests/src/assembler_zfa_tests.cpp
Normal file
414
tests/src/assembler_zfa_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
33
tests/src/assembler_zicond_tests.cpp
Normal file
33
tests/src/assembler_zicond_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
130
tests/src/assembler_zicsr_tests.cpp
Normal file
130
tests/src/assembler_zicsr_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
71
tests/src/assembler_zihintntl_tests.cpp
Normal file
71
tests/src/assembler_zihintntl_tests.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
2
tests/src/main.cpp
Normal file
2
tests/src/main.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch/catch.hpp>
|
||||
Loading…
Add table
Add a link
Reference in a new issue