@@ -147,7 +147,7 @@ class RAGreedy : public MachineFunctionPass,
147
147
// Convenient shortcuts.
148
148
using PQueue = std::priority_queue<std::pair<unsigned , unsigned >>;
149
149
using SmallLISet = SmallPtrSet<LiveInterval *, 4 >;
150
- using SmallVirtRegSet = SmallSet<unsigned , 16 >;
150
+ using SmallVirtRegSet = SmallSet<Register , 16 >;
151
151
152
152
// context
153
153
MachineFunction *MF;
@@ -260,7 +260,7 @@ class RAGreedy : public MachineFunctionPass,
260
260
void setStage (Iterator Begin, Iterator End, LiveRangeStage NewStage) {
261
261
ExtraRegInfo.resize (MRI->getNumVirtRegs ());
262
262
for (;Begin != End; ++Begin) {
263
- unsigned Reg = *Begin;
263
+ Register Reg = *Begin;
264
264
if (ExtraRegInfo[Reg].Stage == RS_New)
265
265
ExtraRegInfo[Reg].Stage = NewStage;
266
266
}
@@ -291,8 +291,8 @@ class RAGreedy : public MachineFunctionPass,
291
291
292
292
public:
293
293
using EvictorInfo =
294
- std::pair<unsigned /* evictor */ , unsigned /* physreg */ >;
295
- using EvicteeInfo = llvm::DenseMap<unsigned /* evictee */ , EvictorInfo>;
294
+ std::pair<Register /* evictor */ , MCRegister /* physreg */ >;
295
+ using EvicteeInfo = llvm::DenseMap<Register /* evictee */ , EvictorInfo>;
296
296
297
297
private:
298
298
// / Each Vreg that has been evicted in the last stage of selectOrSplit will
@@ -308,14 +308,14 @@ class RAGreedy : public MachineFunctionPass,
308
308
// / longer relevant.
309
309
// / \param Evictee The evictee Vreg for whom we want to clear collected
310
310
// / eviction info.
311
- void clearEvicteeInfo (unsigned Evictee) { Evictees.erase (Evictee); }
311
+ void clearEvicteeInfo (Register Evictee) { Evictees.erase (Evictee); }
312
312
313
313
// / Track new eviction.
314
314
// / The Evictor vreg has evicted the Evictee vreg from Physreg.
315
315
// / \param PhysReg The physical register Evictee was evicted from.
316
316
// / \param Evictor The evictor Vreg that evicted Evictee.
317
317
// / \param Evictee The evictee Vreg.
318
- void addEviction (unsigned PhysReg, unsigned Evictor, unsigned Evictee) {
318
+ void addEviction (MCRegister PhysReg, Register Evictor, Register Evictee) {
319
319
Evictees[Evictee].first = Evictor;
320
320
Evictees[Evictee].second = PhysReg;
321
321
}
@@ -324,7 +324,7 @@ class RAGreedy : public MachineFunctionPass,
324
324
// / \param Evictee The evictee vreg.
325
325
// / \return The Evictor vreg which evicted Evictee vreg from PhysReg. 0 if
326
326
// / nobody has evicted Evictee from PhysReg.
327
- EvictorInfo getEvictor (unsigned Evictee) {
327
+ EvictorInfo getEvictor (Register Evictee) {
328
328
if (Evictees.count (Evictee)) {
329
329
return Evictees[Evictee];
330
330
}
@@ -349,7 +349,7 @@ class RAGreedy : public MachineFunctionPass,
349
349
// / Global live range splitting candidate info.
350
350
struct GlobalSplitCandidate {
351
351
// Register intended for assignment, or 0.
352
- unsigned PhysReg;
352
+ MCRegister PhysReg;
353
353
354
354
// SplitKit interval index for this candidate.
355
355
unsigned IntvIdx;
@@ -446,7 +446,7 @@ class RAGreedy : public MachineFunctionPass,
446
446
bool addSplitConstraints (InterferenceCache::Cursor, BlockFrequency&);
447
447
bool addThroughConstraints (InterferenceCache::Cursor, ArrayRef<unsigned >);
448
448
bool growRegion (GlobalSplitCandidate &Cand);
449
- bool splitCanCauseEvictionChain (unsigned Evictee, GlobalSplitCandidate &Cand,
449
+ bool splitCanCauseEvictionChain (Register Evictee, GlobalSplitCandidate &Cand,
450
450
unsigned BBNumber,
451
451
const AllocationOrder &Order);
452
452
bool splitCanCauseLocalSpill (unsigned VirtRegToSplit,
@@ -457,20 +457,20 @@ class RAGreedy : public MachineFunctionPass,
457
457
bool *CanCauseEvictionChain);
458
458
bool calcCompactRegion (GlobalSplitCandidate&);
459
459
void splitAroundRegion (LiveRangeEdit&, ArrayRef<unsigned >);
460
- void calcGapWeights (unsigned , SmallVectorImpl<float >&);
460
+ void calcGapWeights (MCRegister , SmallVectorImpl<float > &);
461
461
Register canReassign (LiveInterval &VirtReg, Register PrevReg);
462
462
bool shouldEvict (LiveInterval &A, bool , LiveInterval &B, bool );
463
463
bool canEvictInterference (LiveInterval &, MCRegister, bool , EvictionCost &,
464
464
const SmallVirtRegSet &);
465
- bool canEvictInterferenceInRange (LiveInterval &VirtReg, Register oPhysReg ,
465
+ bool canEvictInterferenceInRange (LiveInterval &VirtReg, MCRegister PhysReg ,
466
466
SlotIndex Start, SlotIndex End,
467
467
EvictionCost &MaxCost);
468
468
unsigned getCheapestEvicteeWeight (const AllocationOrder &Order,
469
469
LiveInterval &VirtReg, SlotIndex Start,
470
470
SlotIndex End, float *BestEvictWeight);
471
- void evictInterference (LiveInterval&, Register ,
472
- SmallVectorImpl<Register>&);
473
- bool mayRecolorAllInterferences (unsigned PhysReg, LiveInterval &VirtReg,
471
+ void evictInterference (LiveInterval &, MCRegister ,
472
+ SmallVectorImpl<Register> &);
473
+ bool mayRecolorAllInterferences (MCRegister PhysReg, LiveInterval &VirtReg,
474
474
SmallLISet &RecoloringCandidates,
475
475
const SmallVirtRegSet &FixedRegisters);
476
476
@@ -480,8 +480,8 @@ class RAGreedy : public MachineFunctionPass,
480
480
unsigned tryEvict (LiveInterval&, AllocationOrder&,
481
481
SmallVectorImpl<Register>&, unsigned ,
482
482
const SmallVirtRegSet&);
483
- unsigned tryRegionSplit (LiveInterval&, AllocationOrder&,
484
- SmallVectorImpl<Register>&);
483
+ MCRegister tryRegionSplit (LiveInterval &, AllocationOrder &,
484
+ SmallVectorImpl<Register> &);
485
485
// / Calculate cost of region splitting.
486
486
unsigned calculateRegionSplitCost (LiveInterval &VirtReg,
487
487
AllocationOrder &Order,
@@ -530,7 +530,7 @@ class RAGreedy : public MachineFunctionPass,
530
530
};
531
531
using HintsInfo = SmallVector<HintInfo, 4 >;
532
532
533
- BlockFrequency getBrokenHintFreq (const HintsInfo &, unsigned );
533
+ BlockFrequency getBrokenHintFreq (const HintsInfo &, MCRegister );
534
534
void collectHintInfo (unsigned , HintsInfo &);
535
535
536
536
bool isUnusedCalleeSavedReg (MCRegister PhysReg) const ;
@@ -777,12 +777,14 @@ Register RAGreedy::tryAssign(LiveInterval &VirtReg,
777
777
// preferred register.
778
778
if (Register Hint = MRI->getSimpleHint (VirtReg.reg ()))
779
779
if (Order.isHint (Hint)) {
780
- LLVM_DEBUG (dbgs () << " missed hint " << printReg (Hint, TRI) << ' \n ' );
780
+ MCRegister PhysHint = Hint.asMCReg ();
781
+ LLVM_DEBUG (dbgs () << " missed hint " << printReg (PhysHint, TRI) << ' \n ' );
781
782
EvictionCost MaxCost;
782
783
MaxCost.setBrokenHints (1 );
783
- if (canEvictInterference (VirtReg, Hint, true , MaxCost, FixedRegisters)) {
784
- evictInterference (VirtReg, Hint, NewVRegs);
785
- return Hint;
784
+ if (canEvictInterference (VirtReg, PhysHint, true , MaxCost,
785
+ FixedRegisters)) {
786
+ evictInterference (VirtReg, PhysHint, NewVRegs);
787
+ return PhysHint;
786
788
}
787
789
// Record the missed hint, we may be able to recover
788
790
// at the end if the surrounding allocation changed.
@@ -969,7 +971,7 @@ bool RAGreedy::canEvictInterference(LiveInterval &VirtReg, MCRegister PhysReg,
969
971
// / when returning true.
970
972
// / \return True when interference can be evicted cheaper than MaxCost.
971
973
bool RAGreedy::canEvictInterferenceInRange (LiveInterval &VirtReg,
972
- Register PhysReg, SlotIndex Start,
974
+ MCRegister PhysReg, SlotIndex Start,
973
975
SlotIndex End,
974
976
EvictionCost &MaxCost) {
975
977
EvictionCost Cost;
@@ -1045,7 +1047,7 @@ unsigned RAGreedy::getCheapestEvicteeWeight(const AllocationOrder &Order,
1045
1047
// / evictInterference - Evict any interferring registers that prevent VirtReg
1046
1048
// / from being assigned to Physreg. This assumes that canEvictInterference
1047
1049
// / returned true.
1048
- void RAGreedy::evictInterference (LiveInterval &VirtReg, Register PhysReg,
1050
+ void RAGreedy::evictInterference (LiveInterval &VirtReg, MCRegister PhysReg,
1049
1051
SmallVectorImpl<Register> &NewVRegs) {
1050
1052
// Make sure that VirtReg has a cascade number, and assign that cascade
1051
1053
// number to every evicted register. These live ranges than then only be
@@ -1113,7 +1115,7 @@ unsigned RAGreedy::tryEvict(LiveInterval &VirtReg,
1113
1115
// Keep track of the cheapest interference seen so far.
1114
1116
EvictionCost BestCost;
1115
1117
BestCost.setMax ();
1116
- unsigned BestPhys = 0 ;
1118
+ MCRegister BestPhys;
1117
1119
unsigned OrderLimit = Order.getOrder ().size ();
1118
1120
1119
1121
// When we are just looking for a reduced cost per use, don't break any
@@ -1478,13 +1480,13 @@ BlockFrequency RAGreedy::calcSpillCost() {
1478
1480
// / artifact of Evictee.
1479
1481
// / \return True if splitting Evictee may cause a bad eviction chain, false
1480
1482
// / otherwise.
1481
- bool RAGreedy::splitCanCauseEvictionChain (unsigned Evictee,
1483
+ bool RAGreedy::splitCanCauseEvictionChain (Register Evictee,
1482
1484
GlobalSplitCandidate &Cand,
1483
1485
unsigned BBNumber,
1484
1486
const AllocationOrder &Order) {
1485
1487
EvictionTrack::EvictorInfo VregEvictorInfo = LastEvicted.getEvictor (Evictee);
1486
1488
unsigned Evictor = VregEvictorInfo.first ;
1487
- unsigned PhysReg = VregEvictorInfo.second ;
1489
+ MCRegister PhysReg = VregEvictorInfo.second ;
1488
1490
1489
1491
// No actual evictor.
1490
1492
if (!Evictor || !PhysReg)
@@ -1581,7 +1583,7 @@ BlockFrequency RAGreedy::calcGlobalSplitCost(GlobalSplitCandidate &Cand,
1581
1583
bool *CanCauseEvictionChain) {
1582
1584
BlockFrequency GlobalCost = 0 ;
1583
1585
const BitVector &LiveBundles = Cand.LiveBundles ;
1584
- unsigned VirtRegToSplit = SA->getParent ().reg ();
1586
+ Register VirtRegToSplit = SA->getParent ().reg ();
1585
1587
ArrayRef<SplitAnalysis::BlockInfo> UseBlocks = SA->getUseBlocks ();
1586
1588
for (unsigned I = 0 ; I != UseBlocks.size (); ++I) {
1587
1589
const SplitAnalysis::BlockInfo &BI = UseBlocks[I];
@@ -1808,10 +1810,11 @@ void RAGreedy::splitAroundRegion(LiveRangeEdit &LREdit,
1808
1810
MF->verify (this , " After splitting live range around region" );
1809
1811
}
1810
1812
1811
- unsigned RAGreedy::tryRegionSplit (LiveInterval &VirtReg, AllocationOrder &Order,
1812
- SmallVectorImpl<Register> &NewVRegs) {
1813
+ MCRegister RAGreedy::tryRegionSplit (LiveInterval &VirtReg,
1814
+ AllocationOrder &Order,
1815
+ SmallVectorImpl<Register> &NewVRegs) {
1813
1816
if (!TRI->shouldRegionSplitForVirtReg (*MF, VirtReg))
1814
- return 0 ;
1817
+ return MCRegister::NoRegister ;
1815
1818
unsigned NumCands = 0 ;
1816
1819
BlockFrequency SpillCost = calcSpillCost ();
1817
1820
BlockFrequency BestCost;
@@ -1841,12 +1844,12 @@ unsigned RAGreedy::tryRegionSplit(LiveInterval &VirtReg, AllocationOrder &Order,
1841
1844
// current max frequency.
1842
1845
if (HasCompact && (BestCost > SpillCost) && (BestCand != NoCand) &&
1843
1846
CanCauseEvictionChain) {
1844
- return 0 ;
1847
+ return MCRegister::NoRegister ;
1845
1848
}
1846
1849
1847
1850
// No solutions found, fall back to single block splitting.
1848
1851
if (!HasCompact && BestCand == NoCand)
1849
- return 0 ;
1852
+ return MCRegister::NoRegister ;
1850
1853
1851
1854
return doRegionSplit (VirtReg, BestCand, HasCompact, NewVRegs);
1852
1855
}
@@ -2129,7 +2132,7 @@ RAGreedy::tryInstructionSplit(LiveInterval &VirtReg, AllocationOrder &Order,
2129
2132
// /
2130
2133
// / GapWeight[I] represents the gap between UseSlots[I] and UseSlots[I + 1].
2131
2134
// /
2132
- void RAGreedy::calcGapWeights (unsigned PhysReg,
2135
+ void RAGreedy::calcGapWeights (MCRegister PhysReg,
2133
2136
SmallVectorImpl<float > &GapWeight) {
2134
2137
assert (SA->getUseBlocks ().size () == 1 && " Not a local interval" );
2135
2138
const SplitAnalysis::BlockInfo &BI = SA->getUseBlocks ().front ();
@@ -2476,7 +2479,7 @@ unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order,
2476
2479
// ranges already made dubious progress with region splitting, so they go
2477
2480
// straight to single block splitting.
2478
2481
if (getStage (VirtReg) < RS_Split2) {
2479
- unsigned PhysReg = tryRegionSplit (VirtReg, Order, NewVRegs);
2482
+ MCRegister PhysReg = tryRegionSplit (VirtReg, Order, NewVRegs);
2480
2483
if (PhysReg || !NewVRegs.empty ())
2481
2484
return PhysReg;
2482
2485
}
@@ -2506,10 +2509,9 @@ static bool hasTiedDef(MachineRegisterInfo *MRI, unsigned reg) {
2506
2509
// / for \p VirtReg.
2507
2510
// / \p FixedRegisters contains all the virtual registers that cannot be
2508
2511
// / recolored.
2509
- bool
2510
- RAGreedy::mayRecolorAllInterferences (unsigned PhysReg, LiveInterval &VirtReg,
2511
- SmallLISet &RecoloringCandidates,
2512
- const SmallVirtRegSet &FixedRegisters) {
2512
+ bool RAGreedy::mayRecolorAllInterferences (
2513
+ MCRegister PhysReg, LiveInterval &VirtReg, SmallLISet &RecoloringCandidates,
2514
+ const SmallVirtRegSet &FixedRegisters) {
2513
2515
const TargetRegisterClass *CurRC = MRI->getRegClass (VirtReg.reg ());
2514
2516
2515
2517
for (MCRegUnitIterator Units (PhysReg, TRI); Units.isValid (); ++Units) {
@@ -2878,7 +2880,7 @@ void RAGreedy::collectHintInfo(unsigned Reg, HintsInfo &Out) {
2878
2880
// / \p PhysReg was used.
2879
2881
// / \return The cost of \p List for \p PhysReg.
2880
2882
BlockFrequency RAGreedy::getBrokenHintFreq (const HintsInfo &List,
2881
- unsigned PhysReg) {
2883
+ MCRegister PhysReg) {
2882
2884
BlockFrequency Cost = 0 ;
2883
2885
for (const HintInfo &Info : List) {
2884
2886
if (Info.PhysReg != PhysReg)
@@ -2924,7 +2926,7 @@ void RAGreedy::tryHintRecoloring(LiveInterval &VirtReg) {
2924
2926
// Get the live interval mapped with this virtual register to be able
2925
2927
// to check for the interference with the new color.
2926
2928
LiveInterval &LI = LIS->getInterval (Reg);
2927
- Register CurrPhys = VRM->getPhys (Reg);
2929
+ MCRegister CurrPhys = VRM->getPhys (Reg);
2928
2930
// Check that the new color matches the register class constraints and
2929
2931
// that it is free for this live range.
2930
2932
if (CurrPhys != PhysReg && (!MRI->getRegClass (Reg)->contains (PhysReg) ||
0 commit comments