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