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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [config/] [s390/] [fixdfdi.h] - Blame information for rev 825

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

Line No. Rev Author Line
1 38 julius
/* Definitions of target machine for GNU compiler, for IBM S/390
2
   Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
3
   Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4
                  Ulrich Weigand (uweigand@de.ibm.com).
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify it under
9
the terms of the GNU General Public License as published by the Free
10
Software Foundation; either version 3, or (at your option) any later
11
version.
12
 
13
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14
WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16
for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with GCC; see the file COPYING3.  If not see
20
<http://www.gnu.org/licenses/>.  */
21
 
22
#ifdef L_fixunstfdi
23
 
24
#define EXPD(fp)           (((fp.l.i[0]) >> 16) & 0x7FFF)
25
#define EXPONENT_BIAS      16383
26
#define MANTISSA_BITS      112
27
#define PRECISION          (MANTISSA_BITS + 1)
28
#define SIGNBIT            0x80000000
29
#define SIGND(fp)          ((fp.l.i[0]) & SIGNBIT)
30
#define MANTD_HIGH_LL(fp)  ((fp.ll[0] & HIGH_LL_FRAC_MASK) | HIGH_LL_UNIT_BIT)
31
#define MANTD_LOW_LL(fp)   (fp.ll[1])
32
#define FRACD_ZERO_P(fp)   (!fp.ll[1] && !(fp.ll[0] & HIGH_LL_FRAC_MASK))
33
#define HIGH_LL_FRAC_BITS  48
34
#define HIGH_LL_UNIT_BIT   ((UDItype_x)1 << HIGH_LL_FRAC_BITS)
35
#define HIGH_LL_FRAC_MASK  (HIGH_LL_UNIT_BIT - 1)
36
 
37
typedef int DItype_x __attribute__ ((mode (DI)));
38
typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
39
typedef int SItype_x __attribute__ ((mode (SI)));
40
typedef unsigned int USItype_x __attribute__ ((mode (SI)));
41
 
42
union double_long {
43
  long double d;
44
  struct {
45
      SItype_x i[4]; /* 32 bit parts: 0 upper ... 3 lowest */
46
    } l;
47
  UDItype_x ll[2];   /* 64 bit parts: 0 upper, 1 lower */
48
};
49
 
50
UDItype_x __fixunstfdi (long double a1);
51
 
52
/* convert double to unsigned int */
53
UDItype_x
54
__fixunstfdi (long double a1)
55
{
56
    register union double_long dl1;
57
    register int exp;
58
    register UDItype_x l;
59
 
60
    dl1.d = a1;
61
 
62
    /* +/- 0, denormalized, negative */
63
    if (!EXPD (dl1) || SIGND(dl1))
64
      return 0;
65
 
66
    /* The exponent - considered the binary point at the right end of
67
       the mantissa.  */
68
    exp = EXPD (dl1) - EXPONENT_BIAS - MANTISSA_BITS;
69
 
70
    /* number < 1: If the mantissa would need to be right-shifted more bits than
71
       its size (plus the implied one bit on the left) the result would be
72
       zero.  */
73
    if (exp <= -PRECISION)
74
      return 0;
75
 
76
    /* NaN: All exponent bits set and a nonzero fraction.  */
77
    if ((EXPD(dl1) == 0x7fff) && !FRACD_ZERO_P (dl1))
78
      return 0x0ULL;
79
 
80
    /* If the upper ll part of the mantissa isn't
81
       zeroed out after shifting the number would be to large.  */
82
    if (exp >= -HIGH_LL_FRAC_BITS)
83
      return 0xFFFFFFFFFFFFFFFFULL;
84
 
85
    exp += HIGH_LL_FRAC_BITS + 1;
86
 
87
    l = MANTD_LOW_LL (dl1) >> (HIGH_LL_FRAC_BITS + 1)
88
        | MANTD_HIGH_LL (dl1) << (64 - (HIGH_LL_FRAC_BITS + 1));
89
 
90
    return l >> -exp;
91
}
92
#define __fixunstfdi ___fixunstfdi
93
#endif
94
#undef L_fixunstfdi
95
 
