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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [fp-bit.h] - Blame information for rev 328

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

Line No. Rev Author Line
1 282 jeremybenn
/* Header file for fp-bit.c.  */
2
/* Copyright (C) 2000, 2002, 2003, 2006, 2009 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
6
GCC is free software; you can redistribute it and/or modify it under
7
the terms of the GNU General Public License as published by the Free
8
Software Foundation; either version 3, or (at your option) any later
9
version.
10
 
11
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
for more details.
15
 
16
Under Section 7 of GPL version 3, you are granted additional
17
permissions described in the GCC Runtime Library Exception, version
18
3.1, as published by the Free Software Foundation.
19
 
20
You should have received a copy of the GNU General Public License and
21
a copy of the GCC Runtime Library Exception along with this program;
22
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
<http://www.gnu.org/licenses/>.  */
24
 
25
#ifndef GCC_FP_BIT_H
26
#define GCC_FP_BIT_H
27
 
28
/* Defining FINE_GRAINED_LIBRARIES allows one to select which routines
29
   from this file are compiled via additional -D options.
30
 
31
   This avoids the need to pull in the entire fp emulation library
32
   when only a small number of functions are needed.
33
 
34
   If FINE_GRAINED_LIBRARIES is not defined, then compile every
35
   suitable routine.  */
36
#ifndef FINE_GRAINED_LIBRARIES
37
#define L_pack_df
38
#define L_unpack_df
39
#define L_pack_sf
40
#define L_unpack_sf
41
#define L_addsub_sf
42
#define L_addsub_df
43
#define L_mul_sf
44
#define L_mul_df
45
#define L_div_sf
46
#define L_div_df
47
#define L_fpcmp_parts_sf
48
#define L_fpcmp_parts_df
49
#define L_compare_sf
50
#define L_compare_df
51
#define L_eq_sf
52
#define L_eq_df
53
#define L_ne_sf
54
#define L_ne_df
55
#define L_gt_sf
56
#define L_gt_df
57
#define L_ge_sf
58
#define L_ge_df
59
#define L_lt_sf
60
#define L_lt_df
61
#define L_le_sf
62
#define L_le_df
63
#define L_unord_sf
64
#define L_unord_df
65
#define L_usi_to_sf
66
#define L_usi_to_df
67
#define L_si_to_sf
68
#define L_si_to_df
69
#define L_sf_to_si
70
#define L_df_to_si
71
#define L_f_to_usi
72
#define L_df_to_usi
73
#define L_negate_sf
74
#define L_negate_df
75
#define L_make_sf
76
#define L_make_df
77
#define L_sf_to_df
78
#define L_df_to_sf
79
#ifdef FLOAT
80
#define L_thenan_sf
81
#else
82
#define L_thenan_df
83
#endif
84
#endif /* ! FINE_GRAINED_LIBRARIES */
85
 
86
#if __LDBL_MANT_DIG__ == 113 || __LDBL_MANT_DIG__ == 106
87
# if defined(TFLOAT) || defined(L_sf_to_tf) || defined(L_df_to_tf)
88
#  define TMODES
89
# endif
90
#endif
91
 
92
typedef float SFtype __attribute__ ((mode (SF)));
93
typedef float DFtype __attribute__ ((mode (DF)));
94
#ifdef TMODES
95
typedef float TFtype __attribute__ ((mode (TF)));
96
#endif
97
 
98
typedef int HItype __attribute__ ((mode (HI)));
99
typedef int SItype __attribute__ ((mode (SI)));
100
typedef int DItype __attribute__ ((mode (DI)));
101
#ifdef TMODES
102
typedef int TItype __attribute__ ((mode (TI)));
103
#endif
104
 
105
/* The type of the result of a floating point comparison.  This must
106
   match `__libgcc_cmp_return__' in GCC for the target.  */
107
#ifndef CMPtype
108
typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
109
#endif
110
 
