Skip to content

Commit 06da02d

Browse files
authored
[AMDGPU] Allow readonly features to be written to IR when there is no target (llvm#148141) (llvm#3364)
2 parents 22d571d + bebbd85 commit 06da02d

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,11 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
253253

254254
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
255255
CUMode = !(GPUFeatures & llvm::AMDGPU::FEATURE_WGP);
256-
for (auto F : {"image-insts", "gws", "vmem-to-lds-load-insts"})
257-
ReadOnlyFeatures.insert(F);
256+
257+
for (auto F : {"image-insts", "gws", "vmem-to-lds-load-insts"}) {
258+
if (GPUKind != llvm::AMDGPU::GK_NONE)
259+
ReadOnlyFeatures.insert(F);
260+
}
258261
HalfArgsAndReturns = true;
259262
}
260263

clang/test/CodeGenOpenCL/amdgpu-features-readonly.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple amdgcn -target-feature +gws -o /dev/null %s 2>&1 \
1+
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx942 -target-feature +gws -o /dev/null %s 2>&1 \
22
// RUN: | FileCheck --check-prefix=GWS %s
33

44
// GWS: warning: feature flag '+gws' is ignored since the feature is read only [-Winvalid-command-line-argument]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// REQUIRES: amdgpu-registered-target
2+
3+
// Check the readonly feature will can be written to the IR
4+
// if there is no target specified.
5+
6+
// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s | FileCheck --check-prefix=NOCPU %s
7+
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx942 -emit-llvm -o - %s | FileCheck --check-prefix=GFX942 %s
8+
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1100 %s
9+
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1200 %s
10+
11+
__attribute__((target("gws,image-insts,vmem-to-lds-load-insts"))) void test() {}
12+
13+
// NOCPU: "target-features"="+gws,+image-insts,+vmem-to-lds-load-insts"
14+
// GFX942: "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+fp8-conversion-insts,+fp8-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,+xf32-insts"
15+
// GFX1100: "target-features"="+16-bit-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot10-insts,+dot12-insts,+dot5-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx8-insts,+gfx9-insts,+wavefrontsize32"
16+
// GFX1200: "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-buffer-pk-add-bf16-inst,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot10-insts,+dot11-insts,+dot12-insts,+dot7-insts,+dot8-insts,+dot9-insts,+dpp,+fp8-conversion-insts,+gfx10-3-insts,+gfx10-insts,+gfx11-insts,+gfx12-insts,+gfx8-insts,+gfx9-insts,+wavefrontsize32"

llvm/lib/Target/AMDGPU/GCNProcessors.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// The code produced for "generic" is only useful for tests and cannot
1010
// reasonably be expected to execute on any particular target.
1111
def : ProcessorModel<"generic", NoSchedModel,
12-
[FeatureGDS, FeatureGWS]
12+
[FeatureGDS]
1313
>;
1414

1515
def : ProcessorModel<"generic-hsa", NoSchedModel,
16-
[FeatureGDS, FeatureGWS, FeatureFlatAddressSpace]
16+
[FeatureGDS, FeatureFlatAddressSpace]
1717
>;
1818

1919
//===------------------------------------------------------------===//

0 commit comments

Comments
 (0)