]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/libgcc2.h
mips.c (compute_frame_size): Restore the original gp_sp_offset for !GENERATE_MIPS16E_...
[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
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. */
45
46#ifndef LIBGCC2_WORDS_BIG_ENDIAN
47#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
48#endif
49
4f2e0d5e
RH
50#ifndef LIBGCC2_DOUBLE_TYPE_SIZE
51#define LIBGCC2_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
52#endif
299b83b7
KG
53#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
54#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
55#endif
56
cfa7bd9c
RS
57#ifndef LIBGCC2_HAS_SF_MODE
58#define LIBGCC2_HAS_SF_MODE (BITS_PER_UNIT == 8)
59#endif
60
4e9db8b2
SE
61#ifndef LIBGCC2_HAS_DF_MODE
62#define LIBGCC2_HAS_DF_MODE \
cfa7bd9c
RS
63 (BITS_PER_UNIT == 8 \
64 && (LIBGCC2_DOUBLE_TYPE_SIZE == 64 \
65 || LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64))
4e9db8b2
SE
66#endif
67
68#ifndef LIBGCC2_HAS_XF_MODE
cfa7bd9c
RS
69#define LIBGCC2_HAS_XF_MODE \
70 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
4e9db8b2
SE
71#endif
72
73#ifndef LIBGCC2_HAS_TF_MODE
cfa7bd9c
RS
74#define LIBGCC2_HAS_TF_MODE \
75 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
4e9db8b2
SE
76#endif
77
4a73d865
JM
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
85
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
99
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
107
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
115
b04c9063
AM
116/* FIXME: This #ifdef probably should be removed, ie. enable the test
117 for mips too. */
5fb54b91
RH
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. */
b04c9063 122#ifdef __powerpc__
5fb54b91
RH
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)
b04c9063 126#else
5fb54b91 127#define AVOID_FP_TYPE_CONVERSION(SIZE) 0
b04c9063
AM
128#endif
129
299b83b7
KG
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. */
138
139typedef int QItype __attribute__ ((mode (QI)));
140typedef unsigned int UQItype __attribute__ ((mode (QI)));
141typedef int HItype __attribute__ ((mode (HI)));
142typedef unsigned int UHItype __attribute__ ((mode (HI)));
aa63d244 143#if MIN_UNITS_PER_WORD > 1
6614fd40 144/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */
299b83b7
KG
145typedef int SItype __attribute__ ((mode (SI)));
146typedef unsigned int USItype __attribute__ ((mode (SI)));
a746dbf5 147#if LONG_LONG_TYPE_SIZE > 32
6614fd40 148/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */
299b83b7
KG
149typedef int DItype __attribute__ ((mode (DI)));
150typedef unsigned int UDItype __attribute__ ((mode (DI)));
6da9c622 151#if MIN_UNITS_PER_WORD > 4
6614fd40 152/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4. */
6da9c622
RK
153typedef int TItype __attribute__ ((mode (TI)));
154typedef unsigned int UTItype __attribute__ ((mode (TI)));
155#endif
299b83b7
KG
156#endif
157#endif
158
cfa7bd9c 159#if LIBGCC2_HAS_SF_MODE
299b83b7 160typedef float SFtype __attribute__ ((mode (SF)));
7e7e470f 161typedef _Complex float SCtype __attribute__ ((mode (SC)));
cfa7bd9c 162#endif
4e9db8b2 163#if LIBGCC2_HAS_DF_MODE
4f2e0d5e
RH
164typedef float DFtype __attribute__ ((mode (DF)));
165typedef _Complex float DCtype __attribute__ ((mode (DC)));
166#endif
4e9db8b2 167#if LIBGCC2_HAS_XF_MODE
299b83b7 168typedef float XFtype __attribute__ ((mode (XF)));
7e7e470f 169typedef _Complex float XCtype __attribute__ ((mode (XC)));
299b83b7 170#endif
4e9db8b2 171#if LIBGCC2_HAS_TF_MODE
299b83b7 172typedef float TFtype __attribute__ ((mode (TF)));
7e7e470f 173typedef _Complex float TCtype __attribute__ ((mode (TC)));
299b83b7
KG
174#endif
175
299b83b7
KG
176typedef int word_type __attribute__ ((mode (__word__)));
177
178/* Make sure that we don't accidentally use any normal C language built-in
179 type names in the first part of this file. Instead we want to use *only*
180 the type names defined above. The following macro definitions insure
181 that if we *do* accidentally use some normal C language built-in type name,
182 we will get a syntax error. */
183
184#define char bogus_type
185#define short bogus_type
186#define int bogus_type
187#define long bogus_type
188#define unsigned bogus_type
189#define float bogus_type
190#define double bogus_type
191
0aec6014
EB
192/* Versions prior to 3.4.4 were not taking into account the word size for
193 the 5 trapping arithmetic functions absv, addv, subv, mulv and negv. As
194 a consequence, the si and di variants were always and the only ones emitted.
195 To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
196 defined on platforms where it makes sense to still have the si variants
197 emitted. As a bonus, their implementation is now correct. Note that the
198 same mechanism should have been implemented for the di variants, but it
199 turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
200 if it existed. */
201
baffad1f 202#if LIBGCC2_UNITS_PER_WORD == 8
6da9c622
RK
203#define W_TYPE_SIZE (8 * BITS_PER_UNIT)
204#define Wtype DItype
205#define UWtype UDItype
206#define HWtype DItype
207#define UHWtype UDItype
208#define DWtype TItype
209#define UDWtype UTItype
210#define __NW(a,b) __ ## a ## di ## b
211#define __NDW(a,b) __ ## a ## ti ## b
0aec6014 212#define COMPAT_SIMODE_TRAPPING_ARITHMETIC
baffad1f 213#elif LIBGCC2_UNITS_PER_WORD == 4
299b83b7
KG
214#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
215#define Wtype SItype
216#define UWtype USItype
217#define HWtype SItype
218#define UHWtype USItype
219#define DWtype DItype
220#define UDWtype UDItype
221#define __NW(a,b) __ ## a ## si ## b
222#define __NDW(a,b) __ ## a ## di ## b
baffad1f 223#elif LIBGCC2_UNITS_PER_WORD == 2
299b83b7
KG
224#define W_TYPE_SIZE (2 * BITS_PER_UNIT)
225#define Wtype HItype
226#define UWtype UHItype
227#define HWtype HItype
228#define UHWtype UHItype
229#define DWtype SItype
230#define UDWtype USItype
231#define __NW(a,b) __ ## a ## hi ## b
232#define __NDW(a,b) __ ## a ## si ## b
233#else
234#define W_TYPE_SIZE BITS_PER_UNIT
235#define Wtype QItype
236#define UWtype UQItype
237#define HWtype QItype
238#define UHWtype UQItype
239#define DWtype HItype
240#define UDWtype UHItype
241#define __NW(a,b) __ ## a ## qi ## b
242#define __NDW(a,b) __ ## a ## hi ## b
243#endif
244
5d0e6486
AO
245#define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
246#define Wtype_MIN (- Wtype_MAX - 1)
247
4f2e0d5e
RH
248#if W_TYPE_SIZE == 8
249# define Wtype_MAXp1_F 0x1p8f
250#elif W_TYPE_SIZE == 16
251# define Wtype_MAXp1_F 0x1p16f
252#elif W_TYPE_SIZE == 32
253# define Wtype_MAXp1_F 0x1p32f
254#elif W_TYPE_SIZE == 64
255# define Wtype_MAXp1_F 0x1p64f
256#else
257# error "expand the table"
258#endif
259
6da9c622
RK
260#define __muldi3 __NDW(mul,3)
261#define __divdi3 __NDW(div,3)
262#define __udivdi3 __NDW(udiv,3)
263#define __moddi3 __NDW(mod,3)
264#define __umoddi3 __NDW(umod,3)
265#define __negdi2 __NDW(neg,2)
266#define __lshrdi3 __NDW(lshr,3)
267#define __ashldi3 __NDW(ashl,3)
268#define __ashrdi3 __NDW(ashr,3)
6da9c622
RK
269#define __cmpdi2 __NDW(cmp,2)
270#define __ucmpdi2 __NDW(ucmp,2)
271#define __udivmoddi4 __NDW(udivmod,4)
272#define __fixunstfDI __NDW(fixunstf,)
273#define __fixtfdi __NDW(fixtf,)
274#define __fixunsxfDI __NDW(fixunsxf,)
275#define __fixxfdi __NDW(fixxf,)
276#define __fixunsdfDI __NDW(fixunsdf,)
277#define __fixdfdi __NDW(fixdf,)
278#define __fixunssfDI __NDW(fixunssf,)
279#define __fixsfdi __NDW(fixsf,)
280#define __floatdixf __NDW(float,xf)
281#define __floatditf __NDW(float,tf)
282#define __floatdidf __NDW(float,df)
283#define __floatdisf __NDW(float,sf)
d7735880
JM
284#define __floatundixf __NDW(floatun,xf)
285#define __floatunditf __NDW(floatun,tf)
286#define __floatundidf __NDW(floatun,df)
287#define __floatundisf __NDW(floatun,sf)
6da9c622
RK
288#define __fixunsxfSI __NW(fixunsxf,)
289#define __fixunstfSI __NW(fixunstf,)
290#define __fixunsdfSI __NW(fixunsdf,)
291#define __fixunssfSI __NW(fixunssf,)
292
0aec6014
EB
293#define __absvSI2 __NW(absv,2)
294#define __addvSI3 __NW(addv,3)
295#define __subvSI3 __NW(subv,3)
296#define __mulvSI3 __NW(mulv,3)
297#define __negvSI2 __NW(negv,2)
298#define __absvDI2 __NDW(absv,2)
299#define __addvDI3 __NDW(addv,3)
300#define __subvDI3 __NDW(subv,3)
301#define __mulvDI3 __NDW(mulv,3)
302#define __negvDI2 __NDW(negv,2)
303
dfff898c 304#define __ffsSI2 __NW(ffs,2)
8275b011
RH
305#define __clzSI2 __NW(clz,2)
306#define __ctzSI2 __NW(ctz,2)
307#define __popcountSI2 __NW(popcount,2)
308#define __paritySI2 __NW(parity,2)
dfff898c 309#define __ffsDI2 __NDW(ffs,2)
8275b011
RH
310#define __clzDI2 __NDW(clz,2)
311#define __ctzDI2 __NDW(ctz,2)
312#define __popcountDI2 __NDW(popcount,2)
313#define __parityDI2 __NDW(parity,2)
dfff898c 314
d30d6e76
KG
315extern DWtype __muldi3 (DWtype, DWtype);
316extern DWtype __divdi3 (DWtype, DWtype);
317extern UDWtype __udivdi3 (UDWtype, UDWtype);
318extern UDWtype __umoddi3 (UDWtype, UDWtype);
319extern DWtype __moddi3 (DWtype, DWtype);
6da9c622 320
d30d6e76
KG
321/* __udivmoddi4 is static inline when building other libgcc2 portions. */
322#if (!defined (L_udivdi3) && !defined (L_divdi3) && \
323 !defined (L_umoddi3) && !defined (L_moddi3))
324extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
325#endif
326
327/* __negdi2 is static inline when building other libgcc2 portions. */
328#if !defined(L_divdi3) && !defined(L_moddi3)
329extern DWtype __negdi2 (DWtype);
330#endif
331
332extern DWtype __lshrdi3 (DWtype, word_type);
333extern DWtype __ashldi3 (DWtype, word_type);
334extern DWtype __ashrdi3 (DWtype, word_type);
2928cd7a 335
d30d6e76
KG
336/* __udiv_w_sdiv is static inline when building other libgcc2 portions. */
337#if (!defined(L_udivdi3) && !defined(L_divdi3) && \
338 !defined(L_umoddi3) && !defined(L_moddi3))
339extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
340#endif
341
342extern word_type __cmpdi2 (DWtype, DWtype);
343extern word_type __ucmpdi2 (DWtype, DWtype);
344
66965e90
EC
345#if MIN_UNITS_PER_WORD > 1
346extern SItype __bswapsi2 (SItype);
347#endif
348#if LONG_LONG_TYPE_SIZE > 32
349extern DItype __bswapdi2 (DItype);
350#endif
351
0aec6014
EB
352extern Wtype __absvSI2 (Wtype);
353extern Wtype __addvSI3 (Wtype, Wtype);
354extern Wtype __subvSI3 (Wtype, Wtype);
355extern Wtype __mulvSI3 (Wtype, Wtype);
356extern Wtype __negvSI2 (Wtype);
357extern DWtype __absvDI2 (DWtype);
358extern DWtype __addvDI3 (DWtype, DWtype);
359extern DWtype __subvDI3 (DWtype, DWtype);
360extern DWtype __mulvDI3 (DWtype, DWtype);
361extern DWtype __negvDI2 (DWtype);
362
363#ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
364extern SItype __absvsi2 (SItype);
365extern SItype __addvsi3 (SItype, SItype);
366extern SItype __subvsi3 (SItype, SItype);
367extern SItype __mulvsi3 (SItype, SItype);
368extern SItype __negvsi2 (SItype);
369#endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
8f54374e 370
0b8495ae 371#undef int
cfa7bd9c 372#if LIBGCC2_HAS_SF_MODE
d30d6e76 373extern DWtype __fixsfdi (SFtype);
d30d6e76 374extern SFtype __floatdisf (DWtype);
d7735880 375extern SFtype __floatundisf (UDWtype);
6da9c622 376extern UWtype __fixunssfSI (SFtype);
6da9c622 377extern DWtype __fixunssfDI (SFtype);
0b8495ae 378extern SFtype __powisf2 (SFtype, int);
7e7e470f
RH
379extern SCtype __divsc3 (SFtype, SFtype, SFtype, SFtype);
380extern SCtype __mulsc3 (SFtype, SFtype, SFtype, SFtype);
cfa7bd9c 381#endif
4e9db8b2 382#if LIBGCC2_HAS_DF_MODE
4f2e0d5e
RH
383extern DWtype __fixdfdi (DFtype);
384extern DFtype __floatdidf (DWtype);
d7735880 385extern DFtype __floatundidf (UDWtype);
4f2e0d5e
RH
386extern UWtype __fixunsdfSI (DFtype);
387extern DWtype __fixunsdfDI (DFtype);
0b8495ae 388extern DFtype __powidf2 (DFtype, int);
7e7e470f
RH
389extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype);
390extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype);
4f2e0d5e 391#endif
7e7e470f 392
4e9db8b2 393#if LIBGCC2_HAS_XF_MODE
d30d6e76 394extern DWtype __fixxfdi (XFtype);
6da9c622 395extern DWtype __fixunsxfDI (XFtype);
d30d6e76 396extern XFtype __floatdixf (DWtype);
d7735880 397extern XFtype __floatundixf (UDWtype);
6da9c622 398extern UWtype __fixunsxfSI (XFtype);
0b8495ae 399extern XFtype __powixf2 (XFtype, int);
7e7e470f
RH
400extern XCtype __divxc3 (XFtype, XFtype, XFtype, XFtype);
401extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype);
d30d6e76
KG
402#endif
403
4e9db8b2 404#if LIBGCC2_HAS_TF_MODE
6da9c622 405extern DWtype __fixunstfDI (TFtype);
d30d6e76
KG
406extern DWtype __fixtfdi (TFtype);
407extern TFtype __floatditf (DWtype);
d7735880 408extern TFtype __floatunditf (UDWtype);
0b8495ae 409extern TFtype __powitf2 (TFtype, int);
7e7e470f
RH
410extern TCtype __divtc3 (TFtype, TFtype, TFtype, TFtype);
411extern TCtype __multc3 (TFtype, TFtype, TFtype, TFtype);
d30d6e76 412#endif
0b8495ae 413#define int bogus_type
d30d6e76 414
299b83b7
KG
415/* DWstructs are pairs of Wtype values in the order determined by
416 LIBGCC2_WORDS_BIG_ENDIAN. */
417
418#if LIBGCC2_WORDS_BIG_ENDIAN
419 struct DWstruct {Wtype high, low;};
420#else
421 struct DWstruct {Wtype low, high;};
422#endif
423
424/* We need this union to unpack/pack DImode values, since we don't have
425 any arithmetic yet. Incoming DImode parameters are stored into the
426 `ll' field, and the unpacked result is read from the struct `s'. */
427
428typedef union
429{
430 struct DWstruct s;
431 DWtype ll;
432} DWunion;
433
dcfae47c
NC
434/* Defined for L_popcount_tab. Exported here because some targets may
435 want to use it for their own versions of the __popcount builtins. */
436extern const UQItype __popcount_tab[256];
437
438/* Defined for L_clz. Exported here because some targets may want to use
439 it for their own versions of the __clz builtins. It contains the bit
440 position of the first set bit for the numbers 0 - 255. This avoids the
6fc0bb99 441 need for a separate table for the __ctz builtins. */
dcfae47c
NC
442extern const UQItype __clz_tab[256];
443
299b83b7
KG
444#include "longlong.h"
445
3fc1f660
MM
446#undef int
447extern int __clzDI2 (UDWtype);
448extern int __clzSI2 (UWtype);
449extern int __ctzSI2 (UWtype);
450extern int __ffsSI2 (UWtype);
451extern int __ffsDI2 (DWtype);
452extern int __ctzDI2 (UDWtype);
453extern int __popcountSI2 (UWtype);
454extern int __popcountDI2 (UDWtype);
455extern int __paritySI2 (UWtype);
456extern int __parityDI2 (UDWtype);
457#define int bogus_type
458
459extern void __enable_execute_stack (void *);
460
7370bebd 461#ifndef HIDE_EXPORTS
3fc1f660 462#pragma GCC visibility pop
7370bebd 463#endif
3fc1f660 464
88657302 465#endif /* ! GCC_LIBGCC2_H */