1 /* Test AAPCS layout (alignment) for callee. */
2
3 /* { dg-do run { target aarch64*-*-* } } */
4
5 extern int memcmp (const void *s1, const void *s2, __SIZE_TYPE__ n);
6 extern void abort (void);
7
8 /* The underlying struct here has alignment 8. */
9 typedef struct __attribute__ ((__aligned__ (16)))
10 {
11 long x;
12 long y;
13 } overaligned;
14
15 overaligned a = { 2, 3 };
16 overaligned b = { 5, 8 };
17 overaligned c = { 13, 21 };
18
19 void
test_passing_overaligned_struct(int x0,overaligned x1,int x3,int x4,overaligned x5,int x7,int stack,overaligned stack8)20 test_passing_overaligned_struct (int x0, overaligned x1, int x3, int x4,
21 overaligned x5, int x7, int stack,
22 overaligned stack8)
23 {
24 if (x0 != 7 || x3 != 9 || x4 != 11 || x7 != 15 || stack != 10)
25 abort ();
26 if (memcmp ((void *) &x1, (void *)&a, sizeof (overaligned)))
27 abort ();
28 if (memcmp ((void *) &x5, (void *)&b, sizeof (overaligned)))
29 abort ();
30 if (memcmp ((void *)&stack8, (void *)&c, sizeof (overaligned)))
31 abort ();
32 long addr = ((long) &stack8) & 15;
33 if (addr != 0)
34 {
35 __builtin_printf ("Alignment was %d\n", addr);
36 abort ();
37 }
38 }
39
40 int
main(int argc,char ** argv)41 main (int argc, char **argv)
42 {
43 test_passing_overaligned_struct (7, a, 9, 11, b, 15, 10, c);
44 return 0;
45 }
46