Skip to content

Commit 1067930

Browse files
authored
[CodeGen] Use MCRegUnit in more places (NFC) (#167578)
1 parent 519cf3c commit 1067930

14 files changed

+47
-47
lines changed

llvm/include/llvm/CodeGen/LiveIntervals.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class LiveIntervals {
412412

413413
/// Return the live range for register unit \p Unit. It will be computed if
414414
/// it doesn't exist.
415-
LiveRange &getRegUnit(unsigned Unit) {
415+
LiveRange &getRegUnit(MCRegUnit Unit) {
416416
LiveRange *LR = RegUnitRanges[Unit];
417417
if (!LR) {
418418
// Compute missing ranges on demand.
@@ -425,15 +425,15 @@ class LiveIntervals {
425425

426426
/// Return the live range for register unit \p Unit if it has already been
427427
/// computed, or nullptr if it hasn't been computed yet.
428-
LiveRange *getCachedRegUnit(unsigned Unit) { return RegUnitRanges[Unit]; }
428+
LiveRange *getCachedRegUnit(MCRegUnit Unit) { return RegUnitRanges[Unit]; }
429429

430-
const LiveRange *getCachedRegUnit(unsigned Unit) const {
430+
const LiveRange *getCachedRegUnit(MCRegUnit Unit) const {
431431
return RegUnitRanges[Unit];
432432
}
433433

434434
/// Remove computed live range for register unit \p Unit. Subsequent uses
435435
/// should rely on on-demand recomputation.
436-
void removeRegUnit(unsigned Unit) {
436+
void removeRegUnit(MCRegUnit Unit) {
437437
delete RegUnitRanges[Unit];
438438
RegUnitRanges[Unit] = nullptr;
439439
}
@@ -489,7 +489,7 @@ class LiveIntervals {
489489
void dumpInstrs() const;
490490

491491
void computeLiveInRegUnits();
492-
LLVM_ABI void computeRegUnitRange(LiveRange &, unsigned Unit);
492+
LLVM_ABI void computeRegUnitRange(LiveRange &, MCRegUnit Unit);
493493
LLVM_ABI bool computeVirtRegInterval(LiveInterval &);
494494

495495
using ShrinkToUsesWorkList = SmallVector<std::pair<SlotIndex, VNInfo *>, 16>;

llvm/include/llvm/CodeGen/MachineRegisterInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ class MachineRegisterInfo {
982982
/// root registers, the root register and all super registers are reserved.
983983
/// This currently iterates the register hierarchy and may be slower than
984984
/// expected.
985-
LLVM_ABI bool isReservedRegUnit(unsigned Unit) const;
985+
LLVM_ABI bool isReservedRegUnit(MCRegUnit Unit) const;
986986

987987
/// isAllocatable - Returns true when PhysReg belongs to an allocatable
988988
/// register class and it hasn't been reserved.

llvm/include/llvm/CodeGen/ReachingDefAnalysis.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@ class MBBReachingDefsInfo {
7777
AllReachingDefs[MBBNumber].resize(NumRegUnits);
7878
}
7979

80-
void append(unsigned MBBNumber, unsigned Unit, int Def) {
80+
void append(unsigned MBBNumber, MCRegUnit Unit, int Def) {
8181
AllReachingDefs[MBBNumber][Unit].push_back(Def);
8282
}
8383

84-
void prepend(unsigned MBBNumber, unsigned Unit, int Def) {
84+
void prepend(unsigned MBBNumber, MCRegUnit Unit, int Def) {
8585
auto &Defs = AllReachingDefs[MBBNumber][Unit];
8686
Defs.insert(Defs.begin(), Def);
8787
}
8888

89-
void replaceFront(unsigned MBBNumber, unsigned Unit, int Def) {
89+
void replaceFront(unsigned MBBNumber, MCRegUnit Unit, int Def) {
9090
assert(!AllReachingDefs[MBBNumber][Unit].empty());
9191
*AllReachingDefs[MBBNumber][Unit].begin() = Def;
9292
}
9393

9494
void clear() { AllReachingDefs.clear(); }
9595

96-
ArrayRef<ReachingDef> defs(unsigned MBBNumber, unsigned Unit) const {
96+
ArrayRef<ReachingDef> defs(unsigned MBBNumber, MCRegUnit Unit) const {
9797
if (AllReachingDefs[MBBNumber].empty())
9898
// Block IDs are not necessarily dense.
9999
return ArrayRef<ReachingDef>();

llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ namespace llvm {
7777
struct PhysRegSUOper {
7878
SUnit *SU;
7979
int OpIdx;
80-
unsigned RegUnit;
80+
MCRegUnit RegUnit;
8181

82-
PhysRegSUOper(SUnit *su, int op, unsigned R)
82+
PhysRegSUOper(SUnit *su, int op, MCRegUnit R)
8383
: SU(su), OpIdx(op), RegUnit(R) {}
8484

8585
unsigned getSparseSetIndex() const { return RegUnit; }

llvm/include/llvm/CodeGen/TargetRegisterInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ LLVM_ABI Printable printReg(Register Reg,
14461446
/// fp0~st7 - Dual roots.
14471447
///
14481448
/// Usage: OS << printRegUnit(Unit, TRI) << '\n';
1449-
LLVM_ABI Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI);
1449+
LLVM_ABI Printable printRegUnit(MCRegUnit Unit, const TargetRegisterInfo *TRI);
14501450

14511451
/// Create Printable object to print virtual registers and physical
14521452
/// registers on a \ref raw_ostream.

llvm/include/llvm/MC/MCRegisterInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ class MCRegUnitMaskIterator {
687687
}
688688

689689
/// Returns a (RegUnit, LaneMask) pair.
690-
std::pair<unsigned,LaneBitmask> operator*() const {
690+
std::pair<MCRegUnit, LaneBitmask> operator*() const {
691691
return std::make_pair(*RUIter, *MaskListIter);
692692
}
693693

@@ -719,7 +719,7 @@ class MCRegUnitRootIterator {
719719
public:
720720
MCRegUnitRootIterator() = default;
721721

722-
MCRegUnitRootIterator(unsigned RegUnit, const MCRegisterInfo *MCRI) {
722+
MCRegUnitRootIterator(MCRegUnit RegUnit, const MCRegisterInfo *MCRI) {
723723
assert(RegUnit < MCRI->getNumRegUnits() && "Invalid register unit");
724724
Reg0 = MCRI->RegUnitRoots[RegUnit][0];
725725
Reg1 = MCRI->RegUnitRoots[RegUnit][1];

llvm/lib/CodeGen/EarlyIfConversion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class SSAIfConv {
134134
BitVector ClobberedRegUnits;
135135

136136
// Scratch pad for findInsertionPoint.
137-
SparseSet<unsigned> LiveRegUnits;
137+
SparseSet<MCRegUnit> LiveRegUnits;
138138

139139
/// Insertion point in Head for speculatively executed instructions form TBB
140140
/// and FBB.
@@ -421,7 +421,7 @@ bool SSAIfConv::findInsertionPoint() {
421421
if (!LiveRegUnits.empty()) {
422422
LLVM_DEBUG({
423423
dbgs() << "Would clobber";
424-
for (unsigned LRU : LiveRegUnits)
424+
for (MCRegUnit LRU : LiveRegUnits)
425425
dbgs() << ' ' << printRegUnit(LRU, TRI);
426426
dbgs() << " live before " << *I;
427427
});

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ void LiveIntervals::computeRegMasks() {
305305
/// Compute the live range of a register unit, based on the uses and defs of
306306
/// aliasing registers. The range should be empty, or contain only dead
307307
/// phi-defs from ABI blocks.
308-
void LiveIntervals::computeRegUnitRange(LiveRange &LR, unsigned Unit) {
308+
void LiveIntervals::computeRegUnitRange(LiveRange &LR, MCRegUnit Unit) {
309309
assert(LICalc && "LICalc not initialized.");
310310
LICalc->reset(MF, getSlotIndexes(), DomTree, &getVNInfoAllocator());
311311

@@ -354,7 +354,7 @@ void LiveIntervals::computeLiveInRegUnits() {
354354
LLVM_DEBUG(dbgs() << "Computing live-in reg-units in ABI blocks.\n");
355355

356356
// Keep track of the live range sets allocated.
357-
SmallVector<unsigned, 8> NewRanges;
357+
SmallVector<MCRegUnit, 8> NewRanges;
358358

359359
// Check all basic blocks for live-ins.
360360
for (const MachineBasicBlock &MBB : *MF) {
@@ -383,7 +383,7 @@ void LiveIntervals::computeLiveInRegUnits() {
383383
LLVM_DEBUG(dbgs() << "Created " << NewRanges.size() << " new intervals.\n");
384384

385385
// Compute the 'normal' part of the ranges.
386-
for (unsigned Unit : NewRanges)
386+
for (MCRegUnit Unit : NewRanges)
387387
computeRegUnitRange(*RegUnitRanges[Unit], Unit);
388388
}
389389

@@ -1042,7 +1042,7 @@ class LiveIntervals::HMEditor {
10421042
// physregs, even those that aren't needed for regalloc, in order to update
10431043
// kill flags. This is wasteful. Eventually, LiveVariables will strip all kill
10441044
// flags, and postRA passes will use a live register utility instead.
1045-
LiveRange *getRegUnitLI(unsigned Unit) {
1045+
LiveRange *getRegUnitLI(MCRegUnit Unit) {
10461046
if (UpdateFlags && !MRI.isReservedRegUnit(Unit))
10471047
return &LIS.getRegUnit(Unit);
10481048
return LIS.getCachedRegUnit(Unit);

llvm/lib/CodeGen/LiveRegMatrix.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static bool foreachUnit(const TargetRegisterInfo *TRI,
8989
Callable Func) {
9090
if (VRegInterval.hasSubRanges()) {
9191
for (MCRegUnitMaskIterator Units(PhysReg, TRI); Units.isValid(); ++Units) {
92-
unsigned Unit = (*Units).first;
92+
MCRegUnit Unit = (*Units).first;
9393
LaneBitmask Mask = (*Units).second;
9494
for (const LiveInterval::SubRange &S : VRegInterval.subranges()) {
9595
if ((S.LaneMask & Mask).any()) {
@@ -115,7 +115,7 @@ void LiveRegMatrix::assign(const LiveInterval &VirtReg, MCRegister PhysReg) {
115115
VRM->assignVirt2Phys(VirtReg.reg(), PhysReg);
116116

117117
foreachUnit(
118-
TRI, VirtReg, PhysReg, [&](unsigned Unit, const LiveRange &Range) {
118+
TRI, VirtReg, PhysReg, [&](MCRegUnit Unit, const LiveRange &Range) {
119119
LLVM_DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI) << ' ' << Range);
120120
Matrix[Unit].unify(VirtReg, Range);
121121
return false;
@@ -132,7 +132,7 @@ void LiveRegMatrix::unassign(const LiveInterval &VirtReg) {
132132
VRM->clearVirt(VirtReg.reg());
133133

134134
foreachUnit(TRI, VirtReg, PhysReg,
135-
[&](unsigned Unit, const LiveRange &Range) {
135+
[&](MCRegUnit Unit, const LiveRange &Range) {
136136
LLVM_DEBUG(dbgs() << ' ' << printRegUnit(Unit, TRI));
137137
Matrix[Unit].extract(VirtReg, Range);
138138
return false;
@@ -175,11 +175,11 @@ bool LiveRegMatrix::checkRegUnitInterference(const LiveInterval &VirtReg,
175175
return false;
176176
CoalescerPair CP(VirtReg.reg(), PhysReg, *TRI);
177177

178-
bool Result = foreachUnit(TRI, VirtReg, PhysReg, [&](unsigned Unit,
179-
const LiveRange &Range) {
180-
const LiveRange &UnitRange = LIS->getRegUnit(Unit);
181-
return Range.overlaps(UnitRange, CP, *LIS->getSlotIndexes());
182-
});
178+
bool Result = foreachUnit(
179+
TRI, VirtReg, PhysReg, [&](MCRegUnit Unit, const LiveRange &Range) {
180+
const LiveRange &UnitRange = LIS->getRegUnit(Unit);
181+
return Range.overlaps(UnitRange, CP, *LIS->getSlotIndexes());
182+
});
183183
return Result;
184184
}
185185

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CopyTracker {
137137
PreservedRegUnits.resize(TRI.getNumRegUnits());
138138
for (unsigned SafeReg = 0, E = TRI.getNumRegs(); SafeReg < E; ++SafeReg)
139139
if (!RegMaskOp.clobbersPhysReg(SafeReg))
140-
for (auto SafeUnit : TRI.regunits(SafeReg))
140+
for (MCRegUnit SafeUnit : TRI.regunits(SafeReg))
141141
PreservedRegUnits.set(SafeUnit);
142142

143143
return PreservedRegUnits;
@@ -995,7 +995,7 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
995995
// Invalidate all entries in the copy map which are not preserved by
996996
// this register mask.
997997
bool MIRefedinCopyInfo = false;
998-
for (unsigned RegUnit : TRI->regunits(Reg)) {
998+
for (MCRegUnit RegUnit : TRI->regunits(Reg)) {
999999
if (!PreservedRegUnits.test(RegUnit))
10001000
Tracker.clobberRegUnit(RegUnit, *TRI, *TII, UseCopyInstr);
10011001
else {

0 commit comments

Comments
 (0)