change riscv-isa-run to spike
[riscv-tests.git] / isa / Makefile
1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
4
5 include rv64ui/Makefrag
6 include rv64uf/Makefrag
7 include rv64uv/Makefrag
8 include rv64si/Makefrag
9 include rv64sv/Makefrag
10 include rv32ui/Makefrag
11
12 default: all
13
14 #--------------------------------------------------------------------
15 # Build rules
16 #--------------------------------------------------------------------
17
18 RISCV_GCC = riscv-gcc
19 RISCV_GCC_OPTS = -nostdlib -nostartfiles
20 RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.data --section=.bss
21 RISCV_SIM = spike
22
23 #------------------------------------------------------------
24 # Build assembly tests
25
26 %.hex: %
27 elf2hex 16 16384 $< > $@
28
29 %.dump: %
30 $(RISCV_OBJDUMP) $< > $@
31
32 %.out: %
33 $(RISCV_SIM) $< 2> $@
34
35 define compile_template
36
37 $$($(1)_p_tests): $(1)-p-%: $(1)/%.S
38 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I../env/p -I./macros/scalar -T../env/p/link.ld $$< -o $$@
39 tests += $$($(1)_p_tests)
40
41 $$($(1)_pt_tests): $(1)-pt-%: $(1)/%.S
42 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I../env/pt -I./macros/scalar -T../env/p/link.ld $$< -o $$@
43 tests += $$($(1)_pt_tests)
44
45 $$($(1)_pm_tests): $(1)-pm-%: $(1)/%.S
46 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I../env/pm -I./macros/scalar -T../env/pm/link.ld $$< -o $$@
47 tests += $$($(1)_pm_tests)
48
49 $$($(1)_v_tests): $(1)-v-%: $(1)/%.S
50 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I../env/v -I./macros/scalar -T../env/v/link.ld ../env/v/entry.S ../env/v/vm.c $$< -lc -o $$@
51 tests += $$($(1)_v_tests)
52
53 $$($(1)_p_vec_tests): $(1)-p-vec-%: $(1)/%.S
54 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I../env/p -I./macros/vector -T../env/p/link.ld $$< -o $$@
55 tests += $$($(1)_p_vec_tests)
56
57 $$($(1)_pt_vec_tests): $(1)-pt-vec-%: $(1)/%.S
58 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I../env/pt -I./macros/vector -T../env/pt/link.ld $$< -o $$@
59 tests += $$($(1)_pt_vec_tests)
60
61 $$($(1)_v_vec_tests): $(1)-v-vec-%: $(1)/%.S
62 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I../env/v -I./macros/vector -T../env/v/link.ld ../env/v/entry.S ../env/v/vm.c $$< -lc -o $$@
63 tests += $$($(1)_v_vec_tests)
64
65 endef
66
67 $(eval $(call compile_template,rv32ui,-m32))
68 $(eval $(call compile_template,rv64ui))
69 $(eval $(call compile_template,rv64uf))
70 $(eval $(call compile_template,rv64uv))
71 $(eval $(call compile_template,rv64si))
72 $(eval $(call compile_template,rv64sv))
73
74 tests_dump = $(addsuffix .dump, $(tests))
75 tests_hex = $(addsuffix .hex, $(tests))
76 tests_out = $(addsuffix .out, $(spike_tests))
77
78 run: $(tests_out)
79 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
80 $(tests_out); echo;
81
82 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out)
83
84 #------------------------------------------------------------
85 # Default
86
87 all: $(tests_dump) $(tests_hex)
88
89 #------------------------------------------------------------
90 # Clean up
91
92 clean:
93 rm -rf $(junk)