From: Mircea Trofin Date: Fri, 26 Feb 2021 17:54:20 +0000 (-0800) Subject: [NFC][regalloc] const-ed APIs, using MCRegister instead of unsigned X-Git-Tag: llvmorg-14-init~13934 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e992326a510035adcddd284399ba67db374131c;p=platform%2Fupstream%2Fllvm.git [NFC][regalloc] const-ed APIs, using MCRegister instead of unsigned --- diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index f77fd38..d98a3c1 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -467,13 +467,13 @@ private: bool calcCompactRegion(GlobalSplitCandidate&); void splitAroundRegion(LiveRangeEdit&, ArrayRef); void calcGapWeights(MCRegister, SmallVectorImpl &); - Register canReassign(LiveInterval &VirtReg, Register PrevReg); - bool shouldEvict(LiveInterval &A, bool, LiveInterval &B, bool); + Register canReassign(LiveInterval &VirtReg, Register PrevReg) const; + bool shouldEvict(LiveInterval &A, bool, LiveInterval &B, bool) const; bool canEvictInterference(LiveInterval &, MCRegister, bool, EvictionCost &, - const SmallVirtRegSet &); + const SmallVirtRegSet &) const; bool canEvictInterferenceInRange(LiveInterval &VirtReg, MCRegister PhysReg, SlotIndex Start, SlotIndex End, - EvictionCost &MaxCost); + EvictionCost &MaxCost) const; MCRegister getCheapestEvicteeWeight(const AllocationOrder &Order, LiveInterval &VirtReg, SlotIndex Start, SlotIndex End, float *BestEvictWeight); @@ -483,10 +483,10 @@ private: SmallLISet &RecoloringCandidates, const SmallVirtRegSet &FixedRegisters); - Register tryAssign(LiveInterval&, AllocationOrder&, + MCRegister tryAssign(LiveInterval&, AllocationOrder&, SmallVectorImpl&, const SmallVirtRegSet&); - unsigned tryEvict(LiveInterval &, AllocationOrder &, + MCRegister tryEvict(LiveInterval &, AllocationOrder &, SmallVectorImpl &, uint8_t, const SmallVirtRegSet &); MCRegister tryRegionSplit(LiveInterval &, AllocationOrder &, @@ -763,11 +763,11 @@ LiveInterval *RAGreedy::dequeue(PQueue &CurQueue) { //===----------------------------------------------------------------------===// /// tryAssign - Try to assign VirtReg to an available register. -Register RAGreedy::tryAssign(LiveInterval &VirtReg, +MCRegister RAGreedy::tryAssign(LiveInterval &VirtReg, AllocationOrder &Order, SmallVectorImpl &NewVRegs, const SmallVirtRegSet &FixedRegisters) { - Register PhysReg; + MCRegister PhysReg; for (auto I = Order.begin(), E = Order.end(); I != E && !PhysReg; ++I) { assert(*I); if (!Matrix->checkInterference(VirtReg, *I)) { @@ -809,7 +809,7 @@ Register RAGreedy::tryAssign(LiveInterval &VirtReg, LLVM_DEBUG(dbgs() << printReg(PhysReg, TRI) << " is available at cost " << Cost << '\n'); - Register CheapReg = tryEvict(VirtReg, Order, NewVRegs, Cost, FixedRegisters); + MCRegister CheapReg = tryEvict(VirtReg, Order, NewVRegs, Cost, FixedRegisters); return CheapReg ? CheapReg : PhysReg; } @@ -817,7 +817,7 @@ Register RAGreedy::tryAssign(LiveInterval &VirtReg, // Interference eviction //===----------------------------------------------------------------------===// -Register RAGreedy::canReassign(LiveInterval &VirtReg, Register PrevReg) { +Register RAGreedy::canReassign(LiveInterval &VirtReg, Register PrevReg) const { auto Order = AllocationOrder::create(VirtReg.reg(), *VRM, RegClassInfo, Matrix); MCRegister PhysReg; @@ -857,7 +857,7 @@ Register RAGreedy::canReassign(LiveInterval &VirtReg, Register PrevReg) { /// @param B The live range to be evicted. /// @param BreaksHint True when B is already assigned to its preferred register. bool RAGreedy::shouldEvict(LiveInterval &A, bool IsHint, - LiveInterval &B, bool BreaksHint) { + LiveInterval &B, bool BreaksHint) const { bool CanSplit = getStage(B) < RS_Spill; // Be fairly aggressive about following hints as long as the evictee can be @@ -881,9 +881,9 @@ bool RAGreedy::shouldEvict(LiveInterval &A, bool IsHint, /// @param MaxCost Only look for cheaper candidates and update with new cost /// when returning true. /// @returns True when interference can be evicted cheaper than MaxCost. -bool RAGreedy::canEvictInterference(LiveInterval &VirtReg, MCRegister PhysReg, - bool IsHint, EvictionCost &MaxCost, - const SmallVirtRegSet &FixedRegisters) { +bool RAGreedy::canEvictInterference( + LiveInterval &VirtReg, MCRegister PhysReg, bool IsHint, + EvictionCost &MaxCost, const SmallVirtRegSet &FixedRegisters) const { // It is only possible to evict virtual register interference. if (Matrix->checkInterference(VirtReg, PhysReg) > LiveRegMatrix::IK_VirtReg) return false; @@ -982,7 +982,7 @@ bool RAGreedy::canEvictInterference(LiveInterval &VirtReg, MCRegister PhysReg, bool RAGreedy::canEvictInterferenceInRange(LiveInterval &VirtReg, MCRegister PhysReg, SlotIndex Start, SlotIndex End, - EvictionCost &MaxCost) { + EvictionCost &MaxCost) const { EvictionCost Cost; for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units) { @@ -1113,7 +1113,7 @@ bool RAGreedy::isUnusedCalleeSavedReg(MCRegister PhysReg) const { /// @param VirtReg Currently unassigned virtual register. /// @param Order Physregs to try. /// @return Physreg to assign VirtReg, or 0. -unsigned RAGreedy::tryEvict(LiveInterval &VirtReg, AllocationOrder &Order, +MCRegister RAGreedy::tryEvict(LiveInterval &VirtReg, AllocationOrder &Order, SmallVectorImpl &NewVRegs, uint8_t CostPerUseLimit, const SmallVirtRegSet &FixedRegisters) { @@ -1178,10 +1178,8 @@ unsigned RAGreedy::tryEvict(LiveInterval &VirtReg, AllocationOrder &Order, break; } - if (!BestPhys) - return 0; - - evictInterference(VirtReg, BestPhys, NewVRegs); + if (BestPhys.isValid()) + evictInterference(VirtReg, BestPhys, NewVRegs); return BestPhys; }