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