Skip to content

Commit 268ca2e

Browse files
committed
fixup! Rename to VirtRegOrUnit.
1 parent 303e9fc commit 268ca2e

File tree

3 files changed

+89
-85
lines changed

3 files changed

+89
-85
lines changed

llvm/include/llvm/CodeGen/Register.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,33 @@ template <> struct DenseMapInfo<Register> {
161161
};
162162

163163
/// Wrapper class representing a virtual register or register unit.
164-
class RegisterUnit {
165-
unsigned RegUnit;
164+
class VirtRegOrUnit {
165+
unsigned VRegOrUnit;
166166

167167
public:
168-
constexpr explicit RegisterUnit(MCRegUnit Unit) : RegUnit(Unit) {
169-
assert(!Register::isVirtualRegister(RegUnit));
168+
constexpr explicit VirtRegOrUnit(MCRegUnit Unit) : VRegOrUnit(Unit) {
169+
assert(!Register::isVirtualRegister(VRegOrUnit));
170170
}
171-
constexpr explicit RegisterUnit(Register Reg) : RegUnit(Reg.id()) {
171+
constexpr explicit VirtRegOrUnit(Register Reg) : VRegOrUnit(Reg.id()) {
172172
assert(Reg.isVirtual());
173173
}
174174

175-
constexpr bool isVirtual() const {
176-
return Register::isVirtualRegister(RegUnit);
175+
constexpr bool isVirtualReg() const {
176+
return Register::isVirtualRegister(VRegOrUnit);
177177
}
178178

179179
constexpr MCRegUnit asMCRegUnit() const {
180-
assert(!isVirtual() && "Not a register unit");
181-
return RegUnit;
180+
assert(!isVirtualReg() && "Not a register unit");
181+
return VRegOrUnit;
182182
}
183183

184184
constexpr Register asVirtualReg() const {
185-
assert(isVirtual() && "Not a virtual register");
186-
return Register(RegUnit);
185+
assert(isVirtualReg() && "Not a virtual register");
186+
return Register(VRegOrUnit);
187187
}
188188

189-
constexpr bool operator==(const RegisterUnit &Other) const {
190-
return RegUnit == Other.RegUnit;
189+
constexpr bool operator==(const VirtRegOrUnit &Other) const {
190+
return VRegOrUnit == Other.VRegOrUnit;
191191
}
192192
};
193193

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,10 @@ class LiveIntervals::HMEditor {
10661066
for (LiveInterval::SubRange &S : LI.subranges()) {
10671067
if ((S.LaneMask & LaneMask).none())
10681068
continue;
1069-
updateRange(S, RegisterUnit(Reg), S.LaneMask);
1069+
updateRange(S, VirtRegOrUnit(Reg), S.LaneMask);
10701070
}
10711071
}
1072-
updateRange(LI, RegisterUnit(Reg), LaneBitmask::getNone());
1072+
updateRange(LI, VirtRegOrUnit(Reg), LaneBitmask::getNone());
10731073
// If main range has a hole and we are moving a subrange use across
10741074
// the hole updateRange() cannot properly handle it since it only
10751075
// gets the LiveRange and not the whole LiveInterval. As a result
@@ -1096,7 +1096,7 @@ class LiveIntervals::HMEditor {
10961096
// precomputed live range.
10971097
for (MCRegUnit Unit : TRI.regunits(Reg.asMCReg()))
10981098
if (LiveRange *LR = getRegUnitLI(Unit))
1099-
updateRange(*LR, RegisterUnit(Unit), LaneBitmask::getNone());
1099+
updateRange(*LR, VirtRegOrUnit(Unit), LaneBitmask::getNone());
11001100
}
11011101
if (hasRegMask)
11021102
updateRegMaskSlots();
@@ -1105,24 +1105,25 @@ class LiveIntervals::HMEditor {
11051105
private:
11061106
/// Update a single live range, assuming an instruction has been moved from
11071107
/// OldIdx to NewIdx.
1108-
void updateRange(LiveRange &LR, RegisterUnit Reg, LaneBitmask LaneMask) {
1108+
void updateRange(LiveRange &LR, VirtRegOrUnit VRegOrUnit,
1109+
LaneBitmask LaneMask) {
11091110
if (!Updated.insert(&LR).second)
11101111
return;
11111112
LLVM_DEBUG({
11121113
dbgs() << " ";
1113-
if (Reg.isVirtual()) {
1114-
dbgs() << printReg(Reg.asVirtualReg());
1114+
if (VRegOrUnit.isVirtualReg()) {
1115+
dbgs() << printReg(VRegOrUnit.asVirtualReg());
11151116
if (LaneMask.any())
11161117
dbgs() << " L" << PrintLaneMask(LaneMask);
11171118
} else {
1118-
dbgs() << printRegUnit(Reg.asMCRegUnit(), &TRI);
1119+
dbgs() << printRegUnit(VRegOrUnit.asMCRegUnit(), &TRI);
11191120
}
11201121
dbgs() << ":\t" << LR << '\n';
11211122
});
11221123
if (SlotIndex::isEarlierInstr(OldIdx, NewIdx))
11231124
handleMoveDown(LR);
11241125
else
1125-
handleMoveUp(LR, Reg, LaneMask);
1126+
handleMoveUp(LR, VRegOrUnit, LaneMask);
11261127
LLVM_DEBUG(dbgs() << " -->\t" << LR << '\n');
11271128
assert(LR.verify());
11281129
}
@@ -1302,7 +1303,8 @@ class LiveIntervals::HMEditor {
13021303

13031304
/// Update LR to reflect an instruction has been moved upwards from OldIdx
13041305
/// to NewIdx (NewIdx < OldIdx).
1305-
void handleMoveUp(LiveRange &LR, RegisterUnit RegUnit, LaneBitmask LaneMask) {
1306+
void handleMoveUp(LiveRange &LR, VirtRegOrUnit VRegOrUnit,
1307+
LaneBitmask LaneMask) {
13061308
LiveRange::iterator E = LR.end();
13071309
// Segment going into OldIdx.
13081310
LiveRange::iterator OldIdxIn = LR.find(OldIdx.getBaseIndex());
@@ -1326,7 +1328,7 @@ class LiveIntervals::HMEditor {
13261328
SlotIndex DefBeforeOldIdx
13271329
= std::max(OldIdxIn->start.getDeadSlot(),
13281330
NewIdx.getRegSlot(OldIdxIn->end.isEarlyClobber()));
1329-
OldIdxIn->end = findLastUseBefore(DefBeforeOldIdx, RegUnit, LaneMask);
1331+
OldIdxIn->end = findLastUseBefore(DefBeforeOldIdx, VRegOrUnit, LaneMask);
13301332

13311333
// Did we have a Def at OldIdx? If not we are done now.
13321334
OldIdxOut = std::next(OldIdxIn);
@@ -1484,12 +1486,12 @@ class LiveIntervals::HMEditor {
14841486
}
14851487

14861488
// Return the last use of reg between NewIdx and OldIdx.
1487-
SlotIndex findLastUseBefore(SlotIndex Before, RegisterUnit RegUnit,
1489+
SlotIndex findLastUseBefore(SlotIndex Before, VirtRegOrUnit VRegOrUnit,
14881490
LaneBitmask LaneMask) {
1489-
if (RegUnit.isVirtual()) {
1491+
if (VRegOrUnit.isVirtualReg()) {
14901492
SlotIndex LastUse = Before;
14911493
for (MachineOperand &MO :
1492-
MRI.use_nodbg_operands(RegUnit.asVirtualReg())) {
1494+
MRI.use_nodbg_operands(VRegOrUnit.asVirtualReg())) {
14931495
if (MO.isUndef())
14941496
continue;
14951497
unsigned SubReg = MO.getSubReg();
@@ -1532,7 +1534,7 @@ class LiveIntervals::HMEditor {
15321534
// Check if MII uses Reg.
15331535
for (MIBundleOperands MO(*MII); MO.isValid(); ++MO)
15341536
if (MO->isReg() && !MO->isUndef() && MO->getReg().isPhysical() &&
1535-
TRI.hasRegUnit(MO->getReg(), RegUnit.asMCRegUnit()))
1537+
TRI.hasRegUnit(MO->getReg(), VRegOrUnit.asMCRegUnit()))
15361538
return Idx.getRegSlot();
15371539
}
15381540
// Didn't reach Before. It must be the first instruction in the block.

0 commit comments

Comments
 (0)