96
#ifdef L_fixtfdi
97
#define EXPD(fp)           (((fp.l.i[0]) >> 16) & 0x7FFF)
98
#define EXPONENT_BIAS      16383
99
#define MANTISSA_BITS      112
100
#define PRECISION          (MANTISSA_BITS + 1)
101
#define SIGNBIT            0x80000000
102
#define SIGND(fp)          ((fp.l.i[0]) & SIGNBIT)
103
#define MANTD_HIGH_LL(fp)  ((fp.ll[0] & HIGH_LL_FRAC_MASK) | HIGH_LL_UNIT_BIT)
104
#define MANTD_LOW_LL(fp)   (fp.ll[1])
105
#define FRACD_ZERO_P(fp)   (!fp.ll[1] && !(fp.ll[0] & HIGH_LL_FRAC_MASK))
106
#define HIGH_LL_FRAC_BITS  48
107
#define HIGH_LL_UNIT_BIT   ((UDItype_x)1 << HIGH_LL_FRAC_BITS)
108
#define HIGH_LL_FRAC_MASK  (HIGH_LL_UNIT_BIT - 1)
109
 
110
typedef int DItype_x __attribute__ ((mode (DI)));
111
typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
112
typedef int SItype_x __attribute__ ((mode (SI)));
113
typedef unsigned int USItype_x __attribute__ ((mode (SI)));
114
 
115
union double_long {
116
  long double d;
117
  struct {
118
      SItype_x i[4]; /* 32 bit parts: 0 upper ... 3 lowest */
119
    } l;
120
  DItype_x ll[2];   /* 64 bit parts: 0 upper, 1 lower */
121
};
122
 
123
DItype_x __fixtfdi (long double a1);
124
 
125
/* convert double to unsigned int */
126
DItype_x
127
__fixtfdi (long double a1)
128
{
129
    register union double_long dl1;
130
    register int exp;
131
    register UDItype_x l;
132
 
133
    dl1.d = a1;
134
 
135
    /* +/- 0, denormalized */
136
    if (!EXPD (dl1))
137
      return 0;
138
 
139
    /* The exponent - considered the binary point at the right end of
140
       the mantissa.  */
141
    exp = EXPD (dl1) - EXPONENT_BIAS - MANTISSA_BITS;
142
 
143
    /* number < 1: If the mantissa would need to be right-shifted more bits than
144
       its size the result would be zero.  */
145
    if (exp <= -PRECISION)
146
      return 0;
147
 
148
    /* NaN: All exponent bits set and a nonzero fraction.  */
149
    if ((EXPD(dl1) == 0x7fff) && !FRACD_ZERO_P (dl1))
150
      return 0x8000000000000000ULL;
151
 
152
    /* If the upper ll part of the mantissa isn't
153
       zeroed out after shifting the number would be to large.  */
154
    if (exp >= -HIGH_LL_FRAC_BITS)
155
      {
156
        l = (long long)1 << 63; /* long int min */
157
        return SIGND (dl1) ? l : l - 1;
158
      }
159
 
160
    /* The extra bit is needed for the sign bit.  */
161
    exp += HIGH_LL_FRAC_BITS + 1;
162
 
163
    l = MANTD_LOW_LL (dl1) >> (HIGH_LL_FRAC_BITS + 1)
164
        | MANTD_HIGH_LL (dl1) << (64 - (HIGH_LL_FRAC_BITS + 1));
165
 
166
    return SIGND (dl1) ? -(l >> -exp) : l >> -exp;
167
}
168
#define __fixtfdi ___fixtfdi
169
#endif
170
#undef L_fixtfdi
171
 
172
#ifdef L_fixunsdfdi
173
#define EXPD(fp)        (((fp.l.upper) >> 20) & 0x7FF)
174
#define EXCESSD         1022
175
#define SIGNBIT         0x80000000
176
#define SIGND(fp)       ((fp.l.upper) & SIGNBIT)
177
#define MANTD_LL(fp)    ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
178
#define FRACD_LL(fp)    (fp.ll & (HIDDEND_LL-1))
179
#define HIDDEND_LL      ((UDItype_x)1 << 52)
180
 
