Skip to content

Commit 86d712c

Browse files
authored
[AMDGPU] Use MCRegUnit, insert explicit casts to/from unsigned (NFC) (#167889)
The casts are currently no-op because `MCRegUnit` is a typedef'ed to `unsigned`, but this will change soon enough and explicit cast will be required.
1 parent 66e97aa commit 86d712c

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class AMDGPUInsertDelayAlu {
221221
};
222222

223223
// A map from regunits to the delay info for that regunit.
224-
struct DelayState : DenseMap<unsigned, DelayInfo> {
224+
struct DelayState : DenseMap<MCRegUnit, DelayInfo> {
225225
// Merge another DelayState into this one by merging the delay info for each
226226
// regunit.
227227
void merge(const DelayState &RHS) {
@@ -359,7 +359,8 @@ class AMDGPUInsertDelayAlu {
359359
bool Changed = false;
360360
MachineInstr *LastDelayAlu = nullptr;
361361

362-
MCRegUnit LastSGPRFromVALU = 0;
362+
// FIXME: 0 is a valid register unit.
363+
MCRegUnit LastSGPRFromVALU = static_cast<MCRegUnit>(0);
363364
// Iterate over the contents of bundles, but don't emit any instructions
364365
// inside a bundle.
365366
for (auto &MI : MBB.instrs()) {
@@ -379,7 +380,8 @@ class AMDGPUInsertDelayAlu {
379380
if (It != State.end()) {
380381
DelayInfo Info = It->getSecond();
381382
State.advanceByVALUNum(Info.VALUNum);
382-
LastSGPRFromVALU = 0;
383+
// FIXME: 0 is a valid register unit.
384+
LastSGPRFromVALU = static_cast<MCRegUnit>(0);
383385
}
384386
}
385387

llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ int GCNHazardRecognizer::getWaitStatesSinceSetReg(IsHazardFn IsHazard,
643643
static void addRegUnits(const SIRegisterInfo &TRI, BitVector &BV,
644644
MCRegister Reg) {
645645
for (MCRegUnit Unit : TRI.regunits(Reg))
646-
BV.set(Unit);
646+
BV.set(static_cast<unsigned>(Unit));
647647
}
648648

649649
static void addRegsToSet(const SIRegisterInfo &TRI,

llvm/lib/Target/AMDGPU/SIPostRABundler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void SIPostRABundler::collectUsedRegUnits(const MachineInstr &MI,
110110
"subregister indexes should not be present after RA");
111111

112112
for (MCRegUnit Unit : TRI->regunits(Reg))
113-
UsedRegUnits.set(Unit);
113+
UsedRegUnits.set(static_cast<unsigned>(Unit));
114114
}
115115
}
116116

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,12 @@ SIRegisterInfo::SIRegisterInfo(const GCNSubtarget &ST)
340340
"getNumCoveredRegs() will not work with generated subreg masks!");
341341

342342
RegPressureIgnoredUnits.resize(getNumRegUnits());
343-
RegPressureIgnoredUnits.set(*regunits(MCRegister::from(AMDGPU::M0)).begin());
343+
RegPressureIgnoredUnits.set(
344+
static_cast<unsigned>(*regunits(MCRegister::from(AMDGPU::M0)).begin()));
344345
for (auto Reg : AMDGPU::VGPR_16RegClass) {
345346
if (AMDGPU::isHi16Reg(Reg, *this))
346-
RegPressureIgnoredUnits.set(*regunits(Reg).begin());
347+
RegPressureIgnoredUnits.set(
348+
static_cast<unsigned>(*regunits(Reg).begin()));
347349
}
348350

349351
// HACK: Until this is fully tablegen'd.
@@ -3795,7 +3797,7 @@ unsigned SIRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF,
37953797
const int *SIRegisterInfo::getRegUnitPressureSets(MCRegUnit RegUnit) const {
37963798
static const int Empty[] = { -1 };
37973799

3798-
if (RegPressureIgnoredUnits[RegUnit])
3800+
if (RegPressureIgnoredUnits[static_cast<unsigned>(RegUnit)])
37993801
return Empty;
38003802

38013803
return AMDGPUGenRegisterInfo::getRegUnitPressureSets(RegUnit);

0 commit comments

Comments
 (0)