-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinscop
executable file
·35 lines (25 loc) · 1.18 KB
/
inscop
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
#!/bin/bash
# arguments
# inscop <original> <transformed_kernel> <output_file>
# transformed_kernel and output_file can be the same
#
MAXLINES=`wc -l $1 | awk '{print $1}'`
grep -B $MAXLINES "#pragma[[:space:]]\+scop" $1 | grep -v "#pragma[[:space:]]\+scop" > .head
grep -A $MAXLINES "#pragma[[:space:]]\+endscop" $1 | grep -v "#pragma[[:space:]]\+endscop" > .tail
cat .head > __tmp
# The gcc preprocessor inserts some useless comments like "# 1 "<built-in>"
# preprocessor doesn't like pragma's in #defines and so it was not put in from pluto
# when '--bee' was used - instead we will add it here
cat $2 | grep "^#include" > .includes
cat $2 | grep -v "^#include" > .body.c
gcc -E -P -CC .body.c | grep -v "^# " | sed -e 's/__bee_schedule/#pragma schedule/' | \
sed -e 's/_NL_DELIMIT_/\n/' >> __tmp
cat .tail >> __tmp
cat .includes > .head
echo "#include <math.h>" >> .head
echo "#define ceild(n,d) ceil(((double)(n))/((double)(d)))" >> .head
echo "#define floord(n,d) floor(((double)(n))/((double)(d)))" >> .head
echo "#define max(x,y) ((x) > (y)? (x) : (y))" >> .head
echo -e "#define min(x,y) ((x) < (y)? (x) : (y))\n" >> .head
cat .head __tmp > $3
rm -f .head .tail __tmp .includes .body.c