ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DominatorTreesAndDominanceFrontiers::ControlFlowGraph Class Reference

#include <ControlFlowGraph.h>

Inheritance diagram for DominatorTreesAndDominanceFrontiers::ControlFlowGraph:
Collaboration diagram for DominatorTreesAndDominanceFrontiers::ControlFlowGraph:

Public Types

enum  ID_dir {
  FORWARD,
  BACKWARD,
  FORWARD,
  BACKWARD
}
 determines the ordering of id numbers More...
 
enum  ID_dir {
  FORWARD,
  BACKWARD,
  FORWARD,
  BACKWARD
}
 determines the ordering of id numbers More...
 
- Public Types inherited from SimpleDirectedGraph
enum  TraverseDirection {
  FORWARD = 1,
  BACKWARD = 2,
  FORWARD = 1,
  BACKWARD = 2
}
 This enum determines which direction to travel during a reachability pass. More...
 
enum  TraverseDirection {
  FORWARD = 1,
  BACKWARD = 2,
  FORWARD = 1,
  BACKWARD = 2
}
 This enum determines which direction to travel during a reachability pass. More...
 

Public Member Functions

 ControlFlowGraph (SgNode *head)
 The constructor for ControlFlowGraph. Builds a CFG rooted at head. More...
 
void createNode (CFGNodeImpl *node)
 from a given CFGImpl node, create one (or more) ControlNodes More...
 
int getSize ()
 return the number of nodes in the CFG More...
 
ControlNodegetNode (int id, ID_dir dir)
 given a node id (and which numbering scheme to use), return the appropriate control node More...
 
void outputCFGImpl ()
 dump the contents of the original CFGImpl to a dot file More...
 
 ControlFlowGraph (SgNode *head)
 The constructor for ControlFlowGraph. Builds a CFG rooted at head. More...
 
void createNode (CFGNodeImpl *node)
 from a given CFGImpl node, create one (or more) ControlNodes More...
 
int getSize ()
 return the number of nodes in the CFG More...
 
ControlNodegetNode (int id, ID_dir dir)
 given a node id (and which numbering scheme to use), return the appropriate control node More...
 
void outputCFGImpl ()
 dump the contents of the original CFGImpl to a dot file More...
 
- Public Member Functions inherited from SimpleDirectedGraph
 ~SimpleDirectedGraph ()
 
std::set
< SimpleDirectedGraphNode * > 
getNodes ()
 get all the nodes in the graph More...
 
virtual void addNode (SimpleDirectedGraphNode *node)
 Add a node to the graph. More...
 
virtual void addLink (SimpleDirectedGraphNode *from, SimpleDirectedGraphNode *to)
 Add a link to the graph between "from" and to "to". More...
 
bool nodeExists (SimpleDirectedGraphNode *node)
 Check if a node containing data is in the graph. More...
 
bool linkExists (SimpleDirectedGraphNode *from, SimpleDirectedGraphNode *to)
 Check if a dependence is in the graph. More...
 
void printGraph ()
 
virtual void writeDot (char *filename)
 
std::set
< SimpleDirectedGraphNode * > 
getReachable (SimpleDirectedGraphNode *start, TraverseDirection dir)
 
 SimpleDirectedGraph ()
 
virtual ~SimpleDirectedGraph ()
 
std::set
< SimpleDirectedGraphNode * > 
getNodes ()
 get all the nodes in the graph More...
 
virtual void addNode (SimpleDirectedGraphNode *node)
 Add a node to the graph. More...
 
virtual void removeNode (SimpleDirectedGraphNode *node)
 
virtual void removeLink (SimpleDirectedGraphNode *from, SimpleDirectedGraphNode *to)
 Remove a linkt between "from" and "to". More...
 
virtual void addLink (SimpleDirectedGraphNode *from, SimpleDirectedGraphNode *to)
 Add a link to the graph between "from" and to "to". More...
 
bool nodeExists (SimpleDirectedGraphNode *node)
 Check if a node containing data is in the graph. More...
 
bool linkExists (SimpleDirectedGraphNode *from, SimpleDirectedGraphNode *to)
 Check if a dependence is in the graph. More...
 
void printGraph ()
 
virtual void writeDot (char *filename)
 
std::set
< SimpleDirectedGraphNode * > 
getReachable (SimpleDirectedGraphNode *start, TraverseDirection dir)
 

Private Member Functions

void _buildCFGImpl (SgNode *head)
 
void _buildCFG ()
 
void _buildBranches (ControlNode *from, CFGNodeImpl *curr)
 
void _setupIDs (ID_dir)
 
virtual void _displayData (SimpleDirectedGraphNode *data, std::ostream &os)
 
void _buildCFGImpl (SgNode *head)
 
void _buildCFG ()
 
void _buildBranches (ControlNode *from, CFGNodeImpl *curr)
 
void _setupIDs (ID_dir)
 
virtual void _displayData (SimpleDirectedGraphNode *data, std::ostream &os)
 

Private Attributes

DefaultCFGImpl * _cfg
 
int _numNodes
 
ControlNode_entry
 
ControlNode_exit
 
std::map< CFGNodeImpl
*, ControlNode * > 
_cfgnodemap
 Map from CFGImpl nodes to our ControlNodes (used for empty CFGNodeImpls) More...
 
std::map< SgNode *, ControlNode * > _sgnodemap
 Map from SgNodes to ControlNodes (used for ControlNodes with statements) More...
 
