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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [ppc64-abi-dfp-1.c] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 322 jeremybenn
/* { dg-do run { target { powerpc64-*-* && { lp64 && dfprt } } } } */
2
/* { dg-options "-std=gnu99 -O2 -fno-strict-aliasing" } */
3
 
4
/* Testcase to check for ABI compliance of parameter passing
5
   for the PowerPC64 ELF ABI for decimal float values.  */
6
 
7
extern void abort (void);
8
int failcnt = 0;
9
 
10
/* Support compiling the test to report individual failures; default is
11
   to abort as soon as a check fails.  */
12
#ifdef DBG
13
#include <stdio.h>
14
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
15
#else
16
#define FAILURE abort ();
17
#endif
18
 
19
typedef struct
20
{
21
  int pad;
22
  _Decimal32 d;
23
} d32parm_t;
24
 
25
typedef struct
26
{
27
  unsigned long gprs[8];
28
  double fprs[13];
29
} reg_parms_t;
30
 
31
reg_parms_t gparms;
32
 
33
 
34
/* Testcase could break on future gcc's, if parameter regs
35
   are changed before this asm.  */
36
 
37
#ifndef __MACH__
38
#define save_parms(lparms)                              \
39
    asm volatile ("ld 11,gparms@got(2)\n\t"                \
40
                  "std 3,0(11)\n\t"                     \
41
                  "std 4,8(11)\n\t"                     \
42
                  "std 5,16(11)\n\t"                    \
43
                  "std 6,24(11)\n\t"                    \
44
                  "std 7,32(11)\n\t"                    \
45
                  "std 8,40(11)\n\t"                    \
46
                  "std 9,48(11)\n\t"                    \
47
                  "std 10,56(11)\n\t"                   \
48
                  "stfd 1,64(11)\n\t"                   \
49
                  "stfd 2,72(11)\n\t"                   \
50
                  "stfd 3,80(11)\n\t"                   \
51
                  "stfd 4,88(11)\n\t"                   \
52
                  "stfd 5,96(11)\n\t"                   \
53
                  "stfd 6,104(11)\n\t"                  \
54
                  "stfd 7,112(11)\n\t"                  \
55
                  "stfd 8,120(11)\n\t"                  \
56
                  "stfd 9,128(11)\n\t"                  \
57
                  "stfd 10,136(11)\n\t"                 \
58
                  "stfd 11,144(11)\n\t"                 \
59
                  "stfd 12,152(11)\n\t"                 \
60
                  "stfd 13,160(11)\n\t":::"11", "memory");  \
61
                  lparms = gparms;
62
#else
63
#define save_parms(lparms)                              \
64
    asm volatile ("ld r11,gparms@got(r2)\n\t"           \
65
                  "std r3,0(r11)\n\t"                   \
66
                  "std r4,8(r11)\n\t"                   \
67
                  "std r5,16(r11)\n\t"                  \
68
                  "std r6,24(r11)\n\t"                  \
69
                  "std r7,32(r11)\n\t"                  \
70
                  "std r8,40(r11)\n\t"                  \
71
                  "std r9,48(r11)\n\t"                  \
72
                  "std r10,56(r11)\n\t"                 \
73
                  "stfd f1,64(r11)\n\t"                 \
74
                  "stfd f2,72(r11)\n\t"                 \
75
                  "stfd f3,80(r11)\n\t"                 \
76
                  "stfd f4,88(r11)\n\t"                 \
77
                  "stfd f5,96(r11)\n\t"                 \
78
                  "stfd f6,104(r11)\n\t"                \
79
                  "stfd f7,112(r11)\n\t"                \
80
                  "stfd f8,120(r11)\n\t"                \
81
                  "stfd f9,128(r11)\n\t"                \
82
                  "stfd f10,136(r11)\n\t"               \
83
                  "stfd f11,144(r11)\n\t"               \
84
                  "stfd f12,152(r11)\n\t"               \
85
                  "stfd f13,160(r11)\n\t":::"r11", "memory");  \
86
                  lparms = gparms;
87
#endif
88
 
89
typedef struct sf
90
{
91
  struct sf *backchain;
92
  long a1;
93
  long a2;
94
  long a3;
95
  long a4;
96
  long a5;
97
  unsigned long slot[100];
98
} stack_frame_t;
99
 
100
/* Fill up floating point registers with double arguments, forcing
101
   decimal float arguments into the parameter save area.  */
