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