Coherence torture test for VM tests
[riscv-tests.git] / isa / Makefile
1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
4
5 isa_src_dir := .
6
7 include $(isa_src_dir)/rv64ui/Makefrag
8 include $(isa_src_dir)/rv64uf/Makefrag
9 include $(isa_src_dir)/rv64uv/Makefrag
10 include $(isa_src_dir)/rv64si/Makefrag
11 include $(isa_src_dir)/rv64sv/Makefrag
12 include $(isa_src_dir)/rv64mi/Makefrag
13 include $(isa_src_dir)/rv32ui/Makefrag
14 include $(isa_src_dir)/rv32si/Makefrag
15 include $(isa_src_dir)/rv32mi/Makefrag
16
17 default: all
18
19 #--------------------------------------------------------------------
20 # Build rules
21 #--------------------------------------------------------------------
22
23 RISCV_PREFIX=riscv64-unknown-elf-
24 RISCV_GCC = $(RISCV_PREFIX)gcc
25 ENTROPY = -DENTROPY=$(shell echo $$$$)
26 RISCV_GCC_OPTS = $(ENTROPY) -static -fpic -fvisibility=hidden -nostdlib -nostartfiles -Wa,-march=RVIMAFDXhwacha
27 RISCV_OBJDUMP = $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
28 RISCV_SIM = spike --extension=hwacha
29
30 vpath %.S $(isa_src_dir)
31
32 #------------------------------------------------------------
33 # Build assembly tests
34
35 %.hex: %
36 (elf2hex 16 8192 $< 2> /dev/null || elf2hex 16 16384 $<) > $@
37
38 %.dump: %
39 $(RISCV_OBJDUMP) $< > $@
40
41 %.out: %
42 $(RISCV_SIM) $< 2> $@
43
44 %.out32: %
45 $(RISCV_SIM) --isa=RV32 $< 2> $@
46
47 define compile_template
48
49 $$($(1)_p_tests): $(1)-p-%: $(1)/%.S
50 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(isa_src_dir)/../env/p -I$(isa_src_dir)/macros/scalar -T$(isa_src_dir)/../env/p/link.ld $$< -o $$@
51 $(1)_tests += $$($(1)_p_tests)
52
53 $$($(1)_pt_tests): $(1)-pt-%: $(1)/%.S
54 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(isa_src_dir)/../env/pt -I$(isa_src_dir)/macros/scalar -T$(isa_src_dir)/../env/pt/link.ld $$< -o $$@
55 $(1)_tests += $$($(1)_pt_tests)
56
57 $$($(1)_pm_tests): $(1)-pm-%: $(1)/%.S
58 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(isa_src_dir)/../env/pm -I$(isa_src_dir)/macros/scalar -T$(isa_src_dir)/../env/pm/link.ld $$< -o $$@
59 $(1)_tests += $$($(1)_pm_tests)
60
61 $$($(1)_v_tests): $(1)-v-%: $(1)/%.S
62 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I$(isa_src_dir)/../env/v -I$(isa_src_dir)/macros/scalar -T$(isa_src_dir)/../env/v/link.ld $(isa_src_dir)/../env/v/entry.S $(isa_src_dir)/../env/v/vm.c $$< -lc -o $$@
63 $(1)_tests += $$($(1)_v_tests)
64
65 $$($(1)_p_vec_tests): $(1)-p-vec-%: $(1)/%.S
66 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(isa_src_dir)/../env/p -I$(isa_src_dir)/macros/vector -T$(isa_src_dir)/../env/p/link.ld $$< -o $$@
67 $(1)_tests += $$($(1)_p_vec_tests)
68
69 $$($(1)_pt_vec_tests): $(1)-pt-vec-%: $(1)/%.S
70 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(isa_src_dir)/../env/pt -I$(isa_src_dir)/macros/vector -T$(isa_src_dir)/../env/pt/link.ld $$< -o $$@
71 $(1)_tests += $$($(1)_pt_vec_tests)
72
73 $$($(1)_v_vec_tests): $(1)-v-vec-%: $(1)/%.S
74 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I$(isa_src_dir)/../env/v -I$(isa_src_dir)/macros/vector -T$(isa_src_dir)/../env/v/link.ld $(isa_src_dir)/../env/v/entry.S $(isa_src_dir)/../env/v/vm.c $$< -lc -o $$@
75 $(1)_tests += $$($(1)_v_vec_tests)
76
77 $(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests))
78 $(1)_tests_hex = $$(addsuffix .hex, $$($(1)_tests))
79
80 $(1): $$($(1)_tests_dump) $$($(1)_tests_hex)
81
82 .PHONY: $(1)
83
84 tests += $$($(1)_tests)
85
86 endef
87
88 $(eval $(call compile_template,rv32ui,-m32))
89 $(eval $(call compile_template,rv32si,-m32))
90 $(eval $(call compile_template,rv32mi,-m32))
91 $(eval $(call compile_template,rv64ui))
92 $(eval $(call compile_template,rv64uf))
93 $(eval $(call compile_template,rv64uv))
94 $(eval $(call compile_template,rv64si))
95 $(eval $(call compile_template,rv64sv))
96 $(eval $(call compile_template,rv64mi))
97
98 tests_dump = $(addsuffix .dump, $(tests))
99 tests_hex = $(addsuffix .hex, $(tests))
100 tests_out = $(addsuffix .out, $(spike_tests))
101 tests32_out = $(addsuffix .out32, $(spike32_tests))
102
103 run: $(tests_out) $(tests32_out)
104 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
105 $(tests_out) $(tests32_out); echo;
106
107 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out) $(tests32_out)
108
109 #------------------------------------------------------------
110 # Default
111
112 all: $(tests_dump) $(tests_hex)
113
114 #------------------------------------------------------------
115 # Clean up
116
117 clean:
118 rm -rf $(junk)