add empty benchmark
[riscv-tests.git] / isa / Makefile
1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
4
5 src_dir := .
6
7 include $(src_dir)/rv64ui/Makefrag
8 include $(src_dir)/rv64uf/Makefrag
9 include $(src_dir)/rv64si/Makefrag
10 include $(src_dir)/rv64mi/Makefrag
11 include $(src_dir)/rv32ui/Makefrag
12 include $(src_dir)/rv32si/Makefrag
13 include $(src_dir)/rv32mi/Makefrag
14 include $(src_dir)/rvall/Makefrag
15
16 default: all
17
18 #--------------------------------------------------------------------
19 # Build rules
20 #--------------------------------------------------------------------
21
22 RISCV_PREFIX ?= riscv64-unknown-elf-
23 RISCV_GCC ?= $(RISCV_PREFIX)gcc
24 ENTROPY ?= -DENTROPY=$(shell echo $$$$)
25 RISCV_GCC_OPTS ?= $(ENTROPY) -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
26 RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
27 RISCV_SIM ?= spike
28 XLEN ?= 64
29
30 vpath %.S $(src_dir)
31
32 #------------------------------------------------------------
33 # Build assembly tests
34
35 %.dump: %
36 $(RISCV_OBJDUMP) $< > $@
37
38 %.out: %
39 $(RISCV_SIM) $< 2> $@
40
41 %.out32: %
42 $(RISCV_SIM) --isa=RV32 $< 2> $@
43
44 define compile_template
45
46 $$($(1)_p_tests): $(1)-p-%: $(1)/%.S
47 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(src_dir)/../env/p -I$(src_dir)/macros/scalar -T$(src_dir)/../env/p/link.ld $$< -o $$@
48 $(1)_tests += $$($(1)_p_tests)
49
50 $$($(1)_v_tests): $(1)-v-%: $(1)/%.S
51 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I$(src_dir)/../env/v -I$(src_dir)/macros/scalar -T$(src_dir)/../env/v/link.ld $(src_dir)/../env/v/entry.S $(src_dir)/../env/v/*.c $$< -lc -o $$@
52 $(1)_tests += $$($(1)_v_tests)
53
54 $(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests))
55
56 $(1): $$($(1)_tests_dump)
57
58 .PHONY: $(1)
59
60 tests += $$($(1)_tests)
61
62 endef
63
64 $(eval $(call compile_template,rvall))
65 $(eval $(call compile_template,rv32ui,-m32))
66 $(eval $(call compile_template,rv32si,-m32))
67 $(eval $(call compile_template,rv32mi,-m32))
68 ifeq ($(XLEN),64)
69 $(eval $(call compile_template,rv64ui))
70 $(eval $(call compile_template,rv64uf))
71 $(eval $(call compile_template,rv64si))
72 $(eval $(call compile_template,rv64mi))
73 endif
74
75 tests_dump = $(addsuffix .dump, $(tests))
76 tests_hex = $(addsuffix .hex, $(tests))
77 tests_out = $(addsuffix .out, $(spike_tests))
78 tests32_out = $(addsuffix .out32, $(spike32_tests))
79
80 run: $(tests_out) $(tests32_out)
81 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
82 $(tests_out) $(tests32_out); echo;
83
84 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out) $(tests32_out)
85
86 #------------------------------------------------------------
87 # Default
88
89 all: $(tests_dump)
90
91 #------------------------------------------------------------
92 # Clean up
93
94 clean:
95 rm -rf $(junk)