1 // REQUIRES
: amdgpu-registered-target
2 // RUN
: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -verify -S -o - %s
4 #pragma OPENCL EXTENSION cl_khr_fp64
: enable
5 typedef unsigned long ulong
;
6 typedef unsigned int uint
;
8 // To get all errors for feature checking we need to put them in one function
9 // since Clang will stop codegen for the next function if it finds error during
10 // codegen of the previous function.
11 void test_target_builtin
(global int
* out
, int a
)
13 __builtin_amdgcn_s_memrealtime
(); // expected-error {{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}}
14 *out
= __builtin_amdgcn_mov_dpp
(a, 0, 0, 0, false
); // expected-error {{'__builtin_amdgcn_mov_dpp' needs target feature dpp}}
17 void test_s_sleep
(int x
)
19 __builtin_amdgcn_s_sleep
(x); // expected-error {{argument to '__builtin_amdgcn_s_sleep' must be a constant integer}}
22 void test_s_waitcnt
(int x
)
24 __builtin_amdgcn_s_waitcnt
(x); // expected-error {{argument to '__builtin_amdgcn_s_waitcnt' must be a constant integer}}
27 void test_s_sendmsg
(int in
)
29 __builtin_amdgcn_s_sendmsg
(in, 1); // expected-error {{argument to '__builtin_amdgcn_s_sendmsg' must be a constant integer}}
32 void test_s_sendmsg_var
(int in1
, int in2
)
34 __builtin_amdgcn_s_sendmsg
(in1, in2
); // expected-error {{argument to '__builtin_amdgcn_s_sendmsg' must be a constant integer}}
37 void test_s_sendmsghalt
(int in
)
39 __builtin_amdgcn_s_sendmsghalt
(in, 1); // expected-error {{argument to '__builtin_amdgcn_s_sendmsghalt' must be a constant integer}}
42 void test_s_sendmsghalt_var
(int in1
, int in2
)
44 __builtin_amdgcn_s_sendmsghalt
(in1, in2
); // expected-error {{argument to '__builtin_amdgcn_s_sendmsghalt' must be a constant integer}}
47 void test_s_incperflevel
(int x
)
49 __builtin_amdgcn_s_incperflevel
(x); // expected-error {{argument to '__builtin_amdgcn_s_incperflevel' must be a constant integer}}
52 void test_s_decperflevel
(int x
)
54 __builtin_amdgcn_s_decperflevel
(x); // expected-error {{argument to '__builtin_amdgcn_s_decperflevel' must be a constant integer}}
57 void test_s_setprio
(int x
)
59 __builtin_amdgcn_s_setprio
(x); // expected-error {{argument to '__builtin_amdgcn_s_setprio' must be a constant integer}}
60 __builtin_amdgcn_s_setprio
(65536); // expected-warning {{implicit conversion from 'int' to 'short' changes value from 65536 to 0}}
63 void test_sched_barrier
(int x
)
65 __builtin_amdgcn_sched_barrier
(x); // expected-error {{argument to '__builtin_amdgcn_sched_barrier' must be a constant integer}}
68 void test_sched_group_barrier
(int x
)
70 __builtin_amdgcn_sched_group_barrier
(x, 0, 1); // expected-error {{argument to '__builtin_amdgcn_sched_group_barrier' must be a constant integer}}
71 __builtin_amdgcn_sched_group_barrier
(0, x
, 1); // expected-error {{argument to '__builtin_amdgcn_sched_group_barrier' must be a constant integer}}
72 __builtin_amdgcn_sched_group_barrier
(0, 1, x
); // expected-error {{argument to '__builtin_amdgcn_sched_group_barrier' must be a constant integer}}
75 void test_iglp_opt
(int x
)
77 __builtin_amdgcn_iglp_opt
(x); // expected-error {{argument to '__builtin_amdgcn_iglp_opt' must be a constant integer}}
80 void test_sicmp_i32
(global ulong
* out
, int a
, int b
, uint c
)
82 *out
= __builtin_amdgcn_sicmp
(a, b
, c
); // expected-error {{argument to '__builtin_amdgcn_sicmp' must be a constant integer}}
85 void test_uicmp_i32
(global ulong
* out
, uint a
, uint b
, uint c
)
87 *out
= __builtin_amdgcn_uicmp
(a, b
, c
); // expected-error {{argument to '__builtin_amdgcn_uicmp' must be a constant integer}}
90 void test_sicmp_i64
(global ulong
* out
, long a
, long b
, uint c
)
92 *out
= __builtin_amdgcn_sicmpl
(a, b
, c
); // expected-error {{argument to '__builtin_amdgcn_sicmpl' must be a constant integer}}
95 void test_uicmp_i64
(global ulong
* out
, ulong a
, ulong b
, uint c
)
97 *out
= __builtin_amdgcn_uicmpl
(a, b
, c
); // expected-error {{argument to '__builtin_amdgcn_uicmpl' must be a constant integer}}
100 void test_fcmp_f32
(global ulong
* out
, float a
, float b
, uint c
)
102 *out
= __builtin_amdgcn_fcmpf
(a, b
, c
); // expected-error {{argument to '__builtin_amdgcn_fcmpf' must be a constant integer}}
105 void test_fcmp_f64
(global ulong
* out
, double a
, double b
, uint c
)
107 *out
= __builtin_amdgcn_fcmp
(a, b
, c
); // expected-error {{argument to '__builtin_amdgcn_fcmp' must be a constant integer}}
110 void test_ds_swizzle
(global int
* out
, int a
, int b
)
112 *out
= __builtin_amdgcn_ds_swizzle
(a, b
); // expected-error {{argument to '__builtin_amdgcn_ds_swizzle' must be a constant integer}}
115 void test_s_getreg
(global int
* out
, int a
)
117 *out
= __builtin_amdgcn_s_getreg
(a); // expected-error {{argument to '__builtin_amdgcn_s_getreg' must be a constant integer}}
120 void test_mov_dpp2
(global int
* out
, int a
, int b
, int c
, int d
, bool e
)
122 *out
= __builtin_amdgcn_mov_dpp
(a, b
, 0, 0, false
); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
123 *out
= __builtin_amdgcn_mov_dpp
(a, 0, c
, 0, false
); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
124 *out
= __builtin_amdgcn_mov_dpp
(a, 0, 0, d
, false
); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
125 *out
= __builtin_amdgcn_mov_dpp
(a, 0, 0, 0, e
); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
128 void test_update_dpp2
(global int
* out
, int a
, int b
, int c
, int d
, int e
, bool f
)
130 *out
= __builtin_amdgcn_update_dpp
(a, b
, 0, 0, 0, false
);
131 *out
= __builtin_amdgcn_update_dpp
(a, 0, c
, 0, 0, false
); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}}
132 *out
= __builtin_amdgcn_update_dpp
(a, 0, 0, d
, 0, false
); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}}
133 *out
= __builtin_amdgcn_update_dpp
(a, 0, 0, 0, e
, false
); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}}
134 *out
= __builtin_amdgcn_update_dpp
(a, 0, 0, 0, 0, f
); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}}
137 void test_ds_faddf
(local float
*out
, float src
, int a
) {
138 *out
= __builtin_amdgcn_ds_faddf
(out, src
, a
, 0, false
); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}}
139 *out
= __builtin_amdgcn_ds_faddf
(out, src
, 0, a
, false
); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}}
140 *out
= __builtin_amdgcn_ds_faddf
(out, src
, 0, 0, a
); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}}
143 void test_ds_fminf
(local float
*out
, float src
, int a
) {
144 *out
= __builtin_amdgcn_ds_fminf
(out, src
, a
, 0, false
); // expected-error {{argument to '__builtin_amdgcn_ds_fminf' must be a constant integer}}
145 *out
= __builtin_amdgcn_ds_fminf
(out, src
, 0, a
, false
); // expected-error {{argument to '__builtin_amdgcn_ds_fminf' must be a constant integer}}
146 *out
= __builtin_amdgcn_ds_fminf
(out, src
, 0, 0, a
); // expected-error {{argument to '__builtin_amdgcn_ds_fminf' must be a constant integer}}
149 void test_ds_fmaxf
(local float
*out
, float src
, int a
) {
150 *out
= __builtin_amdgcn_ds_fmaxf
(out, src
, a
, 0, false
); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
151 *out
= __builtin_amdgcn_ds_fmaxf
(out, src
, 0, a
, false
); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
152 *out
= __builtin_amdgcn_ds_fmaxf
(out, src
, 0, 0, a
); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
156 __builtin_amdgcn_fence
(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
157 __builtin_amdgcn_fence
(__ATOMIC_ACQUIRE -
1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
158 __builtin_amdgcn_fence
(4); // expected-error {{too few arguments to function call, expected 2}}
159 __builtin_amdgcn_fence
(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
160 __builtin_amdgcn_fence
(3.14
, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
161 __builtin_amdgcn_fence
(__ATOMIC_ACQUIRE, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
162 const char ptr
[] = "workgroup";
163 __builtin_amdgcn_fence
(__ATOMIC_ACQUIRE, ptr
); // expected-error {{expression is not a string literal}}
166 void test_s_setreg
(int x
, int y
) {
167 __builtin_amdgcn_s_setreg
(x, 0); // expected-error {{argument to '__builtin_amdgcn_s_setreg' must be a constant integer}}
168 __builtin_amdgcn_s_setreg
(x, y
); // expected-error {{argument to '__builtin_amdgcn_s_setreg' must be a constant integer}}
171 void test_atomic_inc32
() {
173 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, __ATOMIC_SEQ_CST
+ 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
174 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, __ATOMIC_RELAXED
, "workgroup");
175 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, __ATOMIC_CONSUME
, "workgroup");
176 val
= __builtin_amdgcn_atomic_inc32
(4); // expected-error {{too few arguments to function call, expected 4}}
177 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
178 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
179 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, __ATOMIC_ACQUIRE
, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
180 const char ptr
[] = "workgroup";
181 val
= __builtin_amdgcn_atomic_inc32
(&val
, val
, __ATOMIC_ACQUIRE
, ptr
); // expected-error {{expression is not a string literal}}
183 signedVal
= __builtin_amdgcn_atomic_inc32
(&signedVal
, signedVal
, __ATOMIC_ACQUIRE
, ""); // expected-warning {{passing '__private int *' to parameter of type 'volatile __private unsigned int *' converts between pointers to integer types with different sign}}
186 void test_atomic_inc64
() {
187 __UINT64_TYPE__ val
= 17;
188 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, __ATOMIC_SEQ_CST
+ 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
189 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, __ATOMIC_RELAXED
, "workgroup");
190 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, __ATOMIC_CONSUME
, "workgroup");
191 val
= __builtin_amdgcn_atomic_inc64
(4); // expected-error {{too few arguments to function call, expected 4}}
192 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
193 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
194 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, __ATOMIC_ACQUIRE
, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
195 const char ptr
[] = "workgroup";
196 val
= __builtin_amdgcn_atomic_inc64
(&val
, val
, __ATOMIC_ACQUIRE
, ptr
); // expected-error {{expression is not a string literal}}
197 __INT64_TYPE__ signedVal
= 15;
198 signedVal
= __builtin_amdgcn_atomic_inc64
(&signedVal
, signedVal
, __ATOMIC_ACQUIRE
, ""); // expected-warning {{passing '__private long *' to parameter of type 'volatile __private unsigned long *' converts between pointers to integer types with different sign}}
201 void test_atomic_dec32
() {
203 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, __ATOMIC_SEQ_CST
+ 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
204 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, __ATOMIC_RELAXED
, "workgroup");
205 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, __ATOMIC_CONSUME
, "workgroup");
206 val
= __builtin_amdgcn_atomic_dec32
(4); // expected-error {{too few arguments to function call, expected 4}}
207 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
208 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
209 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, __ATOMIC_ACQUIRE
, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
210 const char ptr
[] = "workgroup";
211 val
= __builtin_amdgcn_atomic_dec32
(&val
, val
, __ATOMIC_ACQUIRE
, ptr
); // expected-error {{expression is not a string literal}}
213 signedVal
= __builtin_amdgcn_atomic_dec32
(&signedVal
, signedVal
, __ATOMIC_ACQUIRE
, ""); // expected-warning {{passing '__private int *' to parameter of type 'volatile __private unsigned int *' converts between pointers to integer types with different sign}}
216 void test_atomic_dec64
() {
217 __UINT64_TYPE__ val
= 17;
218 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, __ATOMIC_SEQ_CST
+ 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
219 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, __ATOMIC_RELAXED
, "workgroup");
220 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, __ATOMIC_CONSUME
, "workgroup");
221 val
= __builtin_amdgcn_atomic_dec64
(4); // expected-error {{too few arguments to function call, expected 4}}
222 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
223 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
224 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, __ATOMIC_ACQUIRE
, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
225 const char ptr
[] = "workgroup";
226 val
= __builtin_amdgcn_atomic_dec64
(&val
, val
, __ATOMIC_ACQUIRE
, ptr
); // expected-error {{expression is not a string literal}}
227 __INT64_TYPE__ signedVal
= 15;
228 signedVal
= __builtin_amdgcn_atomic_dec64
(&signedVal
, signedVal
, __ATOMIC_ACQUIRE
, ""); // expected-warning {{passing '__private long *' to parameter of type 'volatile __private unsigned long *' converts between pointers to integer types with different sign}}