Package com.android.dx.ssa.back
Class RegisterAllocator
java.lang.Object
com.android.dx.ssa.back.RegisterAllocator
- Direct Known Subclasses:
FirstFitAllocator
,FirstFitLocalCombiningAllocator
,NullRegisterAllocator
Base class of all register allocators.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final InterferenceGraph
interference graph, indexed by register in both dimensionsprotected final SsaMethod
method being processed -
Constructor Summary
ConstructorDescriptionRegisterAllocator
(SsaMethod ssaMeth, InterferenceGraph interference) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract RegisterMapper
Runs the algorithm.protected final int
getCategoryForSsaReg
(int reg) Returns the category (width) of the definition site of the register.protected final RegisterSpec
getDefinitionSpecForSsaReg
(int reg) Returns the RegisterSpec of the definition of the register.protected final RegisterSpec
insertMoveBefore
(SsaInsn insn, RegisterSpec reg) Inserts a move instruction for a specified SSA register before a specified instruction, creating a new SSA register and adjusting the interference graph in the process.protected boolean
isDefinitionMoveParam
(int reg) Returns true if the definition site of this register is a move-param (ie, this is a method parameter).abstract boolean
Indicates whether the method params were allocated at the bottom of the namespace, and thus should be moved up to the top of the namespace after phi removal.
-
Field Details
-
ssaMeth
method being processed -
interference
interference graph, indexed by register in both dimensions
-
-
Constructor Details
-
RegisterAllocator
Creates an instance. CallallocateRegisters
to run.- Parameters:
ssaMeth
- method to process.interference
- Interference graph, indexed by register in both dimensions.
-
-
Method Details
-
wantsParamsMovedHigh
public abstract boolean wantsParamsMovedHigh()Indicates whether the method params were allocated at the bottom of the namespace, and thus should be moved up to the top of the namespace after phi removal.- Returns:
true
if params should be moved from low to high
-
allocateRegisters
Runs the algorithm.- Returns:
- a register mapper to apply to the
SsaMethod
-
getCategoryForSsaReg
protected final int getCategoryForSsaReg(int reg) Returns the category (width) of the definition site of the register. Returns1
for undefined registers.- Parameters:
reg
- register- Returns:
1..2
-
getDefinitionSpecForSsaReg
Returns the RegisterSpec of the definition of the register.- Parameters:
reg
->= 0;
SSA register- Returns:
- definition spec of the register or null if it is never defined (for the case of "version 0" SSA registers)
-
isDefinitionMoveParam
protected boolean isDefinitionMoveParam(int reg) Returns true if the definition site of this register is a move-param (ie, this is a method parameter).- Parameters:
reg
- register in question- Returns:
true
if this is a method parameter
-
insertMoveBefore
Inserts a move instruction for a specified SSA register before a specified instruction, creating a new SSA register and adjusting the interference graph in the process. The insn currently must be the last insn in a block.- Parameters:
insn
-non-null;
insn to insert move before, must be last insn in blockreg
-non-null;
SSA register to duplicate- Returns:
non-null;
spec of new SSA register created by move
-