[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / builtins-arm.c
blob7c731204da0938de95bdece2943b495ee73c4f91
1 // RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple armv7 -target-abi apcs-gnu \
3 // RUN: -fsyntax-only -verify %s
5 #include <arm_acle.h>
7 void f(void *a, void *b) {
8 __clear_cache(); // expected-error {{too few arguments to function call, expected 2, have 0}} // expected-note {{'__clear_cache' is a builtin with type 'void (void *, void *)}}
9 __clear_cache(a); // expected-error {{too few arguments to function call, expected 2, have 1}}
10 __clear_cache(a, b);
13 void __clear_cache(char*, char*); // expected-error {{conflicting types for '__clear_cache'}}
14 void __clear_cache(void*, void*);
16 #if defined(__ARM_PCS) || defined(__ARM_EABI__)
17 // va_list on ARM AAPCS is struct { void* __ap }.
18 void test1(void) {
19 __builtin_va_list ptr;
20 ptr.__ap = "x";
21 *(ptr.__ap) = '0'; // expected-error {{incomplete type 'void' is not assignable}}
23 #else
24 // va_list on ARM apcs-gnu is void*.
25 void test1(void) {
26 __builtin_va_list ptr;
27 ptr.__ap = "x"; // expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
28 *(ptr.__ap) = '0';// expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
31 void test2(void) {
32 __builtin_va_list ptr = "x";
33 *ptr = '0'; // expected-error {{incomplete type 'void' is not assignable}}
35 #endif
37 void test3(void) {
38 __builtin_arm_dsb(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
39 __builtin_arm_dmb(17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
40 __builtin_arm_isb(18); // expected-error-re {{argument value {{.*}} is outside the valid range}}
43 void test4(void) {
44 __builtin_arm_prefetch(0, 2, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
45 __builtin_arm_prefetch(0, 0, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
48 void test5(void) {
49 __builtin_arm_dbg(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
52 void test6(int a, int b, int c) {
53 __builtin_arm_ldc(1, 2, &a);
54 __builtin_arm_ldc(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
55 __builtin_arm_ldc(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
57 __builtin_arm_ldcl(1, 2, &a);
58 __builtin_arm_ldcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
59 __builtin_arm_ldcl(1, a, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
61 __builtin_arm_ldc2(1, 2, &a);
62 __builtin_arm_ldc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
63 __builtin_arm_ldc2(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
65 __builtin_arm_ldc2l(1, 2, &a);
66 __builtin_arm_ldc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
67 __builtin_arm_ldc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
69 __builtin_arm_stc(1, 2, &a);
70 __builtin_arm_stc(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
71 __builtin_arm_stc(1, a, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
73 __builtin_arm_stcl(1, 2, &a);
74 __builtin_arm_stcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
75 __builtin_arm_stcl(1, a, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
77 __builtin_arm_stc2(1, 2, &a);
78 __builtin_arm_stc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
79 __builtin_arm_stc2(1, a, &a); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
81 __builtin_arm_stc2l(1, 2, &a);
82 __builtin_arm_stc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
83 __builtin_arm_stc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
85 __builtin_arm_cdp(a, 2, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
86 __builtin_arm_cdp(1, a, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
87 __builtin_arm_cdp(1, 2, a, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
88 __builtin_arm_cdp(1, 2, 3, a, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
89 __builtin_arm_cdp(1, 2, 3, 4, 5, a); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
91 __builtin_arm_cdp2(a, 2, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
92 __builtin_arm_cdp2(1, a, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
93 __builtin_arm_cdp2(1, 2, a, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
94 __builtin_arm_cdp2(1, 2, 3, a, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
95 __builtin_arm_cdp2(1, 2, 3, 4, 5, a); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
97 __builtin_arm_mrc( a, 0, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
98 __builtin_arm_mrc(15, a, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
99 __builtin_arm_mrc(15, 0, a, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
100 __builtin_arm_mrc(15, 0, 13, a, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
101 __builtin_arm_mrc(15, 0, 13, 0, a); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
103 __builtin_arm_mrc2( a, 0, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
104 __builtin_arm_mrc2(15, a, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
105 __builtin_arm_mrc2(15, 0, a, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
106 __builtin_arm_mrc2(15, 0, 13, a, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
107 __builtin_arm_mrc2(15, 0, 13, 0, a); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
109 __builtin_arm_mcr( a, 0, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
110 __builtin_arm_mcr(15, a, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
111 __builtin_arm_mcr(15, 0, b, a, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
112 __builtin_arm_mcr(15, 0, b, 13, a, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
113 __builtin_arm_mcr(15, 0, b, 13, 0, a); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
115 __builtin_arm_mcr2( a, 0, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
116 __builtin_arm_mcr2(15, a, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
117 __builtin_arm_mcr2(15, 0, b, a, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
118 __builtin_arm_mcr2(15, 0, b, 13, a, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
119 __builtin_arm_mcr2(15, 0, b, 13, 0, a); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
121 __builtin_arm_mcrr(15, 0, b, 0);
122 __builtin_arm_mcrr( a, 0, b, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
123 __builtin_arm_mcrr(15, a, b, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
124 __builtin_arm_mcrr(15, 0, b, a); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
126 __builtin_arm_mcrr2(15, 0, b, 0);
127 __builtin_arm_mcrr2( a, 0, b, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
128 __builtin_arm_mcrr2(15, a, b, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
129 __builtin_arm_mcrr2(15, 0, b, a); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
131 __builtin_arm_mrrc(15, 0, 0);
132 __builtin_arm_mrrc( a, 0, 0); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
133 __builtin_arm_mrrc(15, a, 0); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
134 __builtin_arm_mrrc(15, 0, a); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
136 __builtin_arm_mrrc2(15, 0, 0);
137 __builtin_arm_mrrc2( a, 0, 0); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
138 __builtin_arm_mrrc2(15, a, 0); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
139 __builtin_arm_mrrc2(15, 0, a); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
142 void test_9_3_multiplications(int a, int b) {
143 int r;
144 r = __builtin_arm_smulbb(a, b);
145 r = __builtin_arm_smulbb(1, -9);
147 r = __builtin_arm_smulbt(a, b);
148 r = __builtin_arm_smulbt(0, b);
150 r = __builtin_arm_smultb(a, b);
151 r = __builtin_arm_smultb(5, b);
153 r = __builtin_arm_smultt(a, b);
154 r = __builtin_arm_smultt(a, -1);
156 r = __builtin_arm_smulwb(a, b);
157 r = __builtin_arm_smulwb(1, 2);
159 r = __builtin_arm_smulwt(a, b);
160 r = __builtin_arm_smulwt(-1, -2);
161 r = __builtin_arm_smulwt(-1.0f, -2);
164 void test_9_4_1_width_specified_saturation(int a, int b) {
165 unsigned u;
166 int s;
168 s = __builtin_arm_ssat(8, 2);
169 s = __builtin_arm_ssat(a, 1);
170 s = __builtin_arm_ssat(a, 32);
171 s = __builtin_arm_ssat(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
172 s = __builtin_arm_ssat(a, 33); // expected-error-re {{argument value {{.*}} is outside the valid range}}
173 s = __builtin_arm_ssat(a, b); // expected-error {{argument to '__builtin_arm_ssat' must be a constant integer}}
175 u = __builtin_arm_usat(8, 2);
176 u = __builtin_arm_usat(a, 0);
177 u = __builtin_arm_usat(a, 31);
178 u = __builtin_arm_usat(a, 32); // expected-error-re {{argument value {{.*}} is outside the valid range}}
179 u = __builtin_arm_usat(a, b); // expected-error {{argument to '__builtin_arm_usat' must be a constant integer}}
182 void test_9_4_2_saturating_addition_subtraction(int a, int b) {
183 int s;
184 s = __builtin_arm_qadd(a, b);
185 s = __builtin_arm_qadd(-1, 0);
187 s = __builtin_arm_qsub(a, b);
188 s = __builtin_arm_qsub(0, -1);
190 s = __builtin_arm_qdbl(a);
193 void test_9_4_3_accumulating_multiplications(int a, int b, int c) {
194 int s;
196 s = __builtin_arm_smlabb(a, b, c);
197 s = __builtin_arm_smlabb(1, b, c);
198 s = __builtin_arm_smlabb(a, 2, c);
199 s = __builtin_arm_smlabb(a, b, -3);
201 s = __builtin_arm_smlabt(a, b, c);
202 s = __builtin_arm_smlabt(1, b, c);
203 s = __builtin_arm_smlabt(a, 2, c);
204 s = __builtin_arm_smlabt(a, b, -3);
206 s = __builtin_arm_smlatb(a, b, c);
207 s = __builtin_arm_smlatt(1, b, c);
208 s = __builtin_arm_smlawb(a, 2, c);
209 s = __builtin_arm_smlawt(a, b, -3);
212 void test_9_5_4_parallel_16bit_saturation(int16x2_t a) {
213 unsigned u;
214 int s;
216 s = __builtin_arm_ssat16(a, 1);
217 s = __builtin_arm_ssat16(a, 16);
218 s = __builtin_arm_ssat16(a, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
219 s = __builtin_arm_ssat16(a, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
221 u = __builtin_arm_usat16(a, 0);
222 u = __builtin_arm_usat16(a, 15);
223 u = __builtin_arm_usat16(a, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
226 void test_9_5_5_packing_and_unpacking(int16x2_t a, int8x4_t b, uint16x2_t c, uint8x4_t d) {
227 int16x2_t x;
228 uint16x2_t y;
230 x = __builtin_arm_sxtab16(a, b);
231 x = __builtin_arm_sxtab16(1, -1);
232 x = __builtin_arm_sxtb16(b);
233 x = __builtin_arm_sxtb16(-b);
235 y = __builtin_arm_uxtab16(c, d);
236 y = __builtin_arm_uxtab16(-1, -2);
237 y = __builtin_arm_uxtb16(d);
238 y = __builtin_arm_uxtb16(-1);
241 uint8x4_t
242 test_9_5_6_parallel_selection(uint8x4_t a, uint8x4_t b) {
243 return __builtin_arm_sel(a, b);
246 void test_9_5_7_parallel_8bit_addition_substraction(int8x4_t a, int8x4_t b,
247 uint8x4_t c, uint8x4_t d) {
248 int8x4_t s;
249 uint8x4_t u;
251 s = __builtin_arm_qadd8(a, b);
252 s = __builtin_arm_qsub8(a, b);
253 s = __builtin_arm_sadd8(a, b);
254 s = __builtin_arm_shadd8(a, b);
255 s = __builtin_arm_shsub8(a, b);
256 s = __builtin_arm_ssub8(a, b);
258 u = __builtin_arm_uadd8(c, d);
259 u = __builtin_arm_uhadd8(c, d);
260 u = __builtin_arm_uhsub8(c, d);
261 u = __builtin_arm_uqadd8(c, d);
262 u = __builtin_arm_uqsub8(c, d);
263 u = __builtin_arm_usub8(c, d);
266 void test_9_5_8_absolute_differences(uint8x4_t a, uint8x4_t b, uint32_t c) {
267 uint32_t r;
269 r = __builtin_arm_usad8(a, b);
270 r = __builtin_arm_usada8(a, b, c);
273 void test_9_5_9_parallel_addition_and_subtraction(int16x2_t a, int16x2_t b,
274 uint16x2_t c, uint16x2_t d) {
275 int16x2_t x;
276 uint16x2_t y;
278 x = __builtin_arm_qadd16(a, b);
279 x = __builtin_arm_qasx(a, b);
280 x = __builtin_arm_qsax(a, b);
281 x = __builtin_arm_qsub16(a, b);
282 x = __builtin_arm_sadd16(a, b);
283 x = __builtin_arm_sasx(a, b);
284 x = __builtin_arm_shadd16(a, b);
285 x = __builtin_arm_shasx(a, b);
286 x = __builtin_arm_shsax(a, b);
287 x = __builtin_arm_shsub16(a, b);
288 x = __builtin_arm_ssax(a, b);
289 x = __builtin_arm_ssub16(a, b);
291 y = __builtin_arm_uadd16(c, d);
292 y = __builtin_arm_uasx(c, d);
293 y = __builtin_arm_uhadd16(c, d);
294 y = __builtin_arm_uhasx(c, d);
295 y = __builtin_arm_uhsax(c, d);
296 y = __builtin_arm_uhsub16(c, d);
297 y = __builtin_arm_uqadd16(c, d);
298 y = __builtin_arm_uqasx(c, d);
299 y = __builtin_arm_uqsax(c, d);
300 y = __builtin_arm_uqsub16(c, d);
301 y = __builtin_arm_usax(c, d);
302 y = __builtin_arm_usub16(c, d);
305 void test_9_5_10_parallel_16bit_multiplication(int16x2_t a, int16x2_t b,
306 int32_t c, int64_t d) {
307 int32_t x;
308 int64_t y;
310 x = __builtin_arm_smlad(a, b, c);
311 x = __builtin_arm_smladx(a, b, c);
312 y = __builtin_arm_smlald(a, b, d);
313 y = __builtin_arm_smlaldx(a, b, d);
314 x = __builtin_arm_smlsd(a, b, c);
315 x = __builtin_arm_smlsdx(a, b, c);
316 y = __builtin_arm_smlsld(a, b, d);
317 y = __builtin_arm_smlsldx(a, b, d);
318 x = __builtin_arm_smuad(a, b);
319 x = __builtin_arm_smuadx(a, b);
320 x = __builtin_arm_smusd(a, b);
321 x = __builtin_arm_smusdx(a, b);
324 void test_VFP(float f, double d) {
325 float fr;
326 double dr;
328 fr = __builtin_arm_vcvtr_f(f, 0);
329 fr = __builtin_arm_vcvtr_f(f, 1);
330 fr = __builtin_arm_vcvtr_f(f, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
331 fr = __builtin_arm_vcvtr_f(f, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
333 dr = __builtin_arm_vcvtr_f(d, 0);
334 dr = __builtin_arm_vcvtr_f(d, 1);
335 dr = __builtin_arm_vcvtr_f(d, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
336 dr = __builtin_arm_vcvtr_f(d, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}