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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [dfp-test.c] - Blame information for rev 841

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

Line No. Rev Author Line
1 24 jeremybenn
/* This testcase is part of GDB, the GNU debugger.
2
 
3
   Copyright 2007, 2008 Free Software Foundation, Inc.
4
 
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3 of the License, or
8
   (at your option) any later version.
9
 
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
 
18
#include <stdio.h>
19
#include <stdlib.h>
20
 
21
#define DELTA (0.0001df)
22
#define DELTA_B (0.001)
23
 
24
double double_val1 = 45.125;
25
double double_val2 = -67.75;
26
double double_val3 = 0.25;
27
double double_val4 = 1.25;
28
double double_val5 = 2.25;
29
double double_val6 = 3.25;
30
double double_val7 = 4.25;
31
double double_val8 = 5.25;
32
double double_val9 = 6.25;
33
double double_val10 = 7.25;
34
double double_val11 = 8.25;
35
double double_val12 = 9.25;
36
double double_val13 = 10.25;
37
double double_val14 = 11.25;
38
 
39
_Decimal32 dec32_val1 = 3.14159df;
40
_Decimal32 dec32_val2 = -2.3765df;
41
_Decimal32 dec32_val3 = 0.2df;
42
_Decimal32 dec32_val4 = 1.2df;
43
_Decimal32 dec32_val5 = 2.2df;
44
_Decimal32 dec32_val6 = 3.2df;
45
_Decimal32 dec32_val7 = 4.2df;
46
_Decimal32 dec32_val8 = 5.2df;
47
_Decimal32 dec32_val9 = 6.2df;
48
_Decimal32 dec32_val10 = 7.2df;
49
_Decimal32 dec32_val11 = 8.2df;
50
_Decimal32 dec32_val12 = 9.2df;
51
_Decimal32 dec32_val13 = 10.2df;
52
_Decimal32 dec32_val14 = 11.2df;
53
_Decimal32 dec32_val15 = 12.2df;
54
_Decimal32 dec32_val16 = 13.2df;
55
 
56
_Decimal64 dec64_val1 = 3.14159dd;
57
_Decimal64 dec64_val2 = -2.3765dd;
58
_Decimal64 dec64_val3 = 0.2dd;
59
_Decimal64 dec64_val4 = 1.2dd;
60
_Decimal64 dec64_val5 = 2.2dd;
61
_Decimal64 dec64_val6 = 3.2dd;
62
_Decimal64 dec64_val7 = 4.2dd;
63
_Decimal64 dec64_val8 = 5.2dd;
64
_Decimal64 dec64_val9 = 6.2dd;
65
_Decimal64 dec64_val10 = 7.2dd;
66
_Decimal64 dec64_val11 = 8.2dd;
67
_Decimal64 dec64_val12 = 9.2dd;
68
_Decimal64 dec64_val13 = 10.2dd;
69
_Decimal64 dec64_val14 = 11.2dd;
70
_Decimal64 dec64_val15 = 12.2dd;
71
_Decimal64 dec64_val16 = 13.2dd;
72
 
73
_Decimal128 dec128_val1 = 3.14159dl;
74
_Decimal128 dec128_val2 = -2.3765dl;
75
_Decimal128 dec128_val3 = 0.2dl;
76
_Decimal128 dec128_val4 = 1.2dl;
77
_Decimal128 dec128_val5 = 2.2dl;
78
_Decimal128 dec128_val6 = 3.2dl;
79
_Decimal128 dec128_val7 = 4.2dl;
80
_Decimal128 dec128_val8 = 5.2dl;
81
_Decimal128 dec128_val9 = 6.2dl;
82
_Decimal128 dec128_val10 = 7.2dl;
83
_Decimal128 dec128_val11 = 8.2dl;
84
_Decimal128 dec128_val12 = 9.2dl;
85
_Decimal128 dec128_val13 = 10.2dl;
86
_Decimal128 dec128_val14 = 11.2dl;
87
_Decimal128 dec128_val15 = 12.2dl;
88
_Decimal128 dec128_val16 = 13.2dl;
89
 
90
volatile _Decimal32 d32;
91
volatile _Decimal64 d64;
92
volatile _Decimal128 d128;
93
 
94
struct decstruct
95
{
96
  int int4;
97
  long long8;
98
  float float4;
99
  double double8;
100
  _Decimal32 dec32;
101
  _Decimal64 dec64;
102
  _Decimal128 dec128;
103
} ds;
104
 
105
static _Decimal32
106
arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
107
         _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
108
{
109
  return arg0;
110
}
111
 
112
static _Decimal64
113
arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
114
         _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
115
{
116
  return arg0;
117
}
118
 
119
static _Decimal128
120
arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
121
         _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
122
{
123
  return arg0;
124
}
125
 
126
/* Function to test if _Decimal128 argument interferes with stack slots
127
   because of alignment.  */
