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

#include <cong_staticCFG.h>

Inheritance diagram for StaticCFG::ControlFlowGraph:
Collaboration diagram for StaticCFG::ControlFlowGraph:

Classes

struct  EdgeCopier
 This class is used to copy edges when calling copy_graph(). More...
 
struct  VertexCopier
 This class is used to copy vertices when calling copy_graph(). More...
 

Public Types

typedef boost::graph_traits
< ControlFlowGraph
GraphTraits
 
typedef
GraphTraits::vertex_descriptor 
Vertex
 
typedef
GraphTraits::edge_descriptor 
Edge
 
typedef std::map< Vertex, VertexVertexVertexMap
 
typedef std::set< VertexVertices
 

Public Member Functions

 ControlFlowGraph ()
 The default constructor. More...
 
 ControlFlowGraph (SgFunctionDefinition *funcDef, const CFGNodeFilter &cfgNodeFilter=DefaultFilter())
 The constructor building the CFG. More...
 
void build (SgFunctionDefinition *funcDef)
 Build the actual CFG for the given function. More...
 
SgFunctionDefinitiongetFunctionDefinition () const
 Get the function definition of this CFG. More...
 
Vertex getEntry () const
 Get the entry node of the CFG. More...
 
Vertex getExit () const
 Get the exit node of the CFG. More...
 
void setEntry (Vertex entry)
 Set the entry node of the CFG. More...
 
void setExit (Vertex exit)
 Set the exit node of the CFG. More...
 
const VertexVertexMapgetDominatorTree () const
 Build the dominator tree of this CFG. More...
 
const VertexVertexMapgetPostdominatorTree () const
 Build the postdominator tree of this CFG. More...
 
ControlFlowGraph makeReverseCopy () const
 Build a reverse CFG. More...
 
void toDot (const std::string &filename) const
 Output the graph to a DOT file. More...
 
std::vector< CFGNodePtrgetAllNodes () const
 Get all CFG nodes in this graph. More...
 
std::vector< CFGEdgePtrgetAllEdges () const
 Get all CFG edges in this graph. More...
 
Vertex getVertexForNode (const CFGNode &node) const
 Given a CFG node, returns the corresponding vertex in the graph. More...
 
bool isReducible () const
 Return if this CFG is reducible (if all loops are natural loops, the CFG is reducible). More...
 
std::set< EdgegetAllBackEdges () const
 Get all back edges in the CFG. A back edge is one whose target dominates its source. More...
 
Vertices getAllLoopHeaders () const
 Get all loop headers in this CFG. A natural loop only has one header. More...
 
std::map< Vertex, VerticesgetAllLoops () const
 Get all loops in this CFG. More...
 

Protected Member Functions

void buildCFG (const CFGNode &node, std::map< CFGNode, Vertex > &nodesAdded, std::set< CFGNode > &nodesProcessed)
 A internal funtion which builds the actual CFG (boost::graph). More...
 
void setEntryAndExit ()
 Find the entry and exit of this CFG and set the corresponding members. More...
 
CFGNodePtr newCFGNode (const CFGNode &node)
 
CFGEdgePtr newCFGEdge (const CFGEdge &edge)
 
void writeGraphNode (std::ostream &out, const Vertex &node) const
 This function helps to write the DOT file for vertices. More...
 
void writeGraphEdge (std::ostream &out, const Edge &edge) const
 This function helps to write the DOT file for edges. More...
 

Protected Attributes

SgFunctionDefinitionfuncDef_
 The function definition of this CFG. More...
 
CFGNodeFilter filter_
 The CFG node filter. More...
 
Vertex entry_
 The entry node. More...
 
Vertex exit_
 The exit node. More...
 
std::map< CFGNode, VertexnodesToVertices_
 A map from a CFG node to the corresponding vertex. More...
 
VertexVertexMap dominatorTree_
 The dominator tree of this CFG. More...
 
VertexVertexMap postdominatorTree_
 The postdominator tree of this CFG. More...
 

Detailed Description

Definition at line 45 of file cong_staticCFG.h.

Member Typedef Documentation

Definition at line 49 of file cong_staticCFG.h.

typedef GraphTraits::vertex_descriptor StaticCFG::ControlFlowGraph::Vertex

Definition at line 50 of file cong_staticCFG.h.

typedef GraphTraits::edge_descriptor StaticCFG::ControlFlowGraph::Edge

Definition at line 51 of file cong_staticCFG.h.

Definition at line 53 of file cong_staticCFG.h.

Definition at line 54 of file cong_staticCFG.h.

Constructor & Destructor Documentation

StaticCFG::ControlFlowGraph::ControlFlowGraph ( )
inline

The default constructor.

Definition at line 82 of file cong_staticCFG.h.

StaticCFG::ControlFlowGraph::ControlFlowGraph ( SgFunctionDefinition funcDef,
const CFGNodeFilter cfgNodeFilter = DefaultFilter() 
)
inlineexplicit

The constructor building the CFG.

Definition at line 91 of file cong_staticCFG.h.

References build().

Member Function Documentation

void StaticCFG::ControlFlowGraph::build ( SgFunctionDefinition funcDef)

Build the actual CFG for the given function.

Referenced by ControlFlowGraph().

