Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.ssa

public final Class PhiInsn

extends SsaInsn
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.code.*, org.droidparts.dexmaker.dx.rop.type.Type, .TypeBearer, org.droidparts.dexmaker.dx.util.Hex, java.util.ArrayList, .List

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
PhiInsn.Operand

A single phi operand, consiting of source register and block index for move.

public static interface
PhiInsn.Visitor

Visitor interface for instances of this (outer) class.

Field Summary

Modifier and TypeField and Description
private final ArrayList<PhiInsn.Operand>
operands

non-null; operands of the instruction; built up by addPhiOperand

private final int
ropResultReg

result register.

private RegisterSpecList
sources

null-ok; source registers; constructed lazily

Constructor Summary

AccessConstructor and Description
public
PhiInsn(RegisterSpec
the result reg for this phi insn
resultReg
,
SsaBasicBlock
block containing this insn.
block
)

Constructs a new phi insn with no operands.

public
PhiInsn(final int
the result register for this phi insn.
resultReg
,
final SsaBasicBlock
block containing this insn.
block
)

Makes a phi insn with a void result type.

Method Summary

Modifier and TypeMethod and Description
public void
accept(SsaInsn.Visitor
non-null the visitor
v
)

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.accept.

Accepts a visitor.
public void
addPhiOperand(RegisterSpec
register spec, including type and reg of operand
registerSpec
,
SsaBasicBlock
predecessor block to be associated with this operand
predBlock
)

Adds an operand to this phi instruction.

public boolean

Returns:

true if all operands use the same register
areAllOperandsEqual
()

public boolean
canThrow()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.canThrow.

Always returns false for PhiInsns.
public void
changeResultType(TypeBearer
non-null; new TypeBearer
type
,
LocalItem
null-ok; new local info, if available
local
)

Changes the result type.

public PhiInsn
clone()

Overrides org.droidparts.dexmaker.dx.ssa.SsaInsn.clone.

Creates and returns a copy of this object.
public Rop
getOpcode()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.getOpcode.

Returns the Rop opcode for this insn, or null if this is a phi insn.
public Insn
getOriginalRopInsn()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.getOriginalRopInsn.

Returns the original Rop insn for this insn, or null if this is a phi insn.
public int

Returns:

the original rop-form result reg
getRopResultReg
()

Gets the original rop-form result reg. This is useful during renaming.

public RegisterSpecList

Returns:

non-null; sources list
getSources
()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.getSources.

Gets sources.
public boolean
hasSideEffect()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.hasSideEffect.

Returns true if this insn is considered to have a side effect beyond that of assigning to the result reg.
public boolean
public boolean
isRegASource(int
the register in question
reg
)

Overrides org.droidparts.dexmaker.dx.ssa.SsaInsn.isRegASource.

Indicates whether the specified register is amongst the registers used as sources for this instruction.
public final void
mapSourceRegisters(RegisterMapper
new mapping
mapper
)

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.mapSourceRegisters.

Maps only source registers.
public int

Returns:

block index
predBlockIndexForSourcesIndex
(int
index of source in getSources()
sourcesIndex
)

Gets the index of the pred block associated with the RegisterSpec at the particular getSources() index.

public List<SsaBasicBlock>

Returns:

list of predecessor blocks, empty if none
predBlocksForReg
(int
register to look up
reg
,
SsaMethod
method we're operating on
ssaMeth
)

Returns the list of predecessor blocks associated with all operands that have reg as an operand register.

public void
removePhiRegister(RegisterSpec
register spec, including type and reg of operand
registerSpec
)

Removes all operand uses of a register from this phi instruction.

public String
toHuman()

Implements org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Return the "human" string form of this instance.
protected final String

Returns:

human-readable string for listing dumps
toHumanWithInline
(String
null-ok; the argument to print after the opcode
extra
)

Returns human-readable string for listing dumps.

public Insn

Returns:

always throws exception
toRopInsn
()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.toRopInsn.

Always throws an exeption, since a phi insn may not be converted back to rop form.
public void
updateSourcesToDefinitions(SsaMethod
method that contains this insn
ssaMeth
)

Updates the TypeBearers of all the sources (phi operands) to be the current TypeBearer of the register-defining instruction's result.

Inherited from org.droidparts.dexmaker.dx.ssa.SsaInsn:
changeResultReggetBlockgetLocalAssignmentgetResultisMoveExceptionisNormalMoveInsnisResultRegmakeFromRopmapRegisterssetResultsetResultLocal

Field Detail

operandsback to summary
private final ArrayList<PhiInsn.Operand> operands

non-null; operands of the instruction; built up by addPhiOperand

ropResultRegback to summary
private final int ropResultReg

result register. The original result register of the phi insn is needed during the renaming process after the new result register has already been chosen.

sourcesback to summary
private RegisterSpecList sources

null-ok; source registers; constructed lazily

Constructor Detail

PhiInsnback to summary
public PhiInsn(RegisterSpec resultReg, SsaBasicBlock block)

Constructs a new phi insn with no operands.

Parameters
resultReg:RegisterSpec

the result reg for this phi insn

block:SsaBasicBlock

block containing this insn.

PhiInsnback to summary
public PhiInsn(final int resultReg, final SsaBasicBlock block)

Makes a phi insn with a void result type.

Parameters
resultReg:int

the result register for this phi insn.

block:SsaBasicBlock

block containing this insn.

Method Detail

acceptback to summary
public void accept(SsaInsn.Visitor v)

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.accept.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.accept.

Accepts a visitor.

Parameters
v:SsaInsn.Visitor

non-null the visitor

Annotations
@Override
addPhiOperandback to summary
public void addPhiOperand(RegisterSpec registerSpec, SsaBasicBlock predBlock)

