-----------------------------
We assume that the RISCV environment variable is set to the RISC-V tools
-install path, and that the riscv-gcc package is installed.
+install path, and that the riscv-gnu-toolchain package is installed.
$ git clone https://github.com/ucb-bar/riscv-tests
$ cd riscv-tests
HOST_OPTS = -std=gnu99 -DPREALLOCATE=0 -DHOST_DEBUG=1
HOST_COMP = gcc $(HOST_OPTS)
-RISCV_GCC = riscv-gcc
+RISCV_PREFIX=riscv64-unknown-elf-
+RISCV_GCC = $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS = -static -Wa,-march=RVIMAFDXhwacha -std=gnu99 -O2 -ffast-math
-RISCV_LINK = riscv-gcc -T $(bmarkdir)/common/test.ld $(incs)
-RISCV_LINK_MT = riscv-gcc -T $(bmarkdir)/common/test-mt.ld
+RISCV_LINK = $(RISCV_GCC) -T $(bmarkdir)/common/test.ld $(incs)
+RISCV_LINK_MT = $(RISCV_GCC) -T $(bmarkdir)/common/test-mt.ld
RISCV_LINK_OPTS = -nostdlib -nostartfiles -ffast-math -lc
-RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
+RISCV_OBJDUMP = $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
RISCV_SIM = spike
VPATH += $(addprefix $(bmarkdir)/, $(bmarks))
csrr a1, epc
mv a2, sp
jal handle_trap
- csrw epc, v0
+ csrw epc, a0
LREG t0, 256(sp)
LREG t1, 264(sp)
// In setStats, we might trap reading uarch-specific counters.
// The trap handler will skip over the instruction and write 0,
-// but only if v0 is the destination register.
-#define read_csr_safe(reg) ({ register long __tmp asm("v0"); \
+// but only if a0 is the destination register.
+#define read_csr_safe(reg) ({ register long __tmp asm("a0"); \
asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \
__tmp; })
static int handle_stats(int enable)
{
//use csrs to set stats register
- if(enable) {
- asm volatile (R"(
- addi v0, x0, 1
- csrrs v0, stats, v0
- )" : : : "v0");
- }
+ if (enable)
+ asm volatile ("csrrs a0, stats, 1" ::: "a0");
int i = 0;
#define READ_CTR(name) do { \
while (i >= NUM_COUNTERS) ; \
READ_CTR(uarch8); READ_CTR(uarch9); READ_CTR(uarch10); READ_CTR(uarch11);
READ_CTR(uarch12); READ_CTR(uarch13); READ_CTR(uarch14); READ_CTR(uarch15);
#undef READ_CTR
- if(!enable) {
- asm volatile (R"(
- addi v0, x0, 1
- csrrc v0, stats, v0
- )" : : : "v0");
- }
+ if (!enable)
+ asm volatile ("csrrc a0, stats, 1" ::: "a0");
return 0;
}
long handle_trap(long cause, long epc, long regs[32])
{
- int csr_insn;
- asm volatile ("lw %0, 1f; j 2f; 1: csrr v0, stats; 2:" : "=r"(csr_insn));
+ int* csr_insn;
+ asm ("jal %0, 1f; csrr a0, stats; 1:" : "=r"(csr_insn));
long sys_ret = 0;
if (cause == CAUSE_ILLEGAL_INSTRUCTION &&
- (*(int*)epc & csr_insn) == csr_insn)
+ (*(int*)epc & *csr_insn) == *csr_insn)
;
else if (cause != CAUSE_SYSCALL)
tohost_exit(1337);
- else if (regs[16] == SYS_exit)
- tohost_exit(regs[18]);
- else if (regs[16] == SYS_stats)
- sys_ret = handle_stats(regs[18]);
+ else if (regs[17] == SYS_exit)
+ tohost_exit(regs[10]);
+ else if (regs[17] == SYS_stats)
+ sys_ret = handle_stats(regs[10]);
else
- sys_ret = handle_frontend_syscall(regs[16], regs[18], regs[19], regs[20]);
+ sys_ret = handle_frontend_syscall(regs[17], regs[10], regs[11], regs[12]);
- regs[16] = sys_ret;
+ regs[10] = sys_ret;
return epc+4;
}
static long syscall(long num, long arg0, long arg1, long arg2)
{
- register long v0 asm("v0") = num;
+ register long a7 asm("a7") = num;
register long a0 asm("a0") = arg0;
register long a1 asm("a1") = arg1;
register long a2 asm("a2") = arg2;
- asm volatile ("scall" : "+r"(v0) : "r"(a0), "r"(a1), "r"(a2) : "s0");
- return v0;
+ asm volatile ("scall" : "+r"(a0) : "r"(a1), "r"(a2), "r"(a7));
+ return a0;
}
void exit(int code)
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
- for ac_prog in riscv-gcc
+ for ac_prog in riscv64-unknown-elf-gcc
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
fi
if test -z "$CC"; then
ac_ct_CC=$CC
- for ac_prog in riscv-gcc
+ for ac_prog in riscv64-unknown-elf-gcc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
AC_INIT(riscv-tests, 1.0)
cross_compiling=yes
-AC_PROG_CC([riscv-gcc])
+AC_PROG_CC([riscv64-unknown-elf-gcc])
AC_OUTPUT(
Makefile
-Subproject commit cb2f03b341e9b9e2f05e5e0bf999bb7a08904991
+Subproject commit 9be35353ecb3252ec62b86d446c43ba89843b0b4
# Build rules
#--------------------------------------------------------------------
-RISCV_GCC = riscv-gcc
+RISCV_PREFIX=riscv64-unknown-elf-
+RISCV_GCC = $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS = -static -fpic -fvisibility=hidden -nostdlib -nostartfiles -Wa,-march=RVIMAFDXhwacha
-RISCV_OBJDUMP = riscv-objdump --disassemble-all --section=.text --section=.data --section=.bss
+RISCV_OBJDUMP = $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
RISCV_SIM = spike --extension=hwacha
vpath %.S $(isa_src_dir)
# Build rules
#--------------------------------------------------------------------
-RISCV_GCC = riscv-gcc
+RISCV_PREFIX=riscv64-unknown-elf-
+RISCV_GCC = $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS = -Wa,-march=RVIMAFDXhwacha -std=gnu99 -O2 -ffast-math
-RISCV_LINK = riscv-gcc -T $(common)/test.ld $(incs)
+RISCV_LINK = $(RISCV_GCC) -T $(common)/test.ld $(incs)
RISCV_LINK_OPTS = -nostdlib -nostartfiles -ffast-math -lc
-RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
+RISCV_OBJDUMP = $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
RISCV_SIM = spike -p2
VPATH += $(common) $(common)/../mt-matmul $(common)/../mt-vvadd