Package com.android.dx.ssa
Class SsaMethod
java.lang.Object
com.android.dx.ssa.SsaMethod
A method in SSA form.
-
Method Summary
Modifier and TypeMethodDescriptionint
blockIndexToRopLabel
(int bi) int
borrowSpareRegister
(int category) Borrows a register to use as a temp.Computes reachability for all blocks in the method.void
deleteInsns
(Set<SsaInsn> deletedInsns) Deletes all insns in the set from this method.void
forEachBlockDepthFirst
(boolean reverse, SsaBasicBlock.Visitor v) Walks the basic block tree in depth-first order, calling the visitor method once for every block.void
Visits blocks in dom-tree order, starting at the current node.void
forEachInsn
(SsaInsn.Visitor visitor) Visits all insns in this method.void
Visits each phi insn in this methodgetDefinitionForRegister
(int reg) Returns the insn that defines the given registerint
int
int
int
Returns a modifiable copy of the register use list.getUseListForRegister
(int reg) Returns the list of all source uses (not results) for a register.static IntList
indexListFromLabelList
(BasicBlockList ropBlocks, IntList labelList) Builds an IntList of block indices from a basic block list and a list of labels taken from Rop form.boolean
isRegALocal
(RegisterSpec spec) Checks to see if the given SSA reg is ever associated with a local local variable.boolean
isStatic()
Returnstrue
if this is a static method.Makes a new basic block for this method, which is empty besides a singleGOTO
.int
Makes a new SSA register.void
mapRegisters
(RegisterMapper mapper) Remaps unversioned registers.static SsaMethod
newFromRopMethod
(RopMethod ropMethod, int paramWidth, boolean isStatic) void
Indicates that the instruction list has changed or the SSA register count has increased, so that internal datastructures that rely on it should be rebuild.void
Returns all borrowed registers.void
Sets "back-convert mode".
-
Method Details
-
newFromRopMethod
- Parameters:
ropMethod
- rop-form method to convert fromparamWidth
- the total width, in register-units, of the method's parametersisStatic
-true
if this method has nothis
pointer argument
-
indexListFromLabelList
Builds an IntList of block indices from a basic block list and a list of labels taken from Rop form.- Parameters:
ropBlocks
- Rop blockslabelList
- list of rop block labels- Returns:
- IntList of block indices
-
makeNewGotoBlock
Makes a new basic block for this method, which is empty besides a singleGOTO
. Successors and predecessors are not yet set.- Returns:
- new block
-
getEntryBlockIndex
public int getEntryBlockIndex()- Returns:
- block index of first execution block
-
getEntryBlock
- Returns:
- first execution block
-
getExitBlockIndex
public int getExitBlockIndex()- Returns:
- block index of exit block or
-1
if there is none
-
getExitBlock
- Returns:
null-ok;
block of exit block ornull
if there is none
-
blockIndexToRopLabel
public int blockIndexToRopLabel(int bi) - Parameters:
bi
- block index or-1
for none- Returns:
- rop label or {code -1} if
bi
was-1
-
getRegCount
public int getRegCount()- Returns:
- count of registers used in this method
-
getParamWidth
public int getParamWidth()- Returns:
- the total width, in register units, of the method's parameters
-
isStatic
public boolean isStatic()Returnstrue
if this is a static method.- Returns:
true
if this is a static method
-
borrowSpareRegister
public int borrowSpareRegister(int category) Borrows a register to use as a temp. Used in the phi removal process. Call returnSpareRegisters() when done.- Parameters:
category
- width (1 or 2) of the register- Returns:
- register number to use
-
returnSpareRegisters
public void returnSpareRegisters()Returns all borrowed registers. -
getBlocks
- Returns:
non-null;
basic block list. Do not modify.
-
computeReachability
Computes reachability for all blocks in the method.- Returns:
- a BitSet of reachable blocks.
-
mapRegisters
Remaps unversioned registers.- Parameters:
mapper
- maps old registers to new.
-
getDefinitionForRegister
Returns the insn that defines the given register- Parameters:
reg
- register in question- Returns:
- insn (actual instance from code) that defined this reg or null if reg is not defined.
-
onInsnsChanged
public void onInsnsChanged()Indicates that the instruction list has changed or the SSA register count has increased, so that internal datastructures that rely on it should be rebuild. In general, the various other on* methods should be called in preference when changes occur if they are applicable. -
getUseListForRegister
Returns the list of all source uses (not results) for a register.- Parameters:
reg
- register in question- Returns:
- unmodifiable instruction list
-
getUseListCopy
Returns a modifiable copy of the register use list.- Returns:
- modifiable copy of the use-list, indexed by register
-
isRegALocal
Checks to see if the given SSA reg is ever associated with a local local variable. Each SSA reg may be associated with at most one local var.- Parameters:
spec
-non-null;
ssa reg- Returns:
- true if reg is ever associated with a local
-
makeNewSsaReg
public int makeNewSsaReg()Makes a new SSA register. For use after renaming has completed.- Returns:
>=0;
new SSA register.
-
forEachInsn
Visits all insns in this method.- Parameters:
visitor
-non-null;
callback interface
-
forEachPhiInsn
Visits each phi insn in this method- Parameters:
v
-non-null;
callback.
-
forEachBlockDepthFirst
Walks the basic block tree in depth-first order, calling the visitor method once for every block. This depth-first walk may be run forward from the method entry point or backwards from the method exit points.- Parameters:
reverse
- true if this should walk backwards from the exit pointsv
-non-null;
callback interface.parent
is set unless this is the root node
-
forEachBlockDepthFirstDom
Visits blocks in dom-tree order, starting at the current node. Theparent
parameter of the Visitor.visitBlock callback is currently always set to null.- Parameters:
v
-non-null;
callback interface
-
deleteInsns
Deletes all insns in the set from this method.- Parameters:
deletedInsns
-non-null;
insns to delete
-
setBackMode
public void setBackMode()Sets "back-convert mode". Set during back-conversion when registers are about to be mapped into a non-SSA namespace. When true, use and def lists are unavailable.
-