128
int
129
decimal_dec128_align (double arg0, _Decimal128 arg1, double arg2, double arg3,
130
                      double arg4, double arg5, double arg6, double arg7,
131
                      double arg8, double arg9, double arg10, double arg11,
132
                      double arg12, double arg13)
133
{
134
  return ((arg0 - double_val1) < DELTA_B
135
          && (arg0 - double_val1) > -DELTA_B
136
          && (arg1 - dec128_val2) < DELTA
137
          && (arg1 - dec128_val2) > -DELTA
138
          && (arg2 - double_val3) < DELTA_B
139
          && (arg2 - double_val3) > -DELTA_B
140
          && (arg3 - double_val4) < DELTA_B
141
          && (arg3 - double_val4) > -DELTA_B
142
          && (arg4 - double_val5) < DELTA_B
143
          && (arg4 - double_val5) > -DELTA_B
144
          && (arg5 - double_val6) < DELTA_B
145
          && (arg5 - double_val6) > -DELTA_B
146
          && (arg6 - double_val7) < DELTA_B
147
          && (arg6 - double_val7) > -DELTA_B
148
          && (arg7 - double_val8) < DELTA_B
149
          && (arg7 - double_val8) > -DELTA_B
150
          && (arg8 - double_val9) < DELTA_B
151
          && (arg8 - double_val9) > -DELTA_B
152
          && (arg9 - double_val10) < DELTA_B
153
          && (arg9 - double_val10) > -DELTA_B
154
          && (arg10 - double_val11) < DELTA_B
155
          && (arg10 - double_val11) > -DELTA_B
156
          && (arg11 - double_val12) < DELTA_B
157
          && (arg11 - double_val12) > -DELTA_B
158
          && (arg12 - double_val13) < DELTA_B
159
          && (arg12 - double_val13) > -DELTA_B
160
          && (arg13 - double_val14) < DELTA_B
161
          && (arg13 - double_val14) > -DELTA_B);
162
}
163
 
164
int
165
decimal_mixed (_Decimal32 arg0, _Decimal64 arg1, _Decimal128 arg2)
166
{
167
  return ((arg0 - dec32_val1) < DELTA
168
          && (arg0 - dec32_val1) > -DELTA
169
          && (arg1 - dec64_val1) < DELTA
170
          && (arg1 - dec64_val1) > -DELTA
171
          && (arg2 - dec128_val1) < DELTA
172
          && (arg2 - dec128_val1) > -DELTA);
173
}
174
 
175
/* These functions have many arguments to force some of them to be passed via
176
   the stack instead of registers, to test that GDB can construct correctly
177
   the parameter save area. Note that Linux/ppc32 has 8 float registers to use
178
   for float parameter passing and Linux/ppc64 has 13, so the number of
179
   arguments has to be at least 14 to contemplate these platforms.  */
180
 
181
int
182
decimal_many_args_dec32 (_Decimal32 f1, _Decimal32 f2, _Decimal32 f3,
183
                            _Decimal32 f4, _Decimal32 f5, _Decimal32 f6,
184
                            _Decimal32 f7, _Decimal32 f8, _Decimal32 f9,
185
                            _Decimal32 f10, _Decimal32 f11, _Decimal32 f12,
186
                            _Decimal32 f13, _Decimal32 f14, _Decimal32 f15,
187
                            _Decimal32 f16)
188
{
189
  _Decimal32 sum_args;
190
  _Decimal32 sum_values;
191
 
192
  sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
193
             + f13 + f14 + f15 + f16;
194
  sum_values = dec32_val1 + dec32_val2 + dec32_val3 + dec32_val4 + dec32_val5
195
               + dec32_val6 + dec32_val7 + dec32_val8 + dec32_val9
196
               + dec32_val10 + dec32_val11 + dec32_val12 + dec32_val13
197
               + dec32_val14 + dec32_val15 + dec32_val16;
198
 
199
  return ((sum_args - sum_values) < DELTA
200
          && (sum_args - sum_values) > -DELTA);
201
}
202
 
203
int
204
decimal_many_args_dec64 (_Decimal64 f1, _Decimal64 f2, _Decimal64 f3,
205
                            _Decimal64 f4, _Decimal64 f5, _Decimal64 f6,
206
                            _Decimal64 f7, _Decimal64 f8, _Decimal64 f9,
207
                            _Decimal64 f10, _Decimal64 f11, _Decimal64 f12,
208
                            _Decimal64 f13, _Decimal64 f14, _Decimal64 f15,
209
                            _Decimal64 f16)
