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