102
void __attribute__ ((noinline))
103
func0 (double a1, double a2, double a3, double a4, double a5, double a6,
104
       double a7, double a8, double a9, double a10, double a11, double a12,
105
       double a13, double a14,
106
       _Decimal64 a15, _Decimal128 a16, _Decimal64 a17)
107
{
108
  reg_parms_t lparms;
109
  stack_frame_t *sp;
110
 
111
  save_parms (lparms);
112
  sp = __builtin_frame_address (0);
113
  sp = sp->backchain;
114
 
115
  if (a1 != lparms.fprs[0]) FAILURE
116
  if (a2 != lparms.fprs[1]) FAILURE
117
  if (a3 != lparms.fprs[2]) FAILURE
118
  if (a4 != lparms.fprs[3]) FAILURE
119
  if (a5 != lparms.fprs[4]) FAILURE
120
  if (a6 != lparms.fprs[5]) FAILURE
121
  if (a7 != lparms.fprs[6]) FAILURE
122
  if (a8 != lparms.fprs[7]) FAILURE
123
  if (a9 != lparms.fprs[8]) FAILURE
124
  if (a10 != lparms.fprs[9]) FAILURE
125
  if (a11 != lparms.fprs[10]) FAILURE
126
  if (a12 != lparms.fprs[11]) FAILURE
127
  if (a13 != lparms.fprs[12]) FAILURE
128
  if (a14 != *(double *)&sp->slot[13]) FAILURE
129
  if (a15 != *(_Decimal64 *)&sp->slot[14]) FAILURE
130
  if (a16 != *(_Decimal128 *)&sp->slot[15]) FAILURE
131
  if (a17 != *(_Decimal64 *)&sp->slot[17]) FAILURE
132
}
133
 
134
void __attribute__ ((noinline))
135
func1 (double a1, double a2, double a3, double a4, double a5, double a6,
136
       double a7, double a8, double a9, double a10, double a11, double a12,
137
       double a13, _Decimal128 a14)
138
{
139
  reg_parms_t lparms;
140
  stack_frame_t *sp;
141
 
142
  save_parms (lparms);
143
  sp = __builtin_frame_address (0);
144
  sp = sp->backchain;
145
 
146
  if (a1 != lparms.fprs[0]) FAILURE
147
  if (a2 != lparms.fprs[1]) FAILURE
148
  if (a3 != lparms.fprs[2]) FAILURE
149
  if (a4 != lparms.fprs[3]) FAILURE
150
  if (a5 != lparms.fprs[4]) FAILURE
151
  if (a6 != lparms.fprs[5]) FAILURE
152
  if (a7 != lparms.fprs[6]) FAILURE
153
  if (a8 != lparms.fprs[7]) FAILURE
154
  if (a9 != lparms.fprs[8]) FAILURE
155
  if (a10 != lparms.fprs[9]) FAILURE
156
  if (a11 != lparms.fprs[10]) FAILURE
157
  if (a12 != lparms.fprs[11]) FAILURE
158
  if (a13 != lparms.fprs[12]) FAILURE
159
  if (a14 != *(_Decimal128 *)&sp->slot[13]) FAILURE
160
}
161
 
162
void __attribute__ ((noinline))
163
func2 (double a1, double a2, double a3, double a4, double a5, double a6,
164
       double a7, double a8, double a9, double a10, double a11, double a12,
165
       _Decimal128 a13)
166
{
167
  reg_parms_t lparms;
168
  stack_frame_t *sp;
169
 
170
  save_parms (lparms);
171
  sp = __builtin_frame_address (0);
172
  sp = sp->backchain;
173
 
174
  if (a1 != lparms.fprs[0]) FAILURE
175
  if (a2 != lparms.fprs[1]) FAILURE
176
  if (a3 != lparms.fprs[2]) FAILURE
177
  if (a4 != lparms.fprs[3]) FAILURE
178
  if (a5 != lparms.fprs[4]) FAILURE
179
  if (a6 != lparms.fprs[5]) FAILURE
180
  if (a7 != lparms.fprs[6]) FAILURE
181
  if (a8 != lparms.fprs[7]) FAILURE
182
  if (a9 != lparms.fprs[8]) FAILURE
183
  if (a10 != lparms.fprs[9]) FAILURE
184
  if (a11 != lparms.fprs[10]) FAILURE
185
  if (a12 != lparms.fprs[11]) FAILURE
186
  if (a13 != *(_Decimal128 *)&sp->slot[12]) FAILURE
187
}
188
 
