#include "encoding.h"
-#ifdef __riscv64
+#if __riscv_xlen == 64
# define LREG ld
# define SREG sd
# define REGBYTES 8
# make sure XLEN agrees with compilation choice
csrr t0, misa
-#ifdef __riscv64
+#if __riscv_xlen == 64
bltz t0, 1f
#else
bgez t0, 1f
#define STACK_SIZE 512
-#ifdef __riscv64
+#if __riscv_xlen == 64
# define LREG ld
# define SREG sd
# define REGBYTES 8
# update mstatus
csrr t1, CSR_MSTATUS
-#ifdef __riscv32
+#if __riscv_xlen == 32
li t0, (MSTATUS_MPRV | (VM_SV32 << 24))
#else
li t0, (MSTATUS_MPRV | (VM_SV39 << 24))
.balign 0x1000
page_table:
-#ifdef __riscv32
+#if __riscv_xlen == 32
.word ((0x80000000 >> 2) | PTE_V | PTE_R | PTE_W | PTE_X | PTE_G | PTE_U)
#else
.word ((0x80000000 >> 2) | PTE_V | PTE_R | PTE_W | PTE_X | PTE_G | PTE_U)
-#ifdef __riscv64
+#if __riscv_xlen == 64
# define LREG ld
# define SREG sd
# define REGBYTES 8
#include "../../env/encoding.h"
-#ifdef __riscv64
+#if __riscv_xlen == 64
# define LREG ld
# define SREG sd
# define REGBYTES 8
#undef MCONTROL_TYPE
#undef MCONTROL_DMODE
-#ifdef __riscv64
+#if __riscv_xlen == 64
# define MCONTROL_TYPE (0xf<<(64-4))
# define MCONTROL_DMODE (1<<(64-5))
#else
-Subproject commit ce70afbf50a203be04bc326326cfa75831fe7f5d
+Subproject commit 9e219c9ca70459bfda9067d637bb8bf52c5f0326
# Make sure there's a breakpoint there.
csrr a0, tdata1
- srli a0, a0, _RISCV_SZLONG-4
+ srli a0, a0, __riscv_xlen - 4
li a1, 2
bne a0, a1, pass
# Make sure there's a breakpoint there.
csrr a0, tdata1
- srli a0, a0, _RISCV_SZLONG-4
+ srli a0, a0, __riscv_xlen - 4
li a1, 2
bne a0, a1, pass
MISALIGNED_LDST_TEST(5, lw, s0, 2)
MISALIGNED_LDST_TEST(6, lw, s0, 3)
-#ifdef __riscv64
+#if __riscv_xlen == 64
MISALIGNED_LDST_TEST(7, lwu, s0, 1)
MISALIGNED_LDST_TEST(8, lwu, s0, 2)
MISALIGNED_LDST_TEST(9, lwu, s0, 3)
MISALIGNED_LDST_TEST(24, sw, s0, 2)
MISALIGNED_LDST_TEST(25, sw, s0, 3)
-#ifdef __riscv64
+#if __riscv_xlen == 64
MISALIGNED_LDST_TEST(26, sd, s0, 1)
MISALIGNED_LDST_TEST(27, sd, s0, 2)
MISALIGNED_LDST_TEST(28, sd, s0, 3)
RVTEST_CODE_BEGIN
# Check that mcpuid reports the correct XLEN
-#ifdef __riscv64
+#if __riscv_xlen == 64
TEST_CASE(2, a0, 0x2, csrr a0, misa; srl a0, a0, 62)
#else
TEST_CASE(2, a0, 0x1, csrr a0, misa; srl a0, a0, 30)
la a1, data
RVC_TEST_CASE (6, a2, 0xfffffffffedcba99, c.lw a0, 4(a1); addi a0, a0, 1; c.sw a0, 4(a1); c.lw a2, 4(a1))
-#ifdef __riscv64
+#if __riscv_xlen == 64
RVC_TEST_CASE (7, a2, 0xfedcba9976543211, c.ld a0, 0(a1); addi a0, a0, 1; c.sd a0, 0(a1); c.ld a2, 0(a1))
#endif
RVC_TEST_CASE (8, a0, -15, ori a0, x0, 1; c.addi a0, -16)
RVC_TEST_CASE (9, a5, -16, ori a5, x0, 1; c.li a5, -16)
-#ifdef __riscv64
+#if __riscv_xlen == 64
RVC_TEST_CASE (10, a0, 0x76543210, ld a0, (a1); c.addiw a0, -1)
#endif
RVC_TEST_CASE (11, s0, 0xffffffffffffffe1, c.lui s0, 0xfffe1; c.srai s0, 12)
-#ifdef __riscv64
+#if __riscv_xlen == 64
RVC_TEST_CASE (12, s0, 0x000fffffffffffe1, c.lui s0, 0xfffe1; c.srli s0, 12)
#else
RVC_TEST_CASE (12, s0, 0x000fffe1, c.lui s0, 0xfffe1; c.srli s0, 12)
RVC_TEST_CASE (16, s1, 18, li s1, 20; li a0, 6; c.xor s1, a0)
RVC_TEST_CASE (17, s1, 22, li s1, 20; li a0, 6; c.or s1, a0)
RVC_TEST_CASE (18, s1, 4, li s1, 20; li a0, 6; c.and s1, a0)
-#ifdef __riscv64
+#if __riscv_xlen == 64
RVC_TEST_CASE (19, s1, 0xffffffff80000000, li s1, 0x7fffffff; li a0, -1; c.subw s1, a0)
RVC_TEST_CASE (20, s1, 0xffffffff80000000, li s1, 0x7fffffff; li a0, 1; c.addw s1, a0)
#endif
2:j fail; \
1:sub ra, ra, t0)
-#ifdef __riscv32
+#if __riscv_xlen == 32
RVC_TEST_CASE (37, ra, -2, \
la t0, 1f; \
li ra, 0; \
la sp, data
RVC_TEST_CASE (40, a2, 0xfffffffffedcba99, c.lwsp a0, 12(sp); addi a0, a0, 1; c.swsp a0, 12(sp); c.lwsp a2, 12(sp))
-#ifdef __riscv64
+#if __riscv_xlen == 64
RVC_TEST_CASE (41, a2, 0xfedcba9976543211, c.ldsp a0, 8(sp); addi a0, a0, 1; c.sdsp a0, 8(sp); c.ldsp a2, 8(sp))
#endif
TEST_INT_FP_OP_S( 4, fcvt.s.wu, 2.0, 2);
TEST_INT_FP_OP_S( 5, fcvt.s.wu, 4.2949673e9, -2);
-#ifndef __riscv32
+#if __riscv_xlen >= 64
TEST_INT_FP_OP_S( 6, fcvt.s.l, 2.0, 2);
TEST_INT_FP_OP_S( 7, fcvt.s.l, -2.0, -2);
TEST_FP_INT_OP_S(18, fcvt.wu.s, 0x10, 0, -3e9, rtz);
TEST_FP_INT_OP_S(19, fcvt.wu.s, 0x00, 3000000000, 3e9, rtz);
-#ifndef __riscv32
+#if __riscv_xlen >= 64
TEST_FP_INT_OP_S(22, fcvt.l.s, 0x01, -1, -1.1, rtz);
TEST_FP_INT_OP_S(23, fcvt.l.s, 0x00, -1, -1.0, rtz);
TEST_FP_INT_OP_S(24, fcvt.l.s, 0x01, 0, -0.9, rtz);
# test negative NaN, negative infinity conversion
TEST_CASE( 42, x1, 0x000000007fffffff, la x1, tdat ; flw f1, 0(x1); fcvt.w.s x1, f1)
TEST_CASE( 44, x1, 0xffffffff80000000, la x1, tdat ; flw f1, 8(x1); fcvt.w.s x1, f1)
-#ifndef __riscv32
+#if __riscv_xlen >= 64
TEST_CASE( 43, x1, 0x7fffffffffffffff, la x1, tdat ; flw f1, 0(x1); fcvt.l.s x1, f1)
TEST_CASE( 45, x1, 0x8000000000000000, la x1, tdat ; flw f1, 8(x1); fcvt.l.s x1, f1)
#endif
# test positive NaN, positive infinity conversion
TEST_CASE( 52, x1, 0x000000007fffffff, la x1, tdat ; flw f1, 4(x1); fcvt.w.s x1, f1)
TEST_CASE( 54, x1, 0x000000007fffffff, la x1, tdat ; flw f1, 12(x1); fcvt.w.s x1, f1)
-#ifndef __riscv32
+#if __riscv_xlen >= 64
TEST_CASE( 53, x1, 0x7fffffffffffffff, la x1, tdat ; flw f1, 4(x1); fcvt.l.s x1, f1)
TEST_CASE( 55, x1, 0x7fffffffffffffff, la x1, tdat ; flw f1, 12(x1); fcvt.l.s x1, f1)
#endif
TEST_CASE( 63, x1, 0xffffffffffffffff, la x1, tdat ; flw f1, 4(x1); fcvt.wu.s x1, f1)
TEST_CASE( 64, x1, 0, la x1, tdat ; flw f1, 8(x1); fcvt.wu.s x1, f1)
TEST_CASE( 65, x1, 0xffffffffffffffff, la x1, tdat ; flw f1, 12(x1); fcvt.wu.s x1, f1)
-#ifndef __riscv32
+#if __riscv_xlen >= 64
TEST_CASE( 66, x1, 0xffffffffffffffff, la x1, tdat ; flw f1, 0(x1); fcvt.lu.s x1, f1)
TEST_CASE( 67, x1, 0xffffffffffffffff, la x1, tdat ; flw f1, 4(x1); fcvt.lu.s x1, f1)
TEST_CASE( 68, x1, 0, la x1, tdat ; flw f1, 8(x1); fcvt.lu.s x1, f1)
TEST_RR_OP( 19, sll, 0x0000001090909080, 0x0000000021212121, 0xffffffffffffffc7 );
TEST_RR_OP( 20, sll, 0x0000084848484000, 0x0000000021212121, 0xffffffffffffffce );
-#ifdef __riscv64
+#if __riscv_xlen == 64
TEST_RR_OP( 21, sll, 0x8000000000000000, 0x0000000021212121, 0xffffffffffffffff );
TEST_RR_OP( 50, sll, 0x8000000000000000, 0x0000000000000001, 63 );
TEST_RR_OP( 51, sll, 0xffffff8000000000, 0xffffffffffffffff, 39 );
TEST_IMM_OP( 15, slli, 0x0000084848484000, 0x0000000021212121, 14 );
TEST_IMM_OP( 16, slli, 0x1090909080000000, 0x0000000021212121, 31 );
-#ifdef __riscv64
+#if __riscv_xlen == 64
TEST_RR_OP( 50, sll, 0x8000000000000000, 0x0000000000000001, 63 );
TEST_RR_OP( 51, sll, 0xffffff8000000000, 0xffffffffffffffff, 39 );
TEST_RR_OP( 52, sll, 0x0909080000000000, 0x0000000021212121, 43 );
#-------------------------------------------------------------
#define TEST_SRL(n, v, a) \
- TEST_RR_OP(n, srl, ((v) & ((1 << (_RISCV_SZLONG-1) << 1) - 1)) >> (a), v, a)
+ TEST_RR_OP(n, srl, ((v) & ((1 << (__riscv_xlen-1) << 1) - 1)) >> (a), v, a)
TEST_SRL( 2, 0xffffffff80000000, 0 );
TEST_SRL( 3, 0xffffffff80000000, 1 );
#-------------------------------------------------------------
#define TEST_SRL(n, v, a) \
- TEST_IMM_OP(n, srli, ((v) & ((1 << (_RISCV_SZLONG-1) << 1) - 1)) >> (a), v, a)
+ TEST_IMM_OP(n, srli, ((v) & ((1 << (__riscv_xlen-1) << 1) - 1)) >> (a), v, a)
TEST_SRL( 2, 0xffffffff80000000, 0 );
TEST_SRL( 3, 0xffffffff80000000, 1 );