-
Notifications
You must be signed in to change notification settings - Fork 0
/
generatefilesandperformpasses
77 lines (76 loc) · 1.93 KB
/
generatefilesandperformpasses
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
declare -a passarray=(
"-adce"
"-aggressive-instcombine"
"-always-inline"
"-argpromotion"
"-break-crit-edges"
"-codegenprepare"
"-constmerge"
"-dce"
"-deadargelim"
"-dse"
"-function-attrs"
"-globaldce"
"-globalopt"
"-gvn"
"-indvars"
"-inline"
"-instcombine"
"-internalize"
"-ipsccp"
"-jump-threading"
"-lcssa"
"-licm"
"-loop-deletion"
"-loop-extract"
"-loop-extract-single"
"-loop-reduce"
"-loop-rotate"
"-loop-simplify"
"-loop-unroll"
"-loop-unroll-and-jam"
"-loop-unswitch"
"-loweratomic"
"-lowerinvoke"
"-lowerswitch"
"-mem2reg"
"-memcpyopt"
"-mergefunc"
"-mergereturn"
"-partial-inliner"
"-prune-eh"
"-reassociate"
"-reg2mem"
"-sccp"
"-simplifycfg"
"-sink"
"-sroa"
"-strip"
"-strip-dead-debug-info"
"-strip-dead-prototypes"
"-strip-debug-declare"
"-strip-nondebug"
"-tailcallelim"
)
for i in ${passarray[@]};
do
cd ~/Desktop/tacle;
# Location of your testbench files with .c extension, change ~/Desktop/tacle
~/riscv-new/_install/bin/clang --target=riscv32-unknown-elf -S -emit-llvm -Xclang -disable-O0-optnone -Xclang -disable-llvm-passes *.c;
# Use your clang, change ~/riscv-new/_install/bin/clang
# and if necessary use
# --sysroot=/home/shc/riscv-new/_install/riscv64-unknown-elf --gcc-toolchain=/home/shc/riscv-new/_install/
# flags as --sysroot="{your-riscv-gnu-toolchain-install-or-build-path}/riscv64-unknown-elf" --gcc-toolchain="{your-riscv-gnu-toolchain-install-or-build-path}"
# More information here that I answered: https://stackoverflow.com/questions/68580399/using-clang-to-compile-for-risc-v
mkdir -p ~/tactr/$i && mv *.ll ~/tactr/$i;
# Give an empty file location instead of both ~/tactr
cd ~/tactr/$i; for file in *.ll;
# Give same file location above instead of ~/tactr
do
echo ""; echo "${file##*/}"; echo "";
~/llvm/llvm-project/build/bin/opt -S $i "${file##*/}" -o "${file##*/}";
# Use your opt tool, change ~/llvm/llvm-project/build/bin/opt
done;
clang-11 -S --target=riscv32-unknown-elf *.ll
# Use your clang, change clang-11
done