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
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}}
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 }.
19 __builtin_va_list ptr
;
21 *(ptr
.__ap
) = '0'; /* expected-error {{incomplete type 'void' is not assignable}}
22 expected-warning {{ISO C does not allow indirection on operand of type 'void *'}} */
25 // va_list on ARM apcs-gnu is void*.
27 __builtin_va_list ptr
;
28 ptr
.__ap
= "x"; // expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
29 *(ptr
.__ap
) = '0';// expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
33 __builtin_va_list ptr
= "x";
34 *ptr
= '0'; /* expected-error {{incomplete type 'void' is not assignable}}
35 expected-warning {{ISO C does not allow indirection on operand of type '__builtin_va_list'}} */
41 __builtin_arm_dsb(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
42 __builtin_arm_dmb(17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
43 __builtin_arm_isb(18); // expected-error-re {{argument value {{.*}} is outside the valid range}}
47 __builtin_arm_prefetch(0, 2, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
48 __builtin_arm_prefetch(0, 0, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
52 __builtin_arm_dbg(16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
55 void test6(int a
, int b
, int c
) {
56 __builtin_arm_ldc(1, 2, &a
);
57 __builtin_arm_ldc(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
58 __builtin_arm_ldc(1, a
, &a
); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}}
60 __builtin_arm_ldcl(1, 2, &a
);
61 __builtin_arm_ldcl(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
62 __builtin_arm_ldcl(1, a
, &a
); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}}
64 __builtin_arm_ldc2(1, 2, &a
);
65 __builtin_arm_ldc2(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
66 __builtin_arm_ldc2(1, a
, &a
); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}}
68 __builtin_arm_ldc2l(1, 2, &a
);
69 __builtin_arm_ldc2l(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
70 __builtin_arm_ldc2l(1, a
, &a
); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}}
72 __builtin_arm_stc(1, 2, &a
);
73 __builtin_arm_stc(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
74 __builtin_arm_stc(1, a
, &a
); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}}
76 __builtin_arm_stcl(1, 2, &a
);
77 __builtin_arm_stcl(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
78 __builtin_arm_stcl(1, a
, &a
); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}}
80 __builtin_arm_stc2(1, 2, &a
);
81 __builtin_arm_stc2(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
82 __builtin_arm_stc2(1, a
, &a
); // expected-error {{argument to '__builtin_arm_stc2' must be a constant integer}}
84 __builtin_arm_stc2l(1, 2, &a
);
85 __builtin_arm_stc2l(a
, 2, &a
); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
86 __builtin_arm_stc2l(1, a
, &a
); // expected-error {{argument to '__builtin_arm_stc2l' must be a constant integer}}
88 __builtin_arm_cdp(a
, 2, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
89 __builtin_arm_cdp(1, a
, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
90 __builtin_arm_cdp(1, 2, a
, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
91 __builtin_arm_cdp(1, 2, 3, a
, 5, 6); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
92 __builtin_arm_cdp(1, 2, 3, 4, 5, a
); // expected-error {{argument to '__builtin_arm_cdp' must be a constant integer}}
94 __builtin_arm_cdp2(a
, 2, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
95 __builtin_arm_cdp2(1, a
, 3, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
96 __builtin_arm_cdp2(1, 2, a
, 4, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
97 __builtin_arm_cdp2(1, 2, 3, a
, 5, 6); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
98 __builtin_arm_cdp2(1, 2, 3, 4, 5, a
); // expected-error {{argument to '__builtin_arm_cdp2' must be a constant integer}}
100 __builtin_arm_mrc( a
, 0, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
101 __builtin_arm_mrc(15, a
, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
102 __builtin_arm_mrc(15, 0, a
, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
103 __builtin_arm_mrc(15, 0, 13, a
, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
104 __builtin_arm_mrc(15, 0, 13, 0, a
); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
106 __builtin_arm_mrc2( a
, 0, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
107 __builtin_arm_mrc2(15, a
, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
108 __builtin_arm_mrc2(15, 0, a
, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
109 __builtin_arm_mrc2(15, 0, 13, a
, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
110 __builtin_arm_mrc2(15, 0, 13, 0, a
); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
112 __builtin_arm_mcr( a
, 0, b
, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
113 __builtin_arm_mcr(15, a
, b
, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
114 __builtin_arm_mcr(15, 0, b
, a
, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
115 __builtin_arm_mcr(15, 0, b
, 13, a
, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
116 __builtin_arm_mcr(15, 0, b
, 13, 0, a
); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
118 __builtin_arm_mcr2( a
, 0, b
, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
119 __builtin_arm_mcr2(15, a
, b
, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
120 __builtin_arm_mcr2(15, 0, b
, a
, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
121 __builtin_arm_mcr2(15, 0, b
, 13, a
, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
122 __builtin_arm_mcr2(15, 0, b
, 13, 0, a
); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
124 __builtin_arm_mcrr(15, 0, b
, 0);
125 __builtin_arm_mcrr( a
, 0, b
, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
126 __builtin_arm_mcrr(15, a
, b
, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
127 __builtin_arm_mcrr(15, 0, b
, a
); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
129 __builtin_arm_mcrr2(15, 0, b
, 0);
130 __builtin_arm_mcrr2( a
, 0, b
, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
131 __builtin_arm_mcrr2(15, a
, b
, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
132 __builtin_arm_mcrr2(15, 0, b
, a
); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
134 __builtin_arm_mrrc(15, 0, 0);
135 __builtin_arm_mrrc( a
, 0, 0); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
136 __builtin_arm_mrrc(15, a
, 0); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
137 __builtin_arm_mrrc(15, 0, a
); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
139 __builtin_arm_mrrc2(15, 0, 0);
140 __builtin_arm_mrrc2( a
, 0, 0); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
141 __builtin_arm_mrrc2(15, a
, 0); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
142 __builtin_arm_mrrc2(15, 0, a
); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
145 void test_9_3_multiplications(int a
, int b
) {
147 r
= __builtin_arm_smulbb(a
, b
);
148 r
= __builtin_arm_smulbb(1, -9);
150 r
= __builtin_arm_smulbt(a
, b
);
151 r
= __builtin_arm_smulbt(0, b
);
153 r
= __builtin_arm_smultb(a
, b
);
154 r
= __builtin_arm_smultb(5, b
);
156 r
= __builtin_arm_smultt(a
, b
);
157 r
= __builtin_arm_smultt(a
, -1);
159 r
= __builtin_arm_smulwb(a
, b
);
160 r
= __builtin_arm_smulwb(1, 2);
162 r
= __builtin_arm_smulwt(a
, b
);
163 r
= __builtin_arm_smulwt(-1, -2);
164 r
= __builtin_arm_smulwt(-1.0f
, -2);
167 void test_9_4_1_width_specified_saturation(int a
, int b
) {
171 s
= __builtin_arm_ssat(8, 2);
172 s
= __builtin_arm_ssat(a
, 1);
173 s
= __builtin_arm_ssat(a
, 32);
174 s
= __builtin_arm_ssat(a
, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
175 s
= __builtin_arm_ssat(a
, 33); // expected-error-re {{argument value {{.*}} is outside the valid range}}
176 s
= __builtin_arm_ssat(a
, b
); // expected-error {{argument to '__builtin_arm_ssat' must be a constant integer}}
178 u
= __builtin_arm_usat(8, 2);
179 u
= __builtin_arm_usat(a
, 0);
180 u
= __builtin_arm_usat(a
, 31);
181 u
= __builtin_arm_usat(a
, 32); // expected-error-re {{argument value {{.*}} is outside the valid range}}
182 u
= __builtin_arm_usat(a
, b
); // expected-error {{argument to '__builtin_arm_usat' must be a constant integer}}
185 void test_9_4_2_saturating_addition_subtraction(int a
, int b
) {
187 s
= __builtin_arm_qadd(a
, b
);
188 s
= __builtin_arm_qadd(-1, 0);
190 s
= __builtin_arm_qsub(a
, b
);
191 s
= __builtin_arm_qsub(0, -1);
193 s
= __builtin_arm_qdbl(a
);
196 void test_9_4_3_accumulating_multiplications(int a
, int b
, int c
) {
199 s
= __builtin_arm_smlabb(a
, b
, c
);
200 s
= __builtin_arm_smlabb(1, b
, c
);
201 s
= __builtin_arm_smlabb(a
, 2, c
);
202 s
= __builtin_arm_smlabb(a
, b
, -3);
204 s
= __builtin_arm_smlabt(a
, b
, c
);
205 s
= __builtin_arm_smlabt(1, b
, c
);
206 s
= __builtin_arm_smlabt(a
, 2, c
);
207 s
= __builtin_arm_smlabt(a
, b
, -3);
209 s
= __builtin_arm_smlatb(a
, b
, c
);
210 s
= __builtin_arm_smlatt(1, b
, c
);
211 s
= __builtin_arm_smlawb(a
, 2, c
);
212 s
= __builtin_arm_smlawt(a
, b
, -3);
215 void test_9_5_4_parallel_16bit_saturation(int16x2_t a
) {
219 s
= __builtin_arm_ssat16(a
, 1);
220 s
= __builtin_arm_ssat16(a
, 16);
221 s
= __builtin_arm_ssat16(a
, 0); // expected-error-re {{argument value {{.*}} is outside the valid range}}
222 s
= __builtin_arm_ssat16(a
, 17); // expected-error-re {{argument value {{.*}} is outside the valid range}}
224 u
= __builtin_arm_usat16(a
, 0);
225 u
= __builtin_arm_usat16(a
, 15);
226 u
= __builtin_arm_usat16(a
, 16); // expected-error-re {{argument value {{.*}} is outside the valid range}}
229 void test_9_5_5_packing_and_unpacking(int16x2_t a
, int8x4_t b
, uint16x2_t c
, uint8x4_t d
) {
233 x
= __builtin_arm_sxtab16(a
, b
);
234 x
= __builtin_arm_sxtab16(1, -1);
235 x
= __builtin_arm_sxtb16(b
);
236 x
= __builtin_arm_sxtb16(-b
);
238 y
= __builtin_arm_uxtab16(c
, d
);
239 y
= __builtin_arm_uxtab16(-1, -2);
240 y
= __builtin_arm_uxtb16(d
);
241 y
= __builtin_arm_uxtb16(-1);
245 test_9_5_6_parallel_selection(uint8x4_t a
, uint8x4_t b
) {
246 return __builtin_arm_sel(a
, b
);
249 void test_9_5_7_parallel_8bit_addition_substraction(int8x4_t a
, int8x4_t b
,
250 uint8x4_t c
, uint8x4_t d
) {
254 s
= __builtin_arm_qadd8(a
, b
);
255 s
= __builtin_arm_qsub8(a
, b
);
256 s
= __builtin_arm_sadd8(a
, b
);
257 s
= __builtin_arm_shadd8(a
, b
);
258 s
= __builtin_arm_shsub8(a
, b
);
259 s
= __builtin_arm_ssub8(a
, b
);
261 u
= __builtin_arm_uadd8(c
, d
);
262 u
= __builtin_arm_uhadd8(c
, d
);
263 u
= __builtin_arm_uhsub8(c
, d
);
264 u
= __builtin_arm_uqadd8(c
, d
);
265 u
= __builtin_arm_uqsub8(c
, d
);
266 u
= __builtin_arm_usub8(c
, d
);
269 void test_9_5_8_absolute_differences(uint8x4_t a
, uint8x4_t b
, uint32_t c
) {
272 r
= __builtin_arm_usad8(a
, b
);
273 r
= __builtin_arm_usada8(a
, b
, c
);
276 void test_9_5_9_parallel_addition_and_subtraction(int16x2_t a
, int16x2_t b
,
277 uint16x2_t c
, uint16x2_t d
) {
281 x
= __builtin_arm_qadd16(a
, b
);
282 x
= __builtin_arm_qasx(a
, b
);
283 x
= __builtin_arm_qsax(a
, b
);
284 x
= __builtin_arm_qsub16(a
, b
);
285 x
= __builtin_arm_sadd16(a
, b
);
286 x
= __builtin_arm_sasx(a
, b
);
287 x
= __builtin_arm_shadd16(a
, b
);
288 x
= __builtin_arm_shasx(a
, b
);
289 x
= __builtin_arm_shsax(a
, b
);
290 x
= __builtin_arm_shsub16(a
, b
);
291 x
= __builtin_arm_ssax(a
, b
);
292 x
= __builtin_arm_ssub16(a
, b
);
294 y
= __builtin_arm_uadd16(c
, d
);
295 y
= __builtin_arm_uasx(c
, d
);
296 y
= __builtin_arm_uhadd16(c
, d
);
297 y
= __builtin_arm_uhasx(c
, d
);
298 y
= __builtin_arm_uhsax(c
, d
);
299 y
= __builtin_arm_uhsub16(c
, d
);
300 y
= __builtin_arm_uqadd16(c
, d
);
301 y
= __builtin_arm_uqasx(c
, d
);
302 y
= __builtin_arm_uqsax(c
, d
);
303 y
= __builtin_arm_uqsub16(c
, d
);
304 y
= __builtin_arm_usax(c
, d
);
305 y
= __builtin_arm_usub16(c
, d
);
308 void test_9_5_10_parallel_16bit_multiplication(int16x2_t a
, int16x2_t b
,
309 int32_t c
, int64_t d
) {
313 x
= __builtin_arm_smlad(a
, b
, c
);
314 x
= __builtin_arm_smladx(a
, b
, c
);
315 y
= __builtin_arm_smlald(a
, b
, d
);
316 y
= __builtin_arm_smlaldx(a
, b
, d
);
317 x
= __builtin_arm_smlsd(a
, b
, c
);
318 x
= __builtin_arm_smlsdx(a
, b
, c
);
319 y
= __builtin_arm_smlsld(a
, b
, d
);
320 y
= __builtin_arm_smlsldx(a
, b
, d
);
321 x
= __builtin_arm_smuad(a
, b
);
322 x
= __builtin_arm_smuadx(a
, b
);
323 x
= __builtin_arm_smusd(a
, b
);
324 x
= __builtin_arm_smusdx(a
, b
);
327 void test_VFP(float f
, double d
) {
331 fr
= __builtin_arm_vcvtr_f(f
, 0);
332 fr
= __builtin_arm_vcvtr_f(f
, 1);
333 fr
= __builtin_arm_vcvtr_f(f
, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
334 fr
= __builtin_arm_vcvtr_f(f
, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
336 dr
= __builtin_arm_vcvtr_f(d
, 0);
337 dr
= __builtin_arm_vcvtr_f(d
, 1);
338 dr
= __builtin_arm_vcvtr_f(d
, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
339 dr
= __builtin_arm_vcvtr_f(d
, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}