byucc.jhdl.synth
Class ControlFlowGraph

java.lang.Object
  extended bybyucc.jhdl.synth.graph.NamedObject
      extended bybyucc.jhdl.synth.graph.Graph
          extended bybyucc.jhdl.synth.ControlFlowGraph
All Implemented Interfaces:
Nameable

public class ControlFlowGraph
extends Graph

A graph representing control flow of a method. ControlFlowGraph consists of CFVertex and CFEdge objects. Each CFVertex can be either a block or a decision. Each block represents a basic block of a method and each decision represents the possible flow of control between basic blocks. Each basic block also contains a DataFlowGraph representing the dataflow within that basic block.

See Also:
CFVertex, CFEdge, DataFlowGraph

Field Summary
 
Fields inherited from class byucc.jhdl.synth.graph.Graph
printNum, vertexVector
 
Fields inherited from class byucc.jhdl.synth.graph.NamedObject
name
 
Constructor Summary
ControlFlowGraph()
          Create a new unnamed ContorlFlowGraph
ControlFlowGraph(java.lang.String name)
          Constructs a new ControlFlowGraph with the given name.
 
Method Summary
 CFVertex addBlock(SynthBlock sb, DataFlowGraph dfGraph)
          Add a new block to this ControlFlowGraph associated with the given SynthBlock or return one that existed previously.
 CFEdge addCFEdge(CFVertex tail, CFVertex head)
          Add a new CFEdge to the graph.
 CFEdge addCFEdge(CFVertex tail, CFVertex head, java.lang.String weight)
          Add a new CFEdge with the given weight to the graph.
 CFVertex addCFVertex(java.lang.String name)
          Add a new CFVertex to the graph.
 CFVertex addDecision(java.lang.String name)
          Add a new decision to this ControlFlowGraph.
 CFVertex getBlock(SynthBlock sb)
          Get a block from the graph associated with the given SynthBlock, (null if none exists)
 BlockIterator getBlocks()
          Get a list of all the blocks in this ControlFlowGraph
 boolean hasBlock(SynthBlock sb)
          Does this graph have a block vertex associated with the given SynthBlock.
protected  Edge newEdge(Vertex tail, Vertex head)
          Overrides newEdge in Graph so that all edges in a ControlFlowGraph will be of type CFEdge.
protected  Vertex newVertex(java.lang.String name)
          Overrides newVertex in Graph so that all vertices in a ControlFlowGraph will be of type CFVertex.
 
Methods inherited from class byucc.jhdl.synth.graph.Graph
addEdge, addEdge, addVertex, addVertex, getEdge, getEdges, getPrintWriter, getVertices, hasEdge, hasEdge, hasVertex, mergeVertices, printGraph, printGraph, printGraph, printGraph, removeEdge, removeEdge, removeVertex, resetVisited, setEdgeProperty, setVertexProperty, toDot, toDot, toString
 
Methods inherited from class byucc.jhdl.synth.graph.NamedObject
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ControlFlowGraph

public ControlFlowGraph()
Create a new unnamed ContorlFlowGraph


ControlFlowGraph

public ControlFlowGraph(java.lang.String name)
Constructs a new ControlFlowGraph with the given name.

Method Detail

newVertex

protected Vertex newVertex(java.lang.String name)
Overrides newVertex in Graph so that all vertices in a ControlFlowGraph will be of type CFVertex.

Overrides:
newVertex in class Graph
Parameters:
name - the name for the new vertex.
Returns:
a new CFVertex created in this ControlFlowGraph.

newEdge

protected Edge newEdge(Vertex tail,
                       Vertex head)
Overrides newEdge in Graph so that all edges in a ControlFlowGraph will be of type CFEdge.

Overrides:
newEdge in class Graph
Parameters:
tail - the tail for the new edge.
head - the head for the new edge.
Returns:
A new CFEdge in this graph pointing from tail to head.

addCFVertex

public CFVertex addCFVertex(java.lang.String name)
Add a new CFVertex to the graph. This is simply a convenience method allowing a call to addVertex in Graph and hiding the cast to CFVertex.

Parameters:
name - The name for the new vertex.
Returns:
a new CFVertex added to this ControlFlowGraph.

addCFEdge

public CFEdge addCFEdge(CFVertex tail,
                        CFVertex head)
Add a new CFEdge to the graph. This is simply a convenience method allowing a call to addEdge in Graph and hiding the cast to CFEdge.

Parameters:
tail - the tail vertex for the new edge.
head - the head vertex for the new edge.
Returns:
a new CFEdge in this graph pointing from tail to head.

addCFEdge

public CFEdge addCFEdge(CFVertex tail,
                        CFVertex head,
                        java.lang.String weight)
Add a new CFEdge with the given weight to the graph.

Parameters:
tail - the tail vertex for the new edge.
head - the head vertex for the new edge.
weight - the weight for the new edge.
Returns:
a new CFEdge in this graph pointing from tail to head.

hasBlock

public boolean hasBlock(SynthBlock sb)
Does this graph have a block vertex associated with the given SynthBlock.

Parameters:
sb - A SynthBlock to look up in the graph.
Returns:
true if there exists a block in the graph associated with sb, false otherwise.
See Also:
getBlock(byucc.jhdl.synth.SynthBlock)

getBlock

public CFVertex getBlock(SynthBlock sb)
Get a block from the graph associated with the given SynthBlock, (null if none exists)

Parameters:
sb - A SynthBlock to look up in the graph.
Returns:
If there is a block in the graph with the given SynthBlock, return it. If there is no block with that SynthBlock return null.
See Also:
hasBlock(byucc.jhdl.synth.SynthBlock), addBlock(byucc.jhdl.synth.SynthBlock, byucc.jhdl.synth.DataFlowGraph)

addBlock

public CFVertex addBlock(SynthBlock sb,
                         DataFlowGraph dfGraph)
Add a new block to this ControlFlowGraph associated with the given SynthBlock or return one that existed previously.

Parameters:
sb - the SynthBlock with which this vertex will be associated
dfGraph - the DataFlowGraph in which this block will have a subgraph
Returns:
a block in the graph associated with sb, either a new vertex or an existing one.

addDecision

public CFVertex addDecision(java.lang.String name)
Add a new decision to this ControlFlowGraph. This method creates a new CFVertex named name and makes it a decision.

Parameters:
name - the name for the new decision.
Returns:
a new decision in the graph named name.

getBlocks

public BlockIterator getBlocks()
Get a list of all the blocks in this ControlFlowGraph

Returns:
a new BlockIterator which provides access to all blocks in this graph.


Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.