sparse, llvm: Improve sparsec front-end
[smatch.git] / sparsec
blob1e5c8bd05bd6526d48d3c46eb2b50cf2662f255e
1 #!/bin/sh
3 # GCC compatible C compiler based on Sparse LLVM
5 SPARSEOPTS=""
6 DIRNAME=`dirname $0`
8 NEED_LINK=1
10 if [ $# -eq 0 ]; then
11 echo "`basename $0`: no input files"
12 exit 1
15 while [ $# -gt 0 ]; do
16 case $1 in
17 '-o')
18 OUTFILE=$2
19 shift
21 '-c')
22 NEED_LINK=0
25 SPARSEOPTS="$SPARSEOPTS $1 " ;;
26 esac
27 shift
28 done
30 TMPFILE=`mktemp -t tmp.XXXXXX`".o"
32 $DIRNAME/sparse-llvm $SPARSEOPTS | llc | as -o $TMPFILE
34 if [ $NEED_LINK -eq 1 ]; then
35 if [ -z $OUTFILE ]; then
36 OUTFILE=a.out
38 gcc $TMPFILE -o $OUTFILE
39 else
40 if [ -z $OUTFILE ]; then
41 echo "`basename $0`: no output file"
42 exit 1
44 mv $TMPFILE $OUTFILE