Package com.tonic.analysis.ssa.ir
Class PhiInstruction
- java.lang.Object
-
- com.tonic.analysis.ssa.ir.IRInstruction
-
- com.tonic.analysis.ssa.ir.PhiInstruction
-
public class PhiInstruction extends IRInstruction
An SSA phi merging one incoming value per predecessor block.
-
-
Constructor Summary
Constructors Constructor Description PhiInstruction(SSAValue result)Creates a phi with no incoming values yet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(IRVisitor<T> visitor)Accepts a visitor for this instruction.voidaddIncoming(Value value, IRBlock fromBlock)Adds an incoming value from a predecessor block.ValuegetIncoming(IRBlock fromBlock)Gets the incoming value from a specific predecessor block.Set<IRBlock>getIncomingBlocks()Gets all predecessor blocks with incoming values.Map<IRBlock,Value>getIncomingValues()List<Value>getOperands()Gets the operands used by this instruction.booleanisPhi()Checks if this is a phi instruction.voidremoveIncoming(IRBlock fromBlock)Removes an incoming value from a predecessor block.voidreplaceOperand(Value oldValue, Value newValue)Replaces an operand value with a new value.StringtoString()-
Methods inherited from class com.tonic.analysis.ssa.ir.IRInstruction
copyWithNewOperands, equals, getBlock, getBytecodeOffset, getId, getResult, getResultType, hashCode, hasResult, isTerminator, replaceTarget, resetIdCounter, setBlock, setBytecodeOffset, setResult
-
-
-
-
Constructor Detail
-
PhiInstruction
public PhiInstruction(SSAValue result)
Creates a phi with no incoming values yet.- Parameters:
result- the SSA value receiving the merged value
-
-
Method Detail
-
addIncoming
public void addIncoming(Value value, IRBlock fromBlock)
Adds an incoming value from a predecessor block.- Parameters:
value- the incoming valuefromBlock- the predecessor block
-
removeIncoming
public void removeIncoming(IRBlock fromBlock)
Removes an incoming value from a predecessor block.- Parameters:
fromBlock- the predecessor block
-
getIncoming
public Value getIncoming(IRBlock fromBlock)
Gets the incoming value from a specific predecessor block.- Parameters:
fromBlock- the predecessor block- Returns:
- the incoming value, or null if not present
-
getIncomingBlocks
public Set<IRBlock> getIncomingBlocks()
Gets all predecessor blocks with incoming values.- Returns:
- set of predecessor blocks
-
getOperands
public List<Value> getOperands()
Description copied from class:IRInstructionGets the operands used by this instruction.- Specified by:
getOperandsin classIRInstruction- Returns:
- list of operand values
-
replaceOperand
public void replaceOperand(Value oldValue, Value newValue)
Description copied from class:IRInstructionReplaces an operand value with a new value.- Specified by:
replaceOperandin classIRInstruction- Parameters:
oldValue- the value to replacenewValue- the replacement value
-
accept
public <T> T accept(IRVisitor<T> visitor)
Description copied from class:IRInstructionAccepts a visitor for this instruction.- Specified by:
acceptin classIRInstruction- Type Parameters:
T- the return type- Parameters:
visitor- the visitor to accept- Returns:
- the visitor result
-
isPhi
public boolean isPhi()
Description copied from class:IRInstructionChecks if this is a phi instruction.- Overrides:
isPhiin classIRInstruction- Returns:
- true if this is a phi instruction
-
-