-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathbuild-output.sh
executable file
·285 lines (257 loc) · 13.1 KB
/
build-output.sh
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/env bash
OS=`uname -s`
echo "OS =" ${OS}
PWD=`pwd`
if [ "$OS" == "Linux" ]; then
TOOLDIR=~/llvm/test
else
TOOLDIR=~/llvm/test
fi
if [ -e /proc/cpuinfo ]; then
procs=`cat /proc/cpuinfo | grep processor | wc -l`
else
procs=1
fi
rm -rf ${TOOLDIR}/cmake_debug_build/* ${TOOLDIR}/src/lib/Target/Cpu0/*
rm -rf output
mkdir output
cp -rf lbdex/Cpu0/* ${TOOLDIR}/src/lib/Target/Cpu0/.
# Chapter 3
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH3_5" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_BUILD_TYPE=Debug \
-DLLVM_TARGETS_TO_BUILD=Cpu0 -G "Unix Makefiles" ../src
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch3.cpp -emit-llvm \
-o ch3.bc
# Replace \t with " ", Fold 80 characters
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch3.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch3.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-filetype=asm ch3.bc -o - |awk '{gsub("\t"," ",$0); print;}' |fold -w 80 \
|awk '{gsub("\t"," ",$0); print;}' > output/ch3.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch3_2.cpp -emit-llvm \
-o ch3_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch3_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch3_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-filetype=asm ch3_2.bc -o - |awk '{gsub("\t"," ",$0); print;}' |fold -w 80 \
|awk '{gsub("\t"," ",$0); print;}' > output/ch3_2.pic.cpu0.s
# Chapter 4
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH4_1" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch4_1_1.cpp -emit-llvm \
-o ch4_1.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch4_1_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch4_1_1.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-filetype=asm ch4_1_1.bc -o - |awk '{gsub("\t"," ",$0); print;}' |fold -w 80 \
|awk '{gsub("\t"," ",$0); print;}' > output/ch4_1_1.pic.cpu0.s
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH4_2" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch4_2.cpp -emit-llvm \
-o ch4_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch4_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch4_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-filetype=asm ch4_2.bc -o - |awk '{gsub("\t"," ",$0); print;}' |fold -w 80 \
|awk '{gsub("\t"," ",$0); print;}' > output/ch4_2.pic.cpu0.s
# Chapter 5
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH5_1" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-filetype=obj ch4_1.bc -o - |awk '{gsub("\t"," ",$0); print;}' |fold -w 80 \
|awk '{gsub("\t"," ",$0); print;}' > output/ch4_1.cpu0.o
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-filetype=obj ch4_2.bc -o - |awk '{gsub("\t"," ",$0); print;}' |fold -w 80 \
|awk '{gsub("\t"," ",$0); print;}' > output/ch4_2.cpu0el.o
# Chapter 6
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH6_1" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch6_1.cpp -emit-llvm \
-o ch6_1.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch6_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch6_1.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-cpu0-use-small-section=true -filetype=asm ch6_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch6_1.pic.t.cpu0.s
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=pic \
-cpu0-use-small-section=false -filetype=asm ch6_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch6_1.pic.f.cpu0.s
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=static \
-cpu0-use-small-section=true -filetype=asm ch6_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch6_1.static.t.cpu0.s
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -relocation-model=static \
-cpu0-use-small-section=false -filetype=asm ch6_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}'|fold -w 80 > output/ch6_1.static.f.cpu0.s
# Chapter 7
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH7_1" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_1.cpp -emit-llvm \
-o ch7_1.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_1.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_1.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_2.cpp -emit-llvm \
-o ch7_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 |awk > output/ch7_2.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_2_2.cpp -emit-llvm \
-o ch7_2_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_2_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_2_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_2_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 |awk > output/ch7_2_2.pic.cpu0.s
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_3.ll -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_3.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_4.cpp -emit-llvm \
-o ch7_4.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_4.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_4.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_4.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_4.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_5.cpp -emit-llvm \
-o ch7_5.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_5.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_5.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_5.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_5.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_5_2.cpp -emit-llvm \
-o ch7_5_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_5_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_5_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_5_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_5_2.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch7_1_vector.cpp -emit-llvm \
-o ch7_1_vector.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch7_1_vector.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_1_vector.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch7_1_vector.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch7_1_vector.pic.cpu0.s
# Chapter 8
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH8_2" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch8_2.cpp -emit-llvm \
-o ch8_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch8_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=static -filetype=asm -stats ch8_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_2.static.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch8_2_longbranch.cpp -emit-llvm \
-o ch8_2_longbranch.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch8_2_longbranch.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_2_longbranch.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032II \
-relocation-model=pic -filetype=asm -force-cpu0-long-branch ch8_2_longbranch.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_2_longbranch.pic.cpu0.s
clang -O1 -target mips-unknown-linux-gnu -c lbdex/input/ch8_3.cpp -emit-llvm \
-o ch8_3.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch8_3.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_3.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch8_3.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_3.pic.cpu0.s
# Chapter 9
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH9_2" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch9_1.cpp -emit-llvm \
-o ch9_1.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch9_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_1.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch9_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_1.pic.cpu0.s
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH9_3" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch9_3_bswap.cpp -emit-llvm \
-o ch9_3_bswap.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch9_3_bswap.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_3_bswap.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch9_3_bswap.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_3_bswap.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch9_3_detect_exception.cpp -emit-llvm \
-o ch9_3_detect_exception.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch9_3_detect_exception.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_3_detect_exception.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch9_3_detect_exception.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_3_detect_exception.pic.cpu0.s
clang -target mips-unknown-linux-gnu -c lbdex/input/ch9_3_frame_return_addr.cpp -emit-llvm \
-o ch9_3_frame_return_addr.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch9_3_frame_return_addr.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_3_frame_return_addr.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=asm ch9_3_frame_return_addr.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch9_3_frame_return_addr.pic.cpu0.s
# Chapter 10
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH10_1" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch8_1_1.cpp -emit-llvm \
-o ch8_1_1.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch8_1_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_1_1.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=obj -stats ch8_1_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_1_1.cpu0.o
${TOOLDIR}/cmake_debug_build/bin/llvm-objdump -d - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch8_1_1.cpu0.o.hex
# Chapter 11
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH11_1" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch11_1.cpp -emit-llvm \
-o ch11_1.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch11_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch11_1.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=pic -filetype=obj -stats ch11_1.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch11_1.cpu0.o
${TOOLDIR}/cmake_debug_build/bin/llvm-objdump -d - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch11_1.cpu0.o.hex
pushd ${TOOLDIR}/cmake_debug_build
echo "#define CH CH11_2" > ../src/lib/Target/Cpu0/Cpu0SetChapter.h
make -j$procs -l$procs
popd
clang -target mips-unknown-linux-gnu -c lbdex/input/ch11_2.cpp -emit-llvm \
-o ch11_2.bc
${TOOLDIR}/cmake_debug_build/bin/llvm-dis ch11_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch11_2.ll
${TOOLDIR}/cmake_debug_build/bin/llc -march=cpu0 -mcpu=cpu032I \
-relocation-model=static -filetype=obj -stats ch11_2.bc -o - |awk \
'{gsub("\t"," ",$0); print;}'|fold -w 80 > output/ch11_2.cpu0.o
${TOOLDIR}/cmake_debug_build/bin/llvm-objdump -d - |awk \
'{gsub("\t"," ",$0); print;}' |fold -w 80 > output/ch11_2.cpu0.o.hex