-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
130 lines (96 loc) · 4.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
compile:
mill -i fudian.compile
bsp:
mill -i mill.bsp.BSP/install
clean:
rm -rf ./build
reformat:
mill -i __.reformat
checkformat:
mill -i __.checkFormat
init:
git submodule update --init
berkeley-softfloat-3/build/Linux-x86_64-GCC/softfloat.a: berkeley-softfloat-3/.git
$(MAKE) -C berkeley-softfloat-3/build/Linux-x86_64-GCC SPECIALIZE_TYPE=RISCV
berkeley-testfloat-3/build/Linux-x86_64-GCC/testfloat_gen: berkeley-testfloat-3/.git \
berkeley-softfloat-3/build/Linux-x86_64-GCC/softfloat.a
$(MAKE) -C berkeley-testfloat-3/build/Linux-x86_64-GCC SPECIALIZE_TYPE=RISCV
TEST_FLOAT_GEN = berkeley-testfloat-3/build/Linux-x86_64-GCC/testfloat_gen
SEED ?= $(shell shuf -i 1-100000 -n 1)
TEST_FLOAT_OPTS = -tininessafter -exact -level 1 -seed $(SEED)
BUILD_DIR = $(abspath ./build)
CSRC_DIR = $(abspath ./src/test/resources/csrc)
SCALA_SRC = $(shell find ./src/main/scala -name "*.scala")
fadd_tests: f32_add_tests f64_add_tests
fmul_tests: f32_mul_tests f64_mul_tests
fma_tests: f32_mulAdd_tests f64_mulAdd_tests
fdiv_tests: f32_div_tests f64_div_tests
fsqrt_tests: f32_sqrt_tests f64_sqrt_tests
fn_to_int32_tests: f32_to_ui32_tests f32_to_i32_tests f64_to_ui32_tests f64_to_i32_tests
fn_to_int64_tests: f32_to_ui64_tests f32_to_i64_tests f64_to_ui64_tests f64_to_i64_tests
fp_to_int_tests: fn_to_int32_tests fn_to_int64_tests
int32_to_fn_tests: ui32_to_f64_tests i32_to_f64_tests ui32_to_f32_tests i32_to_f32_tests
int64_to_fn_tests: ui64_to_f64_tests i64_to_f64_tests ui64_to_f32_tests i64_to_f32_tests
int_to_fp_tests: int32_to_fn_tests int64_to_fn_tests
fp_to_fp_tests: f64_to_f32_tests f32_to_f64_tests
fcmp_tests: f32_eq_tests f32_le_tests f32_lt_tests f64_eq_tests f64_le_tests f64_lt_tests
all_tests: fadd_tests fmul_tests fma_tests fp_to_int_tests int_to_fp_tests fcmp_tests
define test_template
$(1)_emu = $$(BUILD_DIR)/$(2)_$(3)/$(2).emu
$(1)_v = $$(BUILD_DIR)/$(2)_$(3)/$(2).v
$$($(1)_v): $$(SCALA_SRC)
mill -i fudian.tests.runMain fudian.Generator --fu $(2) --ftype $(3) --full-stacktrace -td $$(@D)
$$($(1)_emu): $$($(1)_v) $$(CSRC_DIR)/$(2)_Test.cpp
verilator --cc --exe $$^ -Mdir $$(@D) -o $$@ --build
$(1)_test_rnear_even: $$($(1)_emu)
$$(TEST_FLOAT_GEN) $$(TEST_FLOAT_OPTS) $(1) -rnear_even | $$< -rnear_even $(4)
$(1)_test_rminMag: $$($(1)_emu)
$$(TEST_FLOAT_GEN) $$(TEST_FLOAT_OPTS) $(1) -rminMag | $$< -rminMag $(4)
$(1)_test_rmin: $$($(1)_emu)
$$(TEST_FLOAT_GEN) $$(TEST_FLOAT_OPTS) $(1) -rmin | $$< -rmin $(4)
$(1)_test_rmax: $$($(1)_emu)
$$(TEST_FLOAT_GEN) $$(TEST_FLOAT_OPTS) $(1) -rmax | $$< -rmax $(4)
$(1)_test_rnear_maxMag: $$($(1)_emu)
$$(TEST_FLOAT_GEN) $$(TEST_FLOAT_OPTS) $(1) -rnear_maxMag | $$< -rnear_maxMag $(4)
$(1)_tests: $(1)_test_rnear_even \
$(1)_test_rminMag \
$(1)_test_rmin \
$(1)_test_rmax \
$(1)_test_rnear_maxMag
endef
$(eval $(call test_template,f32_add,FADD,32,add))
$(eval $(call test_template,f32_sub,FADD,32,sub))
$(eval $(call test_template,f64_add,FADD,64,add))
$(eval $(call test_template,f64_sub,FADD,64,sub))
$(eval $(call test_template,f32_mul,FMUL,32))
$(eval $(call test_template,f64_mul,FMUL,64))
$(eval $(call test_template,f32_mulAdd,FCMA,32))
$(eval $(call test_template,f64_mulAdd,FCMA,64))
$(eval $(call test_template,f32_div,FDIV,32,div))
$(eval $(call test_template,f64_div,FDIV,64,div))
$(eval $(call test_template,f32_sqrt,FDIV,32,sqrt))
$(eval $(call test_template,f64_sqrt,FDIV,64,sqrt))
$(eval $(call test_template,f64_to_ui64,FPToInt,64,f_to_ui64))
$(eval $(call test_template,f64_to_i64,FPToInt,64,f_to_i64))
$(eval $(call test_template,f32_to_ui64,FPToInt,32,f_to_ui64))
$(eval $(call test_template,f32_to_i64,FPToInt,32,f_to_i64))
$(eval $(call test_template,f64_to_ui32,FPToInt,64,f_to_ui32))
$(eval $(call test_template,f64_to_i32,FPToInt,64,f_to_i32))
$(eval $(call test_template,f32_to_ui32,FPToInt,32,f_to_ui32))
$(eval $(call test_template,f32_to_i32,FPToInt,32,f_to_i32))
$(eval $(call test_template,ui32_to_f64,IntToFP,64,ui32_to_f))
$(eval $(call test_template,i32_to_f64,IntToFP,64,i32_to_f))
$(eval $(call test_template,ui32_to_f32,IntToFP,32,ui32_to_f))
$(eval $(call test_template,i32_to_f32,IntToFP,32,i32_to_f))
$(eval $(call test_template,ui64_to_f64,IntToFP,64,ui64_to_f))
$(eval $(call test_template,i64_to_f64,IntToFP,64,i64_to_f))
$(eval $(call test_template,ui64_to_f32,IntToFP,32,ui64_to_f))
$(eval $(call test_template,i64_to_f32,IntToFP,32,i64_to_f))
$(eval $(call test_template,f32_eq,FCMP,32,eq))
$(eval $(call test_template,f32_le,FCMP,32,le))
$(eval $(call test_template,f32_lt,FCMP,32,lt))
$(eval $(call test_template,f64_eq,FCMP,64,eq))
$(eval $(call test_template,f64_le,FCMP,64,le))
$(eval $(call test_template,f64_lt,FCMP,64,lt))
$(eval $(call test_template,f32_to_f64,FPToFP,32_64))
$(eval $(call test_template,f64_to_f32,FPToFP,64_32))