diff options
-rw-r--r-- | isa/macros/scalar/test_macros.h | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/isa/macros/scalar/test_macros.h b/isa/macros/scalar/test_macros.h index 7a489e2..cd7d21d 100644 --- a/isa/macros/scalar/test_macros.h +++ b/isa/macros/scalar/test_macros.h @@ -8,10 +8,12 @@ # Helper macros #----------------------------------------------------------------------- +#define MASK_XLEN(x) ((x) & ((1 << (__riscv_xlen - 1) << 1) - 1)) + #define TEST_CASE( testnum, testreg, correctval, code... ) \ test_ ## testnum: \ code; \ - li x29, correctval; \ + li x29, MASK_XLEN(correctval); \ li TESTNUM, testnum; \ bne testreg, x29, fail; @@ -43,20 +45,20 @@ test_ ## testnum: \ #define TEST_IMM_OP( testnum, inst, result, val1, imm ) \ TEST_CASE( testnum, x3, result, \ - li x1, val1; \ + li x1, MASK_XLEN(val1); \ inst x3, x1, SEXT_IMM(imm); \ ) #define TEST_IMM_SRC1_EQ_DEST( testnum, inst, result, val1, imm ) \ TEST_CASE( testnum, x1, result, \ - li x1, val1; \ + li x1, MASK_XLEN(val1); \ inst x1, x1, SEXT_IMM(imm); \ ) #define TEST_IMM_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \ TEST_CASE( testnum, x6, result, \ li x4, 0; \ -1: li x1, val1; \ +1: li x1, MASK_XLEN(val1); \ inst x3, x1, SEXT_IMM(imm); \ TEST_INSERT_NOPS_ ## nop_cycles \ addi x6, x3, 0; \ @@ -68,7 +70,7 @@ test_ ## testnum: \ #define TEST_IMM_SRC1_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \ TEST_CASE( testnum, x3, result, \ li x4, 0; \ -1: li x1, val1; \ +1: li x1, MASK_XLEN(val1); \ TEST_INSERT_NOPS_ ## nop_cycles \ inst x3, x1, SEXT_IMM(imm); \ addi x4, x4, 1; \ @@ -83,7 +85,7 @@ test_ ## testnum: \ #define TEST_IMM_ZERODEST( testnum, inst, val1, imm ) \ TEST_CASE( testnum, x0, 0, \ - li x1, val1; \ + li x1, MASK_XLEN(val1); \ inst x0, x1, SEXT_IMM(imm); \ ) @@ -149,36 +151,36 @@ test_ ## testnum: \ #define TEST_RR_OP( testnum, inst, result, val1, val2 ) \ TEST_CASE( testnum, x3, result, \ - li x1, val1; \ - li x2, val2; \ + li x1, MASK_XLEN(val1); \ + li x2, MASK_XLEN(val2); \ inst x3, x1, x2; \ ) #define TEST_RR_SRC1_EQ_DEST( testnum, inst, result, val1, val2 ) \ TEST_CASE( testnum, x1, result, \ - li x1, val1; \ - li x2, val2; \ + li x1, MASK_XLEN(val1); \ + li x2, MASK_XLEN(val2); \ inst x1, x1, x2; \ ) #define TEST_RR_SRC2_EQ_DEST( testnum, inst, result, val1, val2 ) \ TEST_CASE( testnum, x2, result, \ - li x1, val1; \ - li x2, val2; \ + li x1, MASK_XLEN(val1); \ + li x2, MASK_XLEN(val2); \ inst x2, x1, x2; \ ) #define TEST_RR_SRC12_EQ_DEST( testnum, inst, result, val1 ) \ TEST_CASE( testnum, x1, result, \ - li x1, val1; \ + li x1, MASK_XLEN(val1); \ inst x1, x1, x1; \ ) #define TEST_RR_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, val2 ) \ TEST_CASE( testnum, x6, result, \ li x4, 0; \ -1: li x1, val1; \ - li x2, val2; \ +1: li x1, MASK_XLEN(val1); \ + li x2, MASK_XLEN(val2); \ inst x3, x1, x2; \ TEST_INSERT_NOPS_ ## nop_cycles \ addi x6, x3, 0; \ @@ -190,9 +192,9 @@ test_ ## testnum: \ #define TEST_RR_SRC12_BYPASS( testnum, src1_nops, src2_nops, inst, result, val1, val2 ) \ TEST_CASE( testnum, x3, result, \ li x4, 0; \ -1: li x1, val1; \ +1: li x1, MASK_XLEN(val1); \ TEST_INSERT_NOPS_ ## src1_nops \ - li x2, val2; \ + li x2, MASK_XLEN(val2); \ TEST_INSERT_NOPS_ ## src2_nops \ inst x3, x1, x2; \ addi x4, x4, 1; \ @@ -203,9 +205,9 @@ test_ ## testnum: \ #define TEST_RR_SRC21_BYPASS( testnum, src1_nops, src2_nops, inst, result, val1, val2 ) \ TEST_CASE( testnum, x3, result, \ li x4, 0; \ -1: li x2, val2; \ +1: li x2, MASK_XLEN(val2); \ TEST_INSERT_NOPS_ ## src1_nops \ - li x1, val1; \ + li x1, MASK_XLEN(val1); \ TEST_INSERT_NOPS_ ## src2_nops \ inst x3, x1, x2; \ addi x4, x4, 1; \ @@ -215,13 +217,13 @@ test_ ## testnum: \ #define TEST_RR_ZEROSRC1( testnum, inst, result, val ) \ TEST_CASE( testnum, x2, result, \ - li x1, val; \ + li x1, MASK_XLEN(val); \ inst x2, x0, x1; \ ) #define TEST_RR_ZEROSRC2( testnum, inst, result, val ) \ TEST_CASE( testnum, x2, result, \ - li x1, val; \ + li x1, MASK_XLEN(val); \ inst x2, x1, x0; \ ) @@ -232,8 +234,8 @@ test_ ## testnum: \ #define TEST_RR_ZERODEST( testnum, inst, val1, val2 ) \ TEST_CASE( testnum, x0, 0, \ - li x1, val1; \ - li x2, val2; \ + li x1, MASK_XLEN(val1); \ + li x2, MASK_XLEN(val2); \ inst x0, x1, x2; \ ) |