Skip to content

Commit 81089f0

Browse files
committed
[CodeGen] Use Register::id(). NFC
1 parent bdf50f0 commit 81089f0

File tree

8 files changed

+37
-36
lines changed

8 files changed

+37
-36
lines changed

llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ void CriticalAntiDepBreaker::PrescanInstruction(MachineInstr &MI) {
190190

191191
// For now, only allow the register to be changed if its register
192192
// class is consistent across all uses.
193-
if (!Classes[Reg] && NewRC)
194-
Classes[Reg] = NewRC;
195-
else if (!NewRC || Classes[Reg] != NewRC)
196-
Classes[Reg] = reinterpret_cast<TargetRegisterClass *>(-1);
193+
if (!Classes[Reg.id()] && NewRC)
194+
Classes[Reg.id()] = NewRC;
195+
else if (!NewRC || Classes[Reg.id()] != NewRC)
196+
Classes[Reg.id()] = reinterpret_cast<TargetRegisterClass *>(-1);
197197

198198
// Now check for aliases.
199199
for (MCRegAliasIterator AI(Reg, TRI, false); AI.isValid(); ++AI) {
@@ -203,16 +203,16 @@ void CriticalAntiDepBreaker::PrescanInstruction(MachineInstr &MI) {
203203
unsigned AliasReg = (*AI).id();
204204
if (Classes[AliasReg]) {
205205
Classes[AliasReg] = reinterpret_cast<TargetRegisterClass *>(-1);
206-
Classes[Reg] = reinterpret_cast<TargetRegisterClass *>(-1);
206+
Classes[Reg.id()] = reinterpret_cast<TargetRegisterClass *>(-1);
207207
}
208208
}
209209

210210
// If we're still willing to consider this register, note the reference.
211-
if (Classes[Reg] != reinterpret_cast<TargetRegisterClass *>(-1))
211+
if (Classes[Reg.id()] != reinterpret_cast<TargetRegisterClass *>(-1))
212212
RegRefs.insert(std::make_pair(Reg, &MO));
213213

214214
if (MO.isUse() && Special) {
215-
if (!KeepRegs.test(Reg)) {
215+
if (!KeepRegs.test(Reg.id())) {
216216
for (MCPhysReg SubReg : TRI->subregs_inclusive(Reg))
217217
KeepRegs.set(SubReg);
218218
}
@@ -236,7 +236,7 @@ void CriticalAntiDepBreaker::PrescanInstruction(MachineInstr &MI) {
236236
// earlier instructions could still replace %eax even though the 'xor'
237237
// itself can't be changed.
238238
if (MI.isRegTiedToUseOperand(I) &&
239-
Classes[Reg] == reinterpret_cast<TargetRegisterClass *>(-1)) {
239+
Classes[Reg.id()] == reinterpret_cast<TargetRegisterClass *>(-1)) {
240240
for (MCPhysReg SubReg : TRI->subregs_inclusive(Reg)) {
241241
KeepRegs.set(SubReg);
242242
}
@@ -287,7 +287,7 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
287287

288288
// If we've already marked this reg as unchangeable, don't remove
289289
// it or any of its subregs from KeepRegs.
290-
bool Keep = KeepRegs.test(Reg);
290+
bool Keep = KeepRegs.test(Reg.id());
291291

292292
// For the reg itself and all subregs: update the def to current;
293293
// reset the kill state, any restrictions, and references.
@@ -317,10 +317,10 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
317317

318318
// For now, only allow the register to be changed if its register
319319
// class is consistent across all uses.
320-
if (!Classes[Reg] && NewRC)
321-
Classes[Reg] = NewRC;
322-
else if (!NewRC || Classes[Reg] != NewRC)
323-
Classes[Reg] = reinterpret_cast<TargetRegisterClass *>(-1);
320+
if (!Classes[Reg.id()] && NewRC)
321+
Classes[Reg.id()] = NewRC;
322+
else if (!NewRC || Classes[Reg.id()] != NewRC)
323+
Classes[Reg.id()] = reinterpret_cast<TargetRegisterClass *>(-1);
324324

325325
RegRefs.insert(std::make_pair(Reg, &MO));
326326

llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ GISelInstProfileBuilder::addNodeIDImmediate(int64_t Imm) const {
385385

386386
const GISelInstProfileBuilder &
387387
GISelInstProfileBuilder::addNodeIDRegNum(Register Reg) const {
388-
ID.AddInteger(Reg);
388+
ID.AddInteger(Reg.id());
389389
return *this;
390390
}
391391

llvm/lib/CodeGen/LiveIntervalUnion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ LiveIntervalUnion::print(raw_ostream &OS, const TargetRegisterInfo *TRI) const {
9696
// Verify the live intervals in this union and add them to the visited set.
9797
void LiveIntervalUnion::verify(LiveVirtRegBitSet& VisitedVRegs) {
9898
for (SegmentIter SI = Segments.begin(); SI.valid(); ++SI)
99-
VisitedVRegs.set(SI.value()->reg());
99+
VisitedVRegs.set(SI.value()->reg().id());
100100
}
101101
#endif //!NDEBUG
102102

llvm/lib/CodeGen/LivePhysRegs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void LivePhysRegs::stepForward(const MachineInstr &MI,
9090
if (O->isDef()) {
9191
// Note, dead defs are still recorded. The caller should decide how to
9292
// handle them.
93-
Clobbers.push_back(std::make_pair(Reg, &*O));
93+
Clobbers.push_back(std::make_pair(Reg.id(), &*O));
9494
} else {
9595
assert(O->isUse());
9696
if (O->isKill())

llvm/lib/CodeGen/LiveVariables.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ LiveVariables::FindLastPartialDef(Register Reg,
253253
/// implicit defs to a machine instruction if there was an earlier def of its
254254
/// super-register.
255255
void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) {
256-
MachineInstr *LastDef = PhysRegDef[Reg];
256+
MachineInstr *LastDef = PhysRegDef[Reg.id()];
257257
// If there was a previous use or a "full" def all is well.
258-
if (!LastDef && !PhysRegUse[Reg]) {
258+
if (!LastDef && !PhysRegUse[Reg.id()]) {
259259
// Otherwise, the last sub-register def implicitly defines this register.
260260
// e.g.
261261
// AH =
@@ -270,7 +270,7 @@ void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) {
270270
if (LastPartialDef) {
271271
LastPartialDef->addOperand(MachineOperand::CreateReg(Reg, true/*IsDef*/,
272272
true/*IsImp*/));
273-
PhysRegDef[Reg] = LastPartialDef;
273+
PhysRegDef[Reg.id()] = LastPartialDef;
274274
SmallSet<MCPhysReg, 8> Processed;
275275
for (MCPhysReg SubReg : TRI->subregs(Reg)) {
276276
if (Processed.count(SubReg))
@@ -287,7 +287,7 @@ void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) {
287287
Processed.insert(SS);
288288
}
289289
}
290-
} else if (LastDef && !PhysRegUse[Reg] &&
290+
} else if (LastDef && !PhysRegUse[Reg.id()] &&
291291
!LastDef->findRegisterDefOperand(Reg, /*TRI=*/nullptr))
292292
// Last def defines the super register, add an implicit def of reg.
293293
LastDef->addOperand(MachineOperand::CreateReg(Reg, true/*IsDef*/,
@@ -301,8 +301,8 @@ void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) {
301301
/// FindLastRefOrPartRef - Return the last reference or partial reference of
302302
/// the specified register.
303303
MachineInstr *LiveVariables::FindLastRefOrPartRef(Register Reg) {
304-
MachineInstr *LastDef = PhysRegDef[Reg];
305-
MachineInstr *LastUse = PhysRegUse[Reg];
304+
MachineInstr *LastDef = PhysRegDef[Reg.id()];
305+
MachineInstr *LastUse = PhysRegUse[Reg.id()];
306306
if (!LastDef && !LastUse)
307307
return nullptr;
308308

@@ -330,8 +330,8 @@ MachineInstr *LiveVariables::FindLastRefOrPartRef(Register Reg) {
330330
}
331331

332332
bool LiveVariables::HandlePhysRegKill(Register Reg, MachineInstr *MI) {
333-
MachineInstr *LastDef = PhysRegDef[Reg];
334-
MachineInstr *LastUse = PhysRegUse[Reg];
333+
MachineInstr *LastDef = PhysRegDef[Reg.id()];
334+
MachineInstr *LastUse = PhysRegUse[Reg.id()];
335335
if (!LastDef && !LastUse)
336336
return false;
337337

@@ -380,27 +380,27 @@ bool LiveVariables::HandlePhysRegKill(Register Reg, MachineInstr *MI) {
380380
}
381381
}
382382

383-
if (!PhysRegUse[Reg]) {
383+
if (!PhysRegUse[Reg.id()]) {
384384
// Partial uses. Mark register def dead and add implicit def of
385385
// sub-registers which are used.
386386
// dead EAX = op implicit-def AL
387387
// That is, EAX def is dead but AL def extends pass it.
388-
PhysRegDef[Reg]->addRegisterDead(Reg, TRI, true);
388+
PhysRegDef[Reg.id()]->addRegisterDead(Reg, TRI, true);
389389
for (MCPhysReg SubReg : TRI->subregs(Reg)) {
390390
if (!PartUses.count(SubReg))
391391
continue;
392392
bool NeedDef = true;
393-
if (PhysRegDef[Reg] == PhysRegDef[SubReg]) {
394-
MachineOperand *MO =
395-
PhysRegDef[Reg]->findRegisterDefOperand(SubReg, /*TRI=*/nullptr);
393+
if (PhysRegDef[Reg.id()] == PhysRegDef[SubReg]) {
394+
MachineOperand *MO = PhysRegDef[Reg.id()]->findRegisterDefOperand(
395+
SubReg, /*TRI=*/nullptr);
396396
if (MO) {
397397
NeedDef = false;
398398
assert(!MO->isDead());
399399
}
400400
}
401401
if (NeedDef)
402-
PhysRegDef[Reg]->addOperand(MachineOperand::CreateReg(SubReg,
403-
true/*IsDef*/, true/*IsImp*/));
402+
PhysRegDef[Reg.id()]->addOperand(
403+
MachineOperand::CreateReg(SubReg, true /*IsDef*/, true /*IsImp*/));
404404
MachineInstr *LastSubRef = FindLastRefOrPartRef(SubReg);
405405
if (LastSubRef)
406406
LastSubRef->addRegisterKilled(SubReg, TRI, true);
@@ -412,7 +412,8 @@ bool LiveVariables::HandlePhysRegKill(Register Reg, MachineInstr *MI) {
412412
for (MCPhysReg SS : TRI->subregs(SubReg))
413413
PartUses.erase(SS);
414414
}
415-
} else if (LastRefOrPartRef == PhysRegDef[Reg] && LastRefOrPartRef != MI) {
415+
} else if (LastRefOrPartRef == PhysRegDef[Reg.id()] &&
416+
LastRefOrPartRef != MI) {
416417
if (LastPartDef)
417418
// The last partial def kills the register.
418419
LastPartDef->addOperand(MachineOperand::CreateReg(Reg, false/*IsDef*/,
@@ -463,7 +464,7 @@ void LiveVariables::HandlePhysRegDef(Register Reg, MachineInstr *MI,
463464
SmallVectorImpl<Register> &Defs) {
464465
// What parts of the register are previously defined?
465466
SmallSet<unsigned, 32> Live;
466-
if (PhysRegDef[Reg] || PhysRegUse[Reg]) {
467+
if (PhysRegDef[Reg.id()] || PhysRegUse[Reg.id()]) {
467468
for (MCPhysReg SubReg : TRI->subregs_inclusive(Reg))
468469
Live.insert(SubReg);
469470
} else {

llvm/lib/CodeGen/MachineStableHash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
6868
}
6969

7070
// Register operands don't have target flags.
71-
return stable_hash_combine(MO.getType(), MO.getReg(), MO.getSubReg(),
71+
return stable_hash_combine(MO.getType(), MO.getReg().id(), MO.getSubReg(),
7272
MO.isDef());
7373
case MachineOperand::MO_Immediate:
7474
return stable_hash_combine(MO.getType(), MO.getTargetFlags(), MO.getImm());

llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,5 @@ TargetFrameLowering::getInitialCFARegister(const MachineFunction &MF) const {
180180
TargetFrameLowering::DwarfFrameBase
181181
TargetFrameLowering::getDwarfFrameBase(const MachineFunction &MF) const {
182182
const TargetRegisterInfo *RI = MF.getSubtarget().getRegisterInfo();
183-
return DwarfFrameBase{DwarfFrameBase::Register, {RI->getFrameRegister(MF)}};
183+
return DwarfFrameBase{DwarfFrameBase::Register, {RI->getFrameRegister(MF).id()}};
184184
}

llvm/lib/CodeGen/TargetRegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ bool TargetRegisterInfo::getRegAllocationHints(
498498
continue;
499499

500500
// All clear, tell the register allocator to prefer this register.
501-
Hints.push_back(Phys);
501+
Hints.push_back(Phys.id());
502502
}
503503
return false;
504504
}

0 commit comments

Comments
 (0)