diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c')
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c b/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c new file mode 100644 index 000000000..1349ae590 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c @@ -0,0 +1,82 @@ +/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ +/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec -mabi=altivec -fno-inline" } */ + +#include <stdarg.h> + +extern void exit (int); +extern void abort (void); + +#define vector __attribute__((vector_size (16))) + +const vector unsigned int v1 = {10,11,12,13}; +const vector unsigned int v2 = {20,21,22,23}; +const vector unsigned int v3 = {30,31,32,33}; +const vector unsigned int v4 = {40,41,42,43}; + +void foo(vector unsigned int a, ...) +{ + va_list args; + vector unsigned int v; + + va_start (args, a); + if (memcmp (&a, &v1, sizeof (v)) != 0) + abort (); + v = va_arg (args, vector unsigned int); + if (memcmp (&v, &v2, sizeof (v)) != 0) + abort (); + v = va_arg (args, vector unsigned int); + if (memcmp (&v, &v3, sizeof (v)) != 0) + abort (); + v = va_arg (args, vector unsigned int); + if (memcmp (&v, &v4, sizeof (v)) != 0) + abort (); + va_end (args); +} + +void bar(vector unsigned int a, ...) +{ + va_list args; + vector unsigned int v; + int b; + + va_start (args, a); + if (memcmp (&a, &v1, sizeof (v)) != 0) + abort (); + b = va_arg (args, int); + if (b != 2) + abort (); + v = va_arg (args, vector unsigned int); + if (memcmp (&v, &v2, sizeof (v)) != 0) + abort (); + v = va_arg (args, vector unsigned int); + if (memcmp (&v, &v3, sizeof (v)) != 0) + abort (); + va_end (args); +} + + +int main1(void) +{ + /* In this call, in the Darwin ABI, the first argument goes into v2 + the second one into r9-r10 and memory, + and the next two in memory. */ + foo ((vector unsigned int){10,11,12,13}, + (vector unsigned int){20,21,22,23}, + (vector unsigned int){30,31,32,33}, + (vector unsigned int){40,41,42,43}); + /* In this call, in the Darwin ABI, the first argument goes into v2 + the second one into r9, then r10 is reserved and + there are two words of padding in memory, and the next two arguments + go after the padding. */ + bar ((vector unsigned int){10,11,12,13}, 2, + (vector unsigned int){20,21,22,23}, + (vector unsigned int){30,31,32,33}); + return 0; +} + +int main (void) +{ + return main1 (); +} |