181
typedef int DItype_x __attribute__ ((mode (DI)));
182
typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
183
typedef int SItype_x __attribute__ ((mode (SI)));
184
typedef unsigned int USItype_x __attribute__ ((mode (SI)));
185
 
186
union double_long {
187
    double d;
188
    struct {
189
      SItype_x upper;
190
      USItype_x lower;
191
    } l;
192
    UDItype_x ll;
193
};
194
 
195
UDItype_x __fixunsdfdi (double a1);
196
 
197
/* convert double to unsigned int */
198
UDItype_x
199
__fixunsdfdi (double a1)
200
{
201
    register union double_long dl1;
202
    register int exp;
203
    register UDItype_x l;
204
 
205
    dl1.d = a1;
206
 
207
    /* +/- 0, denormalized, negative */
208
 
209
    if (!EXPD (dl1) || SIGND(dl1))
210
      return 0;
211
 
212
    exp = EXPD (dl1) - EXCESSD - 53;
213
 
214
    /* number < 1 */
215
 
216
    if (exp < -53)
217
      return 0;
218
 
219
    /* NaN */
220
 
221
    if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
222
      return 0x0ULL;
223
 
224
    /* Number big number & + inf */
225
 
226
    if (exp >= 12) {
227
      return 0xFFFFFFFFFFFFFFFFULL;
228
    }
229
 
230
    l = MANTD_LL(dl1);
231
 
232
    /* shift down until exp < 12 or l = 0 */
233
    if (exp > 0)
234
      l <<= exp;
235
    else
236
      l >>= -exp;
237
 
238
    return l;
239
}
240
#define __fixunsdfdi ___fixunsdfdi
241
#endif
242
#undef L_fixunsdfdi
243
 
244
#ifdef L_fixdfdi
245
#define EXPD(fp)        (((fp.l.upper) >> 20) & 0x7FF)
246
#define EXCESSD         1022
247
#define SIGNBIT         0x80000000
248
#define SIGND(fp)       ((fp.l.upper) & SIGNBIT)
249
#define MANTD_LL(fp)    ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
250
#define FRACD_LL(fp)    (fp.ll & (HIDDEND_LL-1))
251
#define HIDDEND_LL      ((UDItype_x)1 << 52)
252
 
253
typedef int DItype_x __attribute__ ((mode (DI)));
254
typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
255
typedef int SItype_x __attribute__ ((mode (SI)));
256
typedef unsigned int USItype_x __attribute__ ((mode (SI)));
257
 
258
union double_long {
259
    double d;
260
    struct {
261
      SItype_x upper;
262
      USItype_x lower;
263
    } l;
264
    UDItype_x ll;
265
};
266
 
267
DItype_x __fixdfdi (double a1);
268
 
269
/* convert double to int */
270
DItype_x
271
__fixdfdi (double a1)
272
{
273
    register union double_long dl1;
274
    register int exp;
275
    register DItype_x l;
276
 
277
    dl1.d = a1;
278
 
279
    /* +/- 0, denormalized */
280
 
281
    if (!EXPD (dl1))
282
      return 0;
283
 
284
    exp = EXPD (dl1) - EXCESSD - 53;
285
 
286
    /* number < 1 */
287
 
288
    if (exp < -53)
289
      return 0;
290
 
291
    /* NaN */
292
 
293
    if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
294
      return 0x8000000000000000ULL;
295
 
296
    /* Number big number & +/- inf */
297
 
298
    if (exp >= 11) {
299
        l = (long long)1<<63;
300
        if (!SIGND(dl1))
301
            l--;
302
        return l;
303
    }
304
 
305
    l = MANTD_LL(dl1);
306
 
307
    /* shift down until exp < 12 or l = 0 */
308
    if (exp > 0)
309
      l <<= exp;
310
    else
311
      l >>= -exp;
312
 
313
    return (SIGND (dl1) ? -l : l);
314
}
315
#define __fixdfdi ___fixdfdi
316
#endif
317
#undef L_fixdfdi
318
 
