Skip to content

Commit

Permalink
rv32i_tests/rv64i_tests: Get rid of sign conversion warnings
Browse files Browse the repository at this point in the history
Also fix a weird capture issue on MSVC.
  • Loading branch information
lioncash committed Oct 29, 2024
1 parent a6ae5c8 commit 33ebced
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tests/src/assembler_rv32i_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ TEST_CASE("LI", "[rv32i]") {
as.RewindBuffer();
vals = {};

as.LI(x1, -1);
as.LI(x1, uint64_t(-1));
// addi x1, x0, -1
compare_vals(0xFFF00093, 0x00000000);
as.RewindBuffer();
Expand All @@ -373,13 +373,13 @@ TEST_CASE("LI", "[rv32i]") {
as.RewindBuffer();
vals = {};

as.LI(x1, ~0xFFF);
as.LI(x1, ~0xFFFULL);
// lui x1, -1
compare_vals(0xFFFFF0B7, 0x00000000);
as.RewindBuffer();
vals = {};

as.LI(x1, INT32_MIN);
as.LI(x1, uint64_t(INT32_MIN));
// lui x1, -524288
compare_vals(0x800000B7, 0x00000000);
as.RewindBuffer();
Expand Down
11 changes: 6 additions & 5 deletions tests/src/assembler_rv64i_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ TEST_CASE("LD", "[rv64i]") {

TEST_CASE("LI (RV64)", "[rv64i]") {
// Up to 8 instructions can be generated
std::array<uint32_t, 8> vals{};
constexpr size_t MAX_INSTS = 8;
std::array<uint32_t, MAX_INSTS> vals{};
auto as = MakeAssembler64(vals);

const auto compare_vals = [&vals]<typename... Args>(const Args&... args) {
static_assert(sizeof...(args) <= vals.size());
static_assert(sizeof...(args) <= MAX_INSTS);

size_t i = 0;
for (const auto arg : {args...}) {
Expand All @@ -102,7 +103,7 @@ TEST_CASE("LI (RV64)", "[rv64i]") {
as.RewindBuffer();
vals = {};

as.LI(x1, -1);
as.LI(x1, uint64_t(-1));
// addiw x1, x0, -1
compare_vals(0xFFF0009BU, 0x00000000U);
as.RewindBuffer();
Expand All @@ -128,13 +129,13 @@ TEST_CASE("LI (RV64)", "[rv64i]") {
as.RewindBuffer();
vals = {};

as.LI(x1, ~0xFFF);
as.LI(x1, ~0xFFFULL);
// lui x1, -1
compare_vals(0xFFFFF0B7U, 0x00000000U);
as.RewindBuffer();
vals = {};

as.LI(x1, INT32_MIN);
as.LI(x1, uint64_t(INT32_MIN));
// lui x1, -524288
compare_vals(0x800000B7U, 0x00000000U);
as.RewindBuffer();
Expand Down

0 comments on commit 33ebced

Please sign in to comment.