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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.target/] [x86_64/] [abi/] [test_passing_unions.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* This tests passing of structs. Only integers are tested.  */
2
 
3
#include "defines.h"
4
#include "args.h"
5
 
6
struct IntegerRegisters iregs;
7
struct FloatRegisters fregs;
8
unsigned int num_iregs, num_fregs;
9
 
10
struct int_struct
11
{
12
  int i;
13
};
14
 
15
struct long_struct
16
{
17
  long l;
18
};
19
 
20
union un1
21
{
22
  char c;
23
  int i;
24
};
25
 
26
union un2
27
{
28
  char c1;
29
  long l;
30
  char c2;
31
};
32
 
33
union un3
34
{
35
  struct int_struct is;
36
  struct long_struct ls;
37
  union un1 un;
38
};
39
 
40
 
41
void
42
check_union_passing1(union un1 u ATTRIBUTE_UNUSED)
43
{
44
  check_int_arguments;
45
}
46
 
47
void
48
check_union_passing2(union un2 u ATTRIBUTE_UNUSED)
49
{
50
  check_int_arguments;
51
}
52
 
53
void
54
check_union_passing3(union un3 u ATTRIBUTE_UNUSED)
55
{
56
  check_int_arguments;
57
}
58
 
59
#define check_union_passing1 WRAP_CALL(check_union_passing1)
60
#define check_union_passing2 WRAP_CALL(check_union_passing2)
61
#define check_union_passing3 WRAP_CALL(check_union_passing3)
62
 
63
int
64
main (void)
65
{
66
  union un1 u1;
67
#ifdef CHECK_LARGER_UNION_PASSING
68
  union un2 u2;
69
  union un3 u3;
70
  struct int_struct is;
71
  struct long_struct ls;
72
#endif /* CHECK_LARGER_UNION_PASSING */
73
 
74
  /* Check a union with char, int.  */
75
  clear_struct_registers;
76
  u1.i = 0;  /* clear the struct to not have high bits left */
77
  u1.c = 32;
78
  iregs.I0 = 32;
79
  num_iregs = 1;
80
  clear_int_hardware_registers;
81
  check_union_passing1(u1);
82
  u1.i = 0;  /* clear the struct to not have high bits left */
83
  u1.i = 33;
84
  iregs.I0 = 33;
85
  num_iregs = 1;
86
  clear_int_hardware_registers;
87
  check_union_passing1(u1);
88
 
89
  /* Check a union with char, long, char.  */
90
#ifdef CHECK_LARGER_UNION_PASSING
91
  clear_struct_registers;
92
  u2.l = 0;  /* clear the struct to not have high bits left */
93
  u2.c1 = 34;
94
  iregs.I0 = 34;
95
  num_iregs = 1;
96
  clear_int_hardware_registers;
97
  check_union_passing2(u2);
98
  u2.l = 0;  /* clear the struct to not have high bits left */
99
  u2.l = 35;
100
  iregs.I0 = 35;
101
  num_iregs = 1;
102
  clear_int_hardware_registers;
103
  check_union_passing2(u2);
104
  u2.l = 0;  /* clear the struct to not have high bits left */
105
  u2.c2 = 36;
106
  iregs.I0 = 36;
107
  num_iregs = 1;
108
  clear_int_hardware_registers;
109
  check_union_passing2(u2);
110
 
111
  /* check a union containing two structs and a union.  */
112
  clear_struct_registers;
113
  is.i = 37;
114
  u3.ls.l = 0;  /* clear the struct to not have high bits left */
115
  u3.is = is;
116
  iregs.I0 = 37;
117
  num_iregs = 1;
118
  clear_int_hardware_registers;
119
  check_union_passing3(u3);
120
  ls.l = 38;
121
  u3.ls.l = 0;  /* clear the struct to not have high bits left */
122
  u3.ls = ls;
123
  iregs.I0 = 38;
124
  num_iregs = 1;
125
  clear_int_hardware_registers;
126
  check_union_passing3(u3);
127
  u1.c = 39;
128
  u3.ls.l = 0;  /* clear the struct to not have high bits left */
129
  u3.un = u1;
130
  iregs.I0 = 39;
131
  num_iregs = 1;
132
  clear_int_hardware_registers;
133
  check_union_passing3(u3);
134
  u1.i = 40;
135
  u3.ls.l = 0;  /* clear the struct to not have high bits left */
136
  u3.un = u1;
137
  iregs.I0 = 40;
138
  num_iregs = 1;
139
  clear_int_hardware_registers;
140
  check_union_passing3(u3);
141
#endif /* CHECK_LARGER_UNION_PASSING */
142
 
143
  return 0;
144
}

powered by: WebSVN 2.1.0

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