1 /* { dg-do run { target powerpc64-*-linux* } } */
2 /* { dg-require-effective-target lp64 } */
3 /* { dg-options "-O2 -fprofile -mprofile-kernel -maltivec -mabi=altivec" } */
9 /* Testcase to check for ABI compliance of parameter passing
10 for the PowerPC64 ABI. */
12 void __attribute__((no_instrument_function
))
13 sig_ill_handler (int sig
)
18 extern void abort (void);
22 unsigned long gprs
[8];
30 /* _mcount call is done on Linux ppc64 early in the prologue.
31 my_mcount will provide a entry point _mcount,
32 which will save all register to gparms.
33 Note that _mcount need to restore lr to original value,
34 therefor use ctr to return.
37 void __attribute__((no_instrument_function
))
40 asm volatile (".type _mcount,@function\n\t"
47 "ld 11,gparms@got(2)\n\t"
97 /* Stackframe structure relevant for parameter passing. */
107 struct sf
*backchain
;
128 void __attribute__ ((noinline
))
129 fcvi (char *s
, vector
int v
, int i
)
131 reg_parms_t lparms
= gparms
;
133 if (s
!= (char *) lparms
.gprs
[0])
136 if (!vec_all_eq (v
, lparms
.vrs
[0]))
139 if ((long) i
!= lparms
.gprs
[4])
148 void __attribute__ ((noinline
))
149 fcvv (char *s
, vector
int v
, vector
int w
)
151 vector
int a
, c
= {6, 8, 10, 12};
152 reg_parms_t lparms
= gparms
;
154 if (s
!= (char *) lparms
.gprs
[0])
157 if (!vec_all_eq (v
, lparms
.vrs
[0]))
160 if (!vec_all_eq (w
, lparms
.vrs
[1]))
165 if (!vec_all_eq (a
, c
))
175 void __attribute__ ((noinline
))
176 fcivv (char *s
, int i
, vector
int v
, vector
int w
)
178 vector
int a
, c
= {6, 8, 10, 12};
179 reg_parms_t lparms
= gparms
;
181 if (s
!= (char *) lparms
.gprs
[0])
184 if ((long) i
!= lparms
.gprs
[1])
187 if (!vec_all_eq (v
, lparms
.vrs
[0]))
190 if (!vec_all_eq (w
, lparms
.vrs
[1]))
195 if (!vec_all_eq (a
, c
))
205 void __attribute__ ((noinline
))
208 vector
int a
, c
= {6, 8, 10, 12};
211 reg_parms_t lparms
= gparms
;
216 if (s
!= (char *) lparms
.gprs
[0])
219 v
= va_arg(arg
, vector
int);
220 w
= va_arg(arg
, vector
int);
223 if (!vec_all_eq (a
, c
))
226 /* Go back one frame. */
227 sp
= __builtin_frame_address(0);
230 if (sp
->slot
[2].l
!= 0x100000002ULL
231 || sp
->slot
[4].l
!= 0x500000006ULL
)
242 void __attribute__ ((noinline
))
243 fciievv (char *s
, int i
, int j
, ...)
245 vector
int a
, c
= {6, 8, 10, 12};
248 reg_parms_t lparms
= gparms
;
253 if (s
!= (char *) lparms
.gprs
[0])
256 if ((long) i
!= lparms
.gprs
[1])
259 if ((long) j
!= lparms
.gprs
[2])
262 v
= va_arg(arg
, vector
int);
263 w
= va_arg(arg
, vector
int);
266 if (!vec_all_eq (a
, c
))
269 sp
= __builtin_frame_address(0);
272 if (sp
->slot
[4].l
!= 0x100000002ULL
273 || sp
->slot
[6].l
!= 0x500000006ULL
)
277 void __attribute__ ((noinline
))
278 fcvevv (char *s
, vector
int x
, ...)
280 vector
int a
, c
= {7, 10, 13, 16};
283 reg_parms_t lparms
= gparms
;
288 v
= va_arg(arg
, vector
int);
289 w
= va_arg(arg
, vector
int);
294 if (!vec_all_eq (a
, c
))
297 sp
= __builtin_frame_address(0);
300 if (sp
->slot
[4].l
!= 0x100000002ULL
301 || sp
->slot
[6].l
!= 0x500000006ULL
)
307 int __attribute__((no_instrument_function
, noinline
))
311 vector
int v
= {1, 2, 3, 4};
312 vector
int w
= {5, 6, 7, 8};
316 fnp_cvvvv (s
, v
, w
, v
, w
);
319 fciievv (s
, 1, 2, v
, w
);
324 int __attribute__((no_instrument_function
))
327 /* Exit on systems without altivec. */
328 signal (SIGILL
, sig_ill_handler
);
329 /* Altivec instruction, 'vor %v0,%v0,%v0'. */
330 asm volatile (".long 0x10000484");
331 signal (SIGILL
, SIG_DFL
);
337 Function called with no prototype.
345 fnp_cvvvv (char *s
, vector
int v
, vector
int w
,
346 vector
int x
, vector
int y
)
348 vector
int a
, c
= {12, 16, 20, 24};
349 reg_parms_t lparms
= gparms
;
351 vector_int_t v0
, v1
, v2
, v3
;
353 if (s
!= (char *) lparms
.gprs
[0])
356 if (!vec_all_eq (v
, lparms
.vrs
[0]))
359 if (!vec_all_eq (w
, lparms
.vrs
[1]))
362 if (!vec_all_eq (x
, lparms
.vrs
[2]))
365 if (!vec_all_eq (y
, lparms
.vrs
[3]))
372 if (!vec_all_eq (a
, c
))
375 v0
.v
= lparms
.vrs
[0];
376 v1
.v
= lparms
.vrs
[1];
377 v2
.v
= lparms
.vrs
[2];
378 v3
.v
= lparms
.vrs
[3];
380 if (v0
.l
[0] != lparms
.gprs
[2])
383 if (v0
.l
[1] != lparms
.gprs
[3])
386 if (v1
.l
[0] != lparms
.gprs
[4])
389 if (v1
.l
[1] != lparms
.gprs
[5])
392 if (v2
.l
[0] != lparms
.gprs
[6])
395 if (v2
.l
[1] != lparms
.gprs
[7])
398 sp
= __builtin_frame_address(0);
401 if (sp
->slot
[8].l
!= v3
.l
[0])
404 if (sp
->slot
[9].l
!= v3
.l
[1])