111
typedef unsigned int UHItype __attribute__ ((mode (HI)));
112
typedef unsigned int USItype __attribute__ ((mode (SI)));
113
typedef unsigned int UDItype __attribute__ ((mode (DI)));
114
#ifdef TMODES
115
typedef unsigned int UTItype __attribute__ ((mode (TI)));
116
#endif
117
 
118
#define MAX_USI_INT  (~(USItype)0)
119
#define MAX_SI_INT   ((SItype) (MAX_USI_INT >> 1))
120
#define BITS_PER_SI  (4 * BITS_PER_UNIT)
121
#ifdef TMODES
122
#define MAX_UDI_INT  (~(UDItype)0)
123
#define MAX_DI_INT   ((DItype) (MAX_UDI_INT >> 1))
124
#define BITS_PER_DI  (8 * BITS_PER_UNIT)
125
#endif
126
 
127
#ifdef FLOAT_ONLY
128
#define NO_DI_MODE
129
#endif
130
 
131
#ifdef TFLOAT
132
# ifndef TMODES
133
#  error "TFLOAT requires long double to have 113 bits of mantissa"
134
# endif
135
 
136
#       define PREFIXFPDP tp
137
#       define PREFIXSFDF tf
138
#       define NGARDS 10L /* Is this right? */
139
#       define GARDROUND 0x1ff
140
#       define GARDMASK  0x3ff
141
#       define GARDMSB   0x200
142
#       define FRAC_NBITS 128
143
 
144
# if __LDBL_MANT_DIG__ == 113 /* IEEE quad */
145
#       define EXPBITS 15
146
#       define EXPBIAS 16383
147
#       define EXPMAX (0x7fff)
148
#       define QUIET_NAN ((TItype)0x8 << 108)
149
#       define FRACHIGH  ((TItype)0x8 << 124)
150
#       define FRACHIGH2 ((TItype)0xc << 124)
151
#       define FRACBITS 112
152
# endif
153
 
154
# if __LDBL_MANT_DIG__ == 106 /* IBM extended (double+double) */
155
#       define EXPBITS 11
156
#       define EXPBIAS 1023
157
#       define EXPMAX (0x7ff)
158
#       define QUIET_NAN ((TItype)0x8 << (48 + 64))
159
#       define FRACHIGH  ((TItype)0x8 << 124)
160
#       define FRACHIGH2 ((TItype)0xc << 124)
161
#       define FRACBITS 105
162
#       define HALFFRACBITS 52
163
#       define HALFSHIFT 64
164
# endif
165
 
166
#       define pack_d __pack_t
167
#       define unpack_d __unpack_t
168
#       define __fpcmp_parts __fpcmp_parts_t
169
        typedef UTItype fractype;
170
        typedef UDItype halffractype;
171
        typedef USItype qrtrfractype;
172
#define qrtrfractype qrtrfractype
173
        typedef TFtype FLO_type;
174
        typedef TItype intfrac;
175
#elif defined FLOAT
176
#       define NGARDS    7L
177
#       define GARDROUND 0x3f
178
#       define GARDMASK  0x7f
179
#       define GARDMSB   0x40
180
#       define EXPBITS 8
181
#       define EXPBIAS 127
182
#       define FRACBITS 23
183
#       define EXPMAX (0xff)
184
#       define QUIET_NAN 0x100000L
185
#       define FRAC_NBITS 32
186
#       define FRACHIGH  0x80000000L
187
#       define FRACHIGH2 0xc0000000L
188
#       define pack_d __pack_f
189
#       define unpack_d __unpack_f
190
#       define __fpcmp_parts __fpcmp_parts_f
191
        typedef USItype fractype;
192
        typedef UHItype halffractype;
193
        typedef SFtype FLO_type;
194
        typedef SItype intfrac;
195
 
