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
)/rv64si
/Makefrag
10 include $(isa_src_dir
)/rv64mi
/Makefrag
11 include $(isa_src_dir
)/rv32ui
/Makefrag
12 include $(isa_src_dir
)/rv32si
/Makefrag
13 include $(isa_src_dir
)/rv32mi
/Makefrag
17 #--------------------------------------------------------------------
19 #--------------------------------------------------------------------
21 RISCV_PREFIX
=riscv64-unknown-elf-
22 RISCV_GCC
= $(RISCV_PREFIX
)gcc
23 ENTROPY
= -DENTROPY
=$(shell echo
$$$$)
24 RISCV_GCC_OPTS
= $(ENTROPY
) -static
-mcmodel
=medany
-fvisibility
=hidden
-nostdlib
-nostartfiles
25 RISCV_OBJDUMP
= $(RISCV_PREFIX
)objdump
--disassemble-all
--disassemble-zeroes
--section
=.text
--section
=.text.startup
--section
=.text.init
--section
=.data
28 vpath
%.S
$(isa_src_dir
)
30 #------------------------------------------------------------
31 # Build assembly tests
34 (elf2hex
16 8192 $< 2> /dev
/null || elf2hex
16 16384 $<) > $@
37 $(RISCV_OBJDUMP
) $< > $@
43 $(RISCV_SIM
) --isa
=RV32
$< 2> $@
45 define compile_template
47 $$($(1)_p_tests
): $(1)-p-
%: $(1)/%.S
48 $$(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
$$@
49 $(1)_tests
+= $$($(1)_p_tests
)
51 $$($(1)_pt_tests
): $(1)-pt-
%: $(1)/%.S
52 $$(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
$$@
53 $(1)_tests
+= $$($(1)_pt_tests
)
55 $$($(1)_pm_tests
): $(1)-pm-
%: $(1)/%.S
56 $$(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
$$@
57 $(1)_tests
+= $$($(1)_pm_tests
)
59 $$($(1)_v_tests
): $(1)-v-
%: $(1)/%.S
60 $$(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
$$@
61 $(1)_tests
+= $$($(1)_v_tests
)
63 $(1)_tests_dump
= $$(addsuffix .dump
, $$($(1)_tests
))
64 $(1)_tests_hex
= $$(addsuffix .hex
, $$($(1)_tests
))
66 $(1): $$($(1)_tests_dump
) $$($(1)_tests_hex
)
70 tests
+= $$($(1)_tests
)
74 $(eval
$(call compile_template
,rv32ui
,-m32
))
75 $(eval
$(call compile_template
,rv32si
,-m32
))
76 $(eval
$(call compile_template
,rv32mi
,-m32
))
77 $(eval
$(call compile_template
,rv64ui
))
78 $(eval
$(call compile_template
,rv64uf
))
79 $(eval
$(call compile_template
,rv64si
))
80 $(eval
$(call compile_template
,rv64mi
))
82 tests_dump
= $(addsuffix .dump
, $(tests
))
83 tests_hex
= $(addsuffix .hex
, $(tests
))
84 tests_out
= $(addsuffix .out
, $(spike_tests
))
85 tests32_out
= $(addsuffix .out32
, $(spike32_tests
))
87 run
: $(tests_out
) $(tests32_out
)
88 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
89 $(tests_out
) $(tests32_out
); echo
;
91 junk
+= $(tests
) $(tests_dump
) $(tests_hex
) $(tests_out
) $(tests32_out
)
93 #------------------------------------------------------------
96 all: $(tests_dump
) $(tests_hex
)
98 #------------------------------------------------------------