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