ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Backstroke::CFG< CFGNodeFilter > Class Template Reference

A class holding a Control Flow Graph. More...

#include <graphTemplate.h>

Inheritance diagram for Backstroke::CFG< CFGNodeFilter >:
Collaboration diagram for Backstroke::CFG< CFGNodeFilter >:

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
VirtualCFG::FilteredCFGNode
< CFGNodeFilter > 
CFGNodeType
 
typedef
VirtualCFG::FilteredCFGEdge
< CFGNodeFilter > 
CFGEdgeType
 
typedef boost::shared_ptr
< CFGNodeType
CFGNodePtr
 
typedef boost::shared_ptr
< CFGEdgeType
CFGEdgePtr
 
typedef
GraphTraits::vertex_descriptor 
Vertex
 
typedef
GraphTraits::edge_descriptor 
Edge
 
typedef std::map< Vertex, VertexVertexVertexMap
 

Public Member Functions

std::map< CFGNodeType, VertexgetNodeVert ()
 
 CFG ()
 The default constructor. More...
 
 CFG (SgFunctionDefinition *funcDef)
 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...
 
const VertexgetEntry () const
 Get the entry node of the CFG. More...
 
const VertexgetExit () const
 Get the exit node of the CFG. More...
 
const VertexVertexMapgetDominatorTree ()
 Build the dominator tree of this CFG. More...
 
const VertexVertexMapgetPostdominatorTree ()
 Build the postdominator tree of this CFG. More...
 
CFG< CFGNodeFilter > 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 CFGNodeType &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::vector< EdgegetAllBackEdges ()
 Get all back edges in the CFG. A back edge is one whose target dominates its source. More...
 
std::vector< VertexgetAllLoopHeaders ()
 Get all loop headers in this CFG. A natural loop only has one header. More...
 

Public Attributes

Vertex entry_
 The entry node. More...
 
Vertex exit_
 The exit node. More...
 

Protected Member Functions

