| 1 |
/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ |
| 2 |
/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ |
| 3 |
/* { dg-options "-maltivec -mabi=altivec -fno-inline" } */ |
| 4 |
/* { dg-require-effective-target powerpc_altivec } */ |
| 5 |
|
| 6 |
#include <stdarg.h> |
| 7 |
|
| 8 |
extern void exit (int); |
| 9 |
extern void abort (void); |
| 10 |
extern int memcmp (const void *, const void *, __SIZE_TYPE__); |
| 11 |
|
| 12 |
#define vector __attribute__((vector_size (16))) |
| 13 |
|
| 14 |
const vector unsigned int v1 = {10,11,12,13}; |
| 15 |
const vector unsigned int v2 = {20,21,22,23}; |
| 16 |
const vector unsigned int v3 = {30,31,32,33}; |
| 17 |
const vector unsigned int v4 = {40,41,42,43}; |
| 18 |
|
| 19 |
void foo(vector unsigned int a, ...) |
| 20 |
{ |
| 21 |
va_list args; |
| 22 |
vector unsigned int v; |
| 23 |
|
| 24 |
va_start (args, a); |
| 25 |
if (memcmp (&a, &v1, sizeof (v)) != 0) |
| 26 |
abort (); |
| 27 |
v = va_arg (args, vector unsigned int); |
| 28 |
if (memcmp (&v, &v2, sizeof (v)) != 0) |
| 29 |
abort (); |
| 30 |
v = va_arg (args, vector unsigned int); |
| 31 |
if (memcmp (&v, &v3, sizeof (v)) != 0) |
| 32 |
abort (); |
| 33 |
v = va_arg (args, vector unsigned int); |
| 34 |
if (memcmp (&v, &v4, sizeof (v)) != 0) |
| 35 |
abort (); |
| 36 |
va_end (args); |
| 37 |
} |
| 38 |
|
| 39 |
void bar(vector unsigned int a, ...) |
| 40 |
{ |
| 41 |
va_list args; |
| 42 |
vector unsigned int v; |
| 43 |
int b; |
| 44 |
|
| 45 |
va_start (args, a); |
| 46 |
if (memcmp (&a, &v1, sizeof (v)) != 0) |
| 47 |
abort (); |
| 48 |
b = va_arg (args, int); |
| 49 |
if (b != 2) |
| 50 |
abort (); |
| 51 |
v = va_arg (args, vector unsigned int); |
| 52 |
if (memcmp (&v, &v2, sizeof (v)) != 0) |
| 53 |
abort (); |
| 54 |
v = va_arg (args, vector unsigned int); |
| 55 |
if (memcmp (&v, &v3, sizeof (v)) != 0) |
| 56 |
abort (); |
| 57 |
va_end (args); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
int main1(void) |
| 62 |
{ |
| 63 |
/* In this call, in the Darwin ABI, the first argument goes into v2 |
| 64 |
the second one into r9-r10 and memory, |
| 65 |
and the next two in memory. */ |
| 66 |
foo ((vector unsigned int){10,11,12,13}, |
| 67 |
(vector unsigned int){20,21,22,23}, |
| 68 |
(vector unsigned int){30,31,32,33}, |
| 69 |
(vector unsigned int){40,41,42,43}); |
| 70 |
/* In this call, in the Darwin ABI, the first argument goes into v2 |
| 71 |
the second one into r9, then r10 is reserved and |
| 72 |
there are two words of padding in memory, and the next two arguments |
| 73 |
go after the padding. */ |
| 74 |
bar ((vector unsigned int){10,11,12,13}, 2, |
| 75 |
(vector unsigned int){20,21,22,23}, |
| 76 |
(vector unsigned int){30,31,32,33}); |
| 77 |
return 0; |
| 78 |
} |
| 79 |
|
| 80 |
int main (void) |
| 81 |
{ |
| 82 |
return main1 (); |
| 83 |
} |