Skip to content

Commit 9e6494c

Browse files
authored
[CodeGen] Rename RegisterMaskPair to VRegMaskOrUnit. NFC (llvm#123799)
This holds a physical register unit or virtual register and mask. While I was here I've used emplace_back and removed an unneeded use of a template.
1 parent 13d09df commit 9e6494c

File tree

7 files changed

+97
-103
lines changed

7 files changed

+97
-103
lines changed

llvm/include/llvm/CodeGen/MachineScheduler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ class ScheduleDAGMILive : public ScheduleDAGMI {
525525

526526
void initRegPressure();
527527

528-
void updatePressureDiffs(ArrayRef<RegisterMaskPair> LiveUses);
528+
void updatePressureDiffs(ArrayRef<VRegMaskOrUnit> LiveUses);
529529

530530
void updateScheduledPressure(const SUnit *SU,
531531
const std::vector<unsigned> &NewMaxPressure);

llvm/include/llvm/CodeGen/RegisterPressure.h

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class MachineInstr;
3535
class MachineRegisterInfo;
3636
class RegisterClassInfo;
3737

38-
struct RegisterMaskPair {
38+
struct VRegMaskOrUnit {
3939
Register RegUnit; ///< Virtual register or register unit.
4040
LaneBitmask LaneMask;
4141

42-
RegisterMaskPair(Register RegUnit, LaneBitmask LaneMask)
42+
VRegMaskOrUnit(Register RegUnit, LaneBitmask LaneMask)
4343
: RegUnit(RegUnit), LaneMask(LaneMask) {}
4444
};
4545

@@ -49,8 +49,8 @@ struct RegisterPressure {
4949
std::vector<unsigned> MaxSetPressure;
5050

5151
/// List of live in virtual registers or physical register units.
52-
SmallVector<RegisterMaskPair,8> LiveInRegs;
53-
SmallVector<RegisterMaskPair,8> LiveOutRegs;
52+
SmallVector<VRegMaskOrUnit, 8> LiveInRegs;
53+
SmallVector<VRegMaskOrUnit, 8> LiveOutRegs;
5454

5555
void dump(const TargetRegisterInfo *TRI) const;
5656
};
@@ -166,13 +166,13 @@ class PressureDiff {
166166
class RegisterOperands {
167167
public:
168168
/// List of virtual registers and register units read by the instruction.
169-
SmallVector<RegisterMaskPair, 8> Uses;
169+
SmallVector<VRegMaskOrUnit, 8> Uses;
170170
/// List of virtual registers and register units defined by the
171171
/// instruction which are not dead.
172-
SmallVector<RegisterMaskPair, 8> Defs;
172+
SmallVector<VRegMaskOrUnit, 8> Defs;
173173
/// List of virtual registers and register units defined by the
174174
/// instruction but dead.
175-
SmallVector<RegisterMaskPair, 8> DeadDefs;
175+
SmallVector<VRegMaskOrUnit, 8> DeadDefs;
176176

177177
/// Analyze the given instruction \p MI and fill in the Uses, Defs and
178178
/// DeadDefs list based on the MachineOperand flags.
@@ -185,7 +185,7 @@ class RegisterOperands {
185185
void detectDeadDefs(const MachineInstr &MI, const LiveIntervals &LIS);
186186

187187
/// Use liveness information to find out which uses/defs are partially
188-
/// undefined/dead and adjust the RegisterMaskPairs accordingly.
188+
/// undefined/dead and adjust the VRegMaskOrUnits accordingly.
189189
/// If \p AddFlagsMI is given then missing read-undef and dead flags will be
190190
/// added to the instruction.
191191
void adjustLaneLiveness(const LiveIntervals &LIS,
@@ -303,7 +303,7 @@ class LiveRegSet {
303303

304304
/// Mark the \p Pair.LaneMask lanes of \p Pair.Reg as live.
305305
/// Returns the previously live lanes of \p Pair.Reg.
306-
LaneBitmask insert(RegisterMaskPair Pair) {
306+
LaneBitmask insert(VRegMaskOrUnit Pair) {
307307
unsigned SparseIndex = getSparseIndexFromReg(Pair.RegUnit);
308308
auto InsertRes = Regs.insert(IndexMaskPair(SparseIndex, Pair.LaneMask));
309309
if (!InsertRes.second) {
@@ -316,7 +316,7 @@ class LiveRegSet {
316316

317317
/// Clears the \p Pair.LaneMask lanes of \p Pair.Reg (mark them as dead).
318318
/// Returns the previously live lanes of \p Pair.Reg.
319-
LaneBitmask erase(RegisterMaskPair Pair) {
319+
LaneBitmask erase(VRegMaskOrUnit Pair) {
320320
unsigned SparseIndex = getSparseIndexFromReg(Pair.RegUnit);
321321
RegSet::iterator I = Regs.find(SparseIndex);
322322
if (I == Regs.end())
@@ -330,12 +330,11 @@ class LiveRegSet {
330330
return Regs.size();
331331
}
332332

333-
template<typename ContainerT>
334-
void appendTo(ContainerT &To) const {
333+
void appendTo(SmallVectorImpl<VRegMaskOrUnit> &To) const {
335334
for (const IndexMaskPair &P : Regs) {
336335
Register Reg = getRegFromSparseIndex(P.Index);
337336
if (P.LaneMask.any())
338-
To.push_back(RegisterMaskPair(Reg, P.LaneMask));
337+
To.emplace_back(Reg, P.LaneMask);
339338
}
340339
}
341340
};
@@ -409,7 +408,7 @@ class RegPressureTracker {
409408
/// Force liveness of virtual registers or physical register
410409
/// units. Particularly useful to initialize the livein/out state of the
411410
/// tracker before the first call to advance/recede.
412-
void addLiveRegs(ArrayRef<RegisterMaskPair> Regs);
411+
void addLiveRegs(ArrayRef<VRegMaskOrUnit> Regs);
413412

414413
/// Get the MI position corresponding to this register pressure.
415414
MachineBasicBlock::const_iterator getPos() const { return CurrPos; }
@@ -421,14 +420,14 @@ class RegPressureTracker {
421420
void setPos(MachineBasicBlock::const_iterator Pos) { CurrPos = Pos; }
422421

423422
/// Recede across the previous instruction.
424-
void recede(SmallVectorImpl<RegisterMaskPair> *LiveUses = nullptr);
423+
void recede(SmallVectorImpl<VRegMaskOrUnit> *LiveUses = nullptr);
425424

426425
/// Recede across the previous instruction.
427426
/// This "low-level" variant assumes that recedeSkipDebugValues() was
428427
/// called previously and takes precomputed RegisterOperands for the
429428
/// instruction.
430429
void recede(const RegisterOperands &RegOpers,
431-
SmallVectorImpl<RegisterMaskPair> *LiveUses = nullptr);
430+
SmallVectorImpl<VRegMaskOrUnit> *LiveUses = nullptr);
432431

433432
/// Recede until we find an instruction which is not a DebugValue.
434433
void recedeSkipDebugValues();
@@ -546,21 +545,21 @@ class RegPressureTracker {
546545

547546
protected:
548547
/// Add Reg to the live out set and increase max pressure.
549-
void discoverLiveOut(RegisterMaskPair Pair);
548+
void discoverLiveOut(VRegMaskOrUnit Pair);
550549
/// Add Reg to the live in set and increase max pressure.
551-
void discoverLiveIn(RegisterMaskPair Pair);
550+
void discoverLiveIn(VRegMaskOrUnit Pair);
552551

553552
/// Get the SlotIndex for the first nondebug instruction including or
554553
/// after the current position.
555554
SlotIndex getCurrSlot() const;
556555

557-
void bumpDeadDefs(ArrayRef<RegisterMaskPair> DeadDefs);
556+
void bumpDeadDefs(ArrayRef<VRegMaskOrUnit> DeadDefs);
558557

559558
void bumpUpwardPressure(const MachineInstr *MI);
560559
void bumpDownwardPressure(const MachineInstr *MI);
561560

562-
void discoverLiveInOrOut(RegisterMaskPair Pair,
563-
SmallVectorImpl<RegisterMaskPair> &LiveInOrOut);
561+
void discoverLiveInOrOut(VRegMaskOrUnit Pair,
562+
SmallVectorImpl<VRegMaskOrUnit> &LiveInOrOut);
564563

565564
LaneBitmask getLastUsedLanes(Register RegUnit, SlotIndex Pos) const;
566565
LaneBitmask getLiveLanesAt(Register RegUnit, SlotIndex Pos) const;

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ static void computeLiveOuts(MachineFunction &MF, RegPressureTracker &RPTracker,
19811981
NodeSet &NS) {
19821982
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
19831983
MachineRegisterInfo &MRI = MF.getRegInfo();
1984-
SmallVector<RegisterMaskPair, 8> LiveOutRegs;
1984+
SmallVector<VRegMaskOrUnit, 8> LiveOutRegs;
19851985
SmallSet<unsigned, 4> Uses;
19861986
for (SUnit *SU : NS) {
19871987
const MachineInstr *MI = SU->getInstr();
@@ -2002,13 +2002,11 @@ static void computeLiveOuts(MachineFunction &MF, RegPressureTracker &RPTracker,
20022002
Register Reg = MO.getReg();
20032003
if (Reg.isVirtual()) {
20042004
if (!Uses.count(Reg))
2005-
LiveOutRegs.push_back(RegisterMaskPair(Reg,
2006-
LaneBitmask::getNone()));
2005+
LiveOutRegs.emplace_back(Reg, LaneBitmask::getNone());
20072006
} else if (MRI.isAllocatable(Reg)) {
20082007
for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg()))
20092008
if (!Uses.count(Unit))
2010-
LiveOutRegs.push_back(
2011-
RegisterMaskPair(Unit, LaneBitmask::getNone()));
2009+
LiveOutRegs.emplace_back(Unit, LaneBitmask::getNone());
20122010
}
20132011
}
20142012
RPTracker.addLiveRegs(LiveOutRegs);

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ void ScheduleDAGMILive::initRegPressure() {
12881288

12891289
// Account for liveness generated by the region boundary.
12901290
if (LiveRegionEnd != RegionEnd) {
1291-
SmallVector<RegisterMaskPair, 8> LiveUses;
1291+
SmallVector<VRegMaskOrUnit, 8> LiveUses;
12921292
BotRPTracker.recede(&LiveUses);
12931293
updatePressureDiffs(LiveUses);
12941294
}
@@ -1352,9 +1352,8 @@ updateScheduledPressure(const SUnit *SU,
13521352

13531353
/// Update the PressureDiff array for liveness after scheduling this
13541354
/// instruction.
1355-
void ScheduleDAGMILive::updatePressureDiffs(
1356-
ArrayRef<RegisterMaskPair> LiveUses) {
1357-
for (const RegisterMaskPair &P : LiveUses) {
1355+
void ScheduleDAGMILive::updatePressureDiffs(ArrayRef<VRegMaskOrUnit> LiveUses) {
1356+
for (const VRegMaskOrUnit &P : LiveUses) {
13581357
Register Reg = P.RegUnit;
13591358
/// FIXME: Currently assuming single-use physregs.
13601359
if (!Reg.isVirtual())
@@ -1579,7 +1578,7 @@ unsigned ScheduleDAGMILive::computeCyclicCriticalPath() {
15791578

15801579
unsigned MaxCyclicLatency = 0;
15811580
// Visit each live out vreg def to find def/use pairs that cross iterations.
1582-
for (const RegisterMaskPair &P : RPTracker.getPressure().LiveOutRegs) {
1581+
for (const VRegMaskOrUnit &P : RPTracker.getPressure().LiveOutRegs) {
15831582
Register Reg = P.RegUnit;
15841583
if (!Reg.isVirtual())
15851584
continue;
@@ -1707,7 +1706,7 @@ void ScheduleDAGMILive::scheduleMI(SUnit *SU, bool IsTopNode) {
17071706

17081707
if (BotRPTracker.getPos() != CurrentBottom)
17091708
BotRPTracker.recedeSkipDebugValues();
1710-
SmallVector<RegisterMaskPair, 8> LiveUses;
1709+
SmallVector<VRegMaskOrUnit, 8> LiveUses;
17111710
BotRPTracker.recede(RegOpers, &LiveUses);
17121711
assert(BotRPTracker.getPos() == CurrentBottom && "out of sync");
17131712
LLVM_DEBUG(dbgs() << "Bottom Pressure:\n"; dumpRegSetPressure(

0 commit comments

Comments
 (0)