modified VL and MVL CSRs to range from 1-XLEN rather than 0-(XLEN-1)
[riscv-tests.git] / isa / macros / simplev / sv_test_macros.h
1 #define SV_REG_CSR(type, regkey, elwidth, regidx, isvec) \
2 (regkey | (elwidth<<5) | (type<<7) | (regidx<<8) | (isvec<<15))
3 #define SV_PRED_CSR(type, regkey, zero, inv, regidx, packed) \
4 (regkey | (zero<<5) | (inv<<6) | (type<<7) | (regidx<<8) | (packed<<15))
5
6 #define SET_SV_CSR( type, regkey, elwidth, regidx, isvec) \
7 li x1, SV_REG_CSR( type, regkey, elwidth, regidx, isvec); \
8 csrrw x0, 0x4c0, x1
9
10 #define SET_SV_PRED_CSR( type, regkey, zero, inv, regidx, packed ) \
11 li x1, SV_PRED_CSR( type, regkey, zero, inv, regidx, packed ); \
12 csrrw x0, 0x4c8, x1
13
14 #define SET_SV_2CSRS( c1, c2 ) \
15 li x1, c1 | ((c2)<<16); \
16 csrrw x0, 0x4c0, x1
17
18 #define SET_SV_2PREDCSRS( c1, c2 ) \
19 li x1, c1 | ((c2)<<16); \
20 csrrw x0, 0x4c8, x1
21
22 #define CLR_SV_CSRS( ) csrrw x0, 0x4c0, 0
23 #define CLR_SV_PRED_CSRS( ) csrrw x0, 0x4c8, 0
24
25 #define SET_SV_MVL( val ) csrrwi x0, 0x4f1, (val-1)
26 #define SET_SV_VL( val ) csrrwi x0, 0x4f0, (val-1)
27
28 #define SV_LD_DATA( reg, from, offs ) \
29 la x1, from; \
30 lw reg, offs(x1)
31
32 #define SV_FLD_DATA( reg, from, offs ) \
33 la x1, from; \
34 fld reg, offs(x1)
35
36 #define TEST_SV_IMM( reg, imm ) \
37 li t6, imm; \
38 bne reg, t6, fail
39
40 #define TEST_SV_FD( flags, freg, from, offs ) \
41 fsflags x2, x0; \
42 li x1, flags; \
43 bne x2, x1, fail; \
44 la x1, from; \
45 ld x1, offs(x1); \
46 fmv.x.d x2, freg; \
47 bne x2, x1, fail