f4dab3fdd23760d38f2f1bb40d38190e13d8a630
[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)/rv32si/Makefrag
22 include $(src_dir)/rv32mi/Makefrag
23
24 default: all
25
26 #--------------------------------------------------------------------
27 # Build rules
28 #--------------------------------------------------------------------
29
30 RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
31 RISCV_GCC ?= $(RISCV_PREFIX)gcc
32 ENTROPY ?= -DENTROPY=$(shell echo $$$$)
33 RISCV_GCC_OPTS ?= $(ENTROPY) -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) -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,-m32))
72 $(eval $(call compile_template,rv32uc,-m32))
73 $(eval $(call compile_template,rv32um,-m32))
74 $(eval $(call compile_template,rv32ua,-m32))
75 $(eval $(call compile_template,rv32si,-m32))
76 $(eval $(call compile_template,rv32mi,-m32))
77 ifeq ($(XLEN),64)
78 $(eval $(call compile_template,rv64ui))
79 $(eval $(call compile_template,rv64uc))
80 $(eval $(call compile_template,rv64um))
81 $(eval $(call compile_template,rv64ua))
82 $(eval $(call compile_template,rv64uf))
83 $(eval $(call compile_template,rv64ud))
84 $(eval $(call compile_template,rv64si))
85 $(eval $(call compile_template,rv64mi))
86 endif
87
88 tests_dump = $(addsuffix .dump, $(tests))
89 tests_hex = $(addsuffix .hex, $(tests))
90 tests_out = $(addsuffix .out, $(spike_tests))
91 tests32_out = $(addsuffix .out32, $(spike32_tests))
92
93 run: $(tests_out) $(tests32_out)
94 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
95 $(tests_out) $(tests32_out); echo;
96
97 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out) $(tests32_out)
98
99 #------------------------------------------------------------
100 # Default
101
102 all: $(tests_dump)
103
104 #------------------------------------------------------------
105 # Clean up
106
107 clean:
108 rm -rf $(junk)