Skip to content

Commit 870f9a9

Browse files
committed
AMDGPU: Allow readonly features to be written to IR when there is no target
1 parent 56aa23d commit 870f9a9

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,9 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
266266

267267
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
268268
CUMode = !(GPUFeatures & llvm::AMDGPU::FEATURE_WGP);
269-
// Mark these features as read-only when the target supports them.
270-
llvm::StringMap<bool> Features;
271-
llvm::AMDGPU::fillAMDGPUFeatureMap(Opts.CPU, Triple, Features);
269+
272270
for (auto F : {"image-insts", "gws", "vmem-to-lds-load-insts"}) {
273-
if (Features[F] == true)
271+
if (GPUKind != llvm::AMDGPU::GK_NONE)
274272
ReadOnlyFeatures.insert(F);
275273
}
276274
HalfArgsAndReturns = true;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// REQUIRES: amdgpu-registered-target
22

3-
// Check the "gws" feature will not be written to the IR
4-
// if the target supports it (gfx942 and gfx1100)
3+
// Check the readonly feature will can be written to the IR
4+
// if there is no target specified.
55

66
// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s | FileCheck --check-prefix=NOCPU %s
77
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx942 -emit-llvm -o - %s | FileCheck --check-prefix=GFX942 %s
88
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1100 %s
99
// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1200 %s
1010

11-
__attribute__((target("gws"))) void test() {}
11+
__attribute__((target("gws,image-insts,vmem-to-lds-load-insts"))) void test() {}
1212

13-
// NOCPU: "target-features"="+gws"
13+
// NOCPU: "target-features"="+gws,+image-insts,+vmem-to-lds-load-insts"
1414
// 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"
1515
// 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,+gws,+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"

0 commit comments

Comments
 (0)