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