-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate.sh
executable file
·60 lines (48 loc) · 1.54 KB
/
generate.sh
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
#!/usr/bin/env zsh
# Usage:
# ./convert.sh file1.smt2
#
# -> theory.cu
set -e
cd $(realpath $(dirname $0))
mkdir -p bin
mkdir -p cxx
if [ "$#" = "0" ]; then
echo 'Supply a theory file' 1>&2
exit 1
fi
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
format() { clang-format - }
transpose() {
while read line; do
if echo $line | grep "size !=" > /dev/null ; then
varsize=$(echo $line | awk '{ print $4 }' | tr -d ')')
fi
echo $line
if echo $line | grep "End program" > /dev/null ; then
echo "int varsize = $varsize;"
fi
done | \
sed 's/abort();/return 1;/' | \
sed 's/extern "C" int/__device__ int/' | \
sed '/size != /,+4d' | \
sed 's/SMTLIB\/BitVector.h/SMTLIB\/BufferRef.h/' | \
sed 's/#include/\/\/ #include/' | \
sed 's/\/\/ Begin program/#include "theory.h"/'
}
smt2cxx() {
docker run --rm -v $(realpath $(dirname ${1})):/out -u $(id -u):$(id -g) \
delcypher/jfs_build:fse_2019 /bin/bash -c \
"/home/user/jfs/build/bin/jfs-opt -standard-passes /out/$(basename ${1}) | /home/user/jfs/build/bin/jfs-smt2cxx -branch-encoding=try-all"
}
for filename in "$@"; do
rm -f theory.cu
if beginswith http "${filename}"; then
wget "${filename}" -O theory.smt2
filename=theory.smt2
fi
smt2cxx "${filename}" | transpose | format > theory.cu
cp theory.cu "cxx/smt-$(basename ${filename} | tr '.' '-')".cxx
make smt
mv smt "bin/smt-$(basename ${filename} | tr '.' '-')"
done