-Subproject commit f3545105d54ab746efac58b96e998a252cafd16b
+Subproject commit 9c4e0839779f302720173ad063fa25366cef21f7
# 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( testnum, 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( testnum, 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( testnum, x6, result, \
li x4, 0; \
1: li x1, val1; \
- inst x3, x1, imm; \
+ inst x3, x1, SEXT_IMM(imm); \
TEST_INSERT_NOPS_ ## nop_cycles \
addi x6, x3, 0; \
addi x4, x4, 1; \
li x4, 0; \
1: li x1, val1; \
TEST_INSERT_NOPS_ ## nop_cycles \
- inst x3, x1, imm; \
+ inst x3, x1, SEXT_IMM(imm); \
addi x4, x4, 1; \
li x5, 2; \
bne x4, x5, 1b \
#define TEST_IMM_ZEROSRC1( testnum, inst, result, imm ) \
TEST_CASE( testnum, x1, result, \
- inst x1, x0, imm; \
+ inst x1, x0, SEXT_IMM(imm); \
)
#define TEST_IMM_ZERODEST( testnum, inst, val1, imm ) \
TEST_CASE( testnum, x0, 0, \
li x1, val1; \
- inst x0, x1, imm; \
+ inst x0, x1, SEXT_IMM(imm); \
)
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
#define TEST_ILLEGAL_TVEC_REGID( testnum, nxreg, nfreg, inst, reg1, reg2) \
- setpcr status, SR_EI; \
+ csrs status, SR_EI; \
la a0, handler ## testnum; \
- mtpcr a0, evec; \
+ csrw evec, a0; \
vsetcfg nxreg, nfreg; \
li a0, 4; \
vsetvl a0, a0; \
bne a1,a2,fail; \
#define TEST_ILLEGAL_VT_REGID( testnum, nxreg, nfreg, inst, reg1, reg2, reg3) \
- setpcr status, SR_EI; \
+ csrs status, SR_EI; \
la a0, handler ## testnum; \
- mtpcr a0, evec; \
+ csrw evec, a0; \
vsetcfg nxreg, nfreg; \
li a0, 4; \
vsetvl a0, a0; \
# 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; \
)
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); \
)
#-----------------------------------------------------------------------
# Basic tests
#-------------------------------------------------------------
- TEST_CASE( 2, x1, 0x0, mfpcr x1, hartid );
+ TEST_CASE( 2, x1, 0x0, csrr x1, hartid );
TEST_PASSFAIL
# clear pending IPIs then enable interrupts
la a0, handler
- mtpcr a0, evec
- mtpcr x0, clear_ipi
- mfpcr a0, status
+ csrw evec, a0
+ csrw clear_ipi, x0
+ csrr a0, status
li a1, SR_EI | (1 << (IRQ_IPI + SR_IM_SHIFT))
or a0, a0, a1
- mtpcr a0, status
+ csrw status, a0
# wait for all cores to boot
la a0, coreid
blt a1, a3, 1b
# IPI dominoes
- mfpcr a0, hartid
+ csrr a0, hartid
1: bnez a0, 1b
add a0, a0, 1
rem a0, a0, a3
- mtpcr a0, send_ipi
+ csrw send_ipi, a0
1: b 1b
handler:
- mfpcr a0, hartid
+ csrr a0, hartid
bnez a0, 2f
RVTEST_PASS
2: add a0, a0, 1
rem a0, a0, a3
- mtpcr a0, send_ipi
+ csrw send_ipi, a0
1: b 1b
RVTEST_CODE_END
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
li a0,33
slli a0,a0,6
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
li a0,33
vsetcfg a0
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
.word 0xff00002b
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
+ li a0, SR_EA
+ csrs status, a0
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
TEST_ILLEGAL_TVEC_REGID(2, 5, 5, vsd, vx7, a2)
TEST_ILLEGAL_TVEC_REGID(3, 5, 5, vld, vx7, a2)
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
vsetcfg 32,0
li a3,4
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
+ li a0, SR_EA
+ csrs status, a0
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
TEST_ILLEGAL_VT_REGID(2, 5, 5, add, x7, x1, x2)
TEST_ILLEGAL_VT_REGID(3, 5, 5, add, x1, x7, x2)
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
vsetcfg 32,0
li a3,4
RVTEST_RV64S
RVTEST_CODE_BEGIN
-
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
vsetcfg 32,0
li a3,4
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
vsetcfg 32,0
li a3,4
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
vsetcfg 32,0
li a3,4
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
vsetcfg 32,0
li a3,4
RVTEST_RV64S
RVTEST_CODE_BEGIN
- setpcr status, SR_EA # enable accelerator
- setpcr status, SR_EI # enable interrupt
+ li a0, SR_EA | SR_EI
+ csrs status, a0
la a3,handler
- mtpcr a3,evec # set exception handler
+ csrw evec,a3 # set exception handler
- mfpcr a3,status
+ csrr a3,status
li a4,(1 << IRQ_COP)
slli a4,a4,SR_IM_SHIFT
or a3,a3,a4 # enable IM[COP]
- mtpcr a3,status
+ csrw status,a3
- setpcr status, SR_U64
- clearpcr status, SR_S # clear S bit
+ la a0, SR_U64
+ csrs status, a0
+ csrc status, SR_S
privileged_inst:
vxcptcause a3 # privileged inst