Remove Hwacha macros
[riscv-tests.git] / isa / Makefile
1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
4
5 XLEN ?= 64
6
7 src_dir := .
8
9 include $(src_dir)/rv64ui/Makefrag
10 include $(src_dir)/rv64uc/Makefrag
11 include $(src_dir)/rv64um/Makefrag
12 include $(src_dir)/rv64ua/Makefrag
13 include $(src_dir)/rv64uf/Makefrag
14 include $(src_dir)/rv64ud/Makefrag
15 include $(src_dir)/rv64si/Makefrag
16 include $(src_dir)/rv64mi/Makefrag
17 include $(src_dir)/rv32ui/Makefrag
18 include $(src_dir)/rv32uc/Makefrag
19 include $(src_dir)/rv32um/Makefrag
20 include $(src_dir)/rv32ua/Makefrag
21 include $(src_dir)/rv32uf/Makefrag
22 include $(src_dir)/rv32si/Makefrag
23 include $(src_dir)/rv32mi/Makefrag
24
25 default: all
26
27 #--------------------------------------------------------------------
28 # Build rules
29 #--------------------------------------------------------------------
30
31 RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
32 RISCV_GCC ?= $(RISCV_PREFIX)gcc
33 RISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
34 RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
35 RISCV_SIM ?= spike
36
37 vpath %.S $(src_dir)
38
39 #------------------------------------------------------------
40 # Build assembly tests
41
42 %.dump: %
43 $(RISCV_OBJDUMP) $< > $@
44
45 %.out: %
46 $(RISCV_SIM) $< 2> $@
47
48 %.out32: %
49 $(RISCV_SIM) --isa=RV32 $< 2> $@
50
51 define compile_template
52
53 $$($(1)_p_tests): $(1)-p-%: $(1)/%.S
54 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(src_dir)/../env/p -I$(src_dir)/macros/scalar -T$(src_dir)/../env/p/link.ld $$< -o $$@
55 $(1)_tests += $$($(1)_p_tests)
56
57 $$($(1)_v_tests): $(1)-v-%: $(1)/%.S
58 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -DENTROPY=0x$$(shell echo \$$@ | md5sum | cut -c 1-7) -std=gnu99 -O2 -I$(src_dir)/../env/v -I$(src_dir)/macros/scalar -T$(src_dir)/../env/v/link.ld $(src_dir)/../env/v/entry.S $(src_dir)/../env/v/*.c $$< -lc -o $$@
59 $(1)_tests += $$($(1)_v_tests)
60
61 $(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests))
62
63 $(1): $$($(1)_tests_dump)
64
65 .PHONY: $(1)
66
67 tests += $$($(1)_tests)
68
69 endef
70
71 $(eval $(call compile_template,rv32ui,-march=rv32g -mabi=ilp32))
72 $(eval $(call compile_template,rv32uc,-march=rv32g -mabi=ilp32))
73 $(eval $(call compile_template,rv32um,-march=rv32g -mabi=ilp32))
74 $(eval $(call compile_template,rv32ua,-march=rv32g -mabi=ilp32))
75 $(eval $(call compile_template,rv32uf,-march=rv32g -mabi=ilp32))
76 $(eval $(call compile_template,rv32si,-march=rv32g -mabi=ilp32))
77 $(eval $(call compile_template,rv32mi,-march=rv32g -mabi=ilp32))
78 ifeq ($(XLEN),64)
79 $(eval $(call compile_template,rv64ui,-march=rv64g -mabi=lp64))
80 $(eval $(call compile_template,rv64uc,-march=rv64g -mabi=lp64))
81 $(eval $(call compile_template,rv64um,-march=rv64g -mabi=lp64))
82 $(eval $(call compile_template,rv64ua,-march=rv64g -mabi=lp64))
83 $(eval $(call compile_template,rv64uf,-march=rv64g -mabi=lp64))
84 $(eval $(call compile_template,rv64ud,-march=rv64g -mabi=lp64))
85 $(eval $(call compile_template,rv64si,-march=rv64g -mabi=lp64))
86 $(eval $(call compile_template,rv64mi,-march=rv64g -mabi=lp64))
87 endif
88
89 tests_dump = $(addsuffix .dump, $(tests))
90 tests_hex = $(addsuffix .hex, $(tests))
91 tests_out = $(addsuffix .out, $(spike_tests))
92 tests32_out = $(addsuffix .out32, $(spike32_tests))
93
94 run: $(tests_out) $(tests32_out)
95 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
96 $(tests_out) $(tests32_out); echo;
97
98 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out) $(tests32_out)
99
100 #------------------------------------------------------------
101 # Default
102
103 all: $(tests_dump)
104
105 #------------------------------------------------------------
106 # Clean up
107
108 clean:
109 rm -rf $(junk)