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

public abstract Class RegisterAllocator

extends Object
Class Inheritance
Known Direct Subclasses
org.droidparts.dexmaker.dx.ssa.back.FirstFitAllocator, org.droidparts.dexmaker.dx.ssa.back.FirstFitLocalCombiningAllocator, org.droidparts.dexmaker.dx.ssa.back.NullRegisterAllocator
Imports
org.droidparts.dexmaker.dx.rop.code.*, org.droidparts.dexmaker.dx.ssa.*, org.droidparts.dexmaker.dx.util.IntIterator, .IntSet, java.util.ArrayList

Base class of all register allocators.

Field Summary

Modifier and TypeField and Description
protected final InterferenceGraph
interference

interference graph, indexed by register in both dimensions

protected final SsaMethod
ssaMeth

method being processed

Constructor Summary

AccessConstructor and Description
public
RegisterAllocator(SsaMethod
method to process.
ssaMeth
,
InterferenceGraph
Interference graph, indexed by register in both dimensions.
interference
)

Creates an instance.

Method Summary

Modifier and TypeMethod and Description
public abstract RegisterMapper

Returns:

a register mapper to apply to the SsaMethod
allocateRegisters
()

Runs the algorithm.

protected final int

Returns:

1..2
getCategoryForSsaReg
(int
register
reg
)

Returns the category (width) of the definition site of the register.

protected final RegisterSpec

Returns:

definition spec of the register or null if it is never defined (for the case of "version 0" SSA registers)
getDefinitionSpecForSsaReg
(int
>= 0; SSA register
reg
)

Returns the RegisterSpec of the definition of the register.

protected final RegisterSpec

Returns:

non-null; spec of new SSA register created by move
insertMoveBefore
(SsaInsn
non-null; insn to insert move before, must be last insn in block
insn
,
RegisterSpec
non-null; SSA register to duplicate
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

Returns:

true if this is a method parameter
isDefinitionMoveParam
(int
register in question
reg
)

Returns true if the definition site of this register is a move-param (ie, this is a method parameter).

public abstract boolean

Returns:

true if params should be moved from low to high
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

interferenceback to summary
protected final InterferenceGraph interference

interference graph, indexed by register in both dimensions

ssaMethback to summary
protected final SsaMethod ssaMeth

method being processed

Constructor Detail

RegisterAllocatorback to summary
public RegisterAllocator(SsaMethod ssaMeth, InterferenceGraph interference)

Creates an instance. Call allocateRegisters to run.

Parameters
ssaMeth:SsaMethod

method to process.

interference:InterferenceGraph

Interference graph, indexed by register in both dimensions.

Method Detail

allocateRegistersback to summary
public abstract RegisterMapper allocateRegisters()

Runs the algorithm.

Returns:RegisterMapper

a register mapper to apply to the SsaMethod

getCategoryForSsaRegback to summary
protected final int getCategoryForSsaReg(int reg)

Returns the category (width) of the definition site of the register. Returns 1 for undefined registers.

Parameters
reg:int

register

Returns:int

1..2

getDefinitionSpecForSsaRegback to summary
protected final RegisterSpec getDefinitionSpecForSsaReg(int reg)

Returns the RegisterSpec of the definition of the register.

Parameters
reg:int

>= 0; SSA register

Returns:RegisterSpec

definition spec of the register or null if it is never defined (for the case of "version 0" SSA registers)

insertMoveBeforeback to summary
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. The insn currently must be the last insn in a block.

Parameters
insn:SsaInsn

non-null; insn to insert move before, must be last insn in block

reg:RegisterSpec

non-null; SSA register to duplicate

Returns:RegisterSpec

non-null; spec of new SSA register created by move

isDefinitionMoveParamback to summary
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:int

register in question

Returns:boolean

true if this is a method parameter

wantsParamsMovedHighback to summary
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:boolean

true if params should be moved from low to high