210
{
211
  _Decimal64 sum_args;
212
  _Decimal64 sum_values;
213
 
214
  sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
215
             + f13 + f14 + f15 + f16;
216
  sum_values = dec64_val1 + dec64_val2 + dec64_val3 + dec64_val4 + dec64_val5
217
               + dec64_val6 + dec64_val7 + dec64_val8 + dec64_val9
218
               + dec64_val10 + dec64_val11 + dec64_val12 + dec64_val13
219
               + dec64_val14 + dec64_val15 + dec64_val16;
220
 
221
  return ((sum_args - sum_values) < DELTA
222
          && (sum_args - sum_values) > -DELTA);
223
}
224
 
225
int
226
decimal_many_args_dec128 (_Decimal128 f1, _Decimal128 f2, _Decimal128 f3,
227
                            _Decimal128 f4, _Decimal128 f5, _Decimal128 f6,
228
                            _Decimal128 f7, _Decimal128 f8, _Decimal128 f9,
229
                            _Decimal128 f10, _Decimal128 f11, _Decimal128 f12,
230
                            _Decimal128 f13, _Decimal128 f14, _Decimal128 f15,
231
                            _Decimal128 f16)
232
{
233
  _Decimal128 sum_args;
234
  _Decimal128 sum_values;
235
 
236
  sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
237
             + f13 + f14 + f15 + f16;
238
  sum_values = dec128_val1 + dec128_val2 + dec128_val3 + dec128_val4 + dec128_val5
239
               + dec128_val6 + dec128_val7 + dec128_val8 + dec128_val9
240
               + dec128_val10 + dec128_val11 + dec128_val12 + dec128_val13
241
               + dec128_val14 + dec128_val15 + dec128_val16;
242
 
243
  return ((sum_args - sum_values) < DELTA
244
          && (sum_args - sum_values) > -DELTA);
245
}
246
 
247
int
248
decimal_many_args_mixed (_Decimal32 f1, _Decimal32 f2, _Decimal32 f3,
249
                           _Decimal64 f4, _Decimal64 f5, _Decimal64 f6,
250
                           _Decimal64 f7, _Decimal128 f8, _Decimal128 f9,
251
                           _Decimal128 f10, _Decimal32 f11, _Decimal64 f12,
252
                           _Decimal32 f13, _Decimal64 f14, _Decimal128 f15)
253
{
254
  _Decimal128 sum_args;
255
  _Decimal128 sum_values;
256
 
257
  sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
258
             + f13 + f14 + f15;
259
  sum_values = dec32_val1 + dec32_val2 + dec32_val3 + dec64_val4 + dec64_val5
260
               + dec64_val6 + dec64_val7 + dec128_val8 + dec128_val9
261
               + dec128_val10 + dec32_val11 + dec64_val12 + dec32_val13
262
               + dec64_val14 + dec128_val15;
263
 
264
  return ((sum_args - sum_values) < DELTA
265
          && (sum_args - sum_values) > -DELTA);
266
}
267
 
268
int main()
269
{
270
  /* An finite 32-bits decimal floating point.  */
271
  d32 = 1.2345df;               /* Initialize d32.  */
272
 
273
  /* Non-finite 32-bits decimal floating point: infinity and NaN.  */
274
  d32 = __builtin_infd32();     /* Positive infd32.  */
275
  d32 = -__builtin_infd32();    /* Negative infd32.  */
276
  d32 = __builtin_nand32("");
277
 
278
  /* An finite 64-bits decimal floating point.  */
279
  d64 = 1.2345dd;               /* Initialize d64.  */
280
 
281
  /* Non-finite 64-bits decimal floating point: infinity and NaN.  */
282
  d64 = __builtin_infd64();     /* Positive infd64.  */
283
  d64 = -__builtin_infd64();    /* Negative infd64.  */
284
  d64 = __builtin_nand64("");
285
 
286
  /* An finite 128-bits decimal floating point.  */
287
  d128 = 1.2345dl;              /* Initialize d128.  */
288
 
289
  /* Non-finite 128-bits decimal floating point: infinity and NaN.  */
290
  d128 = __builtin_infd128();   /* Positive infd128.  */
291
  d128 = -__builtin_infd128();  /* Negative infd128.  */
292
  d128 = __builtin_nand128("");
293
 
294
  /* Functions with decimal floating point as parameter and return value. */
295
  d32 = arg0_32 (0.1df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df);
296
  d64 = arg0_64 (0.1dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd);
297
  d128 = arg0_128 (0.1dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl);
298
 
299
  ds.int4 = 1;
300
  ds.long8 = 2;
301
  ds.float4 = 3.1;
302
  ds.double8 = 4.2;
303
  ds.dec32 = 1.2345df;
304
  ds.dec64 = 1.2345dd;
305
  ds.dec128 = 1.2345dl;
306
 
307
  return 0;      /* Exit point.  */
308
}

powered by: WebSVN 2.1.0

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