harpoon.IR.Quads
Class Code

java.lang.Object
  extended by harpoon.ClassFile.HCode<Quad>
      extended by harpoon.IR.Quads.Code
All Implemented Interfaces:
Graph<Quad,Edge>, Serializable
Direct Known Subclasses:
Code, QuadNoSSA, QuadRSSx, QuadSSA, QuadSSI, QuadWithTry, ResilientNoSSA

public abstract class Code
extends HCode<Quad>
implements Serializable, Graph<Quad,Edge>

Quads.Code is an abstract superclass of codeviews using the components in IR.Quads. It implements shared methods for the various codeviews using Quads.

Version:
$Id: Code.java,v 1.14 2004/02/08 01:55:25 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class harpoon.ClassFile.HCode
HCode.PrintCallback<HCE extends HCodeElement>
 
Nested classes/interfaces inherited from interface harpoon.Util.Collections.Graph
Graph.Edge<N extends Graph.Node<N,E>,E extends Graph.Edge<N,E>>, Graph.Node<N extends Graph.Node<N,E>,E extends Graph.Edge<N,E>>
 
Field Summary
protected  AllocationInformation<Quad> ai
          AllocationInformation for this HCode.
protected  HMethod parent
          The method that this code view represents.
protected  QuadFactory qf
          Quad factory.
protected  Quad quads
          The quadruples composing this code view.
 
Constructor Summary
protected Code(HMethod parent, Quad quads)
          constructor.
 
Method Summary
abstract  HCodeAndMaps<Quad> clone(HMethod newMethod)
          Clone this code representation.
protected  HCodeAndMaps<Quad> cloneHelper(Code qc)
          Helper for clone
protected  HCodeAndMaps<Quad> cloneHelper(Code _this, Code qc)
          Helper for clone
 ArrayFactory<Quad> elementArrayFactory()
          Return an ArrayFactory for the HCodeElements composing this HCode.
 AllocationInformation<Quad> getAllocationInformation()
          Return the AllocationInformation for this codeview.
 Derivation<Quad> getDerivation()
          Return a Derivation for this codeview.
 Quad[] getElements()
          Deprecated.  
 Iterator<Quad> getElementsI()
          Returns an iterator over the Quads making up this code view.
 Quad[] getLeafElements()
          Returns the leaves of the control flow graph.
 HMethod getMethod()
          Return the HMethod this codeview belongs to.
abstract  String getName()
          Return the name of this code view.
 HEADER getRootElement()
          Returns the root of the control flow graph.
protected  QuadFactory newQF(HMethod parent)
          Create a proper QuadFactory.
 Set<Quad> nodes()
          Return the set of nodes comprising this Graph.
 void notifyReplace(Quad oldquad, Quad newquad, TempMap tm)
          Subclasses of Code that want to be notified when some optimization replace one of their quads with some other quad can override this method.
 void print(PrintWriter pw, HCode.PrintCallback<Quad> callback)
          Pretty-print this code view using the specified callback.
 List<Quad> selectAllocations()
          Returns the list of all allocation sites (ie, NEW and ANEW quads) from this code.
 List<Quad> selectCALLs()
          Returns the list of all CALL quads from this code.
 List<Quad> selectQuads(QuadValueVisitor<Boolean> v)
          Returns the list of all quads q from this code for which q.accept(v) is true.
 void setAllocationInformation(AllocationInformation<Quad> ai)
          Set an AllocationInformation for this codeview.
 
Methods inherited from class harpoon.ClassFile.HCode
clone, elementIndexer, getElementsL, print, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected final HMethod parent
The method that this code view represents.


quads

protected Quad quads
The quadruples composing this code view.


qf

protected final QuadFactory qf
Quad factory.


ai

protected AllocationInformation<Quad> ai
AllocationInformation for this HCode.

Constructor Detail

Code

protected Code(HMethod parent,
               Quad quads)
constructor.

Method Detail

newQF

protected QuadFactory newQF(HMethod parent)
Create a proper QuadFactory.


clone

public abstract HCodeAndMaps<Quad> clone(HMethod newMethod)
Clone this code representation. The clone has its own copy of the quad graph.

Overrides:
clone in class HCode<Quad>

cloneHelper

protected final HCodeAndMaps<Quad> cloneHelper(Code qc)
Helper for clone


cloneHelper

protected HCodeAndMaps<Quad> cloneHelper(Code _this,
                                         Code qc)
Helper for clone


getName

public abstract String getName()
Return the name of this code view.

Specified by:
getName in class HCode<Quad>

getMethod

public HMethod getMethod()
Return the HMethod this codeview belongs to.

Specified by:
getMethod in class HCode<Quad>

getAllocationInformation

public AllocationInformation<Quad> getAllocationInformation()
Return the AllocationInformation for this codeview.


setAllocationInformation

public void setAllocationInformation(AllocationInformation<Quad> ai)
Set an AllocationInformation for this codeview.


getDerivation

public Derivation<Quad> getDerivation()
Return a Derivation for this codeview.

Returns:
null, always.

getRootElement

public HEADER getRootElement()
Returns the root of the control flow graph.

Overrides:
getRootElement in class HCode<Quad>
Returns:
root of the code view, or null if this notion is not applicable.

getLeafElements

public Quad[] getLeafElements()
Returns the leaves of the control flow graph.

Overrides:
getLeafElements in class HCode<Quad>
Returns:
leaves of the code view, or null if this notion is not applicable.

getElements

public Quad[] getElements()
Deprecated. 

Returns an ordered list of the Quads making up this code view. The root of the graph is in element 0 of the array.

Overrides:
getElements in class HCode<Quad>
See Also:
Instr

getElementsI

public Iterator<Quad> getElementsI()
Returns an iterator over the Quads making up this code view. The root of the graph is the first element in the iteration.

Overrides:
getElementsI in class HCode<Quad>

elementArrayFactory

public ArrayFactory<Quad> elementArrayFactory()
Description copied from class: HCode
Return an ArrayFactory for the HCodeElements composing this HCode.

Specified by:
elementArrayFactory in class HCode<Quad>

nodes

public Set<Quad> nodes()
Description copied from interface: Graph
Return the set of nodes comprising this Graph.

Specified by:
nodes in interface Graph<Quad,Edge>

print

public void print(PrintWriter pw,
                  HCode.PrintCallback<Quad> callback)
Description copied from class: HCode
Pretty-print this code view using the specified callback.

Overrides:
print in class HCode<Quad>

selectQuads

public List<Quad> selectQuads(QuadValueVisitor<Boolean> v)
Returns the list of all quads q from this code for which q.accept(v) is true.


selectCALLs

public List<Quad> selectCALLs()
Returns the list of all CALL quads from this code.


selectAllocations

public List<Quad> selectAllocations()
Returns the list of all allocation sites (ie, NEW and ANEW quads) from this code.


notifyReplace

public void notifyReplace(Quad oldquad,
                          Quad newquad,
                          TempMap tm)
Subclasses of Code that want to be notified when some optimization replace one of their quads with some other quad can override this method. This can be useful for updating mappings that attach information to quads (i.e., allocation policies, QuadNoSSA to QuadSSI mappings etc.). See the code of DeadCode.replace for an example.

Parameters:
oldquad - quad that is being replaced
newquad - new quad that replaces oldquad
tm - maps old temps to new temps