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