harpoon.IR.Properties
Class CFGrapher<HCE extends HCodeElement>

java.lang.Object
  extended by harpoon.IR.Properties.CFGrapher<HCE>

public abstract class CFGrapher<HCE extends HCodeElement>
extends Object

CFGrapher provides a means to externally associate control-flow graph information with elements of an intermediate representation.

Version:
$Id: CFGrapher.java,v 1.6 2004/02/08 01:55:20 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
CFGraphable

Field Summary
static CFGrapher DEFAULT
          Default CFGrapher for HCodeElements which implement CFGraphable.
 
Constructor Summary
CFGrapher()
           
 
Method Summary
 List<HCodeEdge<HCE>> edgeC(HCE hc)
          Returns a List of all the edges to and from this HCodeElement.
 CFGrapher<HCE> edgeReversed()
          Returns an edge-reversed grapher based on this one.
 Set<HCE> getElements(HCode<HCE> code)
           
abstract  HCE getFirstElement(HCode<HCE> hcode)
          Deprecated. Use getFirstElements() instead.
 HCE[] getFirstElements(HCode<HCE> hcode)
          Returns the first HCodeElements to be executed; that is, the roots of the control-flow graph.
abstract  HCE[] getLastElements(HCode<HCE> hcode)
          Returns the last HCodeElements to be executed; that is, the leaves of the control-flow graph.
abstract  List<HCodeEdge<HCE>> predC(HCE hc)
          Returns a List of all the edges to this HCodeElement.
 Collection<HCE> predElemC(HCE hc)
          Returns a Collection of all the HCodeElements preceeding hc.
abstract  List<HCodeEdge<HCE>> succC(HCE hc)
          Returns a List of all the edges from this HCodeElement.
 Collection<HCE> succElemC(HCE hc)
          Returns a Collection of all the HCodeElement succeeding hc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final CFGrapher DEFAULT
Default CFGrapher for HCodeElements which implement CFGraphable. Does nothing but cast the supplied HCodeElement to a CFGraphable and invoke the appropriate corresponding method in the CFGraphable interface. The root of the control flow graph is assumed to be whatever HCode.getRootElement returns.

See Also:
Comparator, Comparable, Default.comparator
Constructor Detail

CFGrapher

public CFGrapher()
Method Detail

getFirstElements

public HCE[] getFirstElements(HCode<HCE> hcode)
Returns the first HCodeElements to be executed; that is, the roots of the control-flow graph.


getLastElements

public abstract HCE[] getLastElements(HCode<HCE> hcode)
Returns the last HCodeElements to be executed; that is, the leaves of the control-flow graph.


getFirstElement

public abstract HCE getFirstElement(HCode<HCE> hcode)
Deprecated. Use getFirstElements() instead.

This method is present for compatibility only.


edgeC

public List<HCodeEdge<HCE>> edgeC(HCE hc)
Returns a List of all the edges to and from this HCodeElement.


predC

public abstract List<HCodeEdge<HCE>> predC(HCE hc)
Returns a List of all the edges to this HCodeElement. Each HCodeEdge returned is guaranteed to return hc in response to a call to to(); the actual predecessor will be returned from from().


succC

public abstract List<HCodeEdge<HCE>> succC(HCE hc)
Returns a List of all the edges from this HCodeElement. Each HCodeEdge returned is guaranteed to return hc in response to a call to from(); the actual successor to this will be returned from to().


predElemC

public Collection<HCE> predElemC(HCE hc)
Returns a Collection of all the HCodeElements preceeding hc.


succElemC

public Collection<HCE> succElemC(HCE hc)
Returns a Collection of all the HCodeElement succeeding hc.


getElements

public Set<HCE> getElements(HCode<HCE> code)

edgeReversed

public CFGrapher<HCE> edgeReversed()
Returns an edge-reversed grapher based on this one. Certain algorithms operate more naturally on this representation --- for example, the difference between a dominator tree and a post-dominator tree is now simply whether you use the grapher or grapher.edgeReversed().