1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
7 include $(isa_src_dir
)/rv64ui
/Makefrag
8 include $(isa_src_dir
)/rv64uf
/Makefrag
9 include $(isa_src_dir
)/rv64uv
/Makefrag
10 include $(isa_src_dir
)/rv64si
/Makefrag
11 include $(isa_src_dir
)/rv64sv
/Makefrag
12 include $(isa_src_dir
)/rv64mi
/Makefrag
13 include $(isa_src_dir
)/rv32ui
/Makefrag
14 include $(isa_src_dir
)/rv32si
/Makefrag
15 include $(isa_src_dir
)/rv32mi
/Makefrag
19 #--------------------------------------------------------------------
21 #--------------------------------------------------------------------
23 RISCV_PREFIX
=riscv64-unknown-elf-
24 RISCV_GCC
= $(RISCV_PREFIX
)gcc
25 ENTROPY
= -DENTROPY
=$(shell echo
$$$$)
26 RISCV_GCC_OPTS
= $(ENTROPY
) -static
-mcmodel
=medany
-fvisibility
=hidden
-nostdlib
-nostartfiles
-Wa
,-march
=RVIMAFDXhwacha
27 RISCV_OBJDUMP
= $(RISCV_PREFIX
)objdump
--disassemble-all
--disassemble-zeroes
--section
=.text
--section
=.text.startup
--section
=.text.init
--section
=.data
28 RISCV_SIM
= spike
--extension
=hwacha
30 vpath
%.S
$(isa_src_dir
)
32 #------------------------------------------------------------
33 # Build assembly tests
36 (elf2hex
16 8192 $< 2> /dev
/null || elf2hex
16 16384 $<) > $@
39 $(RISCV_OBJDUMP
) $< > $@
45 $(RISCV_SIM
) --isa
=RV32
$< 2> $@
47 define compile_template
49 $$($(1)_p_tests
): $(1)-p-
%: $(1)/%.S
50 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -I
$(isa_src_dir
)/..
/env
/p
-I
$(isa_src_dir
)/macros
/scalar
-T
$(isa_src_dir
)/..
/env
/p
/link.
ld $$< -o
$$@
51 $(1)_tests
+= $$($(1)_p_tests
)
53 $$($(1)_pt_tests
): $(1)-pt-
%: $(1)/%.S
54 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -I
$(isa_src_dir
)/..
/env
/pt
-I
$(isa_src_dir
)/macros
/scalar
-T
$(isa_src_dir
)/..
/env
/pt
/link.
ld $$< -o
$$@
55 $(1)_tests
+= $$($(1)_pt_tests
)
57 $$($(1)_pm_tests
): $(1)-pm-
%: $(1)/%.S
58 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -I
$(isa_src_dir
)/..
/env
/pm
-I
$(isa_src_dir
)/macros
/scalar
-T
$(isa_src_dir
)/..
/env
/pm
/link.
ld $$< -o
$$@
59 $(1)_tests
+= $$($(1)_pm_tests
)
61 $$($(1)_v_tests
): $(1)-v-
%: $(1)/%.S
62 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -std
=gnu99
-O2
-I
$(isa_src_dir
)/..
/env
/v
-I
$(isa_src_dir
)/macros
/scalar
-T
$(isa_src_dir
)/..
/env
/v
/link.
ld $(isa_src_dir
)/..
/env
/v
/entry.S
$(isa_src_dir
)/..
/env
/v
/vm.c
$$< -lc
-o
$$@
63 $(1)_tests
+= $$($(1)_v_tests
)
65 $$($(1)_p_vec_tests
): $(1)-p-vec-
%: $(1)/%.S
66 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -I
$(isa_src_dir
)/..
/env
/p
-I
$(isa_src_dir
)/macros
/vector
-T
$(isa_src_dir
)/..
/env
/p
/link.
ld $$< -o
$$@
67 $(1)_tests
+= $$($(1)_p_vec_tests
)
69 $$($(1)_pt_vec_tests
): $(1)-pt-vec-
%: $(1)/%.S
70 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -I
$(isa_src_dir
)/..
/env
/pt
-I
$(isa_src_dir
)/macros
/vector
-T
$(isa_src_dir
)/..
/env
/pt
/link.
ld $$< -o
$$@
71 $(1)_tests
+= $$($(1)_pt_vec_tests
)
73 $$($(1)_v_vec_tests
): $(1)-v-vec-
%: $(1)/%.S
74 $$(RISCV_GCC
) $(2) $$(RISCV_GCC_OPTS
) -std
=gnu99
-O2
-I
$(isa_src_dir
)/..
/env
/v
-I
$(isa_src_dir
)/macros
/vector
-T
$(isa_src_dir
)/..
/env
/v
/link.
ld $(isa_src_dir
)/..
/env
/v
/entry.S
$(isa_src_dir
)/..
/env
/v
/vm.c
$$< -lc
-o
$$@
75 $(1)_tests
+= $$($(1)_v_vec_tests
)
77 $(1)_tests_dump
= $$(addsuffix .dump
, $$($(1)_tests
))
78 $(1)_tests_hex
= $$(addsuffix .hex
, $$($(1)_tests
))
80 $(1): $$($(1)_tests_dump
) $$($(1)_tests_hex
)
84 tests
+= $$($(1)_tests
)
88 $(eval
$(call compile_template
,rv32ui
,-m32
))
89 $(eval
$(call compile_template
,rv32si
,-m32
))
90 $(eval
$(call compile_template
,rv32mi
,-m32
))
91 $(eval
$(call compile_template
,rv64ui
))
92 $(eval
$(call compile_template
,rv64uf
))
93 $(eval
$(call compile_template
,rv64uv
))
94 $(eval
$(call compile_template
,rv64si
))
95 $(eval
$(call compile_template
,rv64sv
))
96 $(eval
$(call compile_template
,rv64mi
))
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
))
103 run
: $(tests_out
) $(tests32_out
)
104 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
105 $(tests_out
) $(tests32_out
); echo
;
107 junk
+= $(tests
) $(tests_dump
) $(tests_hex
) $(tests_out
) $(tests32_out
)
109 #------------------------------------------------------------
112 all: $(tests_dump
) $(tests_hex
)
114 #------------------------------------------------------------