Skip to content

Commit c28c99f

Browse files
authored
[NFC][HIP] Add __builtin_*_load_lds type check test cases (#165388)
This tests show how type-checking is performed for `__builtin_amdgcn_load_to_lds`, but not for `__builtin_amdgcn_raw_ptr_buffer_load_lds`, `__builtin_amdgcn_struct_ptr_buffer_load_lds` and `__builtin_amdgcn_global_load_lds` since they are declared with the 't' attribute. Stacked on top of: #165387
1 parent dc8311f commit c28c99f

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

clang/test/SemaHIP/amdgpu-gfx950-load-to-lds.hip

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// REQUIRES: amdgpu-registered-target
22
// RUN: %clang_cc1 -fsyntax-only -triple amdgcn -target-cpu gfx950 -verify %s -fcuda-is-device
33
// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify %s
4-
// expected-no-diagnostics
54

65
#define __device__ __attribute__((device))
76
#define __global__ __attribute__((global))
@@ -58,3 +57,29 @@ __global__ void i_am_kernel(void* src, __amdgpu_buffer_rsrc_t rsrc, __shared__ v
5857
__builtin_amdgcn_global_load_lds(src, dst, 12, 0 , 0);
5958
__builtin_amdgcn_global_load_lds(src, dst, 16, 0 , 0);
6059
}
60+
61+
__device__ void i_am_wrong(void* src, __amdgpu_buffer_rsrc_t rsrc, __shared__ void* dst, int vindex, int voffset, int soffset) {
62+
__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 1, voffset, soffset, 0, 0, 4);
63+
__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 2, voffset, soffset, 0, 0, 4);
64+
__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 4, voffset, soffset, 0, 0, 4);
65+
__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 12, voffset, soffset, 0, 0, 4);
66+
__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 16, voffset, soffset, 0, 0, 4);
67+
68+
__builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 1, vindex, voffset, soffset, 0, 0, 4);
69+
__builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 2, vindex, voffset, soffset, 0, 0, 4);
70+
__builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 4, vindex, voffset, soffset, 0, 0, 4);
71+
__builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 12, vindex, voffset, soffset, 0, 0, 4);
72+
__builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 16, vindex, voffset, soffset, 0, 0, 4);
73+
74+
__builtin_amdgcn_load_to_lds(src, dst, 1, 0, 0, 4); // expected-error{{too many arguments to function call}}
75+
__builtin_amdgcn_load_to_lds(src, dst, 2, 0, 0, 4); // expected-error{{too many arguments to function call}}
76+
__builtin_amdgcn_load_to_lds(src, dst, 4, 0, 0, 4); // expected-error{{too many arguments to function call}}
77+
__builtin_amdgcn_load_to_lds(src, dst, 12, 0, 0, 4); // expected-error{{too many arguments to function call}}
78+
__builtin_amdgcn_load_to_lds(src, dst, 16, 0, 0, 4); // expected-error{{too many arguments to function call}}
79+
80+
__builtin_amdgcn_global_load_lds(src, dst, 1, 0 , 0, 4);
81+
__builtin_amdgcn_global_load_lds(src, dst, 2, 0 , 0, 4);
82+
__builtin_amdgcn_global_load_lds(src, dst, 4, 0 , 0, 4);
83+
__builtin_amdgcn_global_load_lds(src, dst, 12, 0 , 0, 4);
84+
__builtin_amdgcn_global_load_lds(src, dst, 16, 0 , 0, 4);
85+
}

0 commit comments

Comments
 (0)