Debian Codegraph @

tests/riscv-official/isa/Makefile

raw
1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
4
5 XLEN ?= 64
6
7 src_dir := .
8
9 isa_dir := ../riscv-tests/isa
10
11 ifeq ($(XLEN),64)
12 include $(isa_dir)/rv64ui/Makefrag
13 include $(isa_dir)/rv64ua/Makefrag
14 include $(isa_dir)/rv64si/Makefrag
15 include $(isa_dir)/rv64mi/Makefrag
16 include $(isa_dir)/rv64um/Makefrag
17 endif
18 include $(isa_dir)/rv32ui/Makefrag
19 include $(isa_dir)/rv32ua/Makefrag
20 include $(isa_dir)/rv32si/Makefrag
21 include $(isa_dir)/rv32mi/Makefrag
22 include $(isa_dir)/rv32um/Makefrag
23
24 default: clean all
25
26 #--------------------------------------------------------------------
27 # Build rules
28 #--------------------------------------------------------------------
29
30 include toolchain_setup
31
32 vpath %.S $(isa_dir) $(self_test)
33
34 #------------------------------------------------------------
35 # Build assembly tests
36
37 %.dump: %
38 $(RISCV_OBJDUMP) elf/$< > dump/$@
39
40 %.out: %
41 $(RISCV_SIM) --isa=rv64gc $< 2> $@
42
43 %.out32: %
44 $(RISCV_SIM) --isa=rv32gc $< 2> $@
45
46 define compile_template
47
48
49
50 $$($(1)_p_tests): $(1)-p-%: $(1)/%.S
51 $$(RISCV_COMPILER) $(2) $$(RISCV_COMPILER_OPTS) -I$(src_dir)/../env/p -I$(isa_dir)/macros/scalar -T$(src_dir)/../env/p/link.ld $$< -o elf/$$@
52 $(1)_tests += $$($(1)_p_tests)
53
54 $(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests))
55
56 $(1): $$($(1)_tests_dump)
57
58 .PHONY: $(1)
59
60 COMPILER_SUPPORTS_$(1) := $$(shell $$(RISCV_COMPILER) $(2) -c -x c /dev/null -o /dev/null 2> /dev/null; echo $$$$?)
61
62 ifeq ($$(COMPILER_SUPPORTS_$(1)),0)
63 tests += $$($(1)_tests)
64 endif
65
66 endef
67 $(eval $(call compile_template,rv32ui, $(MARCH_OPTS_32)))
68 $(eval $(call compile_template,rv32um, $(MARCH_OPTS_32)))
69 $(eval $(call compile_template,rv32ua, $(MARCH_OPTS_32)))
70 $(eval $(call compile_template,rv32si, $(MARCH_OPTS_32)))
71 $(eval $(call compile_template,rv32mi, $(MARCH_OPTS_32)))
72 ifeq ($(XLEN),64)
73 $(eval $(call compile_template,rv64ui, $(MARCH_OPTS_64)))
74 $(eval $(call compile_template,rv64um, $(MARCH_OPTS_64)))
75 $(eval $(call compile_template,rv64ua, $(MARCH_OPTS_64)))
76 $(eval $(call compile_template,rv64si, $(MARCH_OPTS_64)))
77 $(eval $(call compile_template,rv64mi, $(MARCH_OPTS_64)))
78 endif
79
80 tests_dump = $(addsuffix .dump, $(tests))
81 tests_hex = $(addsuffix .hex, $(tests))
82 tests_out = $(addsuffix .out, $(filter rv64%,$(tests)))
83 tests32_out = $(addsuffix .out32, $(filter rv32%,$(tests)))
84
85 run: $(tests_out) $(tests32_out)
86
87 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out) $(tests32_out)
88
89 #------------------------------------------------------------
90
91 self-tests:
92 cd selftests && make
93
94 all: $(tests_dump) self-tests
95
96 #------------------------------------------------------------
97 # Clean up
98
99 clean:
100 rm -rf $(junk)
101 rm -fr elf/*
102 rm -fr dump/*
103 rm -fr $(self_test)/elf/*