-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile_cc
177 lines (152 loc) · 7.06 KB
/
Makefile_cc
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.SUFFIXES: # no built-in rules
DIR=build
QEMU = qemu-arm-static
$(info $(shell mkdir -p $(DIR)))
LOCAL_TESTS = malloc.a32.asm linkerdef.a32.asm
TESTS = int_op.asm \
reg_torture_f32.asm \
reg_torture.asm \
cmp.asm \
memaddr.32.asm \
switch.asm \
indirect.32.asm \
fib.asm \
fib_debug.asm \
queens.32.asm \
stack.asm \
multiple_results.asm \
multiple_results_f32.asm \
multiple_results_f64.asm \
pfannkuchen.32.asm
TEST_C_EXES = $(TESTS:%.asm=$(DIR)/%.asm.c.exe) $(LOCAL_TESTS:%.asm=$(DIR)/%.asm.c.exe)
tests: $(TEST_C_EXES) $(DIR)/isel_test_c $(DIR)/codegen_parity $(DIR)/nanojpeg_c
@echo "[OK C++ CodeGenA32]"
STD_LIB_NO_ARGV = ../StdLib/startup_no_argv.asm ../StdLib/syscall.a32.asm ../StdLib/std_lib.32.asm
STD_LIB_WITH_ARGV = ../StdLib/startup.a32.asm ../StdLib/syscall.a32.asm ../StdLib/std_lib.32.asm
############################################################
# Code Gen
############################################################
isel_gen.cc: isel_tab.py ../Base/opcode_tab.py
@echo "[$@]"
$(PYPY) ./isel_tab.py gen_c <$@ > $(DIR)/$@.tmp
@mv $(DIR)/$@.tmp $@
isel_gen.h: isel_tab.py ../Base/opcode_tab.py
@echo "[$@]"
$(PYPY) ./isel_tab.py gen_h <$@ > $(DIR)/$@.tmp
@mv $(DIR)/$@.tmp $@
GENERATED = isel_gen.cc isel_gen.h
############################################################
# C++
############################################################
BUILD_DIR=../../build
CODEGEN_TOOL=$(BUILD_DIR)/a32_codegen_tool.exe
$(CODEGEN_TOOL):
@cd $(BUILD_DIR); $(MAKE) -s a32_codegen_tool.exe
$(DIR)/%.asm.c.exe: ../TestData/%.asm $(CODEGEN_TOOL)
@echo "[integration $@]"
cat $(STD_LIB_NO_ARGV) $< | $(CODEGEN_TOOL) -mode binary - $@ >$@.out
@chmod a+rx $@
${QEMU} $@ > $@.actual.out
diff $@.actual.out $<.golden
# same as above but from local TestData dir
$(DIR)/%.asm.c.exe: TestData/%.asm $(CODEGEN_TOOL)
@echo "[integration $@]"
cat $(STD_LIB_NO_ARGV) $< | $(CODEGEN_TOOL) -mode binary - $@ >$@.out
@chmod a+rx $@
${QEMU} $@ > $@.actual.out
diff $@.actual.out $<.golden
$(DIR)/isel_test_c: isel_gen.h isel_gen.cc
@echo "[integration $@]"
@cd $(BUILD_DIR); $(MAKE) -s a32_isel_tester.exe
$(BUILD_DIR)/a32_isel_tester.exe < TestData/codegen_test.asm > $@.actual.out
diff $@.actual.out TestData/codegen_test.asm.golden
$(DIR)/nanojpeg_c: $(CODEGEN_TOOL)
@echo "[$@]"
cat $(STD_LIB_WITH_ARGV) ../TestData/nano_jpeg.32.asm | $(CODEGEN_TOOL) -mode binary - $@.exe >$@.out
@chmod a+rx $@.exe
${QEMU} $@.exe ../TestData/ash_tree.jpg $@.ppm
md5sum $@.ppm | sed -e "s|$@.ppm|nanojpeg.ppm|" > $@.actual
diff $@.actual ../TestData/nano_jpeg.golden
# called from toplevel
benchmark: $(CODEGEN_TOOL)
@echo "[$@]"
wc TestData/benchmark.asm
time $(CODEGEN_TOOL) -mode binary TestData/benchmark.asm $(DIR)/$@.exe > $(DIR)/$@.out
############################################################
# Parity
############################################################
TEST_MODE = normal
#TEST_MODE = reg_alloc_local
#TEST_MODE = reg_alloc_global
# ensure identical output when emitting textual assembly between
# python and c++ implementations
$(DIR)/codegen_parity: isel_gen.h isel_gen.cc $(CODEGEN_TOOL)
@echo "[$@]"
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/threads.32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
cat $(STD_LIB_NO_ARGV) ../TestData/threads.32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/int_op.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
cat $(STD_LIB_NO_ARGV) ../TestData/int_op.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/cmp.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
cat $(STD_LIB_NO_ARGV) ../TestData/cmp.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/reg_torture.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
cat $(STD_LIB_NO_ARGV) ../TestData/reg_torture.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) TestData/linkerdef.a32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) TestData/linkerdef.a32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/multiple_results_f64.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/multiple_results_f64.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/multiple_results_f32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/multiple_results_f32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/fib.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/fib.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/queens.32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/queens.32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/reg_torture_f32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/reg_torture_f32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/stack.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/stack.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/switch.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/switch.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_NO_ARGV) ../TestData/memaddr.32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_NO_ARGV) ../TestData/memaddr.32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
@echo
cat $(STD_LIB_WITH_ARGV) ../TestData/nano_jpeg.32.asm | $(CODEGEN_TOOL) -mode $(TEST_MODE) - $@_c.out
cat $(STD_LIB_WITH_ARGV) ../TestData/nano_jpeg.32.asm | $(PYPY) ./codegen.py -mode $(TEST_MODE) - $@.out
diff $@_c.out $@.out
regenerate_cpua32_tests:
#cat $(STD_LIB_NO_ARGV) ../TestData/memaddr.32.asm | $(CODEGEN_TOOL) -mode normal - ../CpuA32/TestData/memaddr.asm
#cat $(STD_LIB_NO_ARGV) ../TestData/fib.asm | $(CODEGEN_TOOL) -mode normal - ../CpuA32/TestData/fib.asm
cat $(STD_LIB_NO_ARGV) ../TestData/nano_jpeg.32.asm | $(CODEGEN_TOOL) -mode normal - ../CpuA32/TestData/nanojpeg.asm
#cat $(STD_LIB_NO_ARGV) ../TestData/switch.asm | $(CODEGEN_TOOL) -mode normal - ../CpuA32/TestData/switch.asm
############################################################
# Misc
############################################################
clean:
rm -f $(DIR)/* $(CODEGEN_TOOL)
bug:
cat $(STD_LIB) TestData/reg_test1.asm | $(PYPY) ./codegen.py normal - -