forked from lucvoo/sparse
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sparsec
executable file
·62 lines (51 loc) · 958 Bytes
/
sparsec
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
#!/bin/sh
#
# GCC compatible C compiler based on Sparse LLVM
set +e
SPARSEOPTS=""
DIRNAME=`dirname $0`
NEED_LINK=1
if [ $# -eq 0 ]; then
echo "`basename $0`: no input files"
exit 1
fi
while [ $# -gt 0 ]; do
case $1 in
'-o')
OUTFILE=$2
shift
;;
'-c')
NEED_LINK=0
;;
*)
SPARSEOPTS="$SPARSEOPTS $1 " ;;
esac
shift
done
TMPFILE=`mktemp -t tmp.XXXXXX`
LLC=`"${LLVM_CONFIG:-llvm-config}" --bindir`/llc
LLC_ARCH_OPTS=
case "$(uname -s)" in
*CYGWIN*)
# cygwin uses the sjlj (setjmp-longjmp) exception model
LLC_ARCH_OPTS="-exception-model=sjlj"
LLC_ARCH_OPTS="$LLC_ARCH_OPTS -mtriple=$(llvm-config --host-target)"
;;
*)
;;
esac
$DIRNAME/sparse-llvm $SPARSEOPTS | $LLC ${LLC_ARCH_OPTS} | as -o $TMPFILE
if [ $NEED_LINK -eq 1 ]; then
if [ -z $OUTFILE ]; then
OUTFILE=a.out
fi
gcc $TMPFILE -o $OUTFILE
rm -f $TMPFILE
else
if [ -z $OUTFILE ]; then
echo "`basename $0`: no output file"
exit 1
fi
mv $TMPFILE $OUTFILE
fi