Package com.android.dx.ssa
Class PhiInsn
java.lang.Object
com.android.dx.ssa.SsaInsn
com.android.dx.ssa.PhiInsn
A Phi instruction (magical post-control-flow-merge) instruction
in SSA form. Will be converted to moves in predecessor blocks before
conversion back to ROP form.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Visitor interface for instances of this (outer) class. -
Constructor Summary
ConstructorDescriptionPhiInsn
(int resultReg, SsaBasicBlock block) Makes a phi insn with a void result type.PhiInsn
(RegisterSpec resultReg, SsaBasicBlock block) Constructs a new phi insn with no operands. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Accepts a visitor.void
addPhiOperand
(RegisterSpec registerSpec, SsaBasicBlock predBlock) Adds an operand to this phi instruction.boolean
boolean
canThrow()
Always returns false forPhiInsn
s.void
changeResultType
(TypeBearer type, LocalItem local) Changes the result type.clone()
Returns the Rop opcode for this insn, or null if this is a phi insn.Returns the original Rop insn for this insn, or null if this is a phi insn.int
Gets the original rop-form result reg.Gets sources.boolean
Returns true if this insn is considered to have a side effect beyond that of assigning to the result reg.boolean
boolean
isRegASource
(int reg) Indicates whether the specified register is amongst the registers used as sources for this instruction.final void
mapSourceRegisters
(RegisterMapper mapper) Maps only source registers.int
predBlockIndexForSourcesIndex
(int sourcesIndex) Gets the index of the pred block associated with the RegisterSpec at the particular getSources() index.predBlocksForReg
(int reg, SsaMethod ssaMeth) Returns the list of predecessor blocks associated with all operands that havereg
as an operand register.void
removePhiRegister
(RegisterSpec registerSpec) Removes all operand uses of a register from this phi instruction.toHuman()
Return the "human" string form of this instance.protected final String
toHumanWithInline
(String extra) Returns human-readable string for listing dumps.Always throws an exeption, since a phi insn may not be converted back to rop form.void
updateSourcesToDefinitions
(SsaMethod ssaMeth) Updates the TypeBearers of all the sources (phi operands) to be the current TypeBearer of the register-defining instruction's result.Methods inherited from class com.android.dx.ssa.SsaInsn
changeResultReg, getBlock, getLocalAssignment, getResult, isMoveException, isNormalMoveInsn, isResultReg, makeFromRop, mapRegisters, setResult, setResultLocal
-
Constructor Details
-
PhiInsn
Constructs a new phi insn with no operands.- Parameters:
resultReg
- the result reg for this phi insnblock
- block containing this insn.
-
PhiInsn
Makes a phi insn with a void result type.- Parameters:
resultReg
- the result register for this phi insn.block
- block containing this insn.
-
-
Method Details
-
clone
-
updateSourcesToDefinitions
Updates the TypeBearers of all the sources (phi operands) to be the current TypeBearer of the register-defining instruction's result. This is used during phi-type resolution.Note that local association of operands are preserved in this step.
- Parameters:
ssaMeth
- method that contains this insn
-
changeResultType
Changes the result type. Used during phi type resolution- Parameters:
type
-non-null;
new TypeBearerlocal
-null-ok;
new local info, if available
-
getRopResultReg
public int getRopResultReg()Gets the original rop-form result reg. This is useful during renaming.- Returns:
- the original rop-form result reg
-
addPhiOperand
Adds an operand to this phi instruction.- Parameters:
registerSpec
- register spec, including type and reg of operandpredBlock
- predecessor block to be associated with this operand
-
removePhiRegister
Removes all operand uses of a register from this phi instruction.- Parameters:
registerSpec
- register spec, including type and reg of operand
-
predBlockIndexForSourcesIndex
public int predBlockIndexForSourcesIndex(int sourcesIndex) Gets the index of the pred block associated with the RegisterSpec at the particular getSources() index.- Parameters:
sourcesIndex
- index of source in getSources()- Returns:
- block index
-
getOpcode
Returns the Rop opcode for this insn, or null if this is a phi insn. TODO: Move this up into NormalSsaInsn. Always returns null forPhiInsn
s. -
getOriginalRopInsn
Returns the original Rop insn for this insn, or null if this is a phi insn. TODO: Move this up into NormalSsaInsn. Always returns null forPhiInsn
s.- Specified by:
getOriginalRopInsn
in classSsaInsn
- Returns:
null-ok;
Rop insn if there is one.
-
canThrow
public boolean canThrow()Always returns false forPhiInsn
s. -
getSources
Gets sources. Constructed lazily from phi operand data structures and then cached.- Specified by:
getSources
in classSsaInsn
- Returns:
non-null;
sources list
-
isRegASource
public boolean isRegASource(int reg) Indicates whether the specified register is amongst the registers used as sources for this instruction.- Overrides:
isRegASource
in classSsaInsn
- Parameters:
reg
- the register in question- Returns:
- true if the reg is a source
-
areAllOperandsEqual
public boolean areAllOperandsEqual()- Returns:
- true if all operands use the same register
-
mapSourceRegisters
Maps only source registers.- Specified by:
mapSourceRegisters
in classSsaInsn
- Parameters:
mapper
- new mapping
-
toRopInsn
Always throws an exeption, since a phi insn may not be converted back to rop form. -
predBlocksForReg
Returns the list of predecessor blocks associated with all operands that havereg
as an operand register.- Parameters:
reg
- register to look upssaMeth
- method we're operating on- Returns:
- list of predecessor blocks, empty if none
-
isPhiOrMove
public boolean isPhiOrMove()- Specified by:
isPhiOrMove
in classSsaInsn
- Returns:
- true if this is a PhiInsn or a normal move insn
-
hasSideEffect
public boolean hasSideEffect()Returns true if this insn is considered to have a side effect beyond that of assigning to the result reg.- Specified by:
hasSideEffect
in classSsaInsn
- Returns:
- true if this insn is considered to have a side effect beyond that of assigning to the result reg.
-
accept
Accepts a visitor. -
toHuman
Return the "human" string form of this instance. This is generally less "debuggy" thantoString()
.- Returns:
non-null;
the human string form
-
toHumanWithInline
Returns human-readable string for listing dumps. This method allows sub-classes to specify extra text.- Parameters:
extra
-null-ok;
the argument to print after the opcode- Returns:
- human-readable string for listing dumps
-