ControlNode ** _forIndex
 Array matches IDs to ControlNodes using forward ids. More...
 
ControlNode ** _backIndex
 Array matches IDs to ControlNodes using backward ids. More...
 

Additional Inherited Members

- Protected Attributes inherited from SimpleDirectedGraph
std::set
< SimpleDirectedGraphNode * > 
_nodes
 

Detailed Description

This class constructs a control flow graph for a given function definition. It builds off of information provided by CFGImpl.h, and adds some additional bookkeeping information (such as entry and exit points, as well as having a separate node for each statement in the graph).

This class extends SimpleDirectedGraph templated on ControlNode

Definition at line 40 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

Member Enumeration Documentation

determines the ordering of id numbers

Certain uses of the CFG rely on a specific numbering scheme for the nodes of the CFG. The nodes can either be numbered in breadth-first-search order rooted at the entry node, and following edges forward, or in breadth-first-search order rooted at the exit node and following edges backward.

Enumerator
FORWARD 
BACKWARD 
FORWARD 
BACKWARD 

Definition at line 52 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

determines the ordering of id numbers

Certain uses of the CFG rely on a specific numbering scheme for the nodes of the CFG. The nodes can either be numbered in breadth-first-search order rooted at the entry node, and following edges forward, or in breadth-first-search order rooted at the exit node and following edges backward.

Enumerator
FORWARD 
BACKWARD 
FORWARD 
BACKWARD 

Definition at line 52 of file staticInterproceduralSlicing/ControlFlowGraph.h.

Constructor & Destructor Documentation

DominatorTreesAndDominanceFrontiers::ControlFlowGraph::ControlFlowGraph ( SgNode head)

The constructor for ControlFlowGraph. Builds a CFG rooted at head.

DominatorTreesAndDominanceFrontiers::ControlFlowGraph::ControlFlowGraph ( SgNode head)

The constructor for ControlFlowGraph. Builds a CFG rooted at head.

Member Function Documentation

void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::createNode ( CFGNodeImpl *  node)

from a given CFGImpl node, create one (or more) ControlNodes

int DominatorTreesAndDominanceFrontiers::ControlFlowGraph::getSize ( )
inline

return the number of nodes in the CFG

Definition at line 65 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

References _numNodes.

ControlNode* DominatorTreesAndDominanceFrontiers::ControlFlowGraph::getNode ( int  id,
ID_dir  dir 
)
inline

given a node id (and which numbering scheme to use), return the appropriate control node

Definition at line 68 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

References _backIndex, _forIndex, and FORWARD.

void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::outputCFGImpl ( )

dump the contents of the original CFGImpl to a dot file

void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_buildCFGImpl ( SgNode head)
private
void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_buildCFG ( )
private
void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_buildBranches ( ControlNode from,
CFGNodeImpl *  curr 
)
private
void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_setupIDs ( ID_dir  )
private
virtual void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_displayData ( SimpleDirectedGraphNode node,
std::ostream &  os 
)
privatevirtual

This virtual function can be overriden to control how data is presented by printGraph(). It defaults to simply outputting the data onto os.

Reimplemented from SimpleDirectedGraph.

void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::createNode ( CFGNodeImpl *  node)

from a given CFGImpl node, create one (or more) ControlNodes

int DominatorTreesAndDominanceFrontiers::ControlFlowGraph::getSize ( )
inline

return the number of nodes in the CFG

Definition at line 65 of file staticInterproceduralSlicing/ControlFlowGraph.h.

References _numNodes.

ControlNode* DominatorTreesAndDominanceFrontiers::ControlFlowGraph::getNode ( int  id,
ID_dir  dir 
)
inline

given a node id (and which numbering scheme to use), return the appropriate control node

Definition at line 68 of file staticInterproceduralSlicing/ControlFlowGraph.h.

References _backIndex, _forIndex, and FORWARD.

void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::outputCFGImpl ( )

dump the contents of the original CFGImpl to a dot file

void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_buildCFGImpl ( SgNode head)
private
void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_buildCFG ( )
private
void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_buildBranches ( ControlNode from,
CFGNodeImpl *  curr 
)
private
void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_setupIDs ( ID_dir  )
private
virtual void DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_displayData ( SimpleDirectedGraphNode node,
std::ostream &  os 
)
privatevirtual

This virtual function can be overriden to control how data is presented by printGraph(). It defaults to simply outputting the data onto os.

Reimplemented from SimpleDirectedGraph.

Member Data Documentation

DefaultCFGImpl * DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_cfg
private
int DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_numNodes
private

Definition at line 85 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

Referenced by getSize().

ControlNode * DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_entry
private
ControlNode * DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_exit
private
std::map< CFGNodeImpl *, ControlNode * > DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_cfgnodemap
private

Map from CFGImpl nodes to our ControlNodes (used for empty CFGNodeImpls)

Definition at line 90 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

std::map< SgNode *, ControlNode * > DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_sgnodemap
private

Map from SgNodes to ControlNodes (used for ControlNodes with statements)

Definition at line 92 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

ControlNode ** DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_forIndex
private

Array matches IDs to ControlNodes using forward ids.

Definition at line 95 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

Referenced by getNode().

ControlNode ** DominatorTreesAndDominanceFrontiers::ControlFlowGraph::_backIndex
private

Array matches IDs to ControlNodes using backward ids.

Definition at line 97 of file dominatorTreesAndDominanceFrontiers/ControlFlowGraph.h.

Referenced by getNode().


The documentation for this class was generated from the following files: