Avoid deprecated "b" pseudo-op; use "j" instead
[riscv-tests.git] / isa / macros / vector / test_macros.h
index 6cfda128364602e032cabbeb9060814784b7f00d..68e39aee67ccc9d0ba59aa52f150230029614ce0 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __TEST_MACROS_VECTOR_H
 #define __TEST_MACROS_VECTOR_H
 
+#undef EXTRA_INIT
+#define EXTRA_INIT RVTEST_VEC_ENABLE
 
 #-----------------------------------------------------------------------
 # Helper macros
@@ -23,7 +25,7 @@ test_ ## testnum: \
   fence; \
   li a1,correctval; \
   li a2,0; \
-  li x28, testnum; \
+  li TESTNUM, testnum; \
 test_loop ## testnum: \
   ld a0,0(a4); \
   beq a0,a1,skip ## testnum; \
@@ -62,22 +64,24 @@ next ## testnum :
 # Tests for instructions with immediate operand
 #-----------------------------------------------------------------------
 
+#define SEXT_IMM(x) ((x) | (-(((x) >> 11) & 1) << 11))
+
 #define TEST_IMM_OP( testnum, inst, result, val1, imm ) \
     TEST_CASE_NREG( testnum, 4, 0, x3, result, \
       li  x1, val1; \
-      inst x3, x1, imm; \
+      inst x3, x1, SEXT_IMM(imm); \
     )
 
 #define TEST_IMM_SRC1_EQ_DEST( testnum, inst, result, val1, imm ) \
     TEST_CASE_NREG( testnum, 2, 0, x1, result, \
       li  x1, val1; \
-      inst x1, x1, imm; \
+      inst x1, x1, SEXT_IMM(imm); \
     )
 
 #define TEST_IMM_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \
     TEST_CASE_NREG( testnum, 5, 0, x4, result, \
       li  x1, val1; \
-      inst x3, x1, imm; \
+      inst x3, x1, SEXT_IMM(imm); \
       TEST_INSERT_NOPS_ ## nop_cycles \
       addi  x4, x3, 0; \
     )
@@ -86,18 +90,18 @@ next ## testnum :
     TEST_CASE_NREG( testnum, 4, 0, x3, result, \
       li  x1, val1; \
       TEST_INSERT_NOPS_ ## nop_cycles \
-      inst x3, x1, imm; \
+      inst x3, x1, SEXT_IMM(imm); \
     )
 
 #define TEST_IMM_ZEROSRC1( testnum, inst, result, imm ) \
     TEST_CASE_NREG( testnum, 2, 0, x1, result, \
-      inst x1, x0, imm; \
+      inst x1, x0, SEXT_IMM(imm); \
     )
 
 #define TEST_IMM_ZERODEST( testnum, inst, val1, imm ) \
     TEST_CASE_NREG( testnum, 2, 0, x0, 0, \
       li  x1, val1; \
-      inst x0, x1, imm; \
+      inst x0, x1, SEXT_IMM(imm); \
     )
 
 #-----------------------------------------------------------------------
@@ -234,7 +238,7 @@ test_ ## testnum: \
   fence; \
   lw  a1, 0(a5); \
   li a2, 0; \
-  li x28, testnum; \
+  li TESTNUM, testnum; \
 test_loop ## testnum: \
   lw a0,0(a4); \
   beq a0,a1,skip ## testnum; \
@@ -243,7 +247,7 @@ skip ## testnum : \
   addi a4,a4,4; \
   addi a2,a2,1; \
   bne a2,a3,test_loop ## testnum; \
-  b 1f; \
+  j 1f; \
 vtcode ## testnum : \
   code; \
   stop; \
@@ -274,7 +278,7 @@ test_ ## testnum: \
   fence; \
   ld  a1, 0(a5); \
   li a2, 0; \
-  li x28, testnum; \
+  li TESTNUM, testnum; \
 test_loop ## testnum: \
   ld a0,0(a4); \
   beq a0,a1,skip ## testnum; \
@@ -283,7 +287,7 @@ skip ## testnum : \
   addi a4,a4,8; \
   addi a2,a2,1; \
   bne a2,a3,test_loop ## testnum; \
-  b 1f; \
+  j 1f; \
 vtcode ## testnum : \
   code; \
   stop; \
@@ -303,27 +307,27 @@ vtcode ## testnum : \
   TEST_FP_OP_S_INTERNAL_NREG( testnum, 2, 4, float result, val1, 0.0, 0.0, \
                     fcvt.d.s f3, f0; fcvt.s.d f3, f3; fmv.x.s x1, f3)
 
-#define TEST_FP_OP2_S( testnum, inst, result, val1, val2 ) \
+#define TEST_FP_OP2_S( testnum, inst, flags, result, val1, val2 ) \
   TEST_FP_OP_S_INTERNAL_NREG( testnum, 2, 4, float result, val1, val2, 0.0, \
                     inst f3, f0, f1; fmv.x.s x1, f3)
 
-#define TEST_FP_OP2_D( testnum, inst, result, val1, val2 ) \
+#define TEST_FP_OP2_D( testnum, inst, flags, result, val1, val2 ) \
   TEST_FP_OP_D_INTERNAL_NREG( testnum, 2, 4, double result, val1, val2, 0.0, \
                     inst f3, f0, f1; fmv.x.d x1, f3)
 
-#define TEST_FP_OP3_S( testnum, inst, result, val1, val2, val3 ) \
+#define TEST_FP_OP3_S( testnum, inst, flags, result, val1, val2, val3 ) \
   TEST_FP_OP_S_INTERNAL_NREG( testnum, 2, 4, float result, val1, val2, val3, \
                     inst f3, f0, f1, f2; fmv.x.s x1, f3)
 
-#define TEST_FP_OP3_D( testnum, inst, result, val1, val2, val3 ) \
+#define TEST_FP_OP3_D( testnum, inst, flags, result, val1, val2, val3 ) \
   TEST_FP_OP_D_INTERNAL_NREG( testnum, 2, 4, double result, val1, val2, val3, \
                     inst f3, f0, f1, f2; fmv.x.d x1, f3)
 
-#define TEST_FP_INT_OP_S( testnum, inst, result, val1, rm ) \
+#define TEST_FP_INT_OP_S( testnum, inst, flags, result, val1, rm ) \
   TEST_FP_OP_S_INTERNAL_NREG( testnum, 2, 4, word result, val1, 0.0, 0.0, \
                     inst x1, f0, rm)
 
-#define TEST_FP_INT_OP_D( testnum, inst, result, val1, rm ) \
+#define TEST_FP_INT_OP_D( testnum, inst, flags, result, val1, rm ) \
   TEST_FP_OP_D_INTERNAL_NREG( testnum, 2, 4, dword result, val1, 0.0, 0.0, \
                     inst x1, f0, rm)
 
@@ -348,7 +352,7 @@ test_ ## testnum: \
   la  a5, test_ ## testnum ## _data ;\
   lw  a1, 0(a5); \
   li a2, 0; \
-  li x28, testnum; \
+  li TESTNUM, testnum; \
 test_loop ## testnum: \
   lw a0,0(a4); \
   beq a0,a1,skip ## testnum; \
@@ -357,7 +361,7 @@ skip ## testnum : \
   addi a4,a4,4; \
   addi a2,a2,1; \
   bne a2,a3,test_loop ## testnum; \
-  b 1f; \
+  j 1f; \
 vtcode ## testnum : \
   li x1, val1; \
   inst f0, x1; \
@@ -381,7 +385,7 @@ test_ ## testnum: \
   la  a5, test_ ## testnum ## _data ;\
   ld  a1, 0(a5); \
   li a2, 0; \
-  li x28, testnum; \
+  li TESTNUM, testnum; \
 test_loop ## testnum: \
   ld a0,0(a4); \
   beq a0,a1,skip ## testnum; \
@@ -390,7 +394,7 @@ skip ## testnum : \
   addi a4,a4,8; \
   addi a2,a2,1; \
   bne a2,a3,test_loop ## testnum; \
-  b 1f; \
+  j 1f; \
 vtcode ## testnum : \
   li x1, val1; \
   inst f0, x1; \
@@ -529,7 +533,7 @@ test_ ## testnum: \
   fence; \
   li a1,correctval; \
   li a2,0; \
-  li x28, testnum; \
+  li TESTNUM, testnum; \
 test_loop ## testnum: \
   ld a0,0(a4); \
   beq a0,a1,skip ## testnum; \
@@ -587,11 +591,11 @@ next ## testnum :
                  )
 
 #-----------------------------------------------------------------------
-# Pass and fail code (assumes test num is in x28)
+# Pass and fail code (assumes test num is in TESTNUM)
 #-----------------------------------------------------------------------
 
 #define TEST_PASSFAIL \
-        bne x0, x28, pass; \
+        bne x0, TESTNUM, pass; \
 fail: \
         RVTEST_FAIL \
 pass: \