aboutsummaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-04-30 20:45:27 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-04-30 20:45:27 -0700
commit22742246287feda0be2666ba14ca6f4a6bc73bb2 (patch)
treea15d7df63f796e13e6c28a2ec82a36f68af5c3a5 /benchmarks
parent8dda7b2034197109a2387ac3dd03c7ad1e8c0b65 (diff)
downloadriscv-tests-22742246287feda0be2666ba14ca6f4a6bc73bb2.zip
riscv-tests-22742246287feda0be2666ba14ca6f4a6bc73bb2.tar.gz
riscv-tests-22742246287feda0be2666ba14ca6f4a6bc73bb2.tar.bz2
ERET -> xRET; new memory map
For now, we no longer build hex files, because the programs don't start at address 0. This decision will likely be revisited.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/Makefile10
-rw-r--r--benchmarks/common/crt.S12
-rw-r--r--benchmarks/common/syscalls.c92
-rw-r--r--benchmarks/common/test.ld2
4 files changed, 99 insertions, 17 deletions
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index 1145fed..8cc1e35 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -48,10 +48,10 @@ HOST_COMP = gcc $(HOST_OPTS)
RISCV_PREFIX ?= riscv64-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
-RISCV_GCC_OPTS ?= -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
+RISCV_GCC_OPTS ?= -fpie -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
RISCV_LINK_MT ?= $(RISCV_GCC) -T $(src_dir)/common/test-mt.ld
-RISCV_LINK_OPTS ?= -nostdlib -nostartfiles -ffast-math -lc -lgcc
+RISCV_LINK_OPTS ?= -nostdlib -nostartfiles -ffast-math -lgcc
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
RISCV_SIM ?= spike
@@ -68,15 +68,11 @@ include $(patsubst %, $(src_dir)/%/bmark.mk, $(bmarks))
bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks))
bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
-bmarks_riscv_hex = $(addsuffix .riscv.hex, $(bmarks))
bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
bmarks_defs = -DPREALLOCATE=1 -DHOST_DEBUG=0
bmarks_cycles = 80000
-%.hex: %
- elf2hex 16 32768 $< > $@
-
$(bmarks_riscv_dump): %.riscv.dump: %.riscv
$(RISCV_OBJDUMP) $< > $@
@@ -91,7 +87,7 @@ $(bmarks_riscv_out): %.riscv.out: %.riscv
$(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) -D__ASSEMBLY__=1 \
-c $(incs) $< -o $@
-riscv: $(bmarks_riscv_dump) $(bmarks_riscv_hex)
+riscv: $(bmarks_riscv_dump)
run-riscv: $(bmarks_riscv_out)
echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
$(bmarks_riscv_out); echo;
diff --git a/benchmarks/common/crt.S b/benchmarks/common/crt.S
index 919461b..634b864 100644
--- a/benchmarks/common/crt.S
+++ b/benchmarks/common/crt.S
@@ -15,15 +15,9 @@
.text
.globl _start
_start:
- j handle_reset
+ la t0, trap_entry
+ csrw mtvec, t0
-nmi_vector:
- j nmi_vector
-
-trap_vector:
- j trap_entry
-
-handle_reset:
li x1, 0
li x2, 0
li x3, 0
@@ -216,7 +210,7 @@ trap_entry:
LREG x31, 31*REGBYTES(sp)
addi sp, sp, 272
- eret
+ mret
.section ".tdata.begin"
.globl _tdata_begin
diff --git a/benchmarks/common/syscalls.c b/benchmarks/common/syscalls.c
index 87fd358..4620631 100644
--- a/benchmarks/common/syscalls.c
+++ b/benchmarks/common/syscalls.c
@@ -406,3 +406,95 @@ int sprintf(char* str, const char* fmt, ...)
va_end(ap);
return str - str0;
}
+
+void* memcpy(void* dest, const void* src, size_t len)
+{
+ if ((((uintptr_t)dest | (uintptr_t)src | len) & (sizeof(uintptr_t)-1)) == 0) {
+ const uintptr_t* s = src;
+ uintptr_t *d = dest;
+ while (d < (uintptr_t*)(dest + len))
+ *d++ = *s++;
+ } else {
+ const char* s = src;
+ char *d = dest;
+ while (d < (char*)(dest + len))
+ *d++ = *s++;
+ }
+ return dest;
+}
+
+void* memset(void* dest, int byte, size_t len)
+{
+ if ((((uintptr_t)dest | len) & (sizeof(uintptr_t)-1)) == 0) {
+ uintptr_t word = byte & 0xFF;
+ word |= word << 8;
+ word |= word << 16;
+ word |= word << 16 << 16;
+
+ uintptr_t *d = dest;
+ while (d < (uintptr_t*)(dest + len))
+ *d++ = word;
+ } else {
+ char *d = dest;
+ while (d < (char*)(dest + len))
+ *d++ = byte;
+ }
+ return dest;
+}
+
+size_t strlen(const char *s)
+{
+ const char *p = s;
+ while (*p)
+ p++;
+ return p - s;
+}
+
+size_t strnlen(const char *s, size_t n)
+{
+ const char *p = s;
+ while (n-- && *p)
+ p++;
+ return p - s;
+}
+
+int strcmp(const char* s1, const char* s2)
+{
+ unsigned char c1, c2;
+
+ do {
+ c1 = *s1++;
+ c2 = *s2++;
+ } while (c1 != 0 && c1 == c2);
+
+ return c1 - c2;
+}
+
+char* strcpy(char* dest, const char* src)
+{
+ char* d = dest;
+ while ((*d++ = *src++))
+ ;
+ return dest;
+}
+
+long atol(const char* str)
+{
+ long res = 0;
+ int sign = 0;
+
+ while (*str == ' ')
+ str++;
+
+ if (*str == '-' || *str == '+') {
+ sign = *str == '-';
+ str++;
+ }
+
+ while (*str) {
+ res *= 10;
+ res += *str++ - '0';
+ }
+
+ return sign ? -res : res;
+}
diff --git a/benchmarks/common/test.ld b/benchmarks/common/test.ld
index 00eb4a2..7ee56b6 100644
--- a/benchmarks/common/test.ld
+++ b/benchmarks/common/test.ld
@@ -21,7 +21,7 @@ SECTIONS
{
/* text: test code section */
- . = 0x0;
+ . = 0x80000000;
.text :
{
crt.o(.text)