319
#ifdef L_fixunssfdi
320
#define EXP(fp)         (((fp.l) >> 23) & 0xFF)
321
#define EXCESS          126
322
#define SIGNBIT         0x80000000
323
#define SIGN(fp)        ((fp.l) & SIGNBIT)
324
#define HIDDEN          (1 << 23)
325
#define MANT(fp)        (((fp.l) & 0x7FFFFF) | HIDDEN)
326
#define FRAC(fp)        ((fp.l) & 0x7FFFFF)
327
 
328
typedef int DItype_x __attribute__ ((mode (DI)));
329
typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
330
typedef int SItype_x __attribute__ ((mode (SI)));
331
typedef unsigned int USItype_x __attribute__ ((mode (SI)));
332
 
333
union float_long
334
  {
335
    float f;
336
    USItype_x l;
337
  };
338
 
339
UDItype_x __fixunssfdi (float a1);
340
 
341
/* convert float to unsigned int */
342
UDItype_x
343
__fixunssfdi (float a1)
344
{
345
    register union float_long fl1;
346
    register int exp;
347
    register UDItype_x l;
348
 
349
    fl1.f = a1;
350
 
351
    /* +/- 0, denormalized, negative */
352
 
353
    if (!EXP (fl1) || SIGN(fl1))
354
      return 0;
355
 
356
    exp = EXP (fl1) - EXCESS - 24;
357
 
358
    /* number < 1 */
359
 
360
    if (exp < -24)
361
      return 0;
362
 
363
    /* NaN */
364
 
365
    if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
366
      return 0x0ULL;
367
 
368
    /* Number big number & + inf */
369
 
370
    if (exp >= 41) {
371
      return 0xFFFFFFFFFFFFFFFFULL;
372
    }
373
 
374
    l = MANT(fl1);
375
 
376
    if (exp > 0)
377
      l <<= exp;
378
    else
379
      l >>= -exp;
380
 
381
    return l;
382
}
383
#define __fixunssfdi ___fixunssfdi
384
#endif
385
#undef L_fixunssfdi
386
 
387
#ifdef L_fixsfdi
388
#define EXP(fp)         (((fp.l) >> 23) & 0xFF)
389
#define EXCESS          126
390
#define SIGNBIT         0x80000000
391
#define SIGN(fp)        ((fp.l) & SIGNBIT)
392
#define HIDDEN          (1 << 23)
393
#define MANT(fp)        (((fp.l) & 0x7FFFFF) | HIDDEN)
394
#define FRAC(fp)        ((fp.l) & 0x7FFFFF)
395
 
396
typedef int DItype_x __attribute__ ((mode (DI)));
397
typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
398
typedef int SItype_x __attribute__ ((mode (SI)));
399
typedef unsigned int USItype_x __attribute__ ((mode (SI)));
400
 
401
union float_long
402
  {
403
    float f;
404
    USItype_x l;
405
  };
406
 
407
DItype_x __fixsfdi (float a1);
408
 
409
/* convert double to int */
410
DItype_x
411
__fixsfdi (float a1)
412
{
413
    register union float_long fl1;
414
    register int exp;
415
    register DItype_x l;
416
 
417
    fl1.f = a1;
418
 
419
    /* +/- 0, denormalized */
420
 
421
    if (!EXP (fl1))
422
      return 0;
423
 
424
    exp = EXP (fl1) - EXCESS - 24;
425
 
426
    /* number < 1 */
427
 
428
    if (exp < -24)
429
      return 0;
430
 
431
    /* NaN */
432
 
433
    if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
434
      return 0x8000000000000000ULL;
435
 
436
    /* Number big number & +/- inf */
437
 
438
    if (exp >= 40) {
439
        l = (long long)1<<63;
440
        if (!SIGN(fl1))
441
            l--;
442
        return l;
443
    }
444
 
445
    l = MANT(fl1);
446
 
447
    if (exp > 0)
448
      l <<= exp;
449
    else
450
      l >>= -exp;
451
 
452
    return (SIGN (fl1) ? -l : l);
453
}
454
#define __fixsfdi ___fixsfdi
455
#endif
456
#undef L_fixsfdi

powered by: WebSVN 2.1.0

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