196
#else
197
#       define PREFIXFPDP dp
198
#       define PREFIXSFDF df
199
#       define NGARDS 8L
200
#       define GARDROUND 0x7f
201
#       define GARDMASK  0xff
202
#       define GARDMSB   0x80
203
#       define EXPBITS 11
204
#       define EXPBIAS 1023
205
#       define FRACBITS 52
206
#       define EXPMAX (0x7ff)
207
#       define QUIET_NAN 0x8000000000000LL
208
#       define FRAC_NBITS 64
209
#       define FRACHIGH  0x8000000000000000LL
210
#       define FRACHIGH2 0xc000000000000000LL
211
#       define pack_d __pack_d
212
#       define unpack_d __unpack_d
213
#       define __fpcmp_parts __fpcmp_parts_d
214
        typedef UDItype fractype;
215
        typedef USItype halffractype;
216
        typedef DFtype FLO_type;
217
        typedef DItype intfrac;
218
#endif /* FLOAT */
219
 
220
#ifdef US_SOFTWARE_GOFAST
221
#       ifdef TFLOAT
222
#               error "GOFAST TFmode not supported"
223
#       elif defined FLOAT
224
#               define add              fpadd
225
#               define sub              fpsub
226
#               define multiply         fpmul
227
#               define divide           fpdiv
228
#               define compare          fpcmp
229
#               define _unord_f2        __unordsf2
230
#               define usi_to_float     __floatunsisf
231
#               define si_to_float      sitofp
232
#               define float_to_si      fptosi
233
#               define float_to_usi     fptoui
234
#               define negate           __negsf2
235
#               define sf_to_df         fptodp
236
#               define sf_to_tf         __extendsftf2
237
#       else
238
#               define add              dpadd
239
#               define sub              dpsub
240
#               define multiply         dpmul
241
#               define divide           dpdiv
242
#               define compare          dpcmp
243
#               define _unord_f2        __unorddf2
244
#               define usi_to_float     __floatunsidf
245
#               define si_to_float      litodp
246
#               define float_to_si      dptoli
247
#               define float_to_usi     dptoul
248
#               define negate           __negdf2
249
#               define df_to_sf         dptofp
250
#               define df_to_tf         __extenddftf2
251
#       endif /* FLOAT */
252
#else
253
#       ifdef TFLOAT
254
#               define add              __addtf3
255
#               define sub              __subtf3
256
#               define multiply         __multf3
257
#               define divide           __divtf3
258
#               define compare          __cmptf2
259
#               define _eq_f2           __eqtf2
260
#               define _ne_f2           __netf2
261
#               define _gt_f2           __gttf2
262
#               define _ge_f2           __getf2
263
#               define _lt_f2           __lttf2
264
#               define _le_f2           __letf2
265
#               define _unord_f2        __unordtf2
266
#               define usi_to_float     __floatunsitf
267
#               define si_to_float      __floatsitf
268
#               define float_to_si      __fixtfsi
269
#               define float_to_usi     __fixunstfsi
270
#               define negate           __negtf2
271
#               define tf_to_sf         __trunctfsf2
272
#               define tf_to_df         __trunctfdf2
273
#       elif defined FLOAT
274
#               define add              __addsf3
275
#               define sub              __subsf3
276
#               define multiply         __mulsf3
277
#               define divide           __divsf3
278
#               define compare          __cmpsf2
279
#               define _eq_f2           __eqsf2
280
#               define _ne_f2           __nesf2
281
#               define _gt_f2           __gtsf2
282
#               define _ge_f2           __gesf2
283
#               define _lt_f2           __ltsf2
284
#               define _le_f2           __lesf2
285
#               define _unord_f2        __unordsf2
286
#               define usi_to_float     __floatunsisf
287
#               define si_to_float      __floatsisf
288
#               define float_to_si      __fixsfsi
289
#               define float_to_usi     __fixunssfsi
290
#               define negate           __negsf2
291
#               define sf_to_df         __extendsfdf2
292
#               define sf_to_tf         __extendsftf2
293
#       else
294
#               define add              __adddf3
295
#               define sub              __subdf3
296
#               define multiply         __muldf3
297
#               define divide           __divdf3
298
#               define compare          __cmpdf2
299
#               define _eq_f2           __eqdf2
300
#               define _ne_f2           __nedf2
301
#               define _gt_f2           __gtdf2
302
#               define _ge_f2           __gedf2
303
#               define _lt_f2           __ltdf2
304
#               define _le_f2           __ledf2
305
#               define _unord_f2        __unorddf2
306
#               define usi_to_float     __floatunsidf
307
#               define si_to_float      __floatsidf
308
#               define float_to_si      __fixdfsi
309
#               define float_to_usi     __fixunsdfsi
310
#               define negate           __negdf2
311
#               define df_to_sf         __truncdfsf2
312
#               define df_to_tf         __extenddftf2
313
#       endif /* FLOAT */
314
#endif /* US_SOFTWARE_GOFAST */
315
 
