1 /* Test AAPCS64 layout and __builtin_va_arg.
2 
3    This test covers homogeneous floating-point aggregate types and homogeneous
4    short-vector aggregate types as described in AAPCS64 \S 4.3.5.  */
5 
6 /* { dg-do run { target aarch64*-*-* } } */
7 
8 #ifndef IN_FRAMEWORK
9 #define AAPCS64_TEST_STDARG
10 #define TESTFILE "va_arg-4.c"
11 #include "type-def.h"
12 
13 struct hfa_fx1_t hfa_fx1 = {12.345f};
14 struct hfa_fx2_t hfa_fx2 = {123.456f, 234.456f};
15 struct hfa_dx2_t hfa_dx2 = {234.567, 345.678};
16 struct hfa_dx4_t hfa_dx4 = {1234.123, 2345.234, 3456.345, 4567.456};
17 struct hfa_ldx3_t hfa_ldx3 = {123456.7890, 234567.8901, 345678.9012};
18 struct non_hfa_fx5_t non_hfa_fx5 = {456.789f, 567.890f, 678.901f, 789.012f, 890.123f};
19 struct hfa_ffs_t hfa_ffs;
20 struct non_hfa_ffs_t non_hfa_ffs;
21 struct non_hfa_ffs_2_t non_hfa_ffs_2;
22 struct hva_vf2x1_t hva_vf2x1;
23 struct hva_vf2x2_t hva_vf2x2;
24 struct hva_vi4x1_t hva_vi4x1;
25 struct non_hfa_ffd_t non_hfa_ffd = {23.f, 24.f, 25.0};
26 struct non_hfa_ii_t non_hfa_ii = {26, 27};
27 struct non_hfa_c_t non_hfa_c = {28};
28 struct non_hfa_ffvf2_t non_hfa_ffvf2;
29 struct non_hfa_fffd_t non_hfa_fffd = {33.f, 34.f, 35.f, 36.0};
30 union hfa_union_t hfa_union;
31 union non_hfa_union_t non_hfa_union;
32 struct hfa_f16x2_t hfa_f16x2 = {2.0f, 4.0f};
33 struct hfa_f16x3_t hfa_f16x3 = {2.0f, 4.0f, 8.0f};
34 
35 #define HAS_DATA_INIT_FUNC
init_data()36 void init_data ()
37 {
38   hva_vf2x1.a = (vf2_t){17.f, 18.f};
39   hva_vf2x2.a = (vf2_t){19.f, 20.f};
40   hva_vf2x2.b = (vf2_t){21.f, 22.f};
41   hva_vi4x1.a = (vi4_t){19, 20, 21, 22};
42 
43   non_hfa_ffvf2.a = 29.f;
44   non_hfa_ffvf2.b = 30.f;
45   non_hfa_ffvf2.c = (vf2_t){31.f, 32.f};
46 
47   hfa_union.s.a = 37.f;
48   hfa_union.s.b = 38.f;
49   hfa_union.c   = 39.f;
50 
51   non_hfa_union.a = 40.0;
52   non_hfa_union.b = 41.f;
53 
54   hfa_ffs.a = 42.f;
55   hfa_ffs.b = 43.f;
56   hfa_ffs.c.a = 44.f;
57   hfa_ffs.c.b = 45.f;
58 
59   non_hfa_ffs.a = 46.f;
60   non_hfa_ffs.b = 47.f;
61   non_hfa_ffs.c.a = 48.0;
62   non_hfa_ffs.c.b = 49.0;
63 
64   non_hfa_ffs_2.s.a = 50;
65   non_hfa_ffs_2.s.b = 51;
66   non_hfa_ffs_2.c = 52.f;
67   non_hfa_ffs_2.d = 53.f;
68 }
69 
70 #include "abitest.h"
71 #else
72   ARG      (int   , 1, W0, LAST_NAMED_ARG_ID)
73   DOTS
74   /* HFA or HVA passed in fp/simd registers or on stack.  */
75   ANON     (struct hfa_fx1_t  , hfa_fx1 ,  S0      , 0)
76   ANON     (struct hfa_fx2_t  , hfa_fx2 ,  S1      , 1)
77   ANON     (struct hfa_dx2_t  , hfa_dx2 ,  D3      , 2)
78   ANON     (struct hva_vf2x1_t, hva_vf2x1, D5      , 11)
79   ANON     (struct hva_vi4x1_t, hva_vi4x1, Q6      , 12)
80   ANON     (struct hfa_dx4_t  , hfa_dx4 ,  STACK   , 3)
81   ANON     (struct hfa_ffs_t  , hfa_ffs  , STACK+32, 4)
82   ANON     (union  hfa_union_t, hfa_union, STACK+48, 5)
83   ANON     (struct hfa_ldx3_t , hfa_ldx3 , STACK+64, 6)
84   /* Non-H[FV]A passed in general registers or on stack or via reference.  */
85   PTR_ANON (struct non_hfa_fx5_t  , non_hfa_fx5  , X1       , 10)
86   ANON     (struct non_hfa_ffd_t  , non_hfa_ffd  , X2       , 13)
87   ANON     (struct non_hfa_ii_t   , non_hfa_ii   , X4       , 14)
88   ANON     (struct non_hfa_c_t    , non_hfa_c    , X5       , 15)
89   ANON     (struct non_hfa_ffvf2_t, non_hfa_ffvf2, X6       , 16)
90   PTR_ANON (struct non_hfa_fffd_t , non_hfa_fffd , STACK+112, 17)
91   PTR_ANON (struct non_hfa_ffs_t  , non_hfa_ffs  , STACK+120, 18)
92   ANON     (struct non_hfa_ffs_2_t, non_hfa_ffs_2, STACK+128, 19)
93   ANON     (union  non_hfa_union_t, non_hfa_union, STACK+144, 20)
94   /* HFA of __fp16 passed on stack, directed __fp16 test is va_arg-10.c.  */
95   ANON     (struct hfa_f16x2_t    , hfa_f16x2    , STACK+152, 21)
96   ANON     (struct hfa_f16x3_t    , hfa_f16x3    , STACK+160, 22)
97 #ifndef __AAPCS64_BIG_ENDIAN__
98   LAST_ANON(int                   , 2            , STACK+168, 30)
99 #else
100   LAST_ANON(int                   , 2            , STACK+172, 30)
101 #endif
102 #endif
103