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