harpoon.IR.Quads
Class PHI

java.lang.Object
  extended by harpoon.IR.Quads.Quad
      extended by harpoon.IR.Quads.PHI
All Implemented Interfaces:
HCodeElement, CFGraphable<Quad,Edge>, UseDefable, Graph.Node<Quad,Edge>, Serializable, Cloneable, Comparable<Quad>
Direct Known Subclasses:
LABEL

public class PHI
extends Quad

PHI objects represent blocks of phi functions.

Version:
$Id: PHI.java,v 1.6 2002/09/01 07:34:46 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Field Summary
protected  Temp[] dst
          dst[i] is the left-hand side of the i'th phi function in this block.
protected  Temp[][] src
          src[i][j] is the j'th parameter to the i'th phi function in this block.
 
Fields inherited from class harpoon.IR.Quads.Quad
arrayFactory
 
Constructor Summary
PHI(QuadFactory qf, HCodeElement source, Temp[] dst, int arity)
          Creates a PHI object with the specified arity.
PHI(QuadFactory qf, HCodeElement source, Temp[] dst, Temp[][] src, int arity)
          Creates a PHI object representing a block of phi functions.
 
Method Summary
<T> T
accept(QuadValueVisitor<T> v)
           
 void accept(QuadVisitor v)
          Accept a visitor.
 int arity()
          Returns the number of arguments each phi function has.
 Temp[] def()
          Returns all the Temps defined by this Quad.
 Temp dst(int nPhi)
          Returns the right hand side of the nPhi'th phi function assignment in the block.
 PHI grow(Temp[] args, int which_pred)
          Grow the arity of a PHI by one by replacing it.
 boolean hasConflicts()
          Returns true if any of the sources of any of the phi functions match a destination of a phi function.
 int kind()
          Return an integer enumeration of the kind of this Quad.
 int numPhis()
          Returns the number of phi functions in the block.
 void removePhi(int nPhi)
          Deprecated. does not preserve immutability.
 void removePred(int which_pred)
          Deprecated. does not preserve immutability.
 Quad rename(QuadFactory qqf, TempMap defMap, TempMap useMap)
          Create a new Quad identical to the receiver, but with all Temps renamed according to a mapping.
 PHI shrink(int which_pred)
          Shrink the arity of a PHI by replacing it.
 Temp[] src(int nPhi)
          Returns an array holding the arguments to the nPhi'th phi function in the block.
 Temp src(int nPhi, int nParam)
          Returns the nParam'th argument of the nPhi'th phi function in the block.
 String toString()
          Returns a human-readable representation of this Quad.
 Temp[] use()
          Returns all the Temps used by this Quad.
 
Methods inherited from class harpoon.IR.Quads.Quad
addEdge, addEdges, addHandlers, clone, clone, clone, compareTo, defC, edgeC, edges, getFactory, getID, getLineNumber, getSourceFile, handlers, hashCode, isPred, isSucc, map, map, map, next, next, nextEdge, nextEdge, nextLength, pred, predC, prev, prev, prevEdge, prevEdge, prevLength, remove, removeHandlers, rename, replace, succ, succC, toLongString, transferHandlers, useC
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dst

protected Temp[] dst
dst[i] is the left-hand side of the i'th phi function in this block.


src

protected Temp[][] src
src[i][j] is the j'th parameter to the i'th phi function in this block.

Constructor Detail

PHI

public PHI(QuadFactory qf,
           HCodeElement source,
           Temp[] dst,
           Temp[][] src,
           int arity)
Creates a PHI object representing a block of phi functions.

Parameters:
dst - the left hand sides of a phi function assignment block.
src - the phi function parameters in a phi function assignment block.

PHI

public PHI(QuadFactory qf,
           HCodeElement source,
           Temp[] dst,
           int arity)
Creates a PHI object with the specified arity. Each phi function will have arity arguments.

Parameters:
dst - the left hand sides of the phi functions.
arity - the number of predecessors of this quad.
Method Detail

dst

public Temp dst(int nPhi)
Returns the right hand side of the nPhi'th phi function assignment in the block.


src

public Temp src(int nPhi,
                int nParam)
Returns the nParam'th argument of the nPhi'th phi function in the block.


src

public Temp[] src(int nPhi)
Returns an array holding the arguments to the nPhi'th phi function in the block.


numPhis

public int numPhis()
Returns the number of phi functions in the block.


arity

public int arity()
Returns the number of arguments each phi function has.


removePhi

public void removePhi(int nPhi)
Deprecated. does not preserve immutability.

Removes a given phi function from the block.


removePred

public void removePred(int which_pred)
Deprecated. does not preserve immutability.

Remove a predecessor from this phi, reducing the arity.


shrink

public PHI shrink(int which_pred)
Shrink the arity of a PHI by replacing it.

Returns:
the new PHI.

grow

public PHI grow(Temp[] args,
                int which_pred)
Grow the arity of a PHI by one by replacing it.

Returns:
the new PHI.

use

public Temp[] use()
Returns all the Temps used by this Quad.

Specified by:
use in interface UseDefable
Overrides:
use in class Quad

def

public Temp[] def()
Returns all the Temps defined by this Quad.

Specified by:
def in interface UseDefable
Overrides:
def in class Quad

kind

public int kind()
Description copied from class: Quad
Return an integer enumeration of the kind of this Quad. The enumerated values are defined in QuadKind.

Specified by:
kind in class Quad

rename

public Quad rename(QuadFactory qqf,
                   TempMap defMap,
                   TempMap useMap)
Description copied from class: Quad
Create a new Quad identical to the receiver, but with all Temps renamed according to a mapping. The new Quad will have no edges.

The new Quad will come from the specified QuadFactory.

Specified by:
rename in class Quad

hasConflicts

public boolean hasConflicts()
Returns true if any of the sources of any of the phi functions match a destination of a phi function. This case is legal, but makes translating PHI functions to MOVEs 'tricky'.


accept

public void accept(QuadVisitor v)
Description copied from class: Quad
Accept a visitor.

Specified by:
accept in class Quad

accept

public <T> T accept(QuadValueVisitor<T> v)
Specified by:
accept in class Quad

toString

public String toString()
Returns a human-readable representation of this Quad.

Specified by:
toString in class Quad