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 struct s
9 {
10 long x;
11 long y;
12 };
13
14 /* This still has size 16, so is still passed by value. */
15 typedef __attribute__ ((__aligned__ (32))) struct s overaligned;
16
17 /* A few structs, at 32-byte-aligned memory locations. */
18 overaligned a = { 2, 3 };
19 overaligned b = { 5, 8 };
20 overaligned c = { 13, 21 };
21
22 void
test_pass_by_value(int x0,overaligned x1,int x3,int x4,overaligned x5,int x7,int stack,overaligned stack8)23 test_pass_by_value (int x0, overaligned x1, int x3, int x4, overaligned x5,
24 int x7, int stack, overaligned stack8)
25 {
26 if (x0 != 7 || x3 != 9 || x4 != 11 || x7 != 15 || stack != 10)
27 abort ();
28 if (memcmp ((void *) &x1, (void *)&a, sizeof (overaligned)))
29 abort ();
30 if (memcmp ((void *) &x5, (void *)&b, sizeof (overaligned)))
31 abort ();
32 if (memcmp ((void *)&stack8, (void *)&c, sizeof (overaligned)))
33 abort ();
34 long addr = ((long) &stack8) & 15;
35 if (addr != 0)
36 {
37 __builtin_printf ("Alignment was %d\n", addr);
38 abort ();
39 }
40 }
41
42 int
main(int argc,char ** argv)43 main (int argc, char **argv)
44 {
45 test_pass_by_value (7, a, 9, 11, b, 15, 10, c);
46 return 0;
47 }
48