Download ROSE Compiler Framework

Transcript
Generic Dataflow Framework
};
foward intra-procedural data flow analysis: e.g. reaching definition ()
• class IntraFWDataflow : public IntraUniDirectionalDataflow
11.7.2 Initialization: InitDataflowState
Used to initialized the lattices/facts for CFG nodes. It is an analysis by itself. unstructured
pass
// super class: provides the driver of initialization: visit each CFG
node
class UnstructuredPassIntraAnalysis : virtual public
IntraProceduralAnalysis
{
public:
// call the initialization function on each CFG node
bool runAnalysis(const Function& func, NodeState* state);
// to be implemented by InitDataflowState
virtual void visit(const Function& func, const DataflowNode&
n, NodeState& state)=0;
}
bool UnstructuredPassIntraAnalysis::runAnalysis(const Function& func,
NodeState* state)
{
DataflowNode funcCFGStart =
cfgUtils::getFuncStartCFG(func.get_definition());
DataflowNode funcCFGEnd =
cfgUtils::getFuncEndCFG(func.get_definition());
if(analysisDebugLevel>=2)
Dbg::dbg <<
"UnstructuredPassIntraAnalysis::runAnalysis() function
"<<func.get_name().getString()<<"()\n";
// iterate over all the nodes in this function
for(VirtualCFG::iterator it(funcCFGStart);
it!=VirtualCFG::dataflow::end(); it++)
{
DataflowNode n = *it;
// The number of NodeStates associated with the given
dataflow node
//int numStates=NodeState::numNodeStates(n);
// The actual NodeStates associated with the given
dataflow node
const vector<NodeState*> nodeStates =
NodeState::getNodeStates(n);
// Visit each CFG node
for(vector<NodeState*>::const_iterator itS =
nodeStates.begin(); itS!=nodeStates.end(); itS++)
visit(func, n, *(*itS));
}
return false;
}
//-------------------- derived class provide link to a concrete
analysis, and visit() implementation
62