SgFunctionDefinition* StaticCFG::ControlFlowGraph::getFunctionDefinition ( ) const
inline

Get the function definition of this CFG.

Definition at line 106 of file cong_staticCFG.h.

References funcDef_.

Vertex StaticCFG::ControlFlowGraph::getEntry ( ) const
inline

Get the entry node of the CFG.

Definition at line 110 of file cong_staticCFG.h.

References entry_.

Vertex StaticCFG::ControlFlowGraph::getExit ( ) const
inline

Get the exit node of the CFG.

Definition at line 113 of file cong_staticCFG.h.

References exit_.

void StaticCFG::ControlFlowGraph::setEntry ( Vertex  entry)
inline

Set the entry node of the CFG.

Definition at line 116 of file cong_staticCFG.h.

References entry_.

void StaticCFG::ControlFlowGraph::setExit ( Vertex  exit)
inline

Set the exit node of the CFG.

Definition at line 119 of file cong_staticCFG.h.

References exit_.

const VertexVertexMap& StaticCFG::ControlFlowGraph::getDominatorTree ( ) const

Build the dominator tree of this CFG.

Returns
A map from each node to its immediate dominator.
const VertexVertexMap& StaticCFG::ControlFlowGraph::getPostdominatorTree ( ) const

Build the postdominator tree of this CFG.

ControlFlowGraph StaticCFG::ControlFlowGraph::makeReverseCopy ( ) const

Build a reverse CFG.

void StaticCFG::ControlFlowGraph::toDot ( const std::string &  filename) const

Output the graph to a DOT file.

std::vector<CFGNodePtr> StaticCFG::ControlFlowGraph::getAllNodes ( ) const

Get all CFG nodes in this graph.

std::vector<CFGEdgePtr> StaticCFG::ControlFlowGraph::getAllEdges ( ) const

Get all CFG edges in this graph.

Vertex StaticCFG::ControlFlowGraph::getVertexForNode ( const CFGNode node) const

Given a CFG node, returns the corresponding vertex in the graph.

Returns Vertex::null_vertex() if the given node is not in the graph

bool StaticCFG::ControlFlowGraph::isReducible ( ) const
inline

Return if this CFG is reducible (if all loops are natural loops, the CFG is reducible).

Definition at line 146 of file cong_staticCFG.h.

std::set<Edge> StaticCFG::ControlFlowGraph::getAllBackEdges ( ) const

Get all back edges in the CFG. A back edge is one whose target dominates its source.

Vertices StaticCFG::ControlFlowGraph::getAllLoopHeaders ( ) const

Get all loop headers in this CFG. A natural loop only has one header.

std::map<Vertex, Vertices> StaticCFG::ControlFlowGraph::getAllLoops ( ) const

Get all loops in this CFG.

Each loop is represented by its header and all CFG nodes belonging to it.

void StaticCFG::ControlFlowGraph::buildCFG ( const CFGNode node,
std::map< CFGNode, Vertex > &  nodesAdded,
std::set< CFGNode > &  nodesProcessed 
)
protected

A internal funtion which builds the actual CFG (boost::graph).

void StaticCFG::ControlFlowGraph::setEntryAndExit ( )
protected

Find the entry and exit of this CFG and set the corresponding members.

CFGNodePtr StaticCFG::ControlFlowGraph::newCFGNode ( const CFGNode node)
inlineprotected

Definition at line 168 of file cong_staticCFG.h.

CFGEdgePtr StaticCFG::ControlFlowGraph::newCFGEdge ( const CFGEdge edge)
inlineprotected

Definition at line 171 of file cong_staticCFG.h.

void StaticCFG::ControlFlowGraph::writeGraphNode ( std::ostream &  out,
const Vertex node 
) const
protected

This function helps to write the DOT file for vertices.

void StaticCFG::ControlFlowGraph::writeGraphEdge ( std::ostream &  out,
const Edge edge 
) const
protected

This function helps to write the DOT file for edges.

Member Data Documentation

SgFunctionDefinition* StaticCFG::ControlFlowGraph::funcDef_
protected

The function definition of this CFG.

Definition at line 59 of file cong_staticCFG.h.

Referenced by getFunctionDefinition().

CFGNodeFilter StaticCFG::ControlFlowGraph::filter_
protected

The CFG node filter.

Definition at line 62 of file cong_staticCFG.h.

Vertex StaticCFG::ControlFlowGraph::entry_
protected

The entry node.

Definition at line 65 of file cong_staticCFG.h.

Referenced by getEntry(), and setEntry().

Vertex StaticCFG::ControlFlowGraph::exit_
protected

The exit node.

Definition at line 68 of file cong_staticCFG.h.

Referenced by getExit(), and setExit().

std::map<CFGNode, Vertex> StaticCFG::ControlFlowGraph::nodesToVertices_
protected

A map from a CFG node to the corresponding vertex.

Definition at line 71 of file cong_staticCFG.h.

VertexVertexMap StaticCFG::ControlFlowGraph::dominatorTree_
mutableprotected

The dominator tree of this CFG.

Definition at line 74 of file cong_staticCFG.h.

VertexVertexMap StaticCFG::ControlFlowGraph::postdominatorTree_
mutableprotected

The postdominator tree of this CFG.

Definition at line 77 of file cong_staticCFG.h.


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