[llvm] 86d712c - [AMDGPU] Use MCRegUnit, insert explicit casts to/from unsigned (NFC) (#167889)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 13 10:39:06 PST 2025
Author: Sergei Barannikov
Date: 2025-11-13T21:39:02+03:00
New Revision: 86d712cda445ca45e8ac35d6af2854ed85c67187
URL: https://github.com/llvm/llvm-project/commit/86d712cda445ca45e8ac35d6af2854ed85c67187
DIFF: https://github.com/llvm/llvm-project/commit/86d712cda445ca45e8ac35d6af2854ed85c67187.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
index 9a90787963d7b..5f4ca82132335 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
@@ -221,7 +221,7 @@ class AMDGPUInsertDelayAlu {
};
// A map from regunits to the delay info for that regunit.
- struct DelayState : DenseMap<unsigned, DelayInfo> {
+ struct DelayState : DenseMap<MCRegUnit, DelayInfo> {
// Merge another DelayState into this one by merging the delay info for each
// regunit.
void merge(const DelayState &RHS) {
@@ -359,7 +359,8 @@ class AMDGPUInsertDelayAlu {
bool Changed = false;
MachineInstr *LastDelayAlu = nullptr;
- MCRegUnit LastSGPRFromVALU = 0;
+ // FIXME: 0 is a valid register unit.
+ MCRegUnit LastSGPRFromVALU = static_cast<MCRegUnit>(0);
// Iterate over the contents of bundles, but don't emit any instructions
// inside a bundle.
for (auto &MI : MBB.instrs()) {
@@ -379,7 +380,8 @@ class AMDGPUInsertDelayAlu {
if (It != State.end()) {
DelayInfo Info = It->getSecond();
State.advanceByVALUNum(Info.VALUNum);
- LastSGPRFromVALU = 0;
+ // FIXME: 0 is a valid register unit.
+ LastSGPRFromVALU = static_cast<MCRegUnit>(0);
}
}
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index 1a14629fb66b3..7a2f84a2f73eb 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -643,7 +643,7 @@ int GCNHazardRecognizer::getWaitStatesSinceSetReg(IsHazardFn IsHazard,
static void addRegUnits(const SIRegisterInfo &TRI, BitVector &BV,
MCRegister Reg) {
for (MCRegUnit Unit : TRI.regunits(Reg))
- BV.set(Unit);
+ BV.set(static_cast<unsigned>(Unit));
}
static void addRegsToSet(const SIRegisterInfo &TRI,
diff --git a/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp b/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
index 5720b978aada0..b537e44aaa9ea 100644
--- a/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
+++ b/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
@@ -110,7 +110,7 @@ void SIPostRABundler::collectUsedRegUnits(const MachineInstr &MI,
"subregister indexes should not be present after RA");
for (MCRegUnit Unit : TRI->regunits(Reg))
- UsedRegUnits.set(Unit);
+ UsedRegUnits.set(static_cast<unsigned>(Unit));
}
}
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index 0a5b51a33f02d..7663761997602 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -340,10 +340,12 @@ SIRegisterInfo::SIRegisterInfo(const GCNSubtarget &ST)
"getNumCoveredRegs() will not work with generated subreg masks!");
RegPressureIgnoredUnits.resize(getNumRegUnits());
- RegPressureIgnoredUnits.set(*regunits(MCRegister::from(AMDGPU::M0)).begin());
+ RegPressureIgnoredUnits.set(
+ static_cast<unsigned>(*regunits(MCRegister::from(AMDGPU::M0)).begin()));
for (auto Reg : AMDGPU::VGPR_16RegClass) {
if (AMDGPU::isHi16Reg(Reg, *this))
- RegPressureIgnoredUnits.set(*regunits(Reg).begin());
+ RegPressureIgnoredUnits.set(
+ static_cast<unsigned>(*regunits(Reg).begin()));
}
// HACK: Until this is fully tablegen'd.
@@ -3795,7 +3797,7 @@ unsigned SIRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF,
const int *SIRegisterInfo::getRegUnitPressureSets(MCRegUnit RegUnit) const {
static const int Empty[] = { -1 };
- if (RegPressureIgnoredUnits[RegUnit])
+ if (RegPressureIgnoredUnits[static_cast<unsigned>(RegUnit)])
return Empty;
return AMDGPUGenRegisterInfo::getRegUnitPressureSets(RegUnit);
More information about the llvm-commits
mailing list