void buildCFG (const CFGNodeType &node, std::map< CFGNodeType, Vertex > &nodesAdded, std::set< CFGNodeType > &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...
 
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...
 
std::map< CFGNodeType, 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...
 

Private Types

typedef boost::graph_traits
< CFG< CFGNodeFilter > > 
GraphTraits
 

Detailed Description

template<class CFGNodeFilter>
class Backstroke::CFG< CFGNodeFilter >

A class holding a Control Flow Graph.

Definition at line 77 of file graphTemplate.h.

Member Typedef Documentation

template<class CFGNodeFilter>
typedef boost::graph_traits<CFG<CFGNodeFilter> > Backstroke::CFG< CFGNodeFilter >::GraphTraits
private

Definition at line 119 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef VirtualCFG::FilteredCFGNode<CFGNodeFilter> Backstroke::CFG< CFGNodeFilter >::CFGNodeType

Definition at line 122 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef VirtualCFG::FilteredCFGEdge<CFGNodeFilter> Backstroke::CFG< CFGNodeFilter >::CFGEdgeType

Definition at line 123 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef boost::shared_ptr<CFGNodeType> Backstroke::CFG< CFGNodeFilter >::CFGNodePtr

Definition at line 125 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef boost::shared_ptr<CFGEdgeType> Backstroke::CFG< CFGNodeFilter >::CFGEdgePtr

Definition at line 126 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef GraphTraits::vertex_descriptor Backstroke::CFG< CFGNodeFilter >::Vertex

Definition at line 128 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef GraphTraits::edge_descriptor Backstroke::CFG< CFGNodeFilter >::Edge

Definition at line 129 of file graphTemplate.h.

template<class CFGNodeFilter>
typedef std::map<Vertex, Vertex> Backstroke::CFG< CFGNodeFilter >::VertexVertexMap

Definition at line 131 of file graphTemplate.h.

Constructor & Destructor Documentation

template<class CFGNodeFilter>
Backstroke::CFG< CFGNodeFilter >::CFG ( )
inline

The default constructor.

Definition at line 160 of file graphTemplate.h.

template<class CFGNodeFilter>
Backstroke::CFG< CFGNodeFilter >::CFG ( SgFunctionDefinition funcDef)
inlineexplicit

The constructor building the CFG.

Definition at line 168 of file graphTemplate.h.

References Backstroke::CFG< CFGNodeFilter >::build().

Member Function Documentation

template<class CFGNodeFilter>
std::map<CFGNodeType, Vertex> Backstroke::CFG< CFGNodeFilter >::getNodeVert ( )
inline
template<class CFGNodeFilter >
void Backstroke::CFG< CFGNodeFilter >::build ( SgFunctionDefinition funcDef)

Build the actual CFG for the given function.

Definition at line 287 of file graphTemplate.h.

References SgNode::cfgForBeginning(), and isSgFunctionDefinition().

Referenced by Backstroke::CFG< CFGNodeFilter >::CFG().

template<class CFGNodeFilter>
SgFunctionDefinition* Backstroke::CFG< CFGNodeFilter >::getFunctionDefinition ( ) const
inline

Get the function definition of this CFG.

Definition at line 180 of file graphTemplate.h.

References Backstroke::CFG< CFGNodeFilter >::funcDef_.

template<class CFGNodeFilter>
const Vertex& Backstroke::CFG< CFGNodeFilter >::getEntry ( ) const
inline

Get the entry node of the CFG.

Definition at line 184 of file graphTemplate.h.

References Backstroke::CFG< CFGNodeFilter >::entry_.

template<class CFGNodeFilter>
const Vertex& Backstroke::CFG< CFGNodeFilter >::getExit ( ) const
inline

Get the exit node of the CFG.

Definition at line 188 of file graphTemplate.h.

References Backstroke::CFG< CFGNodeFilter >::exit_.

template<class CFGNodeFilter >
const CFG< CFGNodeFilter >::VertexVertexMap & Backstroke::CFG< CFGNodeFilter >::getDominatorTree ( )

Build the dominator tree of this CFG.

Returns
A map from each node to its immediate dominator.

Definition at line 403 of file graphTemplate.h.

template<class CFGNodeFilter >
const CFG< CFGNodeFilter >::VertexVertexMap & Backstroke::CFG< CFGNodeFilter >::getPostdominatorTree ( )

Build the postdominator tree of this CFG.

Definition at line 416 of file graphTemplate.h.

template<class CFGNodeFilter >
CFG< CFGNodeFilter > Backstroke::CFG< CFGNodeFilter >::makeReverseCopy ( ) const

Build a reverse CFG.

Definition at line 429 of file graphTemplate.h.

References Backstroke::CFG< CFGNodeFilter >::entry_, and Backstroke::CFG< CFGNodeFilter >::exit_.

template<class CFGNodeFilter >
void Backstroke::CFG< CFGNodeFilter >::toDot ( const std::string &  filename) const

Output the graph to a DOT file.

Definition at line 278 of file graphTemplate.h.

template<class CFGNodeFilter >
std::vector< typename CFG< CFGNodeFilter >::CFGNodePtr > Backstroke::CFG< CFGNodeFilter >::getAllNodes ( ) const

Get all CFG nodes in this graph.

Definition at line 446 of file graphTemplate.h.

template<class CFGNodeFilter >
std::vector< typename CFG< CFGNodeFilter >::CFGEdgePtr > Backstroke::CFG< CFGNodeFilter >::getAllEdges ( ) const

Get all CFG edges in this graph.

Definition at line 468 of file graphTemplate.h.

template<class CFGNodeFilter >
CFG< CFGNodeFilter >::Vertex Backstroke::CFG< CFGNodeFilter >::getVertexForNode ( const CFGNodeType 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

Definition at line 477 of file graphTemplate.h.

template<class CFGNodeFilter>
bool Backstroke::CFG< CFGNodeFilter >::isReducible ( ) const
inline

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

Definition at line 216 of file graphTemplate.h.

template<class CFGNodeFilter >
std::vector< typename CFG< CFGNodeFilter >::Edge > Backstroke::CFG< CFGNodeFilter >::getAllBackEdges ( )

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

Definition at line 490 of file graphTemplate.h.

template<class CFGNodeFilter >
std::vector< typename CFG< CFGNodeFilter >::Vertex > Backstroke::CFG< CFGNodeFilter >::getAllLoopHeaders ( )

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

Definition at line 519 of file graphTemplate.h.

template<class CFGNodeFilter >
void Backstroke::CFG< CFGNodeFilter >::buildCFG ( const CFGNodeType node,
std::map< CFGNodeType, Vertex > &  nodesAdded,
std::set< CFGNodeType > &  nodesProcessed 
)
protected
template<class CFGNodeFilter >
void Backstroke::CFG< CFGNodeFilter >::setEntryAndExit ( )
protected

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

Definition at line 311 of file graphTemplate.h.

References isSgFunctionDefinition().

template<class CFGNodeFilter>
void Backstroke::CFG< CFGNodeFilter >::writeGraphNode ( std::ostream &  out,
const Vertex node 
) const
inlineprotected

This function helps to write the DOT file for vertices.

Definition at line 235 of file graphTemplate.h.

References Backstroke::writeCFGNode().

template<class CFGNodeFilter>
void Backstroke::CFG< CFGNodeFilter >::writeGraphEdge ( std::ostream &  out,
const Edge edge 
) const
inlineprotected

This function helps to write the DOT file for edges.

Definition at line 242 of file graphTemplate.h.

References Backstroke::writeCFGEdge().

Member Data Documentation

template<class CFGNodeFilter>
Vertex Backstroke::CFG< CFGNodeFilter >::entry_
template<class CFGNodeFilter>
Vertex Backstroke::CFG< CFGNodeFilter >::exit_
template<class CFGNodeFilter>
SgFunctionDefinition* Backstroke::CFG< CFGNodeFilter >::funcDef_
protected

The function definition of this CFG.

Definition at line 142 of file graphTemplate.h.

Referenced by Backstroke::CFG< CFGNodeFilter >::getFunctionDefinition().

template<class CFGNodeFilter>
std::map<CFGNodeType, Vertex> Backstroke::CFG< CFGNodeFilter >::nodesToVertices_
protected

A map from a CFG node to the corresponding vertex.

Definition at line 146 of file graphTemplate.h.

Referenced by Backstroke::CFG< CFGNodeFilter >::getNodeVert().

template<class CFGNodeFilter>
VertexVertexMap Backstroke::CFG< CFGNodeFilter >::dominatorTree_
protected

The dominator tree of this CFG.

Definition at line 149 of file graphTemplate.h.

template<class CFGNodeFilter>
VertexVertexMap Backstroke::CFG< CFGNodeFilter >::postdominatorTree_
protected

The postdominator tree of this CFG.

Definition at line 152 of file graphTemplate.h.


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