OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [altivec-varargs-1.c] - Blame information for rev 816

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.