1 // This program is designed to test some arm64-specific things, such as the
2 // calling convention, but should give the same results on any architecture.
8 struct s1
{ char x
[1]; } s1
= { "0" };
9 struct s2
{ char x
[2]; } s2
= { "12" };
10 struct s3
{ char x
[3]; } s3
= { "345" };
11 struct s4
{ char x
[4]; } s4
= { "6789" };
12 struct s5
{ char x
[5]; } s5
= { "abcde" };
13 struct s6
{ char x
[6]; } s6
= { "fghijk" };
14 struct s7
{ char x
[7]; } s7
= { "lmnopqr" };
15 struct s8
{ char x
[8]; } s8
= { "stuvwxyz" };
16 struct s9
{ char x
[9]; } s9
= { "ABCDEFGHI" };
17 struct s10
{ char x
[10]; } s10
= { "JKLMNOPQRS" };
18 struct s11
{ char x
[11]; } s11
= { "TUVWXYZ0123" };
19 struct s12
{ char x
[12]; } s12
= { "456789abcdef" };
20 struct s13
{ char x
[13]; } s13
= { "ghijklmnopqrs" };
21 struct s14
{ char x
[14]; } s14
= { "tuvwxyzABCDEFG" };
22 struct s15
{ char x
[15]; } s15
= { "HIJKLMNOPQRSTUV" };
23 struct s16
{ char x
[16]; } s16
= { "WXYZ0123456789ab" };
24 struct s17
{ char x
[17]; } s17
= { "cdefghijklmnopqrs" };
26 struct hfa11
{ float a
; } hfa11
= { 11.1 };
27 struct hfa12
{ float a
, b
; } hfa12
= { 12.1, 12.2 };
28 struct hfa13
{ float a
, b
, c
; } hfa13
= { 13.1, 13.2, 13.3 };
29 struct hfa14
{ float a
, b
, c
, d
; } hfa14
= { 14.1, 14.2, 14.3, 14.4 };
31 struct hfa21
{ double a
; } hfa21
= { 21.1 };
32 struct hfa22
{ double a
, b
; } hfa22
= { 22.1, 22.2 };
33 struct hfa23
{ double a
, b
, c
; } hfa23
= { 23.1, 23.2, 23.3 };
34 struct hfa24
{ double a
, b
, c
, d
; } hfa24
= { 24.1, 24.2, 24.3, 24.4 };
36 struct hfa31
{ long double a
; } hfa31
= { 31.1 };
37 struct hfa32
{ long double a
, b
; } hfa32
= { 32.1, 32.2 };
38 struct hfa33
{ long double a
, b
, c
; } hfa33
= { 33.1, 33.2, 33.3 };
39 struct hfa34
{ long double a
, b
, c
, d
; } hfa34
= { 34.1, 34.2, 34.3, 34.4 };
41 void fa_s1(struct s1 a
) { printf("%.1s\n", a
.x
); }
42 void fa_s2(struct s2 a
) { printf("%.2s\n", a
.x
); }
43 void fa_s3(struct s3 a
) { printf("%.3s\n", a
.x
); }
44 void fa_s4(struct s4 a
) { printf("%.4s\n", a
.x
); }
45 void fa_s5(struct s5 a
) { printf("%.5s\n", a
.x
); }
46 void fa_s6(struct s6 a
) { printf("%.6s\n", a
.x
); }
47 void fa_s7(struct s7 a
) { printf("%.7s\n", a
.x
); }
48 void fa_s8(struct s8 a
) { printf("%.8s\n", a
.x
); }
49 void fa_s9(struct s9 a
) { printf("%.9s\n", a
.x
); }
50 void fa_s10(struct s10 a
) { printf("%.10s\n", a
.x
); }
51 void fa_s11(struct s11 a
) { printf("%.11s\n", a
.x
); }
52 void fa_s12(struct s12 a
) { printf("%.12s\n", a
.x
); }
53 void fa_s13(struct s13 a
) { printf("%.13s\n", a
.x
); }
54 void fa_s14(struct s14 a
) { printf("%.14s\n", a
.x
); }
55 void fa_s15(struct s15 a
) { printf("%.15s\n", a
.x
); }
56 void fa_s16(struct s16 a
) { printf("%.16s\n", a
.x
); }
57 void fa_s17(struct s17 a
) { printf("%.17s\n", a
.x
); }
59 void fa_hfa11(struct hfa11 a
)
60 { printf("%.1f\n", a
.a
); }
61 void fa_hfa12(struct hfa12 a
)
62 { printf("%.1f %.1f\n", a
.a
, a
.a
); }
63 void fa_hfa13(struct hfa13 a
)
64 { printf("%.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
); }
65 void fa_hfa14(struct hfa14 a
)
66 { printf("%.1f %.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
, a
.d
); }
68 void fa_hfa21(struct hfa21 a
)
69 { printf("%.1f\n", a
.a
); }
70 void fa_hfa22(struct hfa22 a
)
71 { printf("%.1f %.1f\n", a
.a
, a
.a
); }
72 void fa_hfa23(struct hfa23 a
)
73 { printf("%.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
); }
74 void fa_hfa24(struct hfa24 a
)
75 { printf("%.1f %.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
, a
.d
); }
77 void fa_hfa31(struct hfa31 a
)
78 { printf("%.1Lf\n", a
.a
); }
79 void fa_hfa32(struct hfa32 a
)
80 { printf("%.1Lf %.1Lf\n", a
.a
, a
.a
); }
81 void fa_hfa33(struct hfa33 a
)
82 { printf("%.1Lf %.1Lf %.1Lf\n", a
.a
, a
.b
, a
.c
); }
83 void fa_hfa34(struct hfa34 a
)
84 { printf("%.1Lf %.1Lf %.1Lf %.1Lf\n", a
.a
, a
.b
, a
.c
, a
.d
); }
86 void fa1(struct s8 a
, struct s9 b
, struct s10 c
, struct s11 d
,
87 struct s12 e
, struct s13 f
)
89 printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a
.x
, b
.x
, c
.x
, d
.x
, e
.x
, f
.x
);
92 void fa2(struct s9 a
, struct s10 b
, struct s11 c
, struct s12 d
,
93 struct s13 e
, struct s14 f
)
95 printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a
.x
, b
.x
, c
.x
, d
.x
, e
.x
, f
.x
);
98 void fa3(struct hfa14 a
, struct hfa23 b
, struct hfa32 c
)
100 printf("%.1f %.1f %.1f %.1f %.1Lf %.1Lf\n",
101 a
.a
, a
.d
, b
.a
, b
.c
, c
.a
, c
.b
);
104 void fa4(struct s1 a
, struct hfa14 b
, struct s2 c
, struct hfa24 d
,
105 struct s3 e
, struct hfa34 f
)
107 printf("%.1s %.1f %.1f %.2s %.1f %.1f %.3s %.1Lf %.1Lf\n",
108 a
.x
, b
.a
, b
.d
, c
.x
, d
.a
, d
.d
, e
.x
, f
.a
, f
.d
);
113 printf("Arguments:\n");
143 fa1(s8
, s9
, s10
, s11
, s12
, s13
);
144 fa2(s9
, s10
, s11
, s12
, s13
, s14
);
145 fa3(hfa14
, hfa23
, hfa32
);
146 fa4(s1
, hfa14
, s2
, hfa24
, s3
, hfa34
);
149 struct s1
fr_s1(void) { return s1
; }
150 struct s2
fr_s2(void) { return s2
; }
151 struct s3
fr_s3(void) { return s3
; }
152 struct s4
fr_s4(void) { return s4
; }
153 struct s5
fr_s5(void) { return s5
; }
154 struct s6
fr_s6(void) { return s6
; }
155 struct s7
fr_s7(void) { return s7
; }
156 struct s8
fr_s8(void) { return s8
; }
157 struct s9
fr_s9(void) { return s9
; }
158 struct s10
fr_s10(void) { return s10
; }
159 struct s11
fr_s11(void) { return s11
; }
160 struct s12
fr_s12(void) { return s12
; }
161 struct s13
fr_s13(void) { return s13
; }
162 struct s14
fr_s14(void) { return s14
; }
163 struct s15
fr_s15(void) { return s15
; }
164 struct s16
fr_s16(void) { return s16
; }
165 struct s17
fr_s17(void) { return s17
; }
167 struct hfa11
fr_hfa11(void) { return hfa11
; }
168 struct hfa12
fr_hfa12(void) { return hfa12
; }
169 struct hfa13
fr_hfa13(void) { return hfa13
; }
170 struct hfa14
fr_hfa14(void) { return hfa14
; }
172 struct hfa21
fr_hfa21(void) { return hfa21
; }
173 struct hfa22
fr_hfa22(void) { return hfa22
; }
174 struct hfa23
fr_hfa23(void) { return hfa23
; }
175 struct hfa24
fr_hfa24(void) { return hfa24
; }
177 struct hfa31
fr_hfa31(void) { return hfa31
; }
178 struct hfa32
fr_hfa32(void) { return hfa32
; }
179 struct hfa33
fr_hfa33(void) { return hfa33
; }
180 struct hfa34
fr_hfa34(void) { return hfa34
; }
184 struct s1 t1
= fr_s1();
185 struct s2 t2
= fr_s2();
186 struct s3 t3
= fr_s3();
187 struct s4 t4
= fr_s4();
188 struct s5 t5
= fr_s5();
189 struct s6 t6
= fr_s6();
190 struct s7 t7
= fr_s7();
191 struct s8 t8
= fr_s8();
192 struct s9 t9
= fr_s9();
193 struct s10 t10
= fr_s10();
194 struct s11 t11
= fr_s11();
195 struct s12 t12
= fr_s12();
196 struct s13 t13
= fr_s13();
197 struct s14 t14
= fr_s14();
198 struct s15 t15
= fr_s15();
199 struct s16 t16
= fr_s16();
200 struct s17 t17
= fr_s17();
201 printf("Return values:\n");
202 printf("%.1s\n", t1
.x
);
203 printf("%.2s\n", t2
.x
);
204 printf("%.3s\n", t3
.x
);
205 printf("%.4s\n", t4
.x
);
206 printf("%.5s\n", t5
.x
);
207 printf("%.6s\n", t6
.x
);
208 printf("%.7s\n", t7
.x
);
209 printf("%.8s\n", t8
.x
);
210 printf("%.9s\n", t9
.x
);
211 printf("%.10s\n", t10
.x
);
212 printf("%.11s\n", t11
.x
);
213 printf("%.12s\n", t12
.x
);
214 printf("%.13s\n", t13
.x
);
215 printf("%.14s\n", t14
.x
);
216 printf("%.15s\n", t15
.x
);
217 printf("%.16s\n", t16
.x
);
218 printf("%.17s\n", t17
.x
);
219 printf("%.1f\n", fr_hfa11().a
);
220 printf("%.1f %.1f\n", fr_hfa12().a
, fr_hfa12().b
);
221 printf("%.1f %.1f\n", fr_hfa13().a
, fr_hfa13().c
);
222 printf("%.1f %.1f\n", fr_hfa14().a
, fr_hfa14().d
);
223 printf("%.1f\n", fr_hfa21().a
);
224 printf("%.1f %.1f\n", fr_hfa22().a
, fr_hfa22().b
);
225 printf("%.1f %.1f\n", fr_hfa23().a
, fr_hfa23().c
);
226 printf("%.1f %.1f\n", fr_hfa24().a
, fr_hfa24().d
);
227 printf("%.1Lf\n", fr_hfa31().a
);
228 printf("%.1Lf %.1Lf\n", fr_hfa32().a
, fr_hfa32().b
);
229 printf("%.1Lf %.1Lf\n", fr_hfa33().a
, fr_hfa33().c
);
230 printf("%.1Lf %.1Lf\n", fr_hfa34().a
, fr_hfa34().d
);
234 va_arg_with_struct_ptr(va_list ap
) {
236 * This was a BUG identified with FFTW-3.3.8 on arm64.
237 * The test case only checks it compiles.
239 struct X
{ int _x
; };
240 struct X
*x
= va_arg(ap
, struct X
*);
244 int match(const char **s
, const char *f
)
247 for (p
= *s
; *f
&& *f
== *p
; f
++, p
++)
256 void myprintf(const char *format
, ...)
260 va_start(ap
, format
);
261 for (s
= format
; *s
; s
++) {
262 if (match(&s
, "%7s")) {
263 struct s7 t7
= va_arg(ap
, struct s7
);
264 printf("%.7s", t7
.x
);
266 else if (match(&s
, "%9s")) {
267 struct s9 t9
= va_arg(ap
, struct s9
);
268 printf("%.9s", t9
.x
);
270 else if (match(&s
, "%hfa11")) {
271 struct hfa11 x
= va_arg(ap
, struct hfa11
);
272 printf("%.1f,%.1f", x
.a
, x
.a
);
274 else if (match(&s
, "%hfa12")) {
275 struct hfa12 x
= va_arg(ap
, struct hfa12
);
276 printf("%.1f,%.1f", x
.a
, x
.b
);
278 else if (match(&s
, "%hfa13")) {
279 struct hfa13 x
= va_arg(ap
, struct hfa13
);
280 printf("%.1f,%.1f", x
.a
, x
.c
);
282 else if (match(&s
, "%hfa14")) {
283 struct hfa14 x
= va_arg(ap
, struct hfa14
);
284 printf("%.1f,%.1f", x
.a
, x
.d
);
286 else if (match(&s
, "%hfa21")) {
287 struct hfa21 x
= va_arg(ap
, struct hfa21
);
288 printf("%.1f,%.1f", x
.a
, x
.a
);
290 else if (match(&s
, "%hfa22")) {
291 struct hfa22 x
= va_arg(ap
, struct hfa22
);
292 printf("%.1f,%.1f", x
.a
, x
.b
);
294 else if (match(&s
, "%hfa23")) {
295 struct hfa23 x
= va_arg(ap
, struct hfa23
);
296 printf("%.1f,%.1f", x
.a
, x
.c
);
298 else if (match(&s
, "%hfa24")) {
299 struct hfa24 x
= va_arg(ap
, struct hfa24
);
300 printf("%.1f,%.1f", x
.a
, x
.d
);
302 else if (match(&s
, "%hfa31")) {
303 struct hfa31 x
= va_arg(ap
, struct hfa31
);
304 printf("%.1Lf,%.1Lf", x
.a
, x
.a
);
306 else if (match(&s
, "%hfa32")) {
307 struct hfa32 x
= va_arg(ap
, struct hfa32
);
308 printf("%.1Lf,%.1Lf", x
.a
, x
.b
);
310 else if (match(&s
, "%hfa33")) {
311 struct hfa33 x
= va_arg(ap
, struct hfa33
);
312 printf("%.1Lf,%.1Lf", x
.a
, x
.c
);
314 else if (match(&s
, "%hfa34")) {
315 struct hfa34 x
= va_arg(ap
, struct hfa34
);
316 printf("%.1Lf,%.1Lf", x
.a
, x
.d
);
327 myprintf("%9s %9s %9s %9s %9s %9s", s9
, s9
, s9
, s9
, s9
, s9
);
328 myprintf("%7s %9s %9s %9s %9s %9s", s7
, s9
, s9
, s9
, s9
, s9
);
330 myprintf("HFA long double:");
331 myprintf("%hfa34 %hfa34 %hfa34 %hfa34", hfa34
, hfa34
, hfa34
, hfa34
);
332 myprintf("%hfa33 %hfa34 %hfa34 %hfa34", hfa33
, hfa34
, hfa34
, hfa34
);
333 myprintf("%hfa32 %hfa34 %hfa34 %hfa34", hfa32
, hfa34
, hfa34
, hfa34
);
334 myprintf("%hfa31 %hfa34 %hfa34 %hfa34", hfa31
, hfa34
, hfa34
, hfa34
);
336 myprintf("%hfa32 %hfa33 %hfa33 %hfa33 %hfa33",
337 hfa32
, hfa33
, hfa33
, hfa33
, hfa33
);
338 myprintf("%hfa31 %hfa33 %hfa33 %hfa33 %hfa33",
339 hfa31
, hfa33
, hfa33
, hfa33
, hfa33
);
340 myprintf("%hfa33 %hfa33 %hfa33 %hfa33",
341 hfa33
, hfa33
, hfa33
, hfa33
);
343 myprintf("%hfa34 %hfa32 %hfa32 %hfa32 %hfa32",
344 hfa34
, hfa32
, hfa32
, hfa32
, hfa32
);
345 myprintf("%hfa33 %hfa32 %hfa32 %hfa32 %hfa32",
346 hfa33
, hfa32
, hfa32
, hfa32
, hfa32
);
348 myprintf("%hfa34 %hfa32 %hfa31 %hfa31 %hfa31 %hfa31",
349 hfa34
, hfa32
, hfa31
, hfa31
, hfa31
, hfa31
);
351 myprintf("HFA double:");
352 myprintf("%hfa24 %hfa24 %hfa24 %hfa24", hfa24
, hfa24
, hfa24
, hfa24
);
353 myprintf("%hfa23 %hfa24 %hfa24 %hfa24", hfa23
, hfa24
, hfa24
, hfa24
);
354 myprintf("%hfa22 %hfa24 %hfa24 %hfa24", hfa22
, hfa24
, hfa24
, hfa24
);
355 myprintf("%hfa21 %hfa24 %hfa24 %hfa24", hfa21
, hfa24
, hfa24
, hfa24
);
357 myprintf("%hfa22 %hfa23 %hfa23 %hfa23 %hfa23",
358 hfa22
, hfa23
, hfa23
, hfa23
, hfa23
);
359 myprintf("%hfa21 %hfa23 %hfa23 %hfa23 %hfa23",
360 hfa21
, hfa23
, hfa23
, hfa23
, hfa23
);
361 myprintf("%hfa23 %hfa23 %hfa23 %hfa23",
362 hfa23
, hfa23
, hfa23
, hfa23
);
364 myprintf("%hfa24 %hfa22 %hfa22 %hfa22 %hfa22",
365 hfa24
, hfa22
, hfa22
, hfa22
, hfa22
);
366 myprintf("%hfa23 %hfa22 %hfa22 %hfa22 %hfa22",
367 hfa23
, hfa22
, hfa22
, hfa22
, hfa22
);
369 myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21",
370 hfa24
, hfa22
, hfa21
, hfa21
, hfa21
, hfa21
);
372 myprintf("HFA float:");
373 myprintf("%hfa14 %hfa14 %hfa14 %hfa14", hfa14
, hfa14
, hfa14
, hfa14
);
374 myprintf("%hfa13 %hfa14 %hfa14 %hfa14", hfa13
, hfa14
, hfa14
, hfa14
);
375 myprintf("%hfa12 %hfa14 %hfa14 %hfa14", hfa12
, hfa14
, hfa14
, hfa14
);
376 myprintf("%hfa11 %hfa14 %hfa14 %hfa14", hfa11
, hfa14
, hfa14
, hfa14
);
378 myprintf("%hfa12 %hfa13 %hfa13 %hfa13 %hfa13",
379 hfa12
, hfa13
, hfa13
, hfa13
, hfa13
);
380 myprintf("%hfa11 %hfa13 %hfa13 %hfa13 %hfa13",
381 hfa11
, hfa13
, hfa13
, hfa13
, hfa13
);
382 myprintf("%hfa13 %hfa13 %hfa13 %hfa13",
383 hfa13
, hfa13
, hfa13
, hfa13
);
385 myprintf("%hfa14 %hfa12 %hfa12 %hfa12 %hfa12",
386 hfa14
, hfa12
, hfa12
, hfa12
, hfa12
);
387 myprintf("%hfa13 %hfa12 %hfa12 %hfa12 %hfa12",
388 hfa13
, hfa12
, hfa12
, hfa12
, hfa12
);
390 myprintf("%hfa14 %hfa12 %hfa11 %hfa11 %hfa11 %hfa11",
391 hfa14
, hfa12
, hfa11
, hfa11
, hfa11
, hfa11
);
394 void pll(unsigned long long x
)
406 pll(0xabcd000000000000);
409 pll(0xffffffffffffabcd);
410 pll(0xffffffffabcdffff);
411 pll(0xffffabcdffffffff);
412 pll(0xabcdffffffffffff);
414 pll(0x5555555555555555);
416 pll(0x3333333333333333);
418 pll(0x1e1e1e1e1e1e1e1e);
420 pll(0x01ff01ff01ff01ff);
422 pll(0x03fff80003fff800);
423 pll(0x0007fffffffffe00);
427 pll(0xabcd000000001234);
429 pll(0xabcd000012340000);
430 pll(0xabcd123400000000);
431 pll(0xffffffffabcd1234);
432 pll(0xffffabcdffff1234);
433 pll(0xabcdffffffff1234);
434 pll(0xffffabcd1234ffff);
435 pll(0xabcdffff1234ffff);
436 pll(0xabcd1234ffffffff);
438 pll(0xffffef0123456789);
439 pll(0xabcdef012345ffff);
441 pll(0xabcdef0123456789);
444 static uint32_t addip0(uint32_t x
) { return x
+ 0; }
445 static uint64_t sublp0(uint64_t x
) { return x
- 0; }
446 static uint32_t addip123(uint32_t x
) { return x
+ 123; }
447 static uint64_t addlm123(uint64_t x
) { return x
+ -123; }
448 static uint64_t sublp4095(uint64_t x
) { return x
- 4095; }
449 static uint32_t subim503808(uint32_t x
) { return x
- -503808; }
450 static uint64_t addp12345(uint64_t x
) { return x
+ 12345; }
451 static uint32_t subp12345(uint32_t x
) { return x
- 12345; }
453 static uint32_t mvni(uint32_t x
) { return 0xffffffff - x
; }
454 static uint64_t negl(uint64_t x
) { return 0 - x
; }
455 static uint32_t rsbi123(uint32_t x
) { return 123 - x
; }
456 static uint64_t rsbl123(uint64_t x
) { return 123 - x
; }
458 static uint32_t andi0(uint32_t x
) { return x
& 0; }
459 static uint64_t andlm1(uint64_t x
) { return x
& -1; }
460 static uint64_t orrl0(uint64_t x
) { return x
| 0; }
461 static uint32_t orrim1(uint32_t x
) { return x
| -1; }
462 static uint32_t eori0(uint32_t x
) { return x
^ 0; }
463 static uint64_t eorlm1(uint64_t x
) { return x
^ -1; }
464 static uint32_t and0xf0(uint32_t x
) { return x
& 0xf0; }
465 static uint64_t orr0xf0(uint64_t x
) { return x
| 0xf0; }
466 static uint64_t eor0xf0(uint64_t x
) { return x
^ 0xf0; }
468 static uint32_t lsli0(uint32_t x
) { return x
<< 0; }
469 static uint32_t lsri0(uint32_t x
) { return x
>> 0; }
470 static int64_t asrl0(int64_t x
) { return x
>> 0; }
471 static uint32_t lsli1(uint32_t x
) { return x
<< 1; }
472 static uint32_t lsli31(uint32_t x
) { return x
<< 31; }
473 static uint64_t lsll1(uint64_t x
) { return x
<< 1; }
474 static uint64_t lsll63(uint64_t x
) { return x
<< 63; }
475 static uint32_t lsri1(uint32_t x
) { return x
>> 1; }
476 static uint32_t lsri31(uint32_t x
) { return x
>> 31; }
477 static uint64_t lsrl1(uint64_t x
) { return x
>> 1; }
478 static uint64_t lsrl63(uint64_t x
) { return x
>> 63; }
479 static int32_t asri1(int32_t x
) { return x
>> 1; }
480 static int32_t asri31(int32_t x
) { return x
>> 31; }
481 static int64_t asrl1(int64_t x
) { return x
>> 1; }
482 static int64_t asrl63(int64_t x
) { return x
>> 63; }