316
#ifndef INLINE
317
#define INLINE __inline__
318
#endif
319
 
320
/* Preserve the sticky-bit when shifting fractions to the right.  */
321
#define LSHIFT(a, s) { a = (a >> s) | !!(a & (((fractype) 1 << s) - 1)); }
322
 
323
/* numeric parameters */
324
/* F_D_BITOFF is the number of bits offset between the MSB of the mantissa
325
   of a float and of a double. Assumes there are only two float types.
326
   (double::FRAC_BITS+double::NGARDS-(float::FRAC_BITS-float::NGARDS))
327
 */
328
#define F_D_BITOFF (52+8-(23+7))
329
 
330
#ifdef TMODES
331
# define F_T_BITOFF (__LDBL_MANT_DIG__-1+10-(23+7))
332
# define D_T_BITOFF (__LDBL_MANT_DIG__-1+10-(52+8))
333
#endif
334
 
335
 
336
#define NORMAL_EXPMIN (-(EXPBIAS)+1)
337
#define IMPLICIT_1 ((fractype)1<<(FRACBITS+NGARDS))
338
#define IMPLICIT_2 ((fractype)1<<(FRACBITS+1+NGARDS))
339
 
340
/* common types */
341
 
342
typedef enum
343
{
344
  CLASS_SNAN,
345
  CLASS_QNAN,
346
  CLASS_ZERO,
347
  CLASS_NUMBER,
348
  CLASS_INFINITY
349
} fp_class_type;
350
 
351
typedef struct
352
{
353
#ifdef SMALL_MACHINE
354
  char class;
355
  unsigned char sign;
356
  short normal_exp;
357
#else
358
  fp_class_type class;
359
  unsigned int sign;
360
  int normal_exp;
361
#endif
362
 
363
  union
364
    {
365
      fractype ll;
366
      halffractype l[2];
367
    } fraction;
368
} fp_number_type;
369
 
370
typedef union
371
{
372
  FLO_type value;
373
  fractype value_raw;
374
 
375
#ifndef FLOAT
376
# ifdef qrtrfractype
377
  qrtrfractype qwords[4];
378
# else
379
  halffractype words[2];
380
# endif
381
#endif
382
 
383
#ifdef FLOAT_BIT_ORDER_MISMATCH
384
  struct
385
    {
386
      fractype fraction:FRACBITS __attribute__ ((packed));
387
      unsigned int exp:EXPBITS __attribute__ ((packed));
388
      unsigned int sign:1 __attribute__ ((packed));
389
    }
390
  bits;
391
#endif
392
 
393
#ifdef _DEBUG_BITFLOAT
394
  struct
395
    {
396
      unsigned int sign:1 __attribute__ ((packed));
397
      unsigned int exp:EXPBITS __attribute__ ((packed));
398
      fractype fraction:FRACBITS __attribute__ ((packed));
399
    }
400
  bits_big_endian;
401
 
402
  struct
403
    {
404
      fractype fraction:FRACBITS __attribute__ ((packed));
405
      unsigned int exp:EXPBITS __attribute__ ((packed));
406
      unsigned int sign:1 __attribute__ ((packed));
407
    }
408
  bits_little_endian;
409
#endif
410
}
411
FLO_union_type;
412
 
