1 /* Header file for libgcc2.c. */
2 /* Copyright (C) 2000-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
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
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
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.
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/>. */
29 #pragma GCC visibility push(default)
32 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
33 extern void __clear_cache (char *, char *);
34 extern void __eprintf (const char *, const char *, unsigned int, const char *)
35 __attribute__ ((__noreturn__
));
37 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
38 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
41 #ifdef __LIBGCC_HAS_SF_MODE__
42 #define LIBGCC2_HAS_SF_MODE 1
44 #define LIBGCC2_HAS_SF_MODE 0
47 #ifdef __LIBGCC_HAS_DF_MODE__
48 #define LIBGCC2_HAS_DF_MODE 1
50 #define LIBGCC2_HAS_DF_MODE 0
53 #ifdef __LIBGCC_HAS_XF_MODE__
54 #define LIBGCC2_HAS_XF_MODE 1
56 #define LIBGCC2_HAS_XF_MODE 0
59 #ifdef __LIBGCC_HAS_TF_MODE__
60 #define LIBGCC2_HAS_TF_MODE 1
62 #define LIBGCC2_HAS_TF_MODE 0
65 #ifndef __LIBGCC_SF_MANT_DIG__
66 #if LIBGCC2_HAS_SF_MODE
67 #error __LIBGCC_SF_MANT_DIG__ not defined
69 #define __LIBGCC_SF_MANT_DIG__ 0
73 #ifndef __LIBGCC_DF_MANT_DIG__
74 #if LIBGCC2_HAS_DF_MODE
75 #error __LIBGCC_DF_MANT_DIG__ not defined
77 #define __LIBGCC_DF_MANT_DIG__ 0
81 #ifndef __LIBGCC_XF_MANT_DIG__
82 #if LIBGCC2_HAS_XF_MODE
83 #error __LIBGCC_XF_MANT_DIG__ not defined
85 #define __LIBGCC_XF_MANT_DIG__ 0
89 #ifndef __LIBGCC_TF_MANT_DIG__
90 #if LIBGCC2_HAS_TF_MODE
91 #error __LIBGCC_TF_MANT_DIG__ not defined
93 #define __LIBGCC_TF_MANT_DIG__ 0
97 /* FIXME: This #ifdef probably should be removed, ie. enable the test
99 /* Don't use IBM Extended Double TFmode for TI->SF calculations.
100 The conversion from long double to float suffers from double
101 rounding, because we convert via double. In other cases, going
102 through the software fp routines is much slower than the fallback. */
104 #define AVOID_FP_TYPE_CONVERSION(SIZE) (SIZE == 106)
105 #elif defined(WIDEST_HARDWARE_FP_SIZE)
106 #define AVOID_FP_TYPE_CONVERSION(SIZE) (SIZE > WIDEST_HARDWARE_FP_SIZE)
108 #define AVOID_FP_TYPE_CONVERSION(SIZE) 0
111 /* In the first part of this file, we are interfacing to calls generated
112 by the compiler itself. These calls pass values into these routines
113 which have very specific modes (rather than very specific types), and
114 these compiler-generated calls also expect any return values to have
115 very specific modes (rather than very specific types). Thus, we need
116 to avoid using regular C language type names in this part of the file
117 because the sizes for those types can be configured to be anything.
118 Instead we use the following special type names. */
120 typedef int QItype
__attribute__ ((mode (QI
)));
121 typedef unsigned int UQItype
__attribute__ ((mode (QI
)));
122 typedef int HItype
__attribute__ ((mode (HI
)));
123 typedef unsigned int UHItype
__attribute__ ((mode (HI
)));
124 #if MIN_UNITS_PER_WORD > 1
125 /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */
126 typedef int SItype
__attribute__ ((mode (SI
)));
127 typedef unsigned int USItype
__attribute__ ((mode (SI
)));
128 #if __SIZEOF_LONG_LONG__ > 4
129 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */
130 typedef int DItype
__attribute__ ((mode (DI
)));
131 typedef unsigned int UDItype
__attribute__ ((mode (DI
)));
132 #if MIN_UNITS_PER_WORD > 4
133 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4. */
134 typedef int TItype
__attribute__ ((mode (TI
)));
135 typedef unsigned int UTItype
__attribute__ ((mode (TI
)));
140 #if LIBGCC2_HAS_SF_MODE
141 typedef float SFtype
__attribute__ ((mode (SF
)));
142 typedef _Complex
float SCtype
__attribute__ ((mode (SC
)));
144 #if LIBGCC2_HAS_DF_MODE
145 typedef float DFtype
__attribute__ ((mode (DF
)));
146 typedef _Complex
float DCtype
__attribute__ ((mode (DC
)));
148 #if LIBGCC2_HAS_XF_MODE
149 typedef float XFtype
__attribute__ ((mode (XF
)));
150 typedef _Complex
float XCtype
__attribute__ ((mode (XC
)));
152 #if LIBGCC2_HAS_TF_MODE
153 typedef float TFtype
__attribute__ ((mode (TF
)));
154 typedef _Complex
float TCtype
__attribute__ ((mode (TC
)));
157 typedef int cmp_return_type
__attribute__((mode (__libgcc_cmp_return__
)));
158 typedef int shift_count_type
__attribute__((mode (__libgcc_shift_count__
)));
160 /* Make sure that we don't accidentally use any normal C language built-in
161 type names in the first part of this file. Instead we want to use *only*
162 the type names defined above. The following macro definitions insure
163 that if we *do* accidentally use some normal C language built-in type name,
164 we will get a syntax error. */
166 #define char bogus_type
167 #define short bogus_type
168 #define int bogus_type
169 #define long bogus_type
170 #define unsigned bogus_type
171 #define float bogus_type
172 #define double bogus_type
174 /* Versions prior to 3.4.4 were not taking into account the word size for
175 the 5 trapping arithmetic functions absv, addv, subv, mulv and negv. As
176 a consequence, the si and di variants were always and the only ones emitted.
177 To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
178 defined on platforms where it makes sense to still have the si variants
179 emitted. As a bonus, their implementation is now correct. Note that the
180 same mechanism should have been implemented for the di variants, but it
181 turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
184 #if LIBGCC2_UNITS_PER_WORD == 8
185 #define W_TYPE_SIZE (8 * BITS_PER_UNIT)
187 #define UWtype UDItype
188 #define HWtype DItype
189 #define UHWtype UDItype
190 #define DWtype TItype
191 #define UDWtype UTItype
192 #ifdef LIBGCC2_GNU_PREFIX
193 #define __NW(a,b) __gnu_ ## a ## di ## b
194 #define __NDW(a,b) __gnu_ ## a ## ti ## b
196 #define __NW(a,b) __ ## a ## di ## b
197 #define __NDW(a,b) __ ## a ## ti ## b
199 #define COMPAT_SIMODE_TRAPPING_ARITHMETIC
200 #elif LIBGCC2_UNITS_PER_WORD == 4
201 #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
203 #define UWtype USItype
204 #define HWtype SItype
205 #define UHWtype USItype
206 #define DWtype DItype
207 #define UDWtype UDItype
208 #ifdef LIBGCC2_GNU_PREFIX
209 #define __NW(a,b) __gnu_ ## a ## si ## b
210 #define __NDW(a,b) __gnu_ ## a ## di ## b
212 #define __NW(a,b) __ ## a ## si ## b
213 #define __NDW(a,b) __ ## a ## di ## b
215 #elif LIBGCC2_UNITS_PER_WORD == 2
216 #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
218 #define UWtype UHItype
219 #define HWtype HItype
220 #define UHWtype UHItype
221 #define DWtype SItype
222 #define UDWtype USItype
223 #ifdef LIBGCC2_GNU_PREFIX
224 #define __NW(a,b) __gnu_ ## a ## hi ## b
225 #define __NDW(a,b) __gnu_ ## a ## si ## b
227 #define __NW(a,b) __ ## a ## hi ## b
228 #define __NDW(a,b) __ ## a ## si ## b
231 #define W_TYPE_SIZE BITS_PER_UNIT
233 #define UWtype UQItype
234 #define HWtype QItype
235 #define UHWtype UQItype
236 #define DWtype HItype
237 #define UDWtype UHItype
238 #ifdef LIBGCC2_GNU_PREFIX
239 #define __NW(a,b) __gnu_ ## a ## qi ## b
240 #define __NDW(a,b) __gnu_ ## a ## hi ## b
242 #define __NW(a,b) __ ## a ## qi ## b
243 #define __NDW(a,b) __ ## a ## hi ## b
247 #ifdef LIBGCC2_GNU_PREFIX
248 #define __N(a) __gnu_ ## a
250 #define __N(a) __ ## a
252 #define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
253 #define Wtype_MIN (- Wtype_MAX - 1)
256 # define Wtype_MAXp1_F 0x1p8f
257 #elif W_TYPE_SIZE == 16
258 # define Wtype_MAXp1_F 0x1p16f
259 #elif W_TYPE_SIZE == 32
260 # define Wtype_MAXp1_F 0x1p32f
261 #elif W_TYPE_SIZE == 64
262 # define Wtype_MAXp1_F 0x1p64f
264 # error "expand the table"
267 #define __muldi3 __NDW(mul,3)
268 #define __divdi3 __NDW(div,3)
269 #define __udivdi3 __NDW(udiv,3)
270 #define __moddi3 __NDW(mod,3)
271 #define __umoddi3 __NDW(umod,3)
272 #define __negdi2 __NDW(neg,2)
273 #define __lshrdi3 __NDW(lshr,3)
274 #define __ashldi3 __NDW(ashl,3)
275 #define __ashrdi3 __NDW(ashr,3)
276 #define __cmpdi2 __NDW(cmp,2)
277 #define __ucmpdi2 __NDW(ucmp,2)
278 #define __udivmoddi4 __NDW(udivmod,4)
279 #define __fixunstfDI __NDW(fixunstf,)
280 #define __fixtfdi __NDW(fixtf,)
281 #define __fixunsxfDI __NDW(fixunsxf,)
282 #define __fixxfdi __NDW(fixxf,)
283 #define __fixunsdfDI __NDW(fixunsdf,)
284 #define __fixdfdi __NDW(fixdf,)
285 #define __fixunssfDI __NDW(fixunssf,)
286 #define __fixsfdi __NDW(fixsf,)
287 #define __floatdixf __NDW(float,xf)
288 #define __floatditf __NDW(float,tf)
289 #define __floatdidf __NDW(float,df)
290 #define __floatdisf __NDW(float,sf)
291 #define __floatundixf __NDW(floatun,xf)
292 #define __floatunditf __NDW(floatun,tf)
293 #define __floatundidf __NDW(floatun,df)
294 #define __floatundisf __NDW(floatun,sf)
295 #define __fixunsxfSI __NW(fixunsxf,)
296 #define __fixunstfSI __NW(fixunstf,)
297 #define __fixunsdfSI __NW(fixunsdf,)
298 #define __fixunssfSI __NW(fixunssf,)
300 #define __absvSI2 __NW(absv,2)
301 #define __addvSI3 __NW(addv,3)
302 #define __subvSI3 __NW(subv,3)
303 #define __mulvSI3 __NW(mulv,3)
304 #define __negvSI2 __NW(negv,2)
305 #define __absvDI2 __NDW(absv,2)
306 #define __addvDI3 __NDW(addv,3)
307 #define __subvDI3 __NDW(subv,3)
308 #define __mulvDI3 __NDW(mulv,3)
309 #define __negvDI2 __NDW(negv,2)
311 #define __ffsSI2 __NW(ffs,2)
312 #define __clzSI2 __NW(clz,2)
313 #define __ctzSI2 __NW(ctz,2)
314 #define __clrsbSI2 __NW(clrsb,2)
315 #define __popcountSI2 __NW(popcount,2)
316 #define __paritySI2 __NW(parity,2)
317 #define __ffsDI2 __NDW(ffs,2)
318 #define __clzDI2 __NDW(clz,2)
319 #define __ctzDI2 __NDW(ctz,2)
320 #define __clrsbDI2 __NDW(clrsb,2)
321 #define __popcountDI2 __NDW(popcount,2)
322 #define __parityDI2 __NDW(parity,2)
324 #define __clz_tab __N(clz_tab)
325 #define __bswapsi2 __N(bswapsi2)
326 #define __bswapdi2 __N(bswapdi2)
327 #define __udiv_w_sdiv __N(udiv_w_sdiv)
328 #define __clear_cache __N(clear_cache)
329 #define __enable_execute_stack __N(enable_execute_stack)
332 #define __powisf2 __N(powisf2)
335 #define __powidf2 __N(powidf2)
338 #define __powitf2 __N(powitf2)
341 #define __powixf2 __N(powixf2)
344 #define __mulsc3 __N(mulsc3)
347 #define __muldc3 __N(muldc3)
350 #define __mulxc3 __N(mulxc3)
353 #define __multc3 __N(multc3)
356 #define __divsc3 __N(divsc3)
359 #define __divdc3 __N(divdc3)
362 #define __divxc3 __N(divxc3)
365 #define __divtc3 __N(divtc3)
368 extern DWtype
__muldi3 (DWtype
, DWtype
);
369 extern DWtype
__divdi3 (DWtype
, DWtype
);
370 extern UDWtype
__udivdi3 (UDWtype
, UDWtype
);
371 extern UDWtype
__umoddi3 (UDWtype
, UDWtype
);
372 extern DWtype
__moddi3 (DWtype
, DWtype
);
374 /* __udivmoddi4 is static inline when building other libgcc2 portions. */
375 #if (!defined (L_udivdi3) && !defined (L_divdi3) && \
376 !defined (L_umoddi3) && !defined (L_moddi3))
377 extern UDWtype
__udivmoddi4 (UDWtype
, UDWtype
, UDWtype
*);
380 /* __negdi2 is static inline when building other libgcc2 portions. */
381 #if !defined(L_divdi3) && !defined(L_moddi3)
382 extern DWtype
__negdi2 (DWtype
);
385 extern DWtype
__lshrdi3 (DWtype
, shift_count_type
);
386 extern DWtype
__ashldi3 (DWtype
, shift_count_type
);
387 extern DWtype
__ashrdi3 (DWtype
, shift_count_type
);
389 /* __udiv_w_sdiv is static inline when building other libgcc2 portions. */
390 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
391 !defined(L_umoddi3) && !defined(L_moddi3))
392 extern UWtype
__udiv_w_sdiv (UWtype
*, UWtype
, UWtype
, UWtype
);
395 extern cmp_return_type
__cmpdi2 (DWtype
, DWtype
);
396 extern cmp_return_type
__ucmpdi2 (DWtype
, DWtype
);
398 #if MIN_UNITS_PER_WORD > 1
399 extern SItype
__bswapsi2 (SItype
);
401 #if __SIZEOF_LONG_LONG__ > 4
402 extern DItype
__bswapdi2 (DItype
);
405 extern Wtype
__absvSI2 (Wtype
);
406 extern Wtype
__addvSI3 (Wtype
, Wtype
);
407 extern Wtype
__subvSI3 (Wtype
, Wtype
);
408 extern Wtype
__mulvSI3 (Wtype
, Wtype
);
409 extern Wtype
__negvSI2 (Wtype
);
410 extern DWtype
__absvDI2 (DWtype
);
411 extern DWtype
__addvDI3 (DWtype
, DWtype
);
412 extern DWtype
__subvDI3 (DWtype
, DWtype
);
413 extern DWtype
__mulvDI3 (DWtype
, DWtype
);
414 extern DWtype
__negvDI2 (DWtype
);
416 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
417 #define __absvsi2 __N(absvsi2)
418 #define __negvsi2 __N(negvsi2)
419 #define __addvsi3 __N(addvsi3)
420 #define __subvsi3 __N(subvsi3)
421 #define __mulvsi3 __N(mulvsi3)
423 extern SItype
__absvsi2 (SItype
);
424 extern SItype
__addvsi3 (SItype
, SItype
);
425 extern SItype
__subvsi3 (SItype
, SItype
);
426 extern SItype
__mulvsi3 (SItype
, SItype
);
427 extern SItype
__negvsi2 (SItype
);
428 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
431 #if LIBGCC2_HAS_SF_MODE
432 extern DWtype
__fixsfdi (SFtype
);
433 extern SFtype
__floatdisf (DWtype
);
434 extern SFtype
__floatundisf (UDWtype
);
435 extern UWtype
__fixunssfSI (SFtype
);
436 extern UDWtype
__fixunssfDI (SFtype
);
437 extern SFtype
__powisf2 (SFtype
, int);
438 extern SCtype
__divsc3 (SFtype
, SFtype
, SFtype
, SFtype
);
439 extern SCtype
__mulsc3 (SFtype
, SFtype
, SFtype
, SFtype
);
441 #if LIBGCC2_HAS_DF_MODE
442 extern DWtype
__fixdfdi (DFtype
);
443 extern DFtype
__floatdidf (DWtype
);
444 extern DFtype
__floatundidf (UDWtype
);
445 extern UWtype
__fixunsdfSI (DFtype
);
446 extern UDWtype
__fixunsdfDI (DFtype
);
447 extern DFtype
__powidf2 (DFtype
, int);
448 extern DCtype
__divdc3 (DFtype
, DFtype
, DFtype
, DFtype
);
449 extern DCtype
__muldc3 (DFtype
, DFtype
, DFtype
, DFtype
);
452 #if LIBGCC2_HAS_XF_MODE
453 extern DWtype
__fixxfdi (XFtype
);
454 extern UDWtype
__fixunsxfDI (XFtype
);
455 extern XFtype
__floatdixf (DWtype
);
456 extern XFtype
__floatundixf (UDWtype
);
457 extern UWtype
__fixunsxfSI (XFtype
);
458 extern XFtype
__powixf2 (XFtype
, int);
459 extern XCtype
__divxc3 (XFtype
, XFtype
, XFtype
, XFtype
);
460 extern XCtype
__mulxc3 (XFtype
, XFtype
, XFtype
, XFtype
);
463 #if LIBGCC2_HAS_TF_MODE
464 extern UDWtype
__fixunstfDI (TFtype
);
465 extern DWtype
__fixtfdi (TFtype
);
466 extern TFtype
__floatditf (DWtype
);
467 extern TFtype
__floatunditf (UDWtype
);
468 extern TFtype
__powitf2 (TFtype
, int);
469 extern TCtype
__divtc3 (TFtype
, TFtype
, TFtype
, TFtype
);
470 extern TCtype
__multc3 (TFtype
, TFtype
, TFtype
, TFtype
);
472 #define int bogus_type
474 /* DWstructs are pairs of Wtype values in the order determined by
477 #if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
478 struct DWstruct
{Wtype high
, low
;};
480 struct DWstruct
{Wtype low
, high
;};
483 /* We need this union to unpack/pack DImode values, since we don't have
484 any arithmetic yet. Incoming DImode parameters are stored into the
485 `ll' field, and the unpacked result is read from the struct `s'. */
493 /* Defined for L_popcount_tab. Exported here because some targets may
494 want to use it for their own versions of the __popcount builtins. */
495 extern const UQItype __popcount_tab
[256];
497 /* Defined for L_clz. Exported here because some targets may want to use
498 it for their own versions of the __clz builtins. It contains the bit
499 position of the first set bit for the numbers 0 - 255. This avoids the
500 need for a separate table for the __ctz builtins. */
501 extern const UQItype __clz_tab
[256];
503 #include "longlong.h"
506 extern int __clzDI2 (UDWtype
);
507 extern int __clzSI2 (UWtype
);
508 extern int __ctzSI2 (UWtype
);
509 extern int __ctzDI2 (UDWtype
);
510 extern int __clrsbSI2 (Wtype
);
511 extern int __clrsbDI2 (DWtype
);
512 extern int __ffsSI2 (UWtype
);
513 extern int __ffsDI2 (DWtype
);
514 extern int __popcountSI2 (UWtype
);
515 extern int __popcountDI2 (UDWtype
);
516 extern int __paritySI2 (UWtype
);
517 extern int __parityDI2 (UDWtype
);
518 #define int bogus_type
520 extern void __enable_execute_stack (void *);
523 #pragma GCC visibility pop
526 #endif /* ! GCC_LIBGCC2_H */