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