413
/* Prototypes.  */
414
 
415
#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
416
extern FLO_type pack_d (const fp_number_type *);
417
#endif
418
 
419
extern void unpack_d (FLO_union_type *, fp_number_type *);
420
 
421
#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
422
extern FLO_type add (FLO_type, FLO_type);
423
extern FLO_type sub (FLO_type, FLO_type);
424
#endif
425
 
426
#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
427
extern FLO_type multiply (FLO_type, FLO_type);
428
#endif
429
 
430
#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
431
extern FLO_type divide (FLO_type, FLO_type);
432
#endif
433
 
434
extern int __fpcmp_parts (fp_number_type *, fp_number_type *);
435
 
436
#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compare_tf)
437
extern CMPtype compare (FLO_type, FLO_type);
438
#endif
439
 
440
#ifndef US_SOFTWARE_GOFAST
441
 
442
#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
443
extern CMPtype _eq_f2 (FLO_type, FLO_type);
444
#endif
445
 
446
#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
447
extern CMPtype _ne_f2 (FLO_type, FLO_type);
448
#endif
449
 
450
#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
451
extern CMPtype _gt_f2 (FLO_type, FLO_type);
452
#endif
453
 
454
#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
455
extern CMPtype _ge_f2 (FLO_type, FLO_type);
456
#endif
457
 
458
#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
459
extern CMPtype _lt_f2 (FLO_type, FLO_type);
460
#endif
461
 
462
#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
463
extern CMPtype _le_f2 (FLO_type, FLO_type);
464
#endif
465
 
466
#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
467
extern CMPtype _unord_f2 (FLO_type, FLO_type);
468
#endif
469
 
470
#endif /* ! US_SOFTWARE_GOFAST */
471
 
472
#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
473
extern FLO_type si_to_float (SItype);
474
#endif
475
 
476
#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
477
extern SItype float_to_si (FLO_type);
478
#endif
479
 
480
#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
481
#if defined(US_SOFTWARE_GOFAST) || defined(L_tf_to_usi)
482
extern USItype float_to_usi (FLO_type);
483
#endif
484
#endif
485
 
486
#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
487
extern FLO_type usi_to_float (USItype);
488
#endif
489
 
490
#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
491
extern FLO_type negate (FLO_type);
492
#endif
493
 
494
#ifdef FLOAT
495
#if defined(L_make_sf)
496
extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
497
#endif
498
#ifndef FLOAT_ONLY
499
extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
500
#if defined(L_sf_to_df)
501
extern DFtype sf_to_df (SFtype);
502
#endif
503
#if defined(L_sf_to_tf) && defined(TMODES)
504
extern TFtype sf_to_tf (SFtype);
505
#endif
506
#endif /* ! FLOAT_ONLY */
507
#endif /* FLOAT */
508
 
509
#ifndef FLOAT
510
extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
511
#if defined(L_make_df)
512
extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
513
#endif
514
#if defined(L_df_to_sf)
515
extern SFtype df_to_sf (DFtype);
516
#endif
517
#if defined(L_df_to_tf) && defined(TMODES)
518
extern TFtype df_to_tf (DFtype);
519
#endif
520
#endif /* ! FLOAT */
521
 
522
#ifdef TMODES
523
extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
524
extern TFtype __make_tp (fp_class_type, unsigned int, int, UTItype);
525
#ifdef TFLOAT
526
#if defined(L_tf_to_sf)
527
extern SFtype tf_to_sf (TFtype);
528
#endif
529
#if defined(L_tf_to_df)
530
extern DFtype tf_to_df (TFtype);
531
#endif
532
#if defined(L_di_to_tf)
533
extern TFtype di_to_df (DItype);
534
#endif
535
#endif /* TFLOAT */
536
#endif /* TMODES */
537
 
538
#endif /* ! GCC_FP_BIT_H */

powered by: WebSVN 2.1.0

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