Question: For this assignment, you will create a standalone program named graph in python / c / cpp . The code should be substantially your own.
For this assignment, you will create a standalone program named graph in pythonccpp The code should be substantially your own. Although you may use auxiliary libraries, the fundamental tasks described must be performed by code you wrote for this assignment. The analysis program will perform some basic analysis over an input file in a restricted subset of LLVM In particular, the only pseudoinstructions that you need to cover are:
alloca
getelementpointer
load
store
ret
icmp
br
add
sub
div
mul
phi
call
define
Additionally, your analysis should accomodate programs with both global and local variable allocations. You may assume that all variables are of scalar integer type.
Assignment Details: This assignment consists of CFG inference, ie inducing a controlflow graph over an input. The basic idea of is to construct the controlflow graph of each function declared in a given input file and output those controlflow graphs in the graphviz dot format. For each function in the input, the program will output a graphviz controlflow graph. The nodes should have record shape. It is sufficient to simply output the correct structure of the CFG with the correct edge labels. Edges should be directed and have a label according to their position in the branch, starting at index For example, consider the input:
Example Input:
define i @mainiargc
noArgs icmp eq iargc,
br inoArgs, label lblt label lblf
lblt:
varT add i
br label end
lblf:
varF add i
br label end
end:
var phi ivarT, lbltvarF, lblf
ret ivar
The output would be of the form
Example Output:
digraph
Nodeshaperecord,label
Node Nodelabel;
Node Nodelabel;
Nodeshaperecord,label
Node Nodelabel;
Nodeshaperecord,label
Node Nodelabel;
Nodeshaperecord,label
Note that for this behavior to be correct, the output must be valid in the dot format. Your code should be able to be tested with the following sequence of commands on the cycle servers:
tar xf Ptgz
cd P
make
graph testll
dot main.dot o main.png Tpng
where testll is a file containing a main function.
As described above, you may use any coding language of your choice to complete this assignment. However, the above sequence of commands must work without error. For example, if you are using python, you might include a Makefile that immediately exits since there is no code to build Furthermore, you should either include a helper script named graph that launches the python interpreter with its argument.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
