1 /* { dg-do run { target powerpc64-*-linux* } } */
2 /* { dg-options "-O2 -fprofile -mprofile-kernel -maltivec -mabi=altivec" } */
8 /* Testcase to check for ABI compliance of parameter passing
9 for the PowerPC64 ABI. */
11 void __attribute__((no_instrument_function
))
12 sig_ill_handler (int sig
)
17 extern void abort (void);
21 unsigned long gprs
[8];
29 /* _mcount call is done on Linux ppc64 early in the prologue.
30 my_mcount will provide a entry point _mcount,
31 which will save all register to gparms.
32 Note that _mcount need to restore lr to original value,
33 therefor use ctr to return.
36 void __attribute__((no_instrument_function
))
39 asm volatile (".type _mcount,@function\n\t"
46 "ld 11,gparms@got(2)\n\t"
96 /* Stackframe structure relevant for parameter passing. */
106 struct sf
*backchain
;
127 void __attribute__ ((noinline
))
128 fcvi (char *s
, vector
int v
, int i
)
130 reg_parms_t lparms
= gparms
;
132 if (s
!= (char *) lparms
.gprs
[0])
135 if (!vec_all_eq (v
, lparms
.vrs
[0]))
138 if ((long) i
!= lparms
.gprs
[4])
147 void __attribute__ ((noinline
))
148 fcvv (char *s
, vector
int v
, vector
int w
)
150 vector
int a
, c
= {6, 8, 10, 12};
151 reg_parms_t lparms
= gparms
;
153 if (s
!= (char *) lparms
.gprs
[0])
156 if (!vec_all_eq (v
, lparms
.vrs
[0]))
159 if (!vec_all_eq (w
, lparms
.vrs
[1]))
164 if (!vec_all_eq (a
, c
))
174 void __attribute__ ((noinline
))
175 fcivv (char *s
, int i
, vector
int v
, vector
int w
)
177 vector
int a
, c
= {6, 8, 10, 12};
178 reg_parms_t lparms
= gparms
;
180 if (s
!= (char *) lparms
.gprs
[0])
183 if ((long) i
!= lparms
.gprs
[1])
186 if (!vec_all_eq (v
, lparms
.vrs
[0]))
189 if (!vec_all_eq (w
, lparms
.vrs
[1]))
194 if (!vec_all_eq (a
, c
))
204 void __attribute__ ((noinline
))
207 vector
int a
, c
= {6, 8, 10, 12};
210 reg_parms_t lparms
= gparms
;
215 if (s
!= (char *) lparms
.gprs
[0])
218 v
= va_arg(arg
, vector
int);
219 w
= va_arg(arg
, vector
int);
222 if (!vec_all_eq (a
, c
))
225 /* Go back one frame. */
226 sp
= __builtin_frame_address(0);
229 if (sp
->slot
[2].l
!= 0x100000002ULL
230 || sp
->slot
[4].l
!= 0x500000006ULL
)
241 void __attribute__ ((noinline
))
242 fciievv (char *s
, int i
, int j
, ...)
244 vector
int a
, c
= {6, 8, 10, 12};
247 reg_parms_t lparms
= gparms
;
252 if (s
!= (char *) lparms
.gprs
[0])
255 if ((long) i
!= lparms
.gprs
[1])
258 if ((long) j
!= lparms
.gprs
[2])
261 v
= va_arg(arg
, vector
int);
262 w
= va_arg(arg
, vector
int);
265 if (!vec_all_eq (a
, c
))
268 sp
= __builtin_frame_address(0);
271 if (sp
->slot
[4].l
!= 0x100000002ULL
272 || sp
->slot
[6].l
!= 0x500000006ULL
)
276 void __attribute__ ((noinline
))
277 fcvevv (char *s
, vector
int x
, ...)
279 vector
int a
, c
= {7, 10, 13, 16};
282 reg_parms_t lparms
= gparms
;
287 v
= va_arg(arg
, vector
int);
288 w
= va_arg(arg
, vector
int);
293 if (!vec_all_eq (a
, c
))
296 sp
= __builtin_frame_address(0);
299 if (sp
->slot
[4].l
!= 0x100000002ULL
300 || sp
->slot
[6].l
!= 0x500000006ULL
)
306 int __attribute__((no_instrument_function
, noinline
))
310 vector
int v
= {1, 2, 3, 4};
311 vector
int w
= {5, 6, 7, 8};
315 fnp_cvvvv (s
, v
, w
, v
, w
);
318 fciievv (s
, 1, 2, v
, w
);
323 int __attribute__((no_instrument_function
))
326 /* Exit on systems without altivec. */
327 signal (SIGILL
, sig_ill_handler
);
328 /* Altivec instruction, 'vor %v0,%v0,%v0'. */
329 asm volatile (".long 0x10000484");
330 signal (SIGILL
, SIG_DFL
);
336 Function called with no prototype.
344 fnp_cvvvv (char *s
, vector
int v
, vector
int w
,
345 vector
int x
, vector
int y
)
347 vector
int a
, c
= {12, 16, 20, 24};
348 reg_parms_t lparms
= gparms
;
350 vector_int_t v0
, v1
, v2
, v3
;
352 if (s
!= (char *) lparms
.gprs
[0])
355 if (!vec_all_eq (v
, lparms
.vrs
[0]))
358 if (!vec_all_eq (w
, lparms
.vrs
[1]))
361 if (!vec_all_eq (x
, lparms
.vrs
[2]))
364 if (!vec_all_eq (y
, lparms
.vrs
[3]))
371 if (!vec_all_eq (a
, c
))
374 v0
.v
= lparms
.vrs
[0];
375 v1
.v
= lparms
.vrs
[1];
376 v2
.v
= lparms
.vrs
[2];
377 v3
.v
= lparms
.vrs
[3];
379 if (v0
.l
[0] != lparms
.gprs
[2])
382 if (v0
.l
[1] != lparms
.gprs
[3])
385 if (v1
.l
[0] != lparms
.gprs
[4])
388 if (v1
.l
[1] != lparms
.gprs
[5])
391 if (v2
.l
[0] != lparms
.gprs
[6])
394 if (v2
.l
[1] != lparms
.gprs
[7])
397 sp
= __builtin_frame_address(0);
400 if (sp
->slot
[8].l
!= v3
.l
[0])
403 if (sp
->slot
[9].l
!= v3
.l
[1])