Skip to content

Commit 59c75be

Browse files
committed
Get ArchVGPR alloc granule from AMDGPU::IsaInfo
1 parent fab547a commit 59c75be

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ struct GCNRegPressure {
6363
/// and \p NumAGPRs AGPRS, for a target with a unified VGPR file.
6464
inline static unsigned getUnifiedVGPRNum(unsigned NumArchVGPRs,
6565
unsigned NumAGPRs) {
66-
return alignTo(NumArchVGPRs, 4) + NumAGPRs;
66+
return alignTo(NumArchVGPRs, AMDGPU::IsaInfo::getArchVGPRAllocGranule()) +
67+
NumAGPRs;
6768
}
6869

6970
/// \returns the ArchVGPR32 pressure

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,9 +1714,6 @@ struct ExcessRP {
17141714
/// Whether the subtarget has a unified RF.
17151715
bool UnifiedRF;
17161716

1717-
/// ArchVGPR allocation granule for unified RFs with AGPR usage.
1718-
static const unsigned Granule = 4;
1719-
17201717
/// Constructs the excess RP model; determines the excess pressure w.r.t. a
17211718
/// maximum number of allowed VGPRs.
17221719
ExcessRP(const GCNSubtarget &ST, const GCNRegPressure &RP, unsigned MaxVGPRs);
@@ -1785,6 +1782,7 @@ ExcessRP::ExcessRP(const GCNSubtarget &ST, const GCNRegPressure &RP,
17851782

17861783
// Check overall VGPR usage against the limit; any excess above addressable
17871784
// register limits has already been accounted for.
1785+
const unsigned Granule = AMDGPU::IsaInfo::getArchVGPRAllocGranule();
17881786
unsigned NumVGPRs = GCNRegPressure::getUnifiedVGPRNum(NumArchVGPRs, NumAGPRs);
17891787
if (NumVGPRs > MaxVGPRs) {
17901788
VGPRs = NumVGPRs - MaxVGPRs;
@@ -1812,6 +1810,7 @@ bool ExcessRP::saveArchVGPRs(unsigned NumRegs, bool UseArchVGPRForAGPRSpill) {
18121810
unsigned NumSavedRegs = 0;
18131811

18141812
// Count the number of whole ArchVGPR allocation granules we can save.
1813+
const unsigned Granule = AMDGPU::IsaInfo::getArchVGPRAllocGranule();
18151814
if (unsigned NumGranules = NumRegs / Granule; NumGranules) {
18161815
NumSavedRegs = NumGranules * Granule;
18171816
NumRegs -= NumSavedRegs;

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,8 @@ unsigned getVGPREncodingGranule(const MCSubtargetInfo *STI,
11941194
return IsWave32 ? 8 : 4;
11951195
}
11961196

1197+
unsigned getArchVGPRAllocGranule() { return 4; }
1198+
11971199
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI) {
11981200
if (STI->getFeatureBits().test(FeatureGFX90AInsts))
11991201
return 512;

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ unsigned getVGPREncodingGranule(
318318
const MCSubtargetInfo *STI,
319319
std::optional<bool> EnableWavefrontSize32 = std::nullopt);
320320

321+
/// For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage,
322+
/// returns the allocation granule for ArchVGPRs.
323+
unsigned getArchVGPRAllocGranule();
324+
321325
/// \returns Total number of VGPRs for given subtarget \p STI.
322326
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI);
323327

0 commit comments

Comments
 (0)