]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/libgcc2.h
re PR tree-optimization/20204 (miscompilation of asm-declared registers)
[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
LB
18along with GCC; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, 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
32b32c8f
JJ
61#ifndef MIN_UNITS_PER_WORD
62#define MIN_UNITS_PER_WORD UNITS_PER_WORD
63#endif
64
299b83b7
KG
65/* In the first part of this file, we are interfacing to calls generated
66 by the compiler itself. These calls pass values into these routines
67 which have very specific modes (rather than very specific types), and
68 these compiler-generated calls also expect any return values to have
69 very specific modes (rather than very specific types). Thus, we need
70 to avoid using regular C language type names in this part of the file
71 because the sizes for those types can be configured to be anything.
72 Instead we use the following special type names. */
73
74typedef int QItype __attribute__ ((mode (QI)));
75typedef unsigned int UQItype __attribute__ ((mode (QI)));
76typedef int HItype __attribute__ ((mode (HI)));
77typedef unsigned int UHItype __attribute__ ((mode (HI)));
aa63d244 78#if MIN_UNITS_PER_WORD > 1
6614fd40 79/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */
299b83b7
KG
80typedef int SItype __attribute__ ((mode (SI)));
81typedef unsigned int USItype __attribute__ ((mode (SI)));
a746dbf5 82#if LONG_LONG_TYPE_SIZE > 32
6614fd40 83/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */
299b83b7
KG
84typedef int DItype __attribute__ ((mode (DI)));
85typedef unsigned int UDItype __attribute__ ((mode (DI)));
6da9c622 86#if MIN_UNITS_PER_WORD > 4
6614fd40 87/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4. */
6da9c622
RK
88typedef int TItype __attribute__ ((mode (TI)));
89typedef unsigned int UTItype __attribute__ ((mode (TI)));
90#endif
299b83b7
KG
91#endif
92#endif
93
94#if BITS_PER_UNIT == 8
95
96typedef float SFtype __attribute__ ((mode (SF)));
7e7e470f 97typedef _Complex float SCtype __attribute__ ((mode (SC)));
299b83b7 98
4f2e0d5e
RH
99#if LIBGCC2_DOUBLE_TYPE_SIZE == 64 || LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64
100#define HAVE_DFMODE
101typedef float DFtype __attribute__ ((mode (DF)));
102typedef _Complex float DCtype __attribute__ ((mode (DC)));
103#endif
968a7562 104#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
4f2e0d5e 105#define HAVE_XFMODE
299b83b7 106typedef float XFtype __attribute__ ((mode (XF)));
7e7e470f 107typedef _Complex float XCtype __attribute__ ((mode (XC)));
299b83b7
KG
108#endif
109#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
4f2e0d5e 110#define HAVE_TFMODE
299b83b7 111typedef float TFtype __attribute__ ((mode (TF)));
7e7e470f 112typedef _Complex float TCtype __attribute__ ((mode (TC)));
299b83b7
KG
113#endif
114
115#else /* BITS_PER_UNIT != 8 */
116
117/* On dsp's there are usually qf/hf/tqf modes used instead of the above.
118 For now we don't support them in libgcc2.c. */
119
120#undef L_fixdfdi
121#undef L_fixsfdi
122#undef L_fixtfdi
123#undef L_fixunsdfdi
124#undef L_fixunsdfsi
125#undef L_fixunssfdi
126#undef L_fixunssfsi
127#undef L_fixunstfdi
128#undef L_fixunsxfdi
129#undef L_fixunsxfsi
130#undef L_fixxfdi
131#undef L_floatdidf
132#undef L_floatdisf
133#undef L_floatditf
134#undef L_floatdixf
135
136#endif /* BITS_PER_UNIT != 8 */
137
138typedef int word_type __attribute__ ((mode (__word__)));
139
140/* Make sure that we don't accidentally use any normal C language built-in
141 type names in the first part of this file. Instead we want to use *only*
142 the type names defined above. The following macro definitions insure
143 that if we *do* accidentally use some normal C language built-in type name,
144 we will get a syntax error. */
145
146#define char bogus_type
147#define short bogus_type
148#define int bogus_type
149#define long bogus_type
150#define unsigned bogus_type
151#define float bogus_type
152#define double bogus_type
153
0aec6014
EB
154/* Versions prior to 3.4.4 were not taking into account the word size for
155 the 5 trapping arithmetic functions absv, addv, subv, mulv and negv. As
156 a consequence, the si and di variants were always and the only ones emitted.
157 To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
158 defined on platforms where it makes sense to still have the si variants
159 emitted. As a bonus, their implementation is now correct. Note that the
160 same mechanism should have been implemented for the di variants, but it
161 turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
162 if it existed. */
163
6da9c622
RK
164#if MIN_UNITS_PER_WORD > 4
165#define W_TYPE_SIZE (8 * BITS_PER_UNIT)
166#define Wtype DItype
167#define UWtype UDItype
168#define HWtype DItype
169#define UHWtype UDItype
170#define DWtype TItype
171#define UDWtype UTItype
172#define __NW(a,b) __ ## a ## di ## b
173#define __NDW(a,b) __ ## a ## ti ## b
0aec6014 174#define COMPAT_SIMODE_TRAPPING_ARITHMETIC
a8b462be
MH
175#elif MIN_UNITS_PER_WORD > 2 \
176 || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
299b83b7
KG
177#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
178#define Wtype SItype
179#define UWtype USItype
180#define HWtype SItype
181#define UHWtype USItype
182#define DWtype DItype
183#define UDWtype UDItype
184#define __NW(a,b) __ ## a ## si ## b
185#define __NDW(a,b) __ ## a ## di ## b
aa63d244 186#elif MIN_UNITS_PER_WORD > 1
299b83b7
KG
187#define W_TYPE_SIZE (2 * BITS_PER_UNIT)
188#define Wtype HItype
189#define UWtype UHItype
190#define HWtype HItype
191#define UHWtype UHItype
192#define DWtype SItype
193#define UDWtype USItype
194#define __NW(a,b) __ ## a ## hi ## b
195#define __NDW(a,b) __ ## a ## si ## b
196#else
197#define W_TYPE_SIZE BITS_PER_UNIT
198#define Wtype QItype
199#define UWtype UQItype
200#define HWtype QItype
201#define UHWtype UQItype
202#define DWtype HItype
203#define UDWtype UHItype
204#define __NW(a,b) __ ## a ## qi ## b
205#define __NDW(a,b) __ ## a ## hi ## b
206#endif
207
5d0e6486
AO
208#define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
209#define Wtype_MIN (- Wtype_MAX - 1)
210
4f2e0d5e
RH
211#if W_TYPE_SIZE == 8
212# define Wtype_MAXp1_F 0x1p8f
213#elif W_TYPE_SIZE == 16
214# define Wtype_MAXp1_F 0x1p16f
215#elif W_TYPE_SIZE == 32
216# define Wtype_MAXp1_F 0x1p32f
217#elif W_TYPE_SIZE == 64
218# define Wtype_MAXp1_F 0x1p64f
219#else
220# error "expand the table"
221#endif
222
6da9c622
RK
223#define __muldi3 __NDW(mul,3)
224#define __divdi3 __NDW(div,3)
225#define __udivdi3 __NDW(udiv,3)
226#define __moddi3 __NDW(mod,3)
227#define __umoddi3 __NDW(umod,3)
228#define __negdi2 __NDW(neg,2)
229#define __lshrdi3 __NDW(lshr,3)
230#define __ashldi3 __NDW(ashl,3)
231#define __ashrdi3 __NDW(ashr,3)
6da9c622
RK
232#define __cmpdi2 __NDW(cmp,2)
233#define __ucmpdi2 __NDW(ucmp,2)
234#define __udivmoddi4 __NDW(udivmod,4)
235#define __fixunstfDI __NDW(fixunstf,)
236#define __fixtfdi __NDW(fixtf,)
237#define __fixunsxfDI __NDW(fixunsxf,)
238#define __fixxfdi __NDW(fixxf,)
239#define __fixunsdfDI __NDW(fixunsdf,)
240#define __fixdfdi __NDW(fixdf,)
241#define __fixunssfDI __NDW(fixunssf,)
242#define __fixsfdi __NDW(fixsf,)
243#define __floatdixf __NDW(float,xf)
244#define __floatditf __NDW(float,tf)
245#define __floatdidf __NDW(float,df)
246#define __floatdisf __NDW(float,sf)
247#define __fixunsxfSI __NW(fixunsxf,)
248#define __fixunstfSI __NW(fixunstf,)
249#define __fixunsdfSI __NW(fixunsdf,)
250#define __fixunssfSI __NW(fixunssf,)
251
0aec6014
EB
252#define __absvSI2 __NW(absv,2)
253#define __addvSI3 __NW(addv,3)
254#define __subvSI3 __NW(subv,3)
255#define __mulvSI3 __NW(mulv,3)
256#define __negvSI2 __NW(negv,2)
257#define __absvDI2 __NDW(absv,2)
258#define __addvDI3 __NDW(addv,3)
259#define __subvDI3 __NDW(subv,3)
260#define __mulvDI3 __NDW(mulv,3)
261#define __negvDI2 __NDW(negv,2)
262
dfff898c 263#define __ffsSI2 __NW(ffs,2)
8275b011
RH
264#define __clzSI2 __NW(clz,2)
265#define __ctzSI2 __NW(ctz,2)
266#define __popcountSI2 __NW(popcount,2)
267#define __paritySI2 __NW(parity,2)
dfff898c 268#define __ffsDI2 __NDW(ffs,2)
8275b011
RH
269#define __clzDI2 __NDW(clz,2)
270#define __ctzDI2 __NDW(ctz,2)
271#define __popcountDI2 __NDW(popcount,2)
272#define __parityDI2 __NDW(parity,2)
dfff898c 273
d30d6e76
KG
274extern DWtype __muldi3 (DWtype, DWtype);
275extern DWtype __divdi3 (DWtype, DWtype);
276extern UDWtype __udivdi3 (UDWtype, UDWtype);
277extern UDWtype __umoddi3 (UDWtype, UDWtype);
278extern DWtype __moddi3 (DWtype, DWtype);
6da9c622 279
d30d6e76
KG
280/* __udivmoddi4 is static inline when building other libgcc2 portions. */
281#if (!defined (L_udivdi3) && !defined (L_divdi3) && \
282 !defined (L_umoddi3) && !defined (L_moddi3))
283extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
284#endif
285
286/* __negdi2 is static inline when building other libgcc2 portions. */
287#if !defined(L_divdi3) && !defined(L_moddi3)
288extern DWtype __negdi2 (DWtype);
289#endif
290
291extern DWtype __lshrdi3 (DWtype, word_type);
292extern DWtype __ashldi3 (DWtype, word_type);
293extern DWtype __ashrdi3 (DWtype, word_type);
2928cd7a 294
d30d6e76
KG
295/* __udiv_w_sdiv is static inline when building other libgcc2 portions. */
296#if (!defined(L_udivdi3) && !defined(L_divdi3) && \
297 !defined(L_umoddi3) && !defined(L_moddi3))
298extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
299#endif
300
301extern word_type __cmpdi2 (DWtype, DWtype);
302extern word_type __ucmpdi2 (DWtype, DWtype);
303
0aec6014
EB
304extern Wtype __absvSI2 (Wtype);
305extern Wtype __addvSI3 (Wtype, Wtype);
306extern Wtype __subvSI3 (Wtype, Wtype);
307extern Wtype __mulvSI3 (Wtype, Wtype);
308extern Wtype __negvSI2 (Wtype);
309extern DWtype __absvDI2 (DWtype);
310extern DWtype __addvDI3 (DWtype, DWtype);
311extern DWtype __subvDI3 (DWtype, DWtype);
312extern DWtype __mulvDI3 (DWtype, DWtype);
313extern DWtype __negvDI2 (DWtype);
314
315#ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
316extern SItype __absvsi2 (SItype);
317extern SItype __addvsi3 (SItype, SItype);
318extern SItype __subvsi3 (SItype, SItype);
319extern SItype __mulvsi3 (SItype, SItype);
320extern SItype __negvsi2 (SItype);
321#endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
8f54374e 322
d30d6e76 323#if BITS_PER_UNIT == 8
d30d6e76 324extern DWtype __fixsfdi (SFtype);
d30d6e76 325extern SFtype __floatdisf (DWtype);
6da9c622 326extern UWtype __fixunssfSI (SFtype);
6da9c622 327extern DWtype __fixunssfDI (SFtype);
17684d46 328extern SFtype __powisf2 (SFtype, Wtype);
7e7e470f
RH
329extern SCtype __divsc3 (SFtype, SFtype, SFtype, SFtype);
330extern SCtype __mulsc3 (SFtype, SFtype, SFtype, SFtype);
4f2e0d5e
RH
331
332#ifdef HAVE_DFMODE
333extern DWtype __fixdfdi (DFtype);
334extern DFtype __floatdidf (DWtype);
335extern UWtype __fixunsdfSI (DFtype);
336extern DWtype __fixunsdfDI (DFtype);
337extern DFtype __powidf2 (DFtype, Wtype);
7e7e470f
RH
338extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype);
339extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype);
4f2e0d5e 340#endif
7e7e470f 341
4f2e0d5e 342#ifdef HAVE_XFMODE
d30d6e76 343extern DWtype __fixxfdi (XFtype);
6da9c622 344extern DWtype __fixunsxfDI (XFtype);
d30d6e76 345extern XFtype __floatdixf (DWtype);
6da9c622 346extern UWtype __fixunsxfSI (XFtype);
17684d46 347extern XFtype __powixf2 (XFtype, Wtype);
7e7e470f
RH
348extern XCtype __divxc3 (XFtype, XFtype, XFtype, XFtype);
349extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype);
d30d6e76
KG
350#endif
351
4f2e0d5e 352#ifdef HAVE_TFMODE
6da9c622 353extern DWtype __fixunstfDI (TFtype);
d30d6e76
KG
354extern DWtype __fixtfdi (TFtype);
355extern TFtype __floatditf (DWtype);
17684d46 356extern TFtype __powitf2 (TFtype, Wtype);
7e7e470f
RH
357extern TCtype __divtc3 (TFtype, TFtype, TFtype, TFtype);
358extern TCtype __multc3 (TFtype, TFtype, TFtype, TFtype);
d30d6e76
KG
359#endif
360#endif /* BITS_PER_UNIT == 8 */
361
299b83b7
KG
362/* DWstructs are pairs of Wtype values in the order determined by
363 LIBGCC2_WORDS_BIG_ENDIAN. */
364
365#if LIBGCC2_WORDS_BIG_ENDIAN
366 struct DWstruct {Wtype high, low;};
367#else
368 struct DWstruct {Wtype low, high;};
369#endif
370
371/* We need this union to unpack/pack DImode values, since we don't have
372 any arithmetic yet. Incoming DImode parameters are stored into the
373 `ll' field, and the unpacked result is read from the struct `s'. */
374
375typedef union
376{
377 struct DWstruct s;
378 DWtype ll;
379} DWunion;
380
299b83b7
KG
381#include "longlong.h"
382
3fc1f660
MM
383#undef int
384extern int __clzDI2 (UDWtype);
385extern int __clzSI2 (UWtype);
386extern int __ctzSI2 (UWtype);
387extern int __ffsSI2 (UWtype);
388extern int __ffsDI2 (DWtype);
389extern int __ctzDI2 (UDWtype);
390extern int __popcountSI2 (UWtype);
391extern int __popcountDI2 (UDWtype);
392extern int __paritySI2 (UWtype);
393extern int __parityDI2 (UDWtype);
394#define int bogus_type
395
396extern void __enable_execute_stack (void *);
397
7370bebd 398#ifndef HIDE_EXPORTS
3fc1f660 399#pragma GCC visibility pop
7370bebd 400#endif
3fc1f660 401
88657302 402#endif /* ! GCC_LIBGCC2_H */