Skip to content

Commit dbed898

Browse files
authored
[AMDGPU] Add missing __builtin_amdgcn_wavefrontsize builtin (#80741)
Summary: The backend supports the wavefrontsize intrinsic, and suggests that it is tied to a corresponding clang builtin, but it is not actually present. This simply adds it in so it can be used from clang. This attribute likely isn't the best to rely on, but for the `libc` use-case we will need to detect a struct's differing size in a way that will depend on the wavefront size.
1 parent e2cfdf7 commit dbed898

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
6969
BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
7070
BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
7171
BUILTIN(__builtin_amdgcn_groupstaticsize, "Ui", "n")
72+
BUILTIN(__builtin_amdgcn_wavefrontsize, "Ui", "nc")
7273

7374
BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n")
7475
BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n")

clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,13 @@ void test_atomic_inc_dec(local uint *lptr, global uint *gptr, uint val) {
832832
res = __builtin_amdgcn_atomic_dec32((volatile global uint*)gptr, val, __ATOMIC_SEQ_CST, "");
833833
}
834834

835+
// CHECK-LABEL test_wavefrontsize(
836+
unsigned test_wavefrontsize() {
837+
838+
// CHECK: call i32 @llvm.amdgcn.wavefrontsize()
839+
return __builtin_amdgcn_wavefrontsize();
840+
}
841+
835842
// CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
836843
// CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
837844
// CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent mustprogress nocallback nofree nounwind willreturn memory(none) }

0 commit comments

Comments
 (0)