-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenassembly.sh
executable file
·43 lines (34 loc) · 1.75 KB
/
genassembly.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
#!/bin/bash
ROOTDIR=..
FILE=$1
FLAGS=
if [[ "$FILE" == *"xdp"* ]]; then
FLAGS="-target bpf"
fi
# Build with Clang under no optimizations for LLC build.
clang $FLAGS -c -emit-llvm -O0 -o $ROOTDIR/asm/clangandllc/${FILE}.ll $ROOTDIR/src/${FILE}.c
clang $FLAGS -g -c -emit-llvm -O0 -o $ROOTDIR/asm/clangandllc/${FILE}_debug.ll $ROOTDIR/src/${FILE}.c
# Loop through 0 - 3 optimizations.
x=0
while [ $x -lt 4 ]
do
# LLC (Intel and non-Intel) without debug.
llc -filetype=asm -O=$x -o $ROOTDIR/asm/clangandllc/main/${FILE}O${x}_intel.s --x86-asm-syntax=intel $ROOTDIR/asm/clangandllc/${FILE}.ll
llc -filetype=asm -O=$x -o $ROOTDIR/asm/clangandllc/main/${FILE}O${x}.s $ROOTDIR/asm/clangandllc/${FILE}.ll
# LLC (Intel and non-Intel) with debug.
llc -filetype=asm -O=$x -o $ROOTDIR/asm/clangandllc/debug/${FILE}O${x}_intel.s --x86-asm-syntax=intel $ROOTDIR/asm/clangandllc/${FILE}_debug.ll
llc -filetype=asm -O=$x -o $ROOTDIR/asm/clangandllc/debug/${FILE}O${x}.s $ROOTDIR/asm/clangandllc/${FILE}_debug.ll
# Clang build.
clang $FLAGS -S -O${x} -o $ROOTDIR/asm/clang/main/${FILE}O${x}.s $ROOTDIR/src/${FILE}.c
clang $FLAGS -g -S -O${x} -o $ROOTDIR/asm/clang/debug/${FILE}O${x}.s $ROOTDIR/src/${FILE}.c
# GCC build.
gcc -S -O${x} -o $ROOTDIR/asm/gcc/main/${FILE}O${x}.s $ROOTDIR/src/${FILE}.c
gcc -g -S -O${x} -o $ROOTDIR/asm/gcc/debug/${FILE}O${x}.s $ROOTDIR/src/${FILE}.c
# If we have an XDP program, also try to include objdump.
if [[ "$FILE" == *"xdp"* ]]; then
clang -target bpf -g -c -O${x} -o $ROOTDIR/asm/objdump/${FILE}O${x}.o $ROOTDIR/src/${FILE}.c
llvm-objdump -S --no-show-raw-insn $ROOTDIR/asm/objdump/${FILE}O${x}.o > $ROOTDIR/asm/objdump/${FILE}O${x}.dmp
fi
# Increment.
x=$(( $x + 1 ))
done