Skip to content

Commit c0f8c77

Browse files
committed
Keep subtarget feature until users are migrated
1 parent d7c255c commit c0f8c77

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,13 @@ def FeatureXF32Insts : SubtargetFeature<"xf32-insts",
12571257
"v_mfma_f32_16x16x8_xf32 and v_mfma_f32_32x32x4_xf32"
12581258
>;
12591259

1260+
// FIXME: Remove after all users are migrated to attribute.
1261+
def FeatureDynamicVGPR : SubtargetFeature <"dynamic-vgpr",
1262+
"DynamicVGPR",
1263+
"true",
1264+
"Enable dynamic VGPR mode"
1265+
>;
1266+
12601267
def FeatureDynamicVGPRBlockSize32 : SubtargetFeature<"dynamic-vgpr-block-size-32",
12611268
"DynamicVGPRBlockSize32",
12621269
"true",

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ unsigned getMaxVGPRs(const TargetMachine &TM, const Function &F) {
204204
IsDynamicVGPR = F.getFnAttribute("amdgpu-dynamic-vgpr").getValueAsBool();
205205

206206
const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
207+
208+
// FIXME: Delete after all users are migrated to use the attribute.
209+
if (ST.isDynamicVGPREnabled())
210+
IsDynamicVGPR = true;
211+
207212
unsigned MaxVGPRs =
208213
ST.getMaxNumVGPRs(ST.getWavesPerEU(F).first, IsDynamicVGPR);
209214

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ unsigned GCNSubtarget::getReservedNumSGPRs(const Function &F) const {
405405
std::pair<unsigned, unsigned>
406406
GCNSubtarget::computeOccupancy(const Function &F, unsigned LDSSize,
407407
unsigned NumSGPRs, unsigned NumVGPRs) const {
408-
bool IsDynamicVGPR = false;
408+
bool IsDynamicVGPR = isDynamicVGPREnabled();
409409
if (F.hasFnAttribute("amdgpu-dynamic-vgpr"))
410410
IsDynamicVGPR = F.getFnAttribute("amdgpu-dynamic-vgpr").getValueAsBool();
411411

@@ -504,7 +504,7 @@ unsigned GCNSubtarget::getMaxNumSGPRs(const Function &F) const {
504504

505505
unsigned GCNSubtarget::getBaseMaxNumVGPRs(
506506
const Function &F, std::pair<unsigned, unsigned> WavesPerEU) const {
507-
bool IsDynamicVGPR = false;
507+
bool IsDynamicVGPR = isDynamicVGPREnabled();
508508
if (F.hasFnAttribute("amdgpu-dynamic-vgpr"))
509509
IsDynamicVGPR = F.getFnAttribute("amdgpu-dynamic-vgpr").getValueAsBool();
510510

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
191191
/// indicates a lack of S_CLAUSE support.
192192
unsigned MaxHardClauseLength = 0;
193193
bool SupportsSRAMECC = false;
194+
bool DynamicVGPR = false;
194195
bool DynamicVGPRBlockSize32 = false;
195196

196197
// This should not be used directly. 'TargetID' tracks the dynamic settings
@@ -1657,6 +1658,8 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
16571658
return true;
16581659
}
16591660

1661+
bool isDynamicVGPREnabled() const { return DynamicVGPR; }
1662+
16601663
bool requiresDisjointEarlyClobberAndUndef() const override {
16611664
// AMDGPU doesn't care if early-clobber and undef operands are allocated
16621665
// to the same register.

llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F,
5252
IsDynamicVGPREnabled =
5353
F.getFnAttribute("amdgpu-dynamic-vgpr").getValueAsBool();
5454

55+
// FIXME: Remove after all users are migrated to the attribute.
56+
if (ST.isDynamicVGPREnabled())
57+
IsDynamicVGPREnabled = true;
58+
5559
Occupancy = ST.computeOccupancy(F, getLDSSize()).second;
5660
CallingConv::ID CC = F.getCallingConv();
5761

llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,GFX11 %s
22
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1200 -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,GFX12 %s
3+
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1200 -mattr=+dynamic-vgpr -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,GFX12,DVGPR %s
34

45
; CHECK: .amdgpu_pal_metadata
56
; CHECK-NEXT: ---
67
; CHECK-NEXT: amdpal.pipelines:
78
; CHECK-NEXT: - .api: Vulkan
89
; CHECK-NEXT: .compute_registers:
10+
; DVGPR-NEXT: .dynamic_vgpr_en: true
911
; CHECK-NEXT: .tg_size_en: true
1012
; CHECK-NEXT: .tgid_x_en: false
1113
; CHECK-NEXT: .tgid_y_en: false

llvm/test/CodeGen/AMDGPU/pal-metadata-3.0.ll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 <%s | FileCheck %s --check-prefixes=CHECK,GFX11
2-
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1200 <%s | FileCheck %s --check-prefixes=CHECK
1+
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 <%s | FileCheck %s --check-prefixes=CHECK,GFX11,NODVGPR
2+
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1200 <%s | FileCheck %s --check-prefixes=CHECK,NODVGPR
3+
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1200 -mattr=+dynamic-vgpr <%s | FileCheck %s --check-prefixes=CHECK,DVGPR
34

45
; CHECK-LABEL: {{^}}_amdgpu_cs_main:
5-
; CHECK: ; TotalNumSgprs: 4
6+
; NODVGPR: ; TotalNumSgprs: 4
7+
; DVGPR: ; TotalNumSgprs: 34
68
; CHECK: ; NumVgprs: 2
79
; CHECK: .amdgpu_pal_metadata
810
; CHECK-NEXT: ---
911
; CHECK-NEXT: amdpal.pipelines:
1012
; CHECK-NEXT: - .api: Vulkan
1113
; CHECK-NEXT: .compute_registers:
14+
; DVGPR-NEXT: .dynamic_vgpr_en: true
1215
; CHECK-NEXT: .tg_size_en: true
1316
; CHECK-NEXT: .tgid_x_en: false
1417
; CHECK-NEXT: .tgid_y_en: false
@@ -54,6 +57,7 @@
5457
; CHECK-NEXT: .cs:
5558
; CHECK-NEXT: .checksum_value: 0x9444d7d0
5659
; CHECK-NEXT: .debug_mode: false
60+
; DVGPR-NEXT: .dynamic_vgpr_saved_count: 0x70
5761
; CHECK-NEXT: .entry_point: _amdgpu_cs
5862
; CHECK-NEXT: .entry_point_symbol: _amdgpu_cs_main
5963
; CHECK-NEXT: .excp_en: 0
@@ -64,7 +68,8 @@
6468
; CHECK-NEXT: .mem_ordered: true
6569
; CHECK-NEXT: .scratch_en: false
6670
; CHECK-NEXT: .scratch_memory_size: 0
67-
; CHECK-NEXT: .sgpr_count: 0x4
71+
; NODVGPR-NEXT: .sgpr_count: 0x4
72+
; DVGPR-NEXT: .sgpr_count: 0x22
6873
; CHECK-NEXT: .sgpr_limit: 0x6a
6974
; CHECK-NEXT: .threadgroup_dimensions:
7075
; CHECK-NEXT: - 0x1

0 commit comments

Comments
 (0)