189
void __attribute__ ((noinline))
190
func3 (_Decimal64 a1, _Decimal128 a2, _Decimal64 a3, _Decimal128 a4,
191
       _Decimal64 a5, _Decimal128 a6, _Decimal64 a7, _Decimal128 a8,
192
       _Decimal64 a9, _Decimal128 a10)
193
{
194
  reg_parms_t lparms;
195
  stack_frame_t *sp;
196
 
197
  save_parms (lparms);
198
  sp = __builtin_frame_address (0);
199
  sp = sp->backchain;
200
 
201
  if (a1 != *(_Decimal64 *)&lparms.fprs[0]) FAILURE      /* f1        */
202
  if (a2 != *(_Decimal128 *)&lparms.fprs[1]) FAILURE    /* f2 & f3   */
203
  if (a3 != *(_Decimal64 *)&lparms.fprs[3]) FAILURE     /* f4        */
204
  if (a4 != *(_Decimal128 *)&lparms.fprs[5]) FAILURE    /* f6 & f7   */
205
  if (a5 != *(_Decimal64 *)&lparms.fprs[7]) FAILURE     /* f8        */
206
  if (a6 != *(_Decimal128 *)&lparms.fprs[9]) FAILURE    /* f10 & f11 */
207
  if (a7 != *(_Decimal64 *)&lparms.fprs[11]) FAILURE    /* f12       */
208
  if (a8 != *(_Decimal128 *)&sp->slot[10]) FAILURE
209
  if (a9 != *(_Decimal64 *)&sp->slot[12]) FAILURE
210
  if (a10 != *(_Decimal128 *)&sp->slot[13]) FAILURE
211
}
212
 
213
void __attribute__ ((noinline))
214
func4 (_Decimal128 a1, _Decimal64 a2, _Decimal128 a3, _Decimal64 a4,
215
       _Decimal128 a5, _Decimal64 a6, _Decimal128 a7, _Decimal64 a8)
216
{
217
  reg_parms_t lparms;
218
  stack_frame_t *sp;
219
 
220
  save_parms (lparms);
221
  sp = __builtin_frame_address (0);
222
  sp = sp->backchain;
223
 
224
  if (a1 != *(_Decimal128 *)&lparms.fprs[1]) FAILURE    /* f2 & f3   */
225
  if (a2 != *(_Decimal64 *)&lparms.fprs[3]) FAILURE     /* f4        */
226
  if (a3 != *(_Decimal128 *)&lparms.fprs[5]) FAILURE    /* f6 & f7   */
227
  if (a4 != *(_Decimal64 *)&lparms.fprs[7]) FAILURE     /* f8        */
228
  if (a5 != *(_Decimal128 *)&lparms.fprs[9]) FAILURE    /* f10 & f11 */
229
  if (a6 != *(_Decimal64 *)&lparms.fprs[11]) FAILURE    /* f12       */
230
  if (a7 != *(_Decimal128 *)&sp->slot[9]) FAILURE
231
  if (a8 != *(_Decimal64 *)&sp->slot[11]) FAILURE
232
}
233
 
234
void __attribute__ ((noinline))
235
func5 (_Decimal32 a1, _Decimal32 a2, _Decimal32 a3, _Decimal32 a4,
236
       _Decimal32 a5, _Decimal32 a6, _Decimal32 a7, _Decimal32 a8,
237
       _Decimal32 a9, _Decimal32 a10, _Decimal32 a11, _Decimal32 a12,
238
       _Decimal32 a13, _Decimal32 a14, _Decimal32 a15, _Decimal32 a16)
239
{
240
  reg_parms_t lparms;
241
  stack_frame_t *sp;
242
 
243
  save_parms (lparms);
244
  sp = __builtin_frame_address (0);
245
  sp = sp->backchain;
246
 
247
  /* _Decimal32 is passed in the lower half of an FPR or parameter slot.  */
248
  if (a1 != ((d32parm_t *)&lparms.fprs[0])->d) FAILURE           /* f1  */
249
  if (a2 != ((d32parm_t *)&lparms.fprs[1])->d) FAILURE          /* f2  */
250
  if (a3 != ((d32parm_t *)&lparms.fprs[2])->d) FAILURE          /* f3  */
251
  if (a4 != ((d32parm_t *)&lparms.fprs[3])->d) FAILURE          /* f4  */
252
  if (a5 != ((d32parm_t *)&lparms.fprs[4])->d) FAILURE          /* f5  */
253
  if (a6 != ((d32parm_t *)&lparms.fprs[5])->d) FAILURE          /* f6  */
254
  if (a7 != ((d32parm_t *)&lparms.fprs[6])->d) FAILURE          /* f7  */
255
  if (a8 != ((d32parm_t *)&lparms.fprs[7])->d) FAILURE          /* f8  */
256
  if (a9 != ((d32parm_t *)&lparms.fprs[8])->d) FAILURE          /* f9  */
257
  if (a10 != ((d32parm_t *)&lparms.fprs[9])->d) FAILURE         /* f10 */
258
  if (a11 != ((d32parm_t *)&lparms.fprs[10])->d) FAILURE        /* f11 */
259
  if (a12 != ((d32parm_t *)&lparms.fprs[11])->d) FAILURE        /* f12 */
260
  if (a13 != ((d32parm_t *)&lparms.fprs[12])->d) FAILURE        /* f13 */
261
  if (a14 != ((d32parm_t *)&sp->slot[13])->d) FAILURE
262
  if (a15 != ((d32parm_t *)&sp->slot[14])->d) FAILURE
263
  if (a16 != ((d32parm_t *)&sp->slot[15])->d) FAILURE
264
}
265
 
