$ cat b.c
__IN__ glob;
__RET__ test___NM__(__IN__ a, __IN__ b) {
return a __OPC__ b;
}
__RET__ test___NM___sext(__IN__ a, __IN__ b) {
return -(a __OPC__ b);
}
__RET__ test___NM___z(__IN__ a) {
return a __OPC__ 0;
}
__RET__ test___NM___sext_z(__IN__ a) {
return -(a __OPC__ 0);
}
void test___NM___store(__IN__ a, __IN__ b) {
glob = (a __OPC__ b);
}
void test___NM___sext_store(__IN__ a, __IN__ b) {
glob = -(a __OPC__ b);
}
void test___NM___z_store(__IN__ a) {
glob = (a __OPC__ 0);
}
void test___NM___sext_z_store(__IN__ a) {
glob = -(a __OPC__ 0);
}
$ cat getTCs.sh
for ret in int 'long long'
do
for input in 'signed char' 'unsigned char' 'signed short' 'unsigned short' 'signed int' 'unsigned int' 'signed long long' 'unsigned long long'
do
for opc in '==' '!=' '<' '>' '<=' '>='
do
NAME=$(echo $ret | sed 's/int/i/;s/long long/ll/;')
NAME=$NAME$(echo $opc | sed 's/==/eq/;s/!=/ne/;s/<=/le/;s/>=/ge/;s/</lt/;s/>/gt/;')
NAME=$NAME$(echo $input | sed 's/unsigned/u/g;s/signed/s/g;s/char/c/g;s/short/s/g;s/int/i/g;s/long long/ll/g;s/ //g;')
echo NAME: $NAME
sed "s/__RET__/$ret/g;s/__IN__/$input/g;s/__OPC__/$opc/g;s/__NM__/$NAME/g;" b.c > testCompares$NAME.c
done
done
done
$ ./getTCs.sh
$ ls testCompares* | while read FILE; do echo '#if 0' > tmp; echo "GCC generated code:" >> tmp; \
/home/llvm/gcc/install/gcc-6.2.0/bin/gcc -O2 -S -o - $FILE >> tmp; echo '#endif' >> tmp; cat tmp >> $FILE; done
No comments:
Post a Comment