- initializeCSRCost
-
calculateSpillWeightsAndHints
-
VRAI.calcualteSpillWeightAndHint
- calculate LiveInterval weight
-
allocatePhysRegs
-
seedLiveRegs
-
for all virtual registers
- enqueue(LIS->getInterval(Reg))
-
while (dequeue())
- Matrix-> invalidateVirtRegs
-
selectOrSplit
-
selectOrSplitImpl
- tryAssign(VirtReg)
- for all PhysReg in AllocationOrder
- Matrix->checkInterference(VirtReg, PhysReg)
- if there is hint
- if (canEvictInterference(PhysReg = Hint))
- evictInterference(PhysReg = Hint)
- colloect all interferences of PhysReg
- for each interference
- Matrix->unassign
- NewVRegs.push_back
- return Hint
- if the physical register has cost
- CheapReg = tryEvict
- tryAssignCSRFirstTime
- if (getStage(VirtReg) == RS_Spill)
- SA->analyze
- if (calcSpillCost() >= CSRCost)
- return PhysReg
- return 0
- if (getStage(VirtReg) < RS_Split)
- SA->analyze
- calculateRegionSplitCost
- if (BestCand == NoCand)
- return PhysReg
- doRegionSplit
- splitAroundRegion
- return 0
- return PhysReg
- if (Stage != RS_Split)
- PhysReg = tryEvict
- return PhysReg
- if (Stage < RS_Split)
- setStage(RS_Split)
- NewVRegs.push_back(VirtReg)
- return 0
- if (Stage >= RS_Done || !VirtReg.isSpillable())
- return tryLastChanceRecoloring
- for all PhysReg
- if (Matrix->checkInterference > IK_VirtReg)
- continue
- if (!mayRecolorAllInterferences(RecoloringCandidates))
- continue
- for all RecoloringCandidates
- enqueue(RecoloringQueue, candidate)
- VirtRegToPhysReg[ItVirtReg] = VRM->getPhys(ItVirtReg)
- Matrix->unassign(candidate)
- Matrix->assign(VirtReg, PhysReg)
- if (tryRecoloringCandidate(RecoloringQueue))
- tryRecoloringCandidate
- for all items LI in RecoloringQueue
- dequeue
- PhysReg = selectOrSplitImpl(Depth + 1)
- Matrix->assign(*LI, PhysReg)
- Matrix->unassign(VirtReg)
- return PhysReg
- Matrix->unassign(VirtReg)
- for all RecoloringCandidates
- if (VRM->hasPhys(VirtReg))
- Matrix->unassign(VirtReg)
- PhysReg = VirtRegToPhysReg[VirtReg]
- Matrix->assign(VirtReg, PhysReg)
- return ~0u
- PhysReg = trySplit
- return PhysReg
- spiller().spill(LRE)
- setStage(RS_Done)
- return 0
-
if (AvailablePhysReg)
- Matrix->assign
-
for all VirtReg in SplitVRegs
- enqueue NewVRegs
-
tryHintsRecoloring
-
for all LiveInterval in SetOfBrokenHints
-
if (!VRM->hasPHys(LI->reg))
- continue
- tryHintRecoloring(LI)