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
FieldsModifier and TypeFieldDescriptionprotected final InterferenceGraphinterference graph, indexed by register in both dimensionsprotected final SsaMethodmethod being processed -
Constructor Summary
ConstructorsConstructorDescriptionRegisterAllocator(SsaMethod ssaMeth, InterferenceGraph interference) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract RegisterMapperRuns the algorithm.protected final intgetCategoryForSsaReg(int reg) Returns the category (width) of the definition site of the register.protected final RegisterSpecgetDefinitionSpecForSsaReg(int reg) Returns the RegisterSpec of the definition of the register.protected final RegisterSpecinsertMoveBefore(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 booleanisDefinitionMoveParam(int reg) Returns true if the definition site of this register is a move-param (ie, this is a method parameter).abstract booleanIndicates 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. CallallocateRegistersto 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:
trueif 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. Returns1for 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:
trueif 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
-