Package com.tonic.analysis.ssa.lower
Class RegisterAllocator
- java.lang.Object
-
- com.tonic.analysis.ssa.lower.RegisterAllocator
-
public class RegisterAllocator extends Object
Linear scan register allocator.
-
-
Constructor Summary
Constructors Constructor Description RegisterAllocator(IRMethod method, LivenessAnalysis liveness)Creates an allocator; nothing is assigned untilallocate()runs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidallocate()Runs the linear scan, pinning parameters to the leading slots and letting later values reuse a slot only when no named source variable already owns it.Set<SSAValue>getAffinityPinnedValues()Map<SSAValue,Integer>getAllocation()Map<IRMethod.SourceLocal,Set<SSAValue>>getHomeSlotGroups()The values sharing each source variable's home slot, phi results included.LivenessAnalysisgetLiveness()intgetMaxLocals()IRMethodgetMethod()intgetRegister(SSAValue value)Looks up a value's slot, allocating a fresh one and growing max locals if the main pass missed it.intgetReservedSlotCount()
-
-
-
Constructor Detail
-
RegisterAllocator
public RegisterAllocator(IRMethod method, LivenessAnalysis liveness)
Creates an allocator; nothing is assigned untilallocate()runs.- Parameters:
method- the method whose values need slotsliveness- the liveness result driving interval construction
-
-
Method Detail
-
getMethod
public IRMethod getMethod()
- Returns:
- the method
-
getLiveness
public LivenessAnalysis getLiveness()
- Returns:
- the liveness
-
getMaxLocals
public int getMaxLocals()
- Returns:
- the max locals
-
getReservedSlotCount
public int getReservedSlotCount()
- Returns:
- the reserved slot count
-
allocate
public void allocate()
Runs the linear scan, pinning parameters to the leading slots and letting later values reuse a slot only when no named source variable already owns it.
-
getHomeSlotGroups
public Map<IRMethod.SourceLocal,Set<SSAValue>> getHomeSlotGroups()
The values sharing each source variable's home slot, phi results included.- Returns:
- the live map from source variable to the values in its home slot
-
getAffinityPinnedValues
public Set<SSAValue> getAffinityPinnedValues()
- Returns:
- the affinity pinned values
-
getRegister
public int getRegister(SSAValue value)
Looks up a value's slot, allocating a fresh one and growing max locals if the main pass missed it.- Parameters:
value- the value to look up- Returns:
- the slot index
-
-