public interface PhiExpr extends ShimpleExpr
As much as possible we try to conform to the semantics as described by Cytron et al., TOPLAS Oct. 91. A Phi node such as "x_1 = Phi(x_2, x_3)" is eliminated by respectively adding the statements "x_1 = x_2" and "x_1 = x_3" at the end of the corresponding control flow predecessor.
However, due to the fact that each argument is explicitly associated with the control flow predecessor, there may be some subtle differences. We tried to make the behaviour as robust and transparent as possible by handling the common cases of Unit chain manipulations in the Shimple internal implementation of PatchingChain.
Modifier and Type | Method and Description |
---|---|
boolean |
addArg(Value arg,
Block pred)
Add the given argument associated with the given CFG
predecessor.
|
boolean |
addArg(Value arg,
Unit predTailUnit)
Add the given argument associated with the given CFG
predecessor.
|
void |
apply(Switch sw)
Called when this object is visited.
|
ValueUnitPair |
getArgBox(Block pred)
Returns the argument pair corresponding to the given CFG
predecessor.
|
ValueUnitPair |
getArgBox(int index)
Returns the argument pair for the given index.
|
ValueUnitPair |
getArgBox(Unit predTailUnit)
Returns the argument pair corresponding to the given CFG
predecessor.
|
int |
getArgCount()
Returns the number of arguments in this PhiExpr.
|
int |
getArgIndex(Block pred)
Returns the index of the argument associated with the given
control flow predecessor.
|
int |
getArgIndex(Unit predTailUnit)
Returns the index of the argument associated with the given
control flow predecessor Unit.
|
java.util.List<ValueUnitPair> |
getArgs()
Returns an unmodifiable, backed view of the arguments to this PhiExpr.
|
int |
getBlockId()
Returns the id number of the block from which the Phi node
originated from.
|
Unit |
getPred(int index)
Returns the control flow predecessor Unit for the given index
into the PhiExpr.
|
java.util.List<Unit> |
getPreds()
Returns a list of the control flow predecessor Units being
tracked by this PhiExpr
|
Type |
getType()
The type of the PhiExpr is usually the same as the type of its
arguments.
|
Value |
getValue(Block pred)
Get the PhiExpr argument corresponding to the given control flow
predecessor, returns null if not available.
|
Value |
getValue(int index)
Returns the value for the given index into the PhiExpr.
|
Value |
getValue(Unit predTailUnit)
Get the PhiExpr argument corresponding to the given control
flow predecessor, returns null if not available.
|
java.util.List<Value> |
getValues()
Returns a list of the values used by this PhiExpr.
|
boolean |
removeArg(Block pred)
Remove the argument corresponding to the given CFG predecessor.
|
boolean |
removeArg(int index)
Remove the argument at the given index.
|
boolean |
removeArg(Unit predTailUnit)
Remove the argument corresponding to the given CFG predecessor.
|
boolean |
removeArg(ValueUnitPair arg)
Remove the given argument.
|
boolean |
setArg(int index,
Value arg,
Block pred)
Modify the PhiExpr argument at the given index with the given
information.
|
boolean |
setArg(int index,
Value arg,
Unit predTailUnit)
Modify the PhiExpr argument at the given index with the given
information.
|
void |
setBlockId(int blockId)
Set the block number of the Phi node.
|
boolean |
setPred(int index,
Block pred)
Update the CFG predecessor associated with the PhiExpr
argument at the given index.
|
boolean |
setPred(int index,
Unit predTailUnit)
Update the CFG predecessor associated with the PhiExpr
argument at the given index.
|
boolean |
setValue(Block pred,
Value arg)
Locate the argument associated with the given CFG predecessor
and set the value.
|
boolean |
setValue(int index,
Value arg)
Set the value at the given index into the PhiExpr.
|
boolean |
setValue(Unit predTailUnit,
Value arg)
Locate the argument associated with the given CFG predecessor unit
and set the value.
|
clone, getUseBoxes, toString
equivHashCode, equivTo
clearUnitBoxes, getUnitBoxes
java.util.List<ValueUnitPair> getArgs()
ValueUnitPair
java.util.List<Value> getValues()
java.util.List<Unit> getPreds()
int getArgCount()
ValueUnitPair getArgBox(int index)
Value getValue(int index)
Unit getPred(int index)
int getArgIndex(Unit predTailUnit)
ValueUnitPair getArgBox(Unit predTailUnit)
Value getValue(Unit predTailUnit)
int getArgIndex(Block pred)
ValueUnitPair getArgBox(Block pred)
Value getValue(Block pred)
boolean setArg(int index, Value arg, Unit predTailUnit)
boolean setArg(int index, Value arg, Block pred)
boolean setValue(int index, Value arg)
boolean setValue(Unit predTailUnit, Value arg)
boolean setValue(Block pred, Value arg)
boolean setPred(int index, Unit predTailUnit)
boolean setPred(int index, Block pred)
boolean removeArg(int index)
boolean removeArg(Unit predTailUnit)
boolean removeArg(Block pred)
boolean removeArg(ValueUnitPair arg)
boolean addArg(Value arg, Block pred)
boolean addArg(Value arg, Unit predTailUnit)
void setBlockId(int blockId)
int getBlockId()
Type getType()
void apply(Switch sw)
Switchable
apply
in interface Switchable