266
void __attribute__ ((noinline))
267
func6 (_Decimal32 a1, _Decimal64 a2, _Decimal128 a3,
268
       _Decimal32 a4, _Decimal64 a5, _Decimal128 a6,
269
       _Decimal32 a7, _Decimal64 a8, _Decimal128 a9,
270
       _Decimal32 a10, _Decimal64 a11, _Decimal128 a12)
271
{
272
  reg_parms_t lparms;
273
  stack_frame_t *sp;
274
 
275
  save_parms (lparms);
276
  sp = __builtin_frame_address (0);
277
  sp = sp->backchain;
278
 
279
  if (a1 != ((d32parm_t *)&lparms.fprs[0])->d) FAILURE           /* f1        */
280
  if (a2 != *(_Decimal64 *)&lparms.fprs[1]) FAILURE             /* f2        */
281
  if (a3 != *(_Decimal128 *)&lparms.fprs[3]) FAILURE            /* f4 & f5   */
282
  if (a4 != ((d32parm_t *)&lparms.fprs[5])->d) FAILURE          /* f6        */
283
  if (a5 != *(_Decimal64 *)&lparms.fprs[6]) FAILURE             /* f7        */
284
  if (a6 != *(_Decimal128 *)&lparms.fprs[7]) FAILURE            /* f8 & f9   */
285
  if (a7 != ((d32parm_t *)&lparms.fprs[9])->d) FAILURE          /* f10       */
286
  if (a8 != *(_Decimal64 *)&lparms.fprs[10]) FAILURE            /* f11       */
287
  if (a9 != *(_Decimal128 *)&lparms.fprs[11]) FAILURE           /* f12 & f13 */
288
  if (a10 != ((d32parm_t *)&sp->slot[12])->d) FAILURE
289
  if (a11 != *(_Decimal64 *)&sp->slot[13]) FAILURE
290
}
291
 
292
int
293
main (void)
294
{
295
  func0 (1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5,
296
         14.5, 15.2dd, 16.2dl, 17.2dd);
297
  func1 (101.5, 102.5, 103.5, 104.5, 105.5, 106.5, 107.5, 108.5, 109.5,
298
         110.5, 111.5, 112.5, 113.5, 114.2dd);
299
  func2 (201.5, 202.5, 203.5, 204.5, 205.5, 206.5, 207.5, 208.5, 209.5,
300
         210.5, 211.5, 212.5, 213.2dd);
301
  func3 (301.2dd, 302.2dl, 303.2dd, 304.2dl, 305.2dd, 306.2dl, 307.2dd,
302
         308.2dl, 309.2dd, 310.2dl);
303
  func4 (401.2dl, 402.2dd, 403.2dl, 404.2dd, 405.2dl, 406.2dd, 407.2dl,
304
         408.2dd);
305
#if 0
306
  /* _Decimal32 doesn't yet follow the ABI; enable this when it does.  */
307
  func5 (501.2df, 502.2df, 503.2df, 504.2df, 505.2df, 506.2df, 507.2df,
308
         508.2df, 509.2df, 510.2df, 511.2df, 512.2df, 513.2df, 514.2df,
309
         515.2df, 516.2df);
310
  func6 (601.2df, 602.2dd, 603.2dl, 604.2df, 605.2dd, 606.2dl,
311
         607.2df, 608.2dd, 609.2dl, 610.2df, 611.2dd, 612.2dl);
312
#endif
313
 
314
  if (failcnt != 0)
315
    abort ();
316
 
317
  return 0;
318
}

powered by: WebSVN 2.1.0

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