Adds an operand to this phi instruction.

Parameters
registerSpec:RegisterSpec

register spec, including type and reg of operand

predBlock:SsaBasicBlock

predecessor block to be associated with this operand

areAllOperandsEqualback to summary
public boolean areAllOperandsEqual()
Returns:boolean

true if all operands use the same register

canThrowback to summary
public boolean canThrow()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.canThrow.

Always returns false for PhiInsns.

Returns:boolean

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.canThrow.

true if this instruction can throw.

Annotations
@Override
changeResultTypeback to summary
public void changeResultType(TypeBearer type, LocalItem local)

Changes the result type. Used during phi type resolution

Parameters
type:TypeBearer

non-null; new TypeBearer

local:LocalItem

null-ok; new local info, if available

cloneback to summary
public PhiInsn clone()

Overrides org.droidparts.dexmaker.dx.ssa.SsaInsn.clone.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:PhiInsn

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
getOpcodeback to summary
public Rop getOpcode()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.getOpcode.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.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 for PhiInsns.
Returns:Rop

null-ok; Rop opcode if there is one.

Annotations
@Override
getOriginalRopInsnback to summary
public Insn getOriginalRopInsn()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.getOriginalRopInsn.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.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 for PhiInsns.
Returns:Insn

null-ok; Rop insn if there is one.

Annotations
@Override
getRopResultRegback to summary
public int getRopResultReg()

Gets the original rop-form result reg. This is useful during renaming.

Returns:int

the original rop-form result reg

getSourcesback to summary
public RegisterSpecList getSources()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.getSources.

Gets sources. Constructed lazily from phi operand data structures and then cached.

Returns:RegisterSpecList

non-null; sources list

Annotations
@Override
hasSideEffectback to summary
public boolean hasSideEffect()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.hasSideEffect.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.hasSideEffect.

Returns true if this insn is considered to have a side effect beyond that of assigning to the result reg.

Returns:boolean

true if this insn is considered to have a side effect beyond that of assigning to the result reg.

Annotations
@Override
isPhiOrMoveback to summary
public boolean isPhiOrMove()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.isPhiOrMove.

Returns:boolean

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.isPhiOrMove.

true if this is a PhiInsn or a normal move insn

Annotations
@Override
isRegASourceback to summary
public boolean isRegASource(int reg)

Overrides org.droidparts.dexmaker.dx.ssa.SsaInsn.isRegASource.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.isRegASource.

Indicates whether the specified register is amongst the registers used as sources for this instruction.

Parameters
reg:int

the register in question

Returns:boolean

true if the reg is a source

Annotations
@Override
mapSourceRegistersback to summary
public final void mapSourceRegisters(RegisterMapper mapper)

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.mapSourceRegisters.

Doc from org.droidparts.dexmaker.dx.ssa.SsaInsn.mapSourceRegisters.

Maps only source registers.

Parameters
mapper:RegisterMapper

new mapping

Annotations
@Override
predBlockIndexForSourcesIndexback to summary
public int predBlockIndexForSourcesIndex(int sourcesIndex)

Gets the index of the pred block associated with the RegisterSpec at the particular getSources() index.

Parameters
sourcesIndex:int

index of source in getSources()

Returns:int

block index

predBlocksForRegback to summary
public List<SsaBasicBlock> predBlocksForReg(int reg, SsaMethod ssaMeth)

Returns the list of predecessor blocks associated with all operands that have reg as an operand register.

Parameters
reg:int

register to look up

ssaMeth:SsaMethod

method we're operating on

Returns:List<SsaBasicBlock>

list of predecessor blocks, empty if none

removePhiRegisterback to summary
public void removePhiRegister(RegisterSpec registerSpec)

Removes all operand uses of a register from this phi instruction.

Parameters
registerSpec:RegisterSpec

register spec, including type and reg of operand

toHumanback to summary
public String toHuman()

Implements org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Doc from org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Return the "human" string form of this instance. This is generally less "debuggy" than toString().

Returns:String

non-null; the human string form

toHumanWithInlineback to summary
protected final String toHumanWithInline(String extra)

Returns human-readable string for listing dumps. This method allows sub-classes to specify extra text.

Parameters
extra:String

null-ok; the argument to print after the opcode

Returns:String

human-readable string for listing dumps

toRopInsnback to summary
public Insn toRopInsn()

Implements abstract org.droidparts.dexmaker.dx.ssa.SsaInsn.toRopInsn.

Always throws an exeption, since a phi insn may not be converted back to rop form.

Returns:Insn

always throws exception

Annotations
@Override
updateSourcesToDefinitionsback to summary
public 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. This is used during phi-type resolution.

Note that local association of operands are preserved in this step.

Parameters
ssaMeth:SsaMethod

method that contains this insn

org.droidparts.dexmaker.dx.ssa back to summary

private Class PhiInsn.Operand

extends Object
Class Inheritance

A single phi operand, consiting of source register and block index for move.

Field Summary

Modifier and TypeField and Description
public final int
public RegisterSpec
public final int

Constructor Summary

AccessConstructor and Description
public
Operand(RegisterSpec regSpec, int blockIndex, int ropLabel)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockIndexback to summary
public final int blockIndex
regSpecback to summary
public RegisterSpec regSpec
ropLabelback to summary
public final int ropLabel

Constructor Detail

Operandback to summary
public Operand(RegisterSpec regSpec, int blockIndex, int ropLabel)
org.droidparts.dexmaker.dx.ssa back to summary

public Interface PhiInsn.Visitor

Known Direct Implementers
org.droidparts.dexmaker.dx.ssa.back.SsaToRop.PhiVisitor

Visitor interface for instances of this (outer) class.

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

visitPhiInsnback to summary
public void visitPhiInsn(PhiInsn insn)