* config/xtensa/xtensa.c (xtensa_va_arg): Handle variable-sized types.
[official-gcc.git] / gcc / config / fp-bit.h
blobab1817a282659e726667b8925de4c56b9c9f4013
1 /* Header file for fp-bit.c. */
2 /* Copyright (C) 2000
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
29 #ifndef GCC_FP_BIT_H
30 #define GCC_FP_BIT_H
32 /* Defining FINE_GRAINED_LIBRARIES allows one to select which routines
33 from this file are compiled via additional -D options.
35 This avoids the need to pull in the entire fp emulation library
36 when only a small number of functions are needed.
38 If FINE_GRAINED_LIBRARIES is not defined, then compile every
39 suitable routine. */
40 #ifndef FINE_GRAINED_LIBRARIES
41 #define L_pack_df
42 #define L_unpack_df
43 #define L_pack_sf
44 #define L_unpack_sf
45 #define L_addsub_sf
46 #define L_addsub_df
47 #define L_mul_sf
48 #define L_mul_df
49 #define L_div_sf
50 #define L_div_df
51 #define L_fpcmp_parts_sf
52 #define L_fpcmp_parts_df
53 #define L_compare_sf
54 #define L_compare_df
55 #define L_eq_sf
56 #define L_eq_df
57 #define L_ne_sf
58 #define L_ne_df
59 #define L_gt_sf
60 #define L_gt_df
61 #define L_ge_sf
62 #define L_ge_df
63 #define L_lt_sf
64 #define L_lt_df
65 #define L_le_sf
66 #define L_le_df
67 #define L_unord_sf
68 #define L_unord_df
69 #define L_usi_to_sf
70 #define L_usi_to_df
71 #define L_si_to_sf
72 #define L_si_to_df
73 #define L_sf_to_si
74 #define L_df_to_si
75 #define L_f_to_usi
76 #define L_df_to_usi
77 #define L_negate_sf
78 #define L_negate_df
79 #define L_make_sf
80 #define L_make_df
81 #define L_sf_to_df
82 #define L_df_to_sf
83 #ifdef FLOAT
84 #define L_thenan_sf
85 #else
86 #define L_thenan_df
87 #endif
88 #endif /* ! FINE_GRAINED_LIBRARIES */
90 typedef float SFtype __attribute__ ((mode (SF)));
91 typedef float DFtype __attribute__ ((mode (DF)));
93 typedef int HItype __attribute__ ((mode (HI)));
94 typedef int SItype __attribute__ ((mode (SI)));
95 typedef int DItype __attribute__ ((mode (DI)));
97 /* The type of the result of a fp compare */
98 #ifndef CMPtype
99 #define CMPtype SItype
100 #endif
102 typedef unsigned int UHItype __attribute__ ((mode (HI)));
103 typedef unsigned int USItype __attribute__ ((mode (SI)));
104 typedef unsigned int UDItype __attribute__ ((mode (DI)));
106 #define MAX_USI_INT (~(USItype)0)
107 #define MAX_SI_INT ((SItype) (MAX_USI_INT >> 1))
108 #define BITS_PER_SI (4 * BITS_PER_UNIT)
110 #ifdef FLOAT_ONLY
111 #define NO_DI_MODE
112 #endif
114 #ifdef FLOAT
115 # define NGARDS 7L
116 # define GARDROUND 0x3f
117 # define GARDMASK 0x7f
118 # define GARDMSB 0x40
119 # define EXPBITS 8
120 # define EXPBIAS 127
121 # define FRACBITS 23
122 # define EXPMAX (0xff)
123 # define QUIET_NAN 0x100000L
124 # define FRAC_NBITS 32
125 # define FRACHIGH 0x80000000L
126 # define FRACHIGH2 0xc0000000L
127 # define pack_d __pack_f
128 # define unpack_d __unpack_f
129 # define __fpcmp_parts __fpcmp_parts_f
130 typedef USItype fractype;
131 typedef UHItype halffractype;
132 typedef SFtype FLO_type;
133 typedef SItype intfrac;
135 #else
136 # define PREFIXFPDP dp
137 # define PREFIXSFDF df
138 # define NGARDS 8L
139 # define GARDROUND 0x7f
140 # define GARDMASK 0xff
141 # define GARDMSB 0x80
142 # define EXPBITS 11
143 # define EXPBIAS 1023
144 # define FRACBITS 52
145 # define EXPMAX (0x7ff)
146 # define QUIET_NAN 0x8000000000000LL
147 # define FRAC_NBITS 64
148 # define FRACHIGH 0x8000000000000000LL
149 # define FRACHIGH2 0xc000000000000000LL
150 # define pack_d __pack_d
151 # define unpack_d __unpack_d
152 # define __fpcmp_parts __fpcmp_parts_d
153 typedef UDItype fractype;
154 typedef USItype halffractype;
155 typedef DFtype FLO_type;
156 typedef DItype intfrac;
157 #endif /* FLOAT */
159 #ifdef US_SOFTWARE_GOFAST
160 # ifdef FLOAT
161 # define add fpadd
162 # define sub fpsub
163 # define multiply fpmul
164 # define divide fpdiv
165 # define compare fpcmp
166 # define usi_to_float __floatunsisf
167 # define si_to_float sitofp
168 # define float_to_si fptosi
169 # define float_to_usi fptoui
170 # define negate __negsf2
171 # define sf_to_df fptodp
172 # define dptofp dptofp
173 #else
174 # define add dpadd
175 # define sub dpsub
176 # define multiply dpmul
177 # define divide dpdiv
178 # define compare dpcmp
179 # define usi_to_float __floatunsidf
180 # define si_to_float litodp
181 # define float_to_si dptoli
182 # define float_to_usi dptoul
183 # define negate __negdf2
184 # define df_to_sf dptofp
185 # endif /* FLOAT */
186 #else
187 # ifdef FLOAT
188 # define add __addsf3
189 # define sub __subsf3
190 # define multiply __mulsf3
191 # define divide __divsf3
192 # define compare __cmpsf2
193 # define _eq_f2 __eqsf2
194 # define _ne_f2 __nesf2
195 # define _gt_f2 __gtsf2
196 # define _ge_f2 __gesf2
197 # define _lt_f2 __ltsf2
198 # define _le_f2 __lesf2
199 # define _unord_f2 __unordsf2
200 # define usi_to_float __floatunsisf
201 # define si_to_float __floatsisf
202 # define float_to_si __fixsfsi
203 # define float_to_usi __fixunssfsi
204 # define negate __negsf2
205 # define sf_to_df __extendsfdf2
206 #else
207 # define add __adddf3
208 # define sub __subdf3
209 # define multiply __muldf3
210 # define divide __divdf3
211 # define compare __cmpdf2
212 # define _eq_f2 __eqdf2
213 # define _ne_f2 __nedf2
214 # define _gt_f2 __gtdf2
215 # define _ge_f2 __gedf2
216 # define _lt_f2 __ltdf2
217 # define _le_f2 __ledf2
218 # define _unord_f2 __unorddf2
219 # define usi_to_float __floatunsidf
220 # define si_to_float __floatsidf
221 # define float_to_si __fixdfsi
222 # define float_to_usi __fixunsdfsi
223 # define negate __negdf2
224 # define df_to_sf __truncdfsf2
225 # endif /* FLOAT */
226 #endif /* US_SOFTWARE_GOFAST */
228 #ifndef INLINE
229 #define INLINE __inline__
230 #endif
232 /* Preserve the sticky-bit when shifting fractions to the right. */
233 #define LSHIFT(a) { a = (a & 1) | (a >> 1); }
235 /* numeric parameters */
236 /* F_D_BITOFF is the number of bits offset between the MSB of the mantissa
237 of a float and of a double. Assumes there are only two float types.
238 (double::FRAC_BITS+double::NGARDS-(float::FRAC_BITS-float::NGARDS))
240 #define F_D_BITOFF (52+8-(23+7))
243 #define NORMAL_EXPMIN (-(EXPBIAS)+1)
244 #define IMPLICIT_1 (1LL<<(FRACBITS+NGARDS))
245 #define IMPLICIT_2 (1LL<<(FRACBITS+1+NGARDS))
247 /* common types */
249 typedef enum
251 CLASS_SNAN,
252 CLASS_QNAN,
253 CLASS_ZERO,
254 CLASS_NUMBER,
255 CLASS_INFINITY
256 } fp_class_type;
258 typedef struct
260 #ifdef SMALL_MACHINE
261 char class;
262 unsigned char sign;
263 short normal_exp;
264 #else
265 fp_class_type class;
266 unsigned int sign;
267 int normal_exp;
268 #endif
270 union
272 fractype ll;
273 halffractype l[2];
274 } fraction;
275 } fp_number_type;
277 typedef union
279 FLO_type value;
280 fractype value_raw;
282 #ifndef FLOAT
283 halffractype words[2];
284 #endif
286 #ifdef FLOAT_BIT_ORDER_MISMATCH
287 struct
289 fractype fraction:FRACBITS __attribute__ ((packed));
290 unsigned int exp:EXPBITS __attribute__ ((packed));
291 unsigned int sign:1 __attribute__ ((packed));
293 bits;
294 #endif
296 #ifdef _DEBUG_BITFLOAT
297 struct
299 unsigned int sign:1 __attribute__ ((packed));
300 unsigned int exp:EXPBITS __attribute__ ((packed));
301 fractype fraction:FRACBITS __attribute__ ((packed));
303 bits_big_endian;
305 struct
307 fractype fraction:FRACBITS __attribute__ ((packed));
308 unsigned int exp:EXPBITS __attribute__ ((packed));
309 unsigned int sign:1 __attribute__ ((packed));
311 bits_little_endian;
312 #endif
314 FLO_union_type;
316 /* Prototypes */
318 #if defined(L_pack_df) || defined(L_pack_sf)
319 extern FLO_type pack_d (fp_number_type *);
320 #endif
322 extern void unpack_d (FLO_union_type *, fp_number_type *);
324 #if defined(L_addsub_sf) || defined(L_addsub_df)
325 extern FLO_type add (FLO_type, FLO_type);
326 extern FLO_type sub (FLO_type, FLO_type);
327 #endif
329 #if defined(L_mul_sf) || defined(L_mul_df)
330 extern FLO_type multiply (FLO_type, FLO_type);
331 #endif
333 #if defined(L_div_sf) || defined(L_div_df)
334 extern FLO_type divide (FLO_type, FLO_type);
335 #endif
337 extern int __fpcmp_parts (fp_number_type *, fp_number_type *);
339 #if defined(L_compare_sf) || defined(L_compare_df)
340 extern CMPtype compare (FLO_type, FLO_type);
341 #endif
343 #ifndef US_SOFTWARE_GOFAST
345 #if defined(L_eq_sf) || defined(L_eq_df)
346 extern CMPtype _eq_f2 (FLO_type, FLO_type);
347 #endif
349 #if defined(L_ne_sf) || defined(L_ne_df)
350 extern CMPtype _ne_f2 (FLO_type, FLO_type);
351 #endif
353 #if defined(L_gt_sf) || defined(L_gt_df)
354 extern CMPtype _gt_f2 (FLO_type, FLO_type);
355 #endif
357 #if defined(L_ge_sf) || defined(L_ge_df)
358 extern CMPtype _ge_f2 (FLO_type, FLO_type);
359 #endif
361 #if defined(L_lt_sf) || defined(L_lt_df)
362 extern CMPtype _lt_f2 (FLO_type, FLO_type);
363 #endif
365 #if defined(L_le_sf) || defined(L_le_df)
366 extern CMPtype _le_f2 (FLO_type, FLO_type);
367 #endif
369 #if defined(L_unord_sf) || defined(L_unord_df)
370 extern CMPtype _unord_f2 (FLO_type, FLO_type);
371 #endif
373 #endif /* ! US_SOFTWARE_GOFAST */
375 #if defined(L_si_to_sf) || defined(L_si_to_df)
376 extern FLO_type si_to_float (SItype);
377 #endif
379 #if defined(L_sf_to_si) || defined(L_df_to_si)
380 extern SItype float_to_si (FLO_type);
381 #endif
383 #if defined(L_sf_to_usi) || defined(L_df_to_usi)
384 #ifdef US_SOFTWARE_GOFAST
385 extern USItype float_to_usi (FLO_type);
386 #endif
387 #endif
389 #if defined(L_usi_to_sf) || defined(L_usi_to_df)
390 extern FLO_type usi_to_float (USItype);
391 #endif
393 #if defined(L_negate_sf) || defined(L_negate_df)
394 extern FLO_type negate (FLO_type);
395 #endif
397 #ifdef FLOAT
398 #if defined(L_make_sf)
399 extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
400 #endif
401 #ifndef FLOAT_ONLY
402 extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
403 #if defined(L_sf_to_df)
404 extern DFtype sf_to_df (SFtype);
405 #endif
406 #endif /* ! FLOAT_ONLY */
407 #endif /* FLOAT */
409 #ifndef FLOAT
410 extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
411 #if defined(L_make_df)
412 extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
413 #endif
414 #if defined(L_df_to_sf)
415 extern SFtype df_to_sf (DFtype);
416 #endif
417 #endif /* ! FLOAT */
419 #endif /* ! GCC_FP_BIT_H */