-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile
executable file
·106 lines (105 loc) · 2.46 KB
/
compile
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
spo=31500
if [ "$1" = "" ]; then
echo ""
echo "this script compiles and assembles a source .c code assuming OISC mode"
echo "stack pointer initial value:" $spo
echo "supported architectures: arm, riscv, mipsel, x86"
echo ""
echo "error: expected two arguments, e.g., ./compile examples/sensor arm"
exit 1
fi
if [ "$2" = "" ]; then
echo ""
echo "this script compiles and assembles a source .c code assuming OISC mode"
echo "stack pointer initial value:" $spo
echo "supported architectures: arm, riscv, mipsel, x86"
echo ""
echo "error: expected two arguments, e.g., ./compile examples/sensor arm"
exit 1
fi
if [ "$3" = "" ]; then
arch=''
else
arch=$3
fi
if [ "$4" = "" ]; then
llcc='std'
else
llcc=$4
fi
filename="$1"
if [ "$2" = "riscv" ]; then
echo "compiling for RISC-V architectures (OISC mode):"
python3 mc.py -in $filename -out $filename -arch riscv32,generic-rv32 -spo $spo
if [ $? -eq 0 ]; then
echo "assembling:"
python3 m.py -in $filename -out $filename
if [ $? -eq 0 ]; then
echo "done."
else
exit 1
fi
else
exit 1
fi
fi
if [ "$2" = "mipsel" ]; then
echo "compiling for MIPS architectures (OISC mode):"
python3 mc.py -in $filename -out $filename -arch mipsel,mips32r2 -spo $spo
if [ $? -eq 0 ]; then
echo "assembling:"
python3 m.py -in $filename -out $filename
if [ $? -eq 0 ]; then
echo "done."
else
exit 1
fi
else
exit 1
fi
fi
if [ "$2" = "x86" ]; then
echo "compiling for X86 architectures (OISC mode):"
python3 mc.py -in $filename -out $filename -arch x86,i486 -spo $spo
if [ $? -eq 0 ]; then
echo "assembling:"
python3 m.py -in $filename -out $filename
if [ $? -eq 0 ]; then
echo "done."
else
exit 1
fi
else
exit 1
fi
fi
if [ "$2" = "arm" ]; then
echo "compiling for ARM architectures (OISC mode):"
python3 mc.py -in $filename -out $filename -arch arm,arm9 -spo $spo
if [ $? -eq 0 ]; then
echo "assembling:"
python3 m.py -in $filename -out $filename
if [ $? -eq 0 ]; then
echo "done."
else
exit 1
fi
else
exit 1
fi
fi
if [ "$2" = "ll" ]; then
echo "compiling with LLVM IR (OISC mode):"
python3 mc.py -in $filename -out $filename -arch ll,$arch -spo $spo -llcc $llcc
if [ $? -eq 0 ]; then
echo "assembling:"
python3 m.py -in $filename -out $filename
if [ $? -eq 0 ]; then
echo "done."
else
exit 1
fi
else
exit 1
fi
fi