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