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.
7 struct s1
{ char x
[1]; } s1
= { "0" };
8 struct s2
{ char x
[2]; } s2
= { "12" };
9 struct s3
{ char x
[3]; } s3
= { "345" };
10 struct s4
{ char x
[4]; } s4
= { "6789" };
11 struct s5
{ char x
[5]; } s5
= { "abcde" };
12 struct s6
{ char x
[6]; } s6
= { "fghijk" };
13 struct s7
{ char x
[7]; } s7
= { "lmnopqr" };
14 struct s8
{ char x
[8]; } s8
= { "stuvwxyz" };
15 struct s9
{ char x
[9]; } s9
= { "ABCDEFGHI" };
16 struct s10
{ char x
[10]; } s10
= { "JKLMNOPQRS" };
17 struct s11
{ char x
[11]; } s11
= { "TUVWXYZ0123" };
18 struct s12
{ char x
[12]; } s12
= { "456789abcdef" };
19 struct s13
{ char x
[13]; } s13
= { "ghijklmnopqrs" };
20 struct s14
{ char x
[14]; } s14
= { "tuvwxyzABCDEFG" };
21 struct s15
{ char x
[15]; } s15
= { "HIJKLMNOPQRSTUV" };
22 struct s16
{ char x
[16]; } s16
= { "WXYZ0123456789ab" };
23 struct s17
{ char x
[17]; } s17
= { "cdefghijklmnopqrs" };
25 struct hfa11
{ float a
; } hfa11
= { 11.1 };
26 struct hfa12
{ float a
, b
; } hfa12
= { 12.1, 12.2 };
27 struct hfa13
{ float a
, b
, c
; } hfa13
= { 13.1, 13.2, 13.3 };
28 struct hfa14
{ float a
, b
, c
, d
; } hfa14
= { 14.1, 14.2, 14.3, 14.4 };
30 struct hfa21
{ double a
; } hfa21
= { 21.1 };
31 struct hfa22
{ double a
, b
; } hfa22
= { 22.1, 22.2 };
32 struct hfa23
{ double a
, b
, c
; } hfa23
= { 23.1, 23.2, 23.3 };
33 struct hfa24
{ double a
, b
, c
, d
; } hfa24
= { 24.1, 24.2, 24.3, 24.4 };
35 struct hfa31
{ long double a
; } hfa31
= { 31.1 };
36 struct hfa32
{ long double a
, b
; } hfa32
= { 32.1, 32.2 };
37 struct hfa33
{ long double a
, b
, c
; } hfa33
= { 33.1, 33.2, 33.3 };
38 struct hfa34
{ long double a
, b
, c
, d
; } hfa34
= { 34.1, 34.2, 34.3, 34.4 };
40 void fa_s1(struct s1 a
) { printf("%.1s\n", a
.x
); }
41 void fa_s2(struct s2 a
) { printf("%.2s\n", a
.x
); }
42 void fa_s3(struct s3 a
) { printf("%.3s\n", a
.x
); }
43 void fa_s4(struct s4 a
) { printf("%.4s\n", a
.x
); }
44 void fa_s5(struct s5 a
) { printf("%.5s\n", a
.x
); }
45 void fa_s6(struct s6 a
) { printf("%.6s\n", a
.x
); }
46 void fa_s7(struct s7 a
) { printf("%.7s\n", a
.x
); }
47 void fa_s8(struct s8 a
) { printf("%.8s\n", a
.x
); }
48 void fa_s9(struct s9 a
) { printf("%.9s\n", a
.x
); }
49 void fa_s10(struct s10 a
) { printf("%.10s\n", a
.x
); }
50 void fa_s11(struct s11 a
) { printf("%.11s\n", a
.x
); }
51 void fa_s12(struct s12 a
) { printf("%.12s\n", a
.x
); }
52 void fa_s13(struct s13 a
) { printf("%.13s\n", a
.x
); }
53 void fa_s14(struct s14 a
) { printf("%.14s\n", a
.x
); }
54 void fa_s15(struct s15 a
) { printf("%.15s\n", a
.x
); }
55 void fa_s16(struct s16 a
) { printf("%.16s\n", a
.x
); }
56 void fa_s17(struct s17 a
) { printf("%.17s\n", a
.x
); }
58 void fa_hfa11(struct hfa11 a
)
59 { printf("%.1f\n", a
.a
); }
60 void fa_hfa12(struct hfa12 a
)
61 { printf("%.1f %.1f\n", a
.a
, a
.a
); }
62 void fa_hfa13(struct hfa13 a
)
63 { printf("%.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
); }
64 void fa_hfa14(struct hfa14 a
)
65 { printf("%.1f %.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
, a
.d
); }
67 void fa_hfa21(struct hfa21 a
)
68 { printf("%.1f\n", a
.a
); }
69 void fa_hfa22(struct hfa22 a
)
70 { printf("%.1f %.1f\n", a
.a
, a
.a
); }
71 void fa_hfa23(struct hfa23 a
)
72 { printf("%.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
); }
73 void fa_hfa24(struct hfa24 a
)
74 { printf("%.1f %.1f %.1f %.1f\n", a
.a
, a
.b
, a
.c
, a
.d
); }
76 void fa_hfa31(struct hfa31 a
)
77 { printf("%.1Lf\n", a
.a
); }
78 void fa_hfa32(struct hfa32 a
)
79 { printf("%.1Lf %.1Lf\n", a
.a
, a
.a
); }
80 void fa_hfa33(struct hfa33 a
)
81 { printf("%.1Lf %.1Lf %.1Lf\n", a
.a
, a
.b
, a
.c
); }
82 void fa_hfa34(struct hfa34 a
)
83 { printf("%.1Lf %.1Lf %.1Lf %.1Lf\n", a
.a
, a
.b
, a
.c
, a
.d
); }
85 void fa1(struct s8 a
, struct s9 b
, struct s10 c
, struct s11 d
,
86 struct s12 e
, struct s13 f
)
88 printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a
.x
, b
.x
, c
.x
, d
.x
, e
.x
, f
.x
);
91 void fa2(struct s9 a
, struct s10 b
, struct s11 c
, struct s12 d
,
92 struct s13 e
, struct s14 f
)
94 printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a
.x
, b
.x
, c
.x
, d
.x
, e
.x
, f
.x
);
97 void fa3(struct hfa14 a
, struct hfa23 b
, struct hfa32 c
)
99 printf("%.1f %.1f %.1f %.1f %.1Lf %.1Lf\n",
100 a
.a
, a
.d
, b
.a
, b
.c
, c
.a
, c
.b
);
103 void fa4(struct s1 a
, struct hfa14 b
, struct s2 c
, struct hfa24 d
,
104 struct s3 e
, struct hfa34 f
)
106 printf("%.1s %.1f %.1f %.2s %.1f %.1f %.3s %.1Lf %.1Lf\n",
107 a
.x
, b
.a
, b
.d
, c
.x
, d
.a
, d
.d
, e
.x
, f
.a
, f
.d
);
112 printf("Arguments:\n");
142 fa1(s8
, s9
, s10
, s11
, s12
, s13
);
143 fa2(s9
, s10
, s11
, s12
, s13
, s14
);
144 fa3(hfa14
, hfa23
, hfa32
);
145 fa4(s1
, hfa14
, s2
, hfa24
, s3
, hfa34
);
148 struct s1
fr_s1(void) { return s1
; }
149 struct s2
fr_s2(void) { return s2
; }
150 struct s3
fr_s3(void) { return s3
; }
151 struct s4
fr_s4(void) { return s4
; }
152 struct s5
fr_s5(void) { return s5
; }
153 struct s6
fr_s6(void) { return s6
; }
154 struct s7
fr_s7(void) { return s7
; }
155 struct s8
fr_s8(void) { return s8
; }
156 struct s9
fr_s9(void) { return s9
; }
157 struct s10
fr_s10(void) { return s10
; }
158 struct s11
fr_s11(void) { return s11
; }
159 struct s12
fr_s12(void) { return s12
; }
160 struct s13
fr_s13(void) { return s13
; }
161 struct s14
fr_s14(void) { return s14
; }
162 struct s15
fr_s15(void) { return s15
; }
163 struct s16
fr_s16(void) { return s16
; }
164 struct s17
fr_s17(void) { return s17
; }
166 struct hfa11
fr_hfa11(void) { return hfa11
; }
167 struct hfa12
fr_hfa12(void) { return hfa12
; }
168 struct hfa13
fr_hfa13(void) { return hfa13
; }
169 struct hfa14
fr_hfa14(void) { return hfa14
; }
171 struct hfa21
fr_hfa21(void) { return hfa21
; }
172 struct hfa22
fr_hfa22(void) { return hfa22
; }
173 struct hfa23
fr_hfa23(void) { return hfa23
; }
174 struct hfa24
fr_hfa24(void) { return hfa24
; }
176 struct hfa31
fr_hfa31(void) { return hfa31
; }
177 struct hfa32
fr_hfa32(void) { return hfa32
; }
178 struct hfa33
fr_hfa33(void) { return hfa33
; }
179 struct hfa34
fr_hfa34(void) { return hfa34
; }
183 struct s1 t1
= fr_s1();
184 struct s2 t2
= fr_s2();
185 struct s3 t3
= fr_s3();
186 struct s4 t4
= fr_s4();
187 struct s5 t5
= fr_s5();
188 struct s6 t6
= fr_s6();
189 struct s7 t7
= fr_s7();
190 struct s8 t8
= fr_s8();
191 struct s9 t9
= fr_s9();
192 struct s10 t10
= fr_s10();
193 struct s11 t11
= fr_s11();
194 struct s12 t12
= fr_s12();
195 struct s13 t13
= fr_s13();
196 struct s14 t14
= fr_s14();
197 struct s15 t15
= fr_s15();
198 struct s16 t16
= fr_s16();
199 struct s17 t17
= fr_s17();
200 printf("Return values:\n");
201 printf("%.1s\n", t1
.x
);
202 printf("%.2s\n", t2
.x
);
203 printf("%.3s\n", t3
.x
);
204 printf("%.4s\n", t4
.x
);
205 printf("%.5s\n", t5
.x
);
206 printf("%.6s\n", t6
.x
);
207 printf("%.7s\n", t7
.x
);
208 printf("%.8s\n", t8
.x
);
209 printf("%.9s\n", t9
.x
);
210 printf("%.10s\n", t10
.x
);
211 printf("%.11s\n", t11
.x
);
212 printf("%.12s\n", t12
.x
);
213 printf("%.13s\n", t13
.x
);
214 printf("%.14s\n", t14
.x
);
215 printf("%.15s\n", t15
.x
);
216 printf("%.16s\n", t16
.x
);
217 printf("%.17s\n", t17
.x
);
218 printf("%.1f\n", fr_hfa11().a
);
219 printf("%.1f %.1f\n", fr_hfa12().a
, fr_hfa12().b
);
220 printf("%.1f %.1f\n", fr_hfa13().a
, fr_hfa13().c
);
221 printf("%.1f %.1f\n", fr_hfa14().a
, fr_hfa14().d
);
222 printf("%.1f\n", fr_hfa21().a
);
223 printf("%.1f %.1f\n", fr_hfa22().a
, fr_hfa22().b
);
224 printf("%.1f %.1f\n", fr_hfa23().a
, fr_hfa23().c
);
225 printf("%.1f %.1f\n", fr_hfa24().a
, fr_hfa24().d
);
226 printf("%.1Lf\n", fr_hfa31().a
);
227 printf("%.1Lf %.1Lf\n", fr_hfa32().a
, fr_hfa32().b
);
228 printf("%.1Lf %.1Lf\n", fr_hfa33().a
, fr_hfa33().c
);
229 printf("%.1Lf %.1Lf\n", fr_hfa34().a
, fr_hfa34().d
);
232 int match(const char **s
, const char *f
)
235 for (p
= *s
; *f
&& *f
== *p
; f
++, p
++)
244 void myprintf(const char *format
, ...)
248 va_start(ap
, format
);
249 for (s
= format
; *s
; s
++) {
250 if (match(&s
, "%7s")) {
251 struct s7 t7
= va_arg(ap
, struct s7
);
252 printf("%.7s", t7
.x
);
254 else if (match(&s
, "%9s")) {
255 struct s9 t9
= va_arg(ap
, struct s9
);
256 printf("%.9s", t9
.x
);
258 else if (match(&s
, "%hfa11")) {
259 struct hfa11 x
= va_arg(ap
, struct hfa11
);
260 printf("%.1f,%.1f", x
.a
, x
.a
);
262 else if (match(&s
, "%hfa12")) {
263 struct hfa12 x
= va_arg(ap
, struct hfa12
);
264 printf("%.1f,%.1f", x
.a
, x
.b
);
266 else if (match(&s
, "%hfa13")) {
267 struct hfa13 x
= va_arg(ap
, struct hfa13
);
268 printf("%.1f,%.1f", x
.a
, x
.c
);
270 else if (match(&s
, "%hfa14")) {
271 struct hfa14 x
= va_arg(ap
, struct hfa14
);
272 printf("%.1f,%.1f", x
.a
, x
.d
);
274 else if (match(&s
, "%hfa21")) {
275 struct hfa21 x
= va_arg(ap
, struct hfa21
);
276 printf("%.1f,%.1f", x
.a
, x
.a
);
278 else if (match(&s
, "%hfa22")) {
279 struct hfa22 x
= va_arg(ap
, struct hfa22
);
280 printf("%.1f,%.1f", x
.a
, x
.b
);
282 else if (match(&s
, "%hfa23")) {
283 struct hfa23 x
= va_arg(ap
, struct hfa23
);
284 printf("%.1f,%.1f", x
.a
, x
.c
);
286 else if (match(&s
, "%hfa24")) {
287 struct hfa24 x
= va_arg(ap
, struct hfa24
);
288 printf("%.1f,%.1f", x
.a
, x
.d
);
290 else if (match(&s
, "%hfa31")) {
291 struct hfa31 x
= va_arg(ap
, struct hfa31
);
292 printf("%.1Lf,%.1Lf", x
.a
, x
.a
);
294 else if (match(&s
, "%hfa32")) {
295 struct hfa32 x
= va_arg(ap
, struct hfa32
);
296 printf("%.1Lf,%.1Lf", x
.a
, x
.b
);
298 else if (match(&s
, "%hfa33")) {
299 struct hfa33 x
= va_arg(ap
, struct hfa33
);
300 printf("%.1Lf,%.1Lf", x
.a
, x
.c
);
302 else if (match(&s
, "%hfa34")) {
303 struct hfa34 x
= va_arg(ap
, struct hfa34
);
304 printf("%.1Lf,%.1Lf", x
.a
, x
.d
);
315 myprintf("%9s %9s %9s %9s %9s %9s", s9
, s9
, s9
, s9
, s9
, s9
);
316 myprintf("%7s %9s %9s %9s %9s %9s", s7
, s9
, s9
, s9
, s9
, s9
);
318 myprintf("HFA long double:");
319 myprintf("%hfa34 %hfa34 %hfa34 %hfa34", hfa34
, hfa34
, hfa34
, hfa34
);
320 myprintf("%hfa33 %hfa34 %hfa34 %hfa34", hfa33
, hfa34
, hfa34
, hfa34
);
321 myprintf("%hfa32 %hfa34 %hfa34 %hfa34", hfa32
, hfa34
, hfa34
, hfa34
);
322 myprintf("%hfa31 %hfa34 %hfa34 %hfa34", hfa31
, hfa34
, hfa34
, hfa34
);
324 myprintf("%hfa32 %hfa33 %hfa33 %hfa33 %hfa33",
325 hfa32
, hfa33
, hfa33
, hfa33
, hfa33
);
326 myprintf("%hfa31 %hfa33 %hfa33 %hfa33 %hfa33",
327 hfa31
, hfa33
, hfa33
, hfa33
, hfa33
);
328 myprintf("%hfa33 %hfa33 %hfa33 %hfa33",
329 hfa33
, hfa33
, hfa33
, hfa33
);
331 myprintf("%hfa34 %hfa32 %hfa32 %hfa32 %hfa32",
332 hfa34
, hfa32
, hfa32
, hfa32
, hfa32
);
333 myprintf("%hfa33 %hfa32 %hfa32 %hfa32 %hfa32",
334 hfa33
, hfa32
, hfa32
, hfa32
, hfa32
);
336 myprintf("%hfa34 %hfa32 %hfa31 %hfa31 %hfa31 %hfa31",
337 hfa34
, hfa32
, hfa31
, hfa31
, hfa31
, hfa31
);
339 myprintf("HFA double:");
340 myprintf("%hfa24 %hfa24 %hfa24 %hfa24", hfa24
, hfa24
, hfa24
, hfa24
);
341 myprintf("%hfa23 %hfa24 %hfa24 %hfa24", hfa23
, hfa24
, hfa24
, hfa24
);
342 myprintf("%hfa22 %hfa24 %hfa24 %hfa24", hfa22
, hfa24
, hfa24
, hfa24
);
343 myprintf("%hfa21 %hfa24 %hfa24 %hfa24", hfa21
, hfa24
, hfa24
, hfa24
);
345 myprintf("%hfa22 %hfa23 %hfa23 %hfa23 %hfa23",
346 hfa22
, hfa23
, hfa23
, hfa23
, hfa23
);
347 myprintf("%hfa21 %hfa23 %hfa23 %hfa23 %hfa23",
348 hfa21
, hfa23
, hfa23
, hfa23
, hfa23
);
349 myprintf("%hfa23 %hfa23 %hfa23 %hfa23",
350 hfa23
, hfa23
, hfa23
, hfa23
);
352 myprintf("%hfa24 %hfa22 %hfa22 %hfa22 %hfa22",
353 hfa24
, hfa22
, hfa22
, hfa22
, hfa22
);
354 myprintf("%hfa23 %hfa22 %hfa22 %hfa22 %hfa22",
355 hfa23
, hfa22
, hfa22
, hfa22
, hfa22
);
357 myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21",
358 hfa24
, hfa22
, hfa21
, hfa21
, hfa21
, hfa21
);
360 myprintf("HFA float:");
361 myprintf("%hfa14 %hfa14 %hfa14 %hfa14", hfa14
, hfa14
, hfa14
, hfa14
);
362 myprintf("%hfa13 %hfa14 %hfa14 %hfa14", hfa13
, hfa14
, hfa14
, hfa14
);
363 myprintf("%hfa12 %hfa14 %hfa14 %hfa14", hfa12
, hfa14
, hfa14
, hfa14
);
364 myprintf("%hfa11 %hfa14 %hfa14 %hfa14", hfa11
, hfa14
, hfa14
, hfa14
);
366 myprintf("%hfa12 %hfa13 %hfa13 %hfa13 %hfa13",
367 hfa12
, hfa13
, hfa13
, hfa13
, hfa13
);
368 myprintf("%hfa11 %hfa13 %hfa13 %hfa13 %hfa13",
369 hfa11
, hfa13
, hfa13
, hfa13
, hfa13
);
370 myprintf("%hfa13 %hfa13 %hfa13 %hfa13",
371 hfa13
, hfa13
, hfa13
, hfa13
);
373 myprintf("%hfa14 %hfa12 %hfa12 %hfa12 %hfa12",
374 hfa14
, hfa12
, hfa12
, hfa12
, hfa12
);
375 myprintf("%hfa13 %hfa12 %hfa12 %hfa12 %hfa12",
376 hfa13
, hfa12
, hfa12
, hfa12
, hfa12
);
378 myprintf("%hfa14 %hfa12 %hfa11 %hfa11 %hfa11 %hfa11",
379 hfa14
, hfa12
, hfa11
, hfa11
, hfa11
, hfa11
);
382 void pll(unsigned long long x
)
394 pll(0xabcd000000000000);
397 pll(0xffffffffffffabcd);
398 pll(0xffffffffabcdffff);
399 pll(0xffffabcdffffffff);
400 pll(0xabcdffffffffffff);
402 pll(0x5555555555555555);
404 pll(0x3333333333333333);
406 pll(0x1e1e1e1e1e1e1e1e);
408 pll(0x01ff01ff01ff01ff);
410 pll(0x03fff80003fff800);
411 pll(0x0007fffffffffe00);
415 pll(0xabcd000000001234);
417 pll(0xabcd000012340000);
418 pll(0xabcd123400000000);
419 pll(0xffffffffabcd1234);
420 pll(0xffffabcdffff1234);
421 pll(0xabcdffffffff1234);
422 pll(0xffffabcd1234ffff);
423 pll(0xabcdffff1234ffff);
424 pll(0xabcd1234ffffffff);
426 pll(0xffffef0123456789);
427 pll(0xabcdef012345ffff);
429 pll(0xabcdef0123456789);