1 /* { dg-do run { target { powerpc_fprs && { ilp32 && dfprt } } } } */
2 /* { dg-options "-std=gnu99 -O2 -fno-strict-aliasing" } */
4 /* Testcase to check for ABI compliance of parameter passing
5 for the PowerPC ELF ABI for decimal float values. */
7 extern void abort (void);
10 /* Support compiling the test to report individual failures; default is
11 to abort as soon as a check fails. */
14 #define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
16 #define FAILURE abort ();
37 unsigned int slot
[200];
40 /* Wrapper to save the GPRs and FPRs and then jump to the real function. */
41 #define WRAPPER(NAME) \
42 __asm__ ("\t.globl\t" #NAME "_asm\n\t" \
44 ".type " #NAME "_asm, @function\n" \
46 "lis 11,gparms@ha\n\t" \
47 "la 11,gparms@l(11)\n\t" \
65 ".size " #NAME ",.-" #NAME "\n")
67 /* Fill up floating point registers with double arguments, forcing
68 decimal float arguments into the parameter save area. */
69 extern void func0_asm (double, double, double, double, double,
70 double, double, double, _Decimal64
, _Decimal128
);
74 void __attribute__ ((noinline
))
75 func0 (double a1
, double a2
, double a3
, double a4
, double a5
,
76 double a6
, double a7
, double a8
, _Decimal64 a9
, _Decimal128 a10
)
80 sp
= __builtin_frame_address (0);
83 if (a1
!= gparms
.fprs
[0]) FAILURE
84 if (a2
!= gparms
.fprs
[1]) FAILURE
85 if (a3
!= gparms
.fprs
[2]) FAILURE
86 if (a4
!= gparms
.fprs
[3]) FAILURE
87 if (a5
!= gparms
.fprs
[4]) FAILURE
88 if (a6
!= gparms
.fprs
[5]) FAILURE
89 if (a7
!= gparms
.fprs
[6]) FAILURE
90 if (a8
!= gparms
.fprs
[7]) FAILURE
91 if (a9
!= *(_Decimal64
*)&sp
->slot
[0]) FAILURE
92 if (a10
!= *(_Decimal128
*)&sp
->slot
[2]) FAILURE
95 /* Alternate 64-bit and 128-bit decimal float arguments, checking that
96 _Decimal128 is always passed in even/odd register pairs. */
97 extern void func1_asm (_Decimal64
, _Decimal128
, _Decimal64
, _Decimal128
,
98 _Decimal64
, _Decimal128
, _Decimal64
, _Decimal128
);
102 void __attribute__ ((noinline
))
103 func1 (_Decimal64 a1
, _Decimal128 a2
, _Decimal64 a3
, _Decimal128 a4
,
104 _Decimal64 a5
, _Decimal128 a6
, _Decimal64 a7
, _Decimal128 a8
)
108 sp
= __builtin_frame_address (0);
111 if (a1
!= *(_Decimal64
*)&gparms
.fprs
[0]) FAILURE
/* f1 */
112 if (a2
!= *(_Decimal128
*)&gparms
.fprs
[1]) FAILURE
/* f2 & f3 */
113 if (a3
!= *(_Decimal64
*)&gparms
.fprs
[3]) FAILURE
/* f4 */
114 if (a4
!= *(_Decimal128
*)&gparms
.fprs
[5]) FAILURE
/* f6 & f7 */
115 if (a5
!= *(_Decimal64
*)&gparms
.fprs
[7]) FAILURE
/* f8 */
116 if (a6
!= *(_Decimal128
*)&sp
->slot
[0]) FAILURE
117 if (a7
!= *(_Decimal64
*)&sp
->slot
[4]) FAILURE
118 if (a8
!= *(_Decimal128
*)&sp
->slot
[6]) FAILURE
121 extern void func2_asm (_Decimal128
, _Decimal64
, _Decimal128
, _Decimal64
,
122 _Decimal128
, _Decimal64
, _Decimal128
, _Decimal64
);
126 void __attribute__ ((noinline
))
127 func2 (_Decimal128 a1
, _Decimal64 a2
, _Decimal128 a3
, _Decimal64 a4
,
128 _Decimal128 a5
, _Decimal64 a6
, _Decimal128 a7
, _Decimal64 a8
)
132 sp
= __builtin_frame_address (0);
135 if (a1
!= *(_Decimal128
*)&gparms
.fprs
[1]) FAILURE
/* f2 & f3 */
136 if (a2
!= *(_Decimal64
*)&gparms
.fprs
[3]) FAILURE
/* f4 */
137 if (a3
!= *(_Decimal128
*)&gparms
.fprs
[5]) FAILURE
/* f6 & f7 */
138 if (a4
!= *(_Decimal64
*)&gparms
.fprs
[7]) FAILURE
/* f8 */
139 if (a5
!= *(_Decimal128
*)&sp
->slot
[0]) FAILURE
140 if (a6
!= *(_Decimal64
*)&sp
->slot
[4]) FAILURE
141 if (a7
!= *(_Decimal128
*)&sp
->slot
[6]) FAILURE
142 if (a8
!= *(_Decimal64
*)&sp
->slot
[10]) FAILURE
145 extern void func3_asm (_Decimal64
, _Decimal128
, _Decimal64
, _Decimal128
,
150 void __attribute__ ((noinline
))
151 func3 (_Decimal64 a1
, _Decimal128 a2
, _Decimal64 a3
, _Decimal128 a4
,
156 sp
= __builtin_frame_address (0);
159 if (a1
!= *(_Decimal64
*)&gparms
.fprs
[0]) FAILURE
/* f1 */
160 if (a2
!= *(_Decimal128
*)&gparms
.fprs
[1]) FAILURE
/* f2 & f3 */
161 if (a3
!= *(_Decimal64
*)&gparms
.fprs
[3]) FAILURE
/* f4 */
162 if (a4
!= *(_Decimal128
*)&gparms
.fprs
[5]) FAILURE
/* f6 & f7 */
163 if (a5
!= *(_Decimal128
*)&sp
->slot
[0]) FAILURE
166 extern void func4_asm (_Decimal32
, _Decimal32
, _Decimal32
, _Decimal32
,
167 _Decimal32
, _Decimal32
, _Decimal32
, _Decimal32
,
168 _Decimal32
, _Decimal32
, _Decimal32
, _Decimal32
,
169 _Decimal32
, _Decimal32
, _Decimal32
, _Decimal32
);
173 void __attribute__ ((noinline
))
174 func4 (_Decimal32 a1
, _Decimal32 a2
, _Decimal32 a3
, _Decimal32 a4
,
175 _Decimal32 a5
, _Decimal32 a6
, _Decimal32 a7
, _Decimal32 a8
,
176 _Decimal32 a9
, _Decimal32 a10
, _Decimal32 a11
, _Decimal32 a12
,
177 _Decimal32 a13
, _Decimal32 a14
, _Decimal32 a15
, _Decimal32 a16
)
181 sp
= __builtin_frame_address (0);
184 /* _Decimal32 is passed in the lower half of an FPR, or in parameter slot. */
185 if (a1
!= ((d32parm_t
*)&gparms
.fprs
[0])->d
) FAILURE
/* f1 */
186 if (a2
!= ((d32parm_t
*)&gparms
.fprs
[1])->d
) FAILURE
/* f2 */
187 if (a3
!= ((d32parm_t
*)&gparms
.fprs
[2])->d
) FAILURE
/* f3 */
188 if (a4
!= ((d32parm_t
*)&gparms
.fprs
[3])->d
) FAILURE
/* f4 */
189 if (a5
!= ((d32parm_t
*)&gparms
.fprs
[4])->d
) FAILURE
/* f5 */
190 if (a6
!= ((d32parm_t
*)&gparms
.fprs
[5])->d
) FAILURE
/* f6 */
191 if (a7
!= ((d32parm_t
*)&gparms
.fprs
[6])->d
) FAILURE
/* f7 */
192 if (a8
!= ((d32parm_t
*)&gparms
.fprs
[7])->d
) FAILURE
/* f8 */
193 if (a9
!= *(_Decimal32
*)&sp
->slot
[0]) FAILURE
194 if (a10
!= *(_Decimal32
*)&sp
->slot
[1]) FAILURE
195 if (a11
!= *(_Decimal32
*)&sp
->slot
[2]) FAILURE
196 if (a12
!= *(_Decimal32
*)&sp
->slot
[3]) FAILURE
197 if (a13
!= *(_Decimal32
*)&sp
->slot
[4]) FAILURE
198 if (a14
!= *(_Decimal32
*)&sp
->slot
[5]) FAILURE
199 if (a15
!= *(_Decimal32
*)&sp
->slot
[6]) FAILURE
200 if (a16
!= *(_Decimal32
*)&sp
->slot
[7]) FAILURE
203 extern void func5_asm (_Decimal32
, _Decimal64
, _Decimal128
,
204 _Decimal32
, _Decimal64
, _Decimal128
,
205 _Decimal32
, _Decimal64
, _Decimal128
,
206 _Decimal32
, _Decimal64
, _Decimal128
);
210 void __attribute__ ((noinline
))
211 func5 (_Decimal32 a1
, _Decimal64 a2
, _Decimal128 a3
,
212 _Decimal32 a4
, _Decimal64 a5
, _Decimal128 a6
,
213 _Decimal32 a7
, _Decimal64 a8
, _Decimal128 a9
,
214 _Decimal32 a10
, _Decimal64 a11
, _Decimal128 a12
)
218 sp
= __builtin_frame_address (0);
221 if (a1
!= ((d32parm_t
*)&gparms
.fprs
[0])->d
) FAILURE
/* f1 */
222 if (a2
!= *(_Decimal64
*)&gparms
.fprs
[1]) FAILURE
/* f2 */
223 if (a3
!= *(_Decimal128
*)&gparms
.fprs
[3]) FAILURE
/* f4 & f5 */
224 if (a4
!= ((d32parm_t
*)&gparms
.fprs
[5])->d
) FAILURE
/* f6 */
225 if (a5
!= *(_Decimal64
*)&gparms
.fprs
[6]) FAILURE
/* f7 */
227 if (a6
!= *(_Decimal128
*)&sp
->slot
[0]) FAILURE
228 if (a7
!= *(_Decimal32
*)&sp
->slot
[4]) FAILURE
229 if (a8
!= *(_Decimal64
*)&sp
->slot
[6]) FAILURE
230 if (a9
!= *(_Decimal128
*)&sp
->slot
[8]) FAILURE
231 if (a10
!= *(_Decimal32
*)&sp
->slot
[12]) FAILURE
232 if (a11
!= *(_Decimal64
*)&sp
->slot
[14]) FAILURE
233 if (a12
!= *(_Decimal128
*)&sp
->slot
[16]) FAILURE
239 func0_asm (1., 2., 3., 4., 5., 6., 7., 8., 9.dd
, 10.dl
);
240 func1_asm (1.dd
, 2.dl
, 3.dd
, 4.dl
, 5.dd
, 6.dl
, 7.dd
, 8.dl
);
241 func2_asm (1.dl
, 2.dd
, 3.dl
, 4.dd
, 5.dl
, 6.dd
, 7.dl
, 8.dd
);
242 func3_asm (1.dd
, 2.dl
, 3.dd
, 4.dl
, 5.dl
);
243 func4_asm (501.2df
, 502.2df
, 503.2df
, 504.2df
, 505.2df
, 506.2df
, 507.2df
,
244 508.2df
, 509.2df
, 510.2df
, 511.2df
, 512.2df
, 513.2df
, 514.2df
,
246 func5_asm (601.2df
, 602.2dd
, 603.2dl
, 604.2df
, 605.2dd
, 606.2dl
,
247 607.2df
, 608.2dd
, 609.2dl
, 610.2df
, 611.2dd
, 612.2dl
);