-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpatch
executable file
·128 lines (107 loc) · 4.72 KB
/
patch
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
#StitchUp configuration script
#LEGUP_DIR needs to be set to the root directory of the LegUp tool
if [ "$#" -ne 1 ]; then
echo "Usage ./configure <LegUp Directory>"
exit 126
fi
#Get the home directory for the legup installation.
echo "LegUp is installed at $1";
LEGUP_HOME=$1
#For now I will just assume that the LegUp directory looks sane
#Checks should be implemented here in the future though
LLVM_DIR=$LEGUP_HOME/llvm
LLVM_LIB_DIR=$LLVM_DIR/lib/Transforms
STITCH_UP_DIR=$LLVM_LIB_DIR/StitchUp
LABEL_BB_DIR=$LLVM_LIB_DIR/LabelBB
LOCAL_TRANSFORMS=./libs/Transforms
LOCAL_TARGETS=./libs/Targets
LLVMStitchUp=$LOCAL_TRANSFORMS/LLVMStitchUp
LLVMLabelBB=$LOCAL_TRANSFORMS/LVMStitchUp
STITCHUPBACKEND=$LOCAL_TARGETS/StitchUpBackend
TARGET_DIR=$LLVM_DIR/lib/Target
LLVMSTITCHUP_BACKEND=$TARGET_DIR/StitchUp
CHSTONE_DIR=$(pwd)/benchmarks/chstone_stitchup
MMM_DIR=$(pwd)/benchmarks/matrixmultiply
LEGUP_EXAMPLES_DIR=$LEGUP_HOME/examples
#Making the StitchUp LLVM library directory and creating a symbolic link to it
if [ ! -L $STITCH_UP_DIR ]; then
cp -rs $(pwd)/$LOCAL_TRANSFORMS/LLVMStitchUp $STITCH_UP_DIR
fi
#Making the StitchUp LLVM library directory and creating a symbolic link to it
if [ ! -L $LABEL_BB_DIR ]; then
cp -rs $(pwd)/$LOCAL_TRANSFORMS/LLVMLabelBB $LABEL_BB_DIR
fi
#Create the Backend Dir in Target
if [ ! -L $LLVMSTITCHUP_BACKEND ]; then
cp -rs $(pwd)/$LOCAL_TARGETS/StitchUpBackend $LLVMSTITCHUP_BACKEND
fi
#Create a symbolic link for the chstone_stitchup benchmarks
if [ ! -L $LEGUP_EXAMPLES_DIR/chstone_stitchup ]; then
cp -rs $CHSTONE_DIR $LEGUP_EXAMPLES_DIR/chstone_stitchup
fi
#Create the chstone_stitchup build and run scripts
echo "BUILD_DIR=$LEGUP_EXAMPLES_DIR/chstone_stitchup" > $CHSTONE_DIR/build.config
chmod u+x $CHSTONE_DIR/build.config
#Create a symbolic link for the matrixmultiply benchmark
if [ ! -L $LEGUP_EXAMPLES_DIR/matrixmultiply_stitchup ]; then
cp -rs $MMM_DIR $LEGUP_EXAMPLES_DIR/matrixmultiply_stitchup
cp $LEGUP_HOME/ip/libs/altera/altfp_multiplier_11.v $LEGUP_EXAMPLES_DIR/matrixmultiply_stitchup
cp $LEGUP_HOME/ip/libs/altera/altfp_adder_14.v $LEGUP_EXAMPLES_DIR/matrixmultiply_stitchup
fi
#Create the matrixmultiply build and run scripts
echo "BUILD_DIR=$LEGUP_EXAMPLES_DIR/matrixmultiply_stitchup" > $MMM_DIR/build.config
chmod u+x $MMM_DIR/build.config
CURR_DIR=$(pwd)
#Include StitchUp to the library makefile lists.
if grep -q "StitchUp" $LLVM_LIB_DIR/Makefile; then
echo "The StitchUp Library has already been included into the LLVM lib Makefile $LLVM_LIB_DIR/Makefile"
else
sed -i '/^PARALLEL_DIRS = .*/ s/$/ StitchUp/' $LLVM_LIB_DIR/Makefile
fi
#Include StitchUp to the library makefile lists.
if grep -q "LabelBB" $LLVM_LIB_DIR/Makefile; then
echo "The LabelBB Library has already been included into the LLVM lib Makefile $LLVM_LIB_DIR/Makefile"
else
sed -i '/^PARALLEL_DIRS = .*/ s/$/ LabelBB/' $LLVM_LIB_DIR/Makefile
fi
#Include StitchUp into the TargetMakefile list
if grep -q "StitchUp" $LLVM_DIR/configure; then
echo "The StitchUp Target backend has already been included into the LLVM Makefile.config"
else
sed -i "s/Verilog/Verilog StitchUp/g" $LLVM_DIR/configure
fi
#Include StitchUp into the TargetMakefile list
if grep -q "StitchUp" $LLVM_DIR/lib/Target/LLVMBuild.txt; then
echo "The StitchUp Target backend has already been included into the Target LLVMBuild.txt "
else
sed -i "s/Verilog/Verilog StitchUp/g" $LLVM_DIR/lib/Target/LLVMBuild.txt
fi
echo "LLVM_DIR=$LLVM_DIR" > Makefile.config
echo "LLVM_LIB_DIR=$LLVM_LIB_DIR" >> Makefile.config
echo "STITCH_UP_DIR=$STITCH_UP_DIR" >>Makefile.config
echo "LEGUP_HOME=$LEGUP_HOME" >> Makefile.config
echo "CURRDIR=$(pwd)" > ./build
echo "(cd $STITCH_UP_DIR; make)" >> ./build
echo "(cd $LABEL_BB_DIR; make)" >> ./build
echo "(cd $LLVMSTITCHUP_BACKEND; make)" >> ./build
echo "echo \"\n\n......ControlFlowAnalysis Tests......\"" >> ./build
echo "(cd \$CURRDIR/tests/ControlFlowAnalysis;./runChecks)" >> ./build
echo "echo \"\n\n......StitchUpBackend Tests......\"" >> ./build
echo "(cd \$CURRDIR/tests/StitchUpBackend;./runChecks)" >> ./build
chmod u+x build
echo "Reconfiguring the LLVM base"
(cd $LLVM_DIR; ./configure; cd $CURR_DIR;)
echo "Finished configuring the LLVM base"
(cd $LLVM_DIR; make; cd $CURR_DIR;)
#Attempting to build the StitchUp pass
(cd $STITCH_UP_DIR; make; cd $CURR_DIR;)
#Attempting to build the LabelBB pass
(cd $LABEL_BB_DIR; make; cd $CURR_DIR;)
#Edit the LegUp makefile so that the makefile argument STITCHUP=1 can be used to build the system with stitchup
cp config/Makefile.common $LEGUP_HOME/examples/
cp config/legup.tcl $LEGUP_HOME/examples/
(cd $LLVMSTITCHUP_BACKEND; make; cd $CURR_DIR; )
(cd $LLVM_DIR/tools/llc; make; cd $CURR_DIR; )
mkdir doxy
(cd libs/Transforms/LLVMStitchUp/ && doxygen stitchup_doxy )