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