Skip to content

Commit b7eee2c

Browse files
committed
[CodeGen] Remove some implict conversions of MCRegister to unsigned by using(). NFC
Many of these are indexing BitVectors or something where we can't using MCRegister and need the register number.
1 parent 69d3ba3 commit b7eee2c

19 files changed

+41
-38
lines changed

llvm/include/llvm/CodeGen/CallingConvLower.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class CCState {
254254
/// isAllocated - Return true if the specified register (or an alias) is
255255
/// allocated.
256256
bool isAllocated(MCRegister Reg) const {
257-
return UsedRegs[Reg / 32] & (1 << (Reg & 31));
257+
return UsedRegs[Reg.id() / 32] & (1 << (Reg.id() & 31));
258258
}
259259

260260
/// AnalyzeFormalArguments - Analyze an array of argument values,

llvm/include/llvm/CodeGen/LivePhysRegs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class LivePhysRegs {
9393
assert(TRI && "LivePhysRegs is not initialized.");
9494
assert(Reg <= TRI->getNumRegs() && "Expected a physical register.");
9595
for (MCRegAliasIterator R(Reg, TRI, true); R.isValid(); ++R)
96-
LiveRegs.erase(*R);
96+
LiveRegs.erase((*R).id());
9797
}
9898

9999
/// Removes physical registers clobbered by the regmask operand \p MO.

llvm/include/llvm/CodeGen/MachineOperand.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,9 @@ class MachineOperand {
645645
/// mask pointers.
646646
static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg) {
647647
// See TargetRegisterInfo.h.
648-
assert(PhysReg < (1u << 30) && "Not a physical register");
649-
return !(RegMask[PhysReg / 32] & (1u << PhysReg % 32));
648+
assert((!PhysReg.isValid() || PhysReg.isPhysical()) &&
649+
"Not a physical register");
650+
return !(RegMask[PhysReg.id() / 32] & (1u << PhysReg.id() % 32));
650651
}
651652

652653
/// clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.

llvm/include/llvm/CodeGen/MachineRegisterInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ class MachineRegisterInfo {
938938
MCRegAliasIterator R(PhysReg, TRI, true);
939939

940940
for (; R.isValid(); ++R)
941-
ReservedRegs.set(*R);
941+
ReservedRegs.set((*R).id());
942942
}
943943

944944
/// reservedRegsFrozen - Returns true after freezeReservedRegs() was called
@@ -951,7 +951,7 @@ class MachineRegisterInfo {
951951
/// register. Any register can be reserved before freezeReservedRegs() is
952952
/// called.
953953
bool canReserveReg(MCRegister PhysReg) const {
954-
return !reservedRegsFrozen() || ReservedRegs.test(PhysReg);
954+
return !reservedRegsFrozen() || ReservedRegs.test(PhysReg.id());
955955
}
956956

957957
/// getReservedRegs - Returns a reference to the frozen set of reserved

llvm/include/llvm/CodeGen/Register.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Register {
2121

2222
public:
2323
constexpr Register(unsigned Val = 0) : Reg(Val) {}
24-
constexpr Register(MCRegister Val) : Reg(Val) {}
24+
constexpr Register(MCRegister Val) : Reg(Val.id()) {}
2525

2626
// Register numbers can represent physical registers, virtual registers, and
2727
// sometimes stack slots. The unsigned values are divided into these ranges:

llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ void AggressiveAntiDepBreaker::PrescanInstruction(
420420
if (TRI->isSuperRegister(Reg, *AI) && State->IsLive(*AI))
421421
continue;
422422

423-
DefIndices[*AI] = Count;
423+
DefIndices[(*AI).id()] = Count;
424424
}
425425
}
426426
}

llvm/lib/CodeGen/CallingConvLower.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ void CCState::HandleByVal(unsigned ValNo, MVT ValVT, MVT LocVT,
6161
/// Mark a register and all of its aliases as allocated.
6262
void CCState::MarkAllocated(MCPhysReg Reg) {
6363
for (MCRegAliasIterator AI(Reg, &TRI, true); AI.isValid(); ++AI)
64-
UsedRegs[*AI / 32] |= 1 << (*AI & 31);
64+
UsedRegs[(*AI).id() / 32] |= 1 << ((*AI).id() & 31);
6565
}
6666

6767
void CCState::MarkUnallocated(MCPhysReg Reg) {
6868
for (MCRegAliasIterator AI(Reg, &TRI, true); AI.isValid(); ++AI)
69-
UsedRegs[*AI / 32] &= ~(1 << (*AI & 31));
69+
UsedRegs[(*AI).id() / 32] &= ~(1 << ((*AI).id() & 31));
7070
}
7171

7272
bool CCState::IsShadowAllocatedReg(MCRegister Reg) const {

llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void CriticalAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
6767
for (const MachineBasicBlock *Succ : BB->successors())
6868
for (const auto &LI : Succ->liveins()) {
6969
for (MCRegAliasIterator AI(LI.PhysReg, TRI, true); AI.isValid(); ++AI) {
70-
unsigned Reg = *AI;
70+
unsigned Reg = (*AI).id();
7171
Classes[Reg] = reinterpret_cast<TargetRegisterClass *>(-1);
7272
KillIndices[Reg] = BBSize;
7373
DefIndices[Reg] = ~0u;
@@ -85,7 +85,7 @@ void CriticalAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
8585
if (!IsReturnBlock && !Pristine.test(Reg))
8686
continue;
8787
for (MCRegAliasIterator AI(*I, TRI, true); AI.isValid(); ++AI) {
88-
unsigned Reg = *AI;
88+
unsigned Reg = (*AI).id();
8989
Classes[Reg] = reinterpret_cast<TargetRegisterClass *>(-1);
9090
KillIndices[Reg] = BBSize;
9191
DefIndices[Reg] = ~0u;
@@ -200,7 +200,7 @@ void CriticalAntiDepBreaker::PrescanInstruction(MachineInstr &MI) {
200200
// If an alias of the reg is used during the live range, give up.
201201
// Note that this allows us to skip checking if AntiDepReg
202202
// overlaps with any of the aliases, among other things.
203-
unsigned AliasReg = *AI;
203+
unsigned AliasReg = (*AI).id();
204204
if (Classes[AliasReg]) {
205205
Classes[AliasReg] = reinterpret_cast<TargetRegisterClass *>(-1);
206206
Classes[Reg] = reinterpret_cast<TargetRegisterClass *>(-1);
@@ -327,7 +327,7 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
327327
// It wasn't previously live but now it is, this is a kill.
328328
// Repeat for all aliases.
329329
for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) {
330-
unsigned AliasReg = *AI;
330+
unsigned AliasReg = (*AI).id();
331331
if (KillIndices[AliasReg] == ~0u) {
332332
KillIndices[AliasReg] = Count;
333333
DefIndices[AliasReg] = ~0u;

llvm/lib/CodeGen/ExecutionDomainFix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ bool ExecutionDomainFix::runOnMachineFunction(MachineFunction &mf) {
445445
for (unsigned i = 0, e = RC->getNumRegs(); i != e; ++i)
446446
for (MCRegAliasIterator AI(RC->getRegister(i), TRI, true); AI.isValid();
447447
++AI)
448-
AliasMap[*AI].push_back(i);
448+
AliasMap[(*AI).id()].push_back(i);
449449
}
450450

451451
// Initialize the MBBOutRegsInfos

llvm/lib/CodeGen/InterferenceCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ InterferenceCache::Entry *InterferenceCache::get(MCRegister PhysReg) {
7878
continue;
7979
}
8080
Entries[E].reset(PhysReg, LIUArray, TRI, MF);
81-
PhysRegEntries[PhysReg] = E;
81+
PhysRegEntries[PhysReg.id()] = E;
8282
return &Entries[E];
8383
}
8484
llvm_unreachable("Ran out of interference cache entries.");

0 commit comments

Comments
 (0)