Daily bump.
[official-gcc.git] / gcc / libgcc2.h
blob9f2ca39d53a147a646a2980ace6129e4087bf2db
1 /* Header file for libgcc2.c. */
2 /* Copyright (C) 2000, 2001, 2004, 2005
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, 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. */
30 #ifndef GCC_LIBGCC2_H
31 #define GCC_LIBGCC2_H
33 #ifndef HIDE_EXPORTS
34 #pragma GCC visibility push(default)
35 #endif
37 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
38 extern void __clear_cache (char *, char *);
39 extern void __eprintf (const char *, const char *, unsigned int, const char *)
40 __attribute__ ((__noreturn__));
42 /* Permit the tm.h file to select the endianness to use just for this
43 file. This is used when the endianness is determined when the
44 compiler is run. */
46 #ifndef LIBGCC2_WORDS_BIG_ENDIAN
47 #define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
48 #endif
50 #ifndef LIBGCC2_DOUBLE_TYPE_SIZE
51 #define LIBGCC2_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
52 #endif
53 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
54 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
55 #endif
57 #ifndef LIBGCC2_HAS_SF_MODE
58 #define LIBGCC2_HAS_SF_MODE (BITS_PER_UNIT == 8)
59 #endif
61 #ifndef LIBGCC2_HAS_DF_MODE
62 #define LIBGCC2_HAS_DF_MODE \
63 (BITS_PER_UNIT == 8 \
64 && (LIBGCC2_DOUBLE_TYPE_SIZE == 64 \
65 || LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64))
66 #endif
68 #ifndef LIBGCC2_HAS_XF_MODE
69 #define LIBGCC2_HAS_XF_MODE \
70 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
71 #endif
73 #ifndef LIBGCC2_HAS_TF_MODE
74 #define LIBGCC2_HAS_TF_MODE \
75 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
76 #endif
78 #ifndef SF_SIZE
79 #if LIBGCC2_HAS_SF_MODE
80 #define SF_SIZE FLT_MANT_DIG
81 #else
82 #define SF_SIZE 0
83 #endif
84 #endif
86 #ifndef DF_SIZE
87 #if LIBGCC2_HAS_DF_MODE
88 #if LIBGCC2_DOUBLE_TYPE_SIZE == 64
89 #define DF_SIZE DBL_MANT_DIG
90 #elif LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64
91 #define DF_SIZE LDBL_MANT_DIG
92 #else
93 #define DF_SIZE 0
94 #endif
95 #else
96 #define DF_SIZE 0
97 #endif
98 #endif
100 #ifndef XF_SIZE
101 #if LIBGCC2_HAS_XF_MODE
102 #define XF_SIZE LDBL_MANT_DIG
103 #else
104 #define XF_SIZE 0
105 #endif
106 #endif
108 #ifndef TF_SIZE
109 #if LIBGCC2_HAS_TF_MODE
110 #define TF_SIZE LDBL_MANT_DIG
111 #else
112 #define TF_SIZE 0
113 #endif
114 #endif
116 /* FIXME: This #ifdef probably should be removed, ie. enable the test
117 for mips too. */
118 /* Don't use IBM Extended Double TFmode for TI->SF calculations.
119 The conversion from long double to float suffers from double
120 rounding, because we convert via double. In other cases, going
121 through the software fp routines is much slower than the fallback. */
122 #ifdef __powerpc__
123 #define AVOID_FP_TYPE_CONVERSION(SIZE) (SIZE == 106)
124 #elif defined(WIDEST_HARDWARE_FP_SIZE)
125 #define AVOID_FP_TYPE_CONVERSION(SIZE) (SIZE > WIDEST_HARDWARE_FP_SIZE)
126 #else
127 #define AVOID_FP_TYPE_CONVERSION(SIZE) 0
128 #endif
130 /* In the first part of this file, we are interfacing to calls generated
131 by the compiler itself. These calls pass values into these routines
132 which have very specific modes (rather than very specific types), and
133 these compiler-generated calls also expect any return values to have
134 very specific modes (rather than very specific types). Thus, we need
135 to avoid using regular C language type names in this part of the file
136 because the sizes for those types can be configured to be anything.
137 Instead we use the following special type names. */
139 typedef int QItype __attribute__ ((mode (QI)));
140 typedef unsigned int UQItype __attribute__ ((mode (QI)));
141 typedef int HItype __attribute__ ((mode (HI)));
142 typedef unsigned int UHItype __attribute__ ((mode (HI)));
143 #if MIN_UNITS_PER_WORD > 1
144 /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */
145 typedef int SItype __attribute__ ((mode (SI)));
146 typedef unsigned int USItype __attribute__ ((mode (SI)));
147 #if LONG_LONG_TYPE_SIZE > 32
148 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */
149 typedef int DItype __attribute__ ((mode (DI)));
150 typedef unsigned int UDItype __attribute__ ((mode (DI)));
151 #if MIN_UNITS_PER_WORD > 4
152 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4. */
153 typedef int TItype __attribute__ ((mode (TI)));
154 typedef unsigned int UTItype __attribute__ ((mode (TI)));
155 #endif
156 #endif
157 #endif
159 #if LIBGCC2_HAS_SF_MODE
160 typedef float SFtype __attribute__ ((mode (SF)));
161 typedef _Complex float SCtype __attribute__ ((mode (SC)));
162 #endif
163 #if LIBGCC2_HAS_DF_MODE
164 typedef float DFtype __attribute__ ((mode (DF)));
165 typedef _Complex float DCtype __attribute__ ((mode (DC)));
166 #endif
167 #if LIBGCC2_HAS_XF_MODE
168 typedef float XFtype __attribute__ ((mode (XF)));
169 typedef _Complex float XCtype __attribute__ ((mode (XC)));
170 #endif
171 #if LIBGCC2_HAS_TF_MODE
172 typedef float TFtype __attribute__ ((mode (TF)));
173 typedef _Complex float TCtype __attribute__ ((mode (TC)));
174 #endif
176 typedef int cmp_return_type __attribute__((mode (__libgcc_cmp_return__)));
177 typedef int shift_count_type __attribute__((mode (__libgcc_shift_count__)));
179 /* Make sure that we don't accidentally use any normal C language built-in
180 type names in the first part of this file. Instead we want to use *only*
181 the type names defined above. The following macro definitions insure
182 that if we *do* accidentally use some normal C language built-in type name,
183 we will get a syntax error. */
185 #define char bogus_type
186 #define short bogus_type
187 #define int bogus_type
188 #define long bogus_type
189 #define unsigned bogus_type
190 #define float bogus_type
191 #define double bogus_type
193 /* Versions prior to 3.4.4 were not taking into account the word size for
194 the 5 trapping arithmetic functions absv, addv, subv, mulv and negv. As
195 a consequence, the si and di variants were always and the only ones emitted.
196 To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
197 defined on platforms where it makes sense to still have the si variants
198 emitted. As a bonus, their implementation is now correct. Note that the
199 same mechanism should have been implemented for the di variants, but it
200 turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
201 if it existed. */
203 #if LIBGCC2_UNITS_PER_WORD == 8
204 #define W_TYPE_SIZE (8 * BITS_PER_UNIT)
205 #define Wtype DItype
206 #define UWtype UDItype
207 #define HWtype DItype
208 #define UHWtype UDItype
209 #define DWtype TItype
210 #define UDWtype UTItype
211 #define __NW(a,b) __ ## a ## di ## b
212 #define __NDW(a,b) __ ## a ## ti ## b
213 #define COMPAT_SIMODE_TRAPPING_ARITHMETIC
214 #elif LIBGCC2_UNITS_PER_WORD == 4
215 #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
216 #define Wtype SItype
217 #define UWtype USItype
218 #define HWtype SItype
219 #define UHWtype USItype
220 #define DWtype DItype
221 #define UDWtype UDItype
222 #define __NW(a,b) __ ## a ## si ## b
223 #define __NDW(a,b) __ ## a ## di ## b
224 #elif LIBGCC2_UNITS_PER_WORD == 2
225 #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
226 #define Wtype HItype
227 #define UWtype UHItype
228 #define HWtype HItype
229 #define UHWtype UHItype
230 #define DWtype SItype
231 #define UDWtype USItype
232 #define __NW(a,b) __ ## a ## hi ## b
233 #define __NDW(a,b) __ ## a ## si ## b
234 #else
235 #define W_TYPE_SIZE BITS_PER_UNIT
236 #define Wtype QItype
237 #define UWtype UQItype
238 #define HWtype QItype
239 #define UHWtype UQItype
240 #define DWtype HItype
241 #define UDWtype UHItype
242 #define __NW(a,b) __ ## a ## qi ## b
243 #define __NDW(a,b) __ ## a ## hi ## b
244 #endif
246 #define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
247 #define Wtype_MIN (- Wtype_MAX - 1)
249 #if W_TYPE_SIZE == 8
250 # define Wtype_MAXp1_F 0x1p8f
251 #elif W_TYPE_SIZE == 16
252 # define Wtype_MAXp1_F 0x1p16f
253 #elif W_TYPE_SIZE == 32
254 # define Wtype_MAXp1_F 0x1p32f
255 #elif W_TYPE_SIZE == 64
256 # define Wtype_MAXp1_F 0x1p64f
257 #else
258 # error "expand the table"
259 #endif
261 #define __muldi3 __NDW(mul,3)
262 #define __divdi3 __NDW(div,3)
263 #define __udivdi3 __NDW(udiv,3)
264 #define __moddi3 __NDW(mod,3)
265 #define __umoddi3 __NDW(umod,3)
266 #define __negdi2 __NDW(neg,2)
267 #define __lshrdi3 __NDW(lshr,3)
268 #define __ashldi3 __NDW(ashl,3)
269 #define __ashrdi3 __NDW(ashr,3)
270 #define __cmpdi2 __NDW(cmp,2)
271 #define __ucmpdi2 __NDW(ucmp,2)
272 #define __udivmoddi4 __NDW(udivmod,4)
273 #define __fixunstfDI __NDW(fixunstf,)
274 #define __fixtfdi __NDW(fixtf,)
275 #define __fixunsxfDI __NDW(fixunsxf,)
276 #define __fixxfdi __NDW(fixxf,)
277 #define __fixunsdfDI __NDW(fixunsdf,)
278 #define __fixdfdi __NDW(fixdf,)
279 #define __fixunssfDI __NDW(fixunssf,)
280 #define __fixsfdi __NDW(fixsf,)
281 #define __floatdixf __NDW(float,xf)
282 #define __floatditf __NDW(float,tf)
283 #define __floatdidf __NDW(float,df)
284 #define __floatdisf __NDW(float,sf)
285 #define __floatundixf __NDW(floatun,xf)
286 #define __floatunditf __NDW(floatun,tf)
287 #define __floatundidf __NDW(floatun,df)
288 #define __floatundisf __NDW(floatun,sf)
289 #define __fixunsxfSI __NW(fixunsxf,)
290 #define __fixunstfSI __NW(fixunstf,)
291 #define __fixunsdfSI __NW(fixunsdf,)
292 #define __fixunssfSI __NW(fixunssf,)
294 #define __absvSI2 __NW(absv,2)
295 #define __addvSI3 __NW(addv,3)
296 #define __subvSI3 __NW(subv,3)
297 #define __mulvSI3 __NW(mulv,3)
298 #define __negvSI2 __NW(negv,2)
299 #define __absvDI2 __NDW(absv,2)
300 #define __addvDI3 __NDW(addv,3)
301 #define __subvDI3 __NDW(subv,3)
302 #define __mulvDI3 __NDW(mulv,3)
303 #define __negvDI2 __NDW(negv,2)
305 #define __ffsSI2 __NW(ffs,2)
306 #define __clzSI2 __NW(clz,2)
307 #define __ctzSI2 __NW(ctz,2)
308 #define __popcountSI2 __NW(popcount,2)
309 #define __paritySI2 __NW(parity,2)
310 #define __ffsDI2 __NDW(ffs,2)
311 #define __clzDI2 __NDW(clz,2)
312 #define __ctzDI2 __NDW(ctz,2)
313 #define __popcountDI2 __NDW(popcount,2)
314 #define __parityDI2 __NDW(parity,2)
316 extern DWtype __muldi3 (DWtype, DWtype);
317 extern DWtype __divdi3 (DWtype, DWtype);
318 extern UDWtype __udivdi3 (UDWtype, UDWtype);
319 extern UDWtype __umoddi3 (UDWtype, UDWtype);
320 extern DWtype __moddi3 (DWtype, DWtype);
322 /* __udivmoddi4 is static inline when building other libgcc2 portions. */
323 #if (!defined (L_udivdi3) && !defined (L_divdi3) && \
324 !defined (L_umoddi3) && !defined (L_moddi3))
325 extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
326 #endif
328 /* __negdi2 is static inline when building other libgcc2 portions. */
329 #if !defined(L_divdi3) && !defined(L_moddi3)
330 extern DWtype __negdi2 (DWtype);
331 #endif
333 extern DWtype __lshrdi3 (DWtype, shift_count_type);
334 extern DWtype __ashldi3 (DWtype, shift_count_type);
335 extern DWtype __ashrdi3 (DWtype, shift_count_type);
337 /* __udiv_w_sdiv is static inline when building other libgcc2 portions. */
338 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
339 !defined(L_umoddi3) && !defined(L_moddi3))
340 extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
341 #endif
343 extern cmp_return_type __cmpdi2 (DWtype, DWtype);
344 extern cmp_return_type __ucmpdi2 (DWtype, DWtype);
346 #if MIN_UNITS_PER_WORD > 1
347 extern SItype __bswapsi2 (SItype);
348 #endif
349 #if LONG_LONG_TYPE_SIZE > 32
350 extern DItype __bswapdi2 (DItype);
351 #endif
353 extern Wtype __absvSI2 (Wtype);
354 extern Wtype __addvSI3 (Wtype, Wtype);
355 extern Wtype __subvSI3 (Wtype, Wtype);
356 extern Wtype __mulvSI3 (Wtype, Wtype);
357 extern Wtype __negvSI2 (Wtype);
358 extern DWtype __absvDI2 (DWtype);
359 extern DWtype __addvDI3 (DWtype, DWtype);
360 extern DWtype __subvDI3 (DWtype, DWtype);
361 extern DWtype __mulvDI3 (DWtype, DWtype);
362 extern DWtype __negvDI2 (DWtype);
364 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
365 extern SItype __absvsi2 (SItype);
366 extern SItype __addvsi3 (SItype, SItype);
367 extern SItype __subvsi3 (SItype, SItype);
368 extern SItype __mulvsi3 (SItype, SItype);
369 extern SItype __negvsi2 (SItype);
370 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
372 #undef int
373 #if LIBGCC2_HAS_SF_MODE
374 extern DWtype __fixsfdi (SFtype);
375 extern SFtype __floatdisf (DWtype);
376 extern SFtype __floatundisf (UDWtype);
377 extern UWtype __fixunssfSI (SFtype);
378 extern UDWtype __fixunssfDI (SFtype);
379 extern SFtype __powisf2 (SFtype, int);
380 extern SCtype __divsc3 (SFtype, SFtype, SFtype, SFtype);
381 extern SCtype __mulsc3 (SFtype, SFtype, SFtype, SFtype);
382 #endif
383 #if LIBGCC2_HAS_DF_MODE
384 extern DWtype __fixdfdi (DFtype);
385 extern DFtype __floatdidf (DWtype);
386 extern DFtype __floatundidf (UDWtype);
387 extern UWtype __fixunsdfSI (DFtype);
388 extern UDWtype __fixunsdfDI (DFtype);
389 extern DFtype __powidf2 (DFtype, int);
390 extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype);
391 extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype);
392 #endif
394 #if LIBGCC2_HAS_XF_MODE
395 extern DWtype __fixxfdi (XFtype);
396 extern UDWtype __fixunsxfDI (XFtype);
397 extern XFtype __floatdixf (DWtype);
398 extern XFtype __floatundixf (UDWtype);
399 extern UWtype __fixunsxfSI (XFtype);
400 extern XFtype __powixf2 (XFtype, int);
401 extern XCtype __divxc3 (XFtype, XFtype, XFtype, XFtype);
402 extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype);
403 #endif
405 #if LIBGCC2_HAS_TF_MODE
406 extern UDWtype __fixunstfDI (TFtype);
407 extern DWtype __fixtfdi (TFtype);
408 extern TFtype __floatditf (DWtype);
409 extern TFtype __floatunditf (UDWtype);
410 extern TFtype __powitf2 (TFtype, int);
411 extern TCtype __divtc3 (TFtype, TFtype, TFtype, TFtype);
412 extern TCtype __multc3 (TFtype, TFtype, TFtype, TFtype);
413 #endif
414 #define int bogus_type
416 /* DWstructs are pairs of Wtype values in the order determined by
417 LIBGCC2_WORDS_BIG_ENDIAN. */
419 #if LIBGCC2_WORDS_BIG_ENDIAN
420 struct DWstruct {Wtype high, low;};
421 #else
422 struct DWstruct {Wtype low, high;};
423 #endif
425 /* We need this union to unpack/pack DImode values, since we don't have
426 any arithmetic yet. Incoming DImode parameters are stored into the
427 `ll' field, and the unpacked result is read from the struct `s'. */
429 typedef union
431 struct DWstruct s;
432 DWtype ll;
433 } DWunion;
435 /* Defined for L_popcount_tab. Exported here because some targets may
436 want to use it for their own versions of the __popcount builtins. */
437 extern const UQItype __popcount_tab[256];
439 /* Defined for L_clz. Exported here because some targets may want to use
440 it for their own versions of the __clz builtins. It contains the bit
441 position of the first set bit for the numbers 0 - 255. This avoids the
442 need for a separate table for the __ctz builtins. */
443 extern const UQItype __clz_tab[256];
445 #include "longlong.h"
447 #undef int
448 extern int __clzDI2 (UDWtype);
449 extern int __clzSI2 (UWtype);
450 extern int __ctzSI2 (UWtype);
451 extern int __ffsSI2 (UWtype);
452 extern int __ffsDI2 (DWtype);
453 extern int __ctzDI2 (UDWtype);
454 extern int __popcountSI2 (UWtype);
455 extern int __popcountDI2 (UDWtype);
456 extern int __paritySI2 (UWtype);
457 extern int __parityDI2 (UDWtype);
458 #define int bogus_type
460 extern void __enable_execute_stack (void *);
462 #ifndef HIDE_EXPORTS
463 #pragma GCC visibility pop
464 #endif
466 #endif /* ! GCC_LIBGCC2_H */