cfg
Class PhiInst

java.lang.Object
  extended by cfg.TACInst
      extended by cfg.PhiInst

public class PhiInst
extends TACInst

A class representing a three-address code Phi instruction (BinaryPhiInst). A phi instruction consists of a destination variable and a number of source operands, one for each predecessor.


Field Summary
 
Fields inherited from class cfg.TACInst
BINADD, BINAND, BINDIV, BINMOD, BINMUL, BINOR, BINSUB, comments, DIRCALL, ERRPARAM, IF, INDIRCALL, LDADDR, LDCONST, LDENTRY, LDVAR, NUM_INSN_TYPES, opcode, PHI, REFPARAM, RETN, STDPARAM, STENTRY, UNNEG, UNNOT
 
Constructor Summary
PhiInst(java.lang.String destination, java.lang.String orgVar, int initialParams)
          BinaryPhiInst constructor
 
Method Summary
<ReturnType,ArgumentType>
ReturnType
accept(TACInstVisitor<ReturnType,ArgumentType> visitor, ArgumentType o)
          Abstract visitor method.
 boolean equals(java.lang.Object o)
          Compares this object with the parameter object
 java.lang.String getDestination()
          Returns the destination.
 int getNonRedundantParam()
          Returns the index of the first parameter which is not equal to the destination.
 java.lang.String getNthSource(int n)
          Returns the nth source operand of the phi-instruction.
 int getNumParams()
          Returns the number of params.
 java.lang.String getOriginalVar()
          Returns the name of the original variable this phi assignment is for.
 java.lang.String getString()
          Get string representation of instruction (without comments) (note: in general, you want to use toString() to get instruction string)
 boolean isCompletelyRedundant()
          Returns true, if phi-instruction is of general form x = phi(x, x, ..., x).
 boolean isRedundant()
          Returns true, if phi-instruction is of general form x = phi(x, ..., x, y, x, ..., x).
 void setDestination(java.lang.String dest)
          Sets the destination.
 void setNthSource(int n, java.lang.String source)
          Sets the nth source operand of the phi-instruction.
 
Methods inherited from class cfg.TACInst
addComment, checkBoolConst, checkConst, checkIntConst, checkLabel, checkStrConst, checkVar, getBinaryOpcode, getComments, getOp, getOpcode, getUnaryOpcode, isBinary, isCall, isIf, isLoad, isParam, isReturn, isStore, isUnary, isValidID, removeComments, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PhiInst

public PhiInst(java.lang.String destination,
               java.lang.String orgVar,
               int initialParams)
BinaryPhiInst constructor

Parameters:
destination - destination variable
orgVar - original variable
initialParams - initial number of source operands
Method Detail

getDestination

public java.lang.String getDestination()
Returns the destination.

Returns:
destination

setDestination

public void setDestination(java.lang.String dest)
Sets the destination.

Parameters:
dest - destination

getNumParams

public int getNumParams()
Returns the number of params.

Returns:
number of params

getNthSource

public java.lang.String getNthSource(int n)
Returns the nth source operand of the phi-instruction.

Parameters:
n - nth param
Returns:
nth source

setNthSource

public void setNthSource(int n,
                         java.lang.String source)
Sets the nth source operand of the phi-instruction.

Parameters:
n - nth param
source - new source operand

accept

public <ReturnType,ArgumentType> ReturnType accept(TACInstVisitor<ReturnType,ArgumentType> visitor,
                                                   ArgumentType o)
Description copied from class: TACInst
Abstract visitor method.

Specified by:
accept in class TACInst
Parameters:
visitor - TACInstVisitor.
o - Data to pass down.
Returns:
return value of visitor.

getOriginalVar

public java.lang.String getOriginalVar()
Returns the name of the original variable this phi assignment is for.

Returns:
variable name.

getString

public java.lang.String getString()
Get string representation of instruction (without comments) (note: in general, you want to use toString() to get instruction string)

Specified by:
getString in class TACInst
Returns:
string representation of three address code instruction (without comments)

isCompletelyRedundant

public boolean isCompletelyRedundant()
Returns true, if phi-instruction is of general form x = phi(x, x, ..., x).

Returns:

isRedundant

public boolean isRedundant()
Returns true, if phi-instruction is of general form x = phi(x, ..., x, y, x, ..., x).

Returns:

getNonRedundantParam

public int getNonRedundantParam()
Returns the index of the first parameter which is not equal to the destination.

Returns:
index of source param

equals

public boolean equals(java.lang.Object o)
Description copied from class: TACInst
Compares this object with the parameter object

Specified by:
equals in class TACInst
Parameters:
o - object to compare the reference object with
Returns:
boolean indicating whether the objects are equivalent