1 /* Header file for libgcc2.c. */
2 /* Copyright (C) 2000, 2001, 2004, 2005
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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. */
34 #pragma GCC visibility push(default)
37 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
38 extern void __clear_cache (char *, char *);
39 extern void __eprintf (const char *, const char *, unsigned int, const char *)
40 __attribute__ ((__noreturn__));
42 struct exception_descriptor;
43 extern short int __get_eh_table_language (struct exception_descriptor *);
44 extern short int __get_eh_table_version (struct exception_descriptor *);
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
50 #ifndef LIBGCC2_WORDS_BIG_ENDIAN
51 #define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
54 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
55 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
58 #ifndef MIN_UNITS_PER_WORD
59 #define MIN_UNITS_PER_WORD UNITS_PER_WORD
62 /* In the first part of this file, we are interfacing to calls generated
63 by the compiler itself. These calls pass values into these routines
64 which have very specific modes (rather than very specific types), and
65 these compiler-generated calls also expect any return values to have
66 very specific modes (rather than very specific types). Thus, we need
67 to avoid using regular C language type names in this part of the file
68 because the sizes for those types can be configured to be anything.
69 Instead we use the following special type names. */
71 typedef int QItype __attribute__ ((mode (QI)));
72 typedef unsigned int UQItype __attribute__ ((mode (QI)));
73 typedef int HItype __attribute__ ((mode (HI)));
74 typedef unsigned int UHItype __attribute__ ((mode (HI)));
75 #if MIN_UNITS_PER_WORD > 1
76 /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */
77 typedef int SItype __attribute__ ((mode (SI)));
78 typedef unsigned int USItype __attribute__ ((mode (SI)));
79 #if LONG_LONG_TYPE_SIZE > 32
80 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */
81 typedef int DItype __attribute__ ((mode (DI)));
82 typedef unsigned int UDItype __attribute__ ((mode (DI)));
83 #if MIN_UNITS_PER_WORD > 4
84 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4. */
85 typedef int TItype __attribute__ ((mode (TI)));
86 typedef unsigned int UTItype __attribute__ ((mode (TI)));
91 #if BITS_PER_UNIT == 8
93 typedef float SFtype __attribute__ ((mode (SF)));
94 typedef float DFtype __attribute__ ((mode (DF)));
95 typedef _Complex float SCtype __attribute__ ((mode (SC)));
96 typedef _Complex float DCtype __attribute__ ((mode (DC)));
98 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
99 typedef float XFtype __attribute__ ((mode (XF)));
100 typedef _Complex float XCtype __attribute__ ((mode (XC)));
102 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
103 typedef float TFtype __attribute__ ((mode (TF)));
104 typedef _Complex float TCtype __attribute__ ((mode (TC)));
107 #else /* BITS_PER_UNIT != 8 */
109 /* On dsp's there are usually qf/hf/tqf modes used instead of the above.
110 For now we don't support them in libgcc2.c. */
128 #endif /* BITS_PER_UNIT != 8 */
130 typedef int word_type __attribute__ ((mode (__word__)));
132 /* Make sure that we don't accidentally use any normal C language built-in
133 type names in the first part of this file. Instead we want to use *only*
134 the type names defined above. The following macro definitions insure
135 that if we *do* accidentally use some normal C language built-in type name,
136 we will get a syntax error. */
138 #define char bogus_type
139 #define short bogus_type
140 #define int bogus_type
141 #define long bogus_type
142 #define unsigned bogus_type
143 #define float bogus_type
144 #define double bogus_type
146 /* Versions prior to 3.4.4 were not taking into account the word size for
147 the 5 trapping arithmetic functions absv, addv, subv, mulv and negv. As
148 a consequence, the si and di variants were always and the only ones emitted.
149 To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
150 defined on platforms where it makes sense to still have the si variants
151 emitted. As a bonus, their implementation is now correct. Note that the
152 same mechanism should have been implemented for the di variants, but it
153 turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
156 #if MIN_UNITS_PER_WORD > 4
157 #define W_TYPE_SIZE (8 * BITS_PER_UNIT)
159 #define UWtype UDItype
160 #define HWtype DItype
161 #define UHWtype UDItype
162 #define DWtype TItype
163 #define UDWtype UTItype
164 #define __NW(a,b) __ ## a ## di ## b
165 #define __NDW(a,b) __ ## a ## ti ## b
166 #define COMPAT_SIMODE_TRAPPING_ARITHMETIC
167 #elif MIN_UNITS_PER_WORD > 2 \
168 || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
169 #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
171 #define UWtype USItype
172 #define HWtype SItype
173 #define UHWtype USItype
174 #define DWtype DItype
175 #define UDWtype UDItype
176 #define __NW(a,b) __ ## a ## si ## b
177 #define __NDW(a,b) __ ## a ## di ## b
178 #elif MIN_UNITS_PER_WORD > 1
179 #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
181 #define UWtype UHItype
182 #define HWtype HItype
183 #define UHWtype UHItype
184 #define DWtype SItype
185 #define UDWtype USItype
186 #define __NW(a,b) __ ## a ## hi ## b
187 #define __NDW(a,b) __ ## a ## si ## b
189 #define W_TYPE_SIZE BITS_PER_UNIT
191 #define UWtype UQItype
192 #define HWtype QItype
193 #define UHWtype UQItype
194 #define DWtype HItype
195 #define UDWtype UHItype
196 #define __NW(a,b) __ ## a ## qi ## b
197 #define __NDW(a,b) __ ## a ## hi ## b
200 #define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
201 #define Wtype_MIN (- Wtype_MAX - 1)
203 #define __muldi3 __NDW(mul,3)
204 #define __divdi3 __NDW(div,3)
205 #define __udivdi3 __NDW(udiv,3)
206 #define __moddi3 __NDW(mod,3)
207 #define __umoddi3 __NDW(umod,3)
208 #define __negdi2 __NDW(neg,2)
209 #define __lshrdi3 __NDW(lshr,3)
210 #define __ashldi3 __NDW(ashl,3)
211 #define __ashrdi3 __NDW(ashr,3)
212 #define __cmpdi2 __NDW(cmp,2)
213 #define __ucmpdi2 __NDW(ucmp,2)
214 #define __udivmoddi4 __NDW(udivmod,4)
215 #define __fixunstfDI __NDW(fixunstf,)
216 #define __fixtfdi __NDW(fixtf,)
217 #define __fixunsxfDI __NDW(fixunsxf,)
218 #define __fixxfdi __NDW(fixxf,)
219 #define __fixunsdfDI __NDW(fixunsdf,)
220 #define __fixdfdi __NDW(fixdf,)
221 #define __fixunssfDI __NDW(fixunssf,)
222 #define __fixsfdi __NDW(fixsf,)
223 #define __floatdixf __NDW(float,xf)
224 #define __floatditf __NDW(float,tf)
225 #define __floatdidf __NDW(float,df)
226 #define __floatdisf __NDW(float,sf)
227 #define __fixunsxfSI __NW(fixunsxf,)
228 #define __fixunstfSI __NW(fixunstf,)
229 #define __fixunsdfSI __NW(fixunsdf,)
230 #define __fixunssfSI __NW(fixunssf,)
232 #define __absvSI2 __NW(absv,2)
233 #define __addvSI3 __NW(addv,3)
234 #define __subvSI3 __NW(subv,3)
235 #define __mulvSI3 __NW(mulv,3)
236 #define __negvSI2 __NW(negv,2)
237 #define __absvDI2 __NDW(absv,2)
238 #define __addvDI3 __NDW(addv,3)
239 #define __subvDI3 __NDW(subv,3)
240 #define __mulvDI3 __NDW(mulv,3)
241 #define __negvDI2 __NDW(negv,2)
243 #define __ffsSI2 __NW(ffs,2)
244 #define __clzSI2 __NW(clz,2)
245 #define __ctzSI2 __NW(ctz,2)
246 #define __popcountSI2 __NW(popcount,2)
247 #define __paritySI2 __NW(parity,2)
248 #define __ffsDI2 __NDW(ffs,2)
249 #define __clzDI2 __NDW(clz,2)
250 #define __ctzDI2 __NDW(ctz,2)
251 #define __popcountDI2 __NDW(popcount,2)
252 #define __parityDI2 __NDW(parity,2)
254 extern DWtype __muldi3 (DWtype, DWtype);
255 extern DWtype __divdi3 (DWtype, DWtype);
256 extern UDWtype __udivdi3 (UDWtype, UDWtype);
257 extern UDWtype __umoddi3 (UDWtype, UDWtype);
258 extern DWtype __moddi3 (DWtype, DWtype);
260 /* __udivmoddi4 is static inline when building other libgcc2 portions. */
261 #if (!defined (L_udivdi3) && !defined (L_divdi3) && \
262 !defined (L_umoddi3) && !defined (L_moddi3))
263 extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
266 /* __negdi2 is static inline when building other libgcc2 portions. */
267 #if !defined(L_divdi3) && !defined(L_moddi3)
268 extern DWtype __negdi2 (DWtype);
271 extern DWtype __lshrdi3 (DWtype, word_type);
272 extern DWtype __ashldi3 (DWtype, word_type);
273 extern DWtype __ashrdi3 (DWtype, word_type);
275 /* __udiv_w_sdiv is static inline when building other libgcc2 portions. */
276 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
277 !defined(L_umoddi3) && !defined(L_moddi3))
278 extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
281 extern word_type __cmpdi2 (DWtype, DWtype);
282 extern word_type __ucmpdi2 (DWtype, DWtype);
284 extern Wtype __absvSI2 (Wtype);
285 extern Wtype __addvSI3 (Wtype, Wtype);
286 extern Wtype __subvSI3 (Wtype, Wtype);
287 extern Wtype __mulvSI3 (Wtype, Wtype);
288 extern Wtype __negvSI2 (Wtype);
289 extern DWtype __absvDI2 (DWtype);
290 extern DWtype __addvDI3 (DWtype, DWtype);
291 extern DWtype __subvDI3 (DWtype, DWtype);
292 extern DWtype __mulvDI3 (DWtype, DWtype);
293 extern DWtype __negvDI2 (DWtype);
295 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
296 extern SItype __absvsi2 (SItype);
297 extern SItype __addvsi3 (SItype, SItype);
298 extern SItype __subvsi3 (SItype, SItype);
299 extern SItype __mulvsi3 (SItype, SItype);
300 extern SItype __negvsi2 (SItype);
301 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
303 #if BITS_PER_UNIT == 8
304 extern DWtype __fixdfdi (DFtype);
305 extern DWtype __fixsfdi (SFtype);
306 extern DFtype __floatdidf (DWtype);
307 extern SFtype __floatdisf (DWtype);
308 extern UWtype __fixunsdfSI (DFtype);
309 extern UWtype __fixunssfSI (SFtype);
310 extern DWtype __fixunsdfDI (DFtype);
311 extern DWtype __fixunssfDI (SFtype);
312 extern SFtype __powisf2 (SFtype, Wtype);
313 extern DFtype __powidf2 (DFtype, Wtype);
315 extern SCtype __divsc3 (SFtype, SFtype, SFtype, SFtype);
316 extern SCtype __mulsc3 (SFtype, SFtype, SFtype, SFtype);
317 extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype);
318 extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype);
320 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
321 extern DWtype __fixxfdi (XFtype);
322 extern DWtype __fixunsxfDI (XFtype);
323 extern XFtype __floatdixf (DWtype);
324 extern UWtype __fixunsxfSI (XFtype);
325 extern XFtype __powixf2 (XFtype, Wtype);
326 extern XCtype __divxc3 (XFtype, XFtype, XFtype, XFtype);
327 extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype);
330 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
331 extern DWtype __fixunstfDI (TFtype);
332 extern DWtype __fixtfdi (TFtype);
333 extern TFtype __floatditf (DWtype);
334 extern TFtype __powitf2 (TFtype, Wtype);
335 extern TCtype __divtc3 (TFtype, TFtype, TFtype, TFtype);
336 extern TCtype __multc3 (TFtype, TFtype, TFtype, TFtype);
338 #endif /* BITS_PER_UNIT == 8 */
340 /* DWstructs are pairs of Wtype values in the order determined by
341 LIBGCC2_WORDS_BIG_ENDIAN. */
343 #if LIBGCC2_WORDS_BIG_ENDIAN
344 struct DWstruct {Wtype high, low;};
346 struct DWstruct {Wtype low, high;};
349 /* We need this union to unpack/pack DImode values, since we don't have
350 any arithmetic yet. Incoming DImode parameters are stored into the
351 `ll' field, and the unpacked result is read from the struct `s'. */
359 #include "longlong.h"
362 extern int __clzDI2 (UDWtype);
363 extern int __clzSI2 (UWtype);
364 extern int __ctzSI2 (UWtype);
365 extern int __ffsSI2 (UWtype);
366 extern int __ffsDI2 (DWtype);
367 extern int __ctzDI2 (UDWtype);
368 extern int __popcountSI2 (UWtype);
369 extern int __popcountDI2 (UDWtype);
370 extern int __paritySI2 (UWtype);
371 extern int __parityDI2 (UDWtype);
372 #define int bogus_type
374 extern void __enable_execute_stack (void *);
377 #pragma GCC visibility pop
380 #endif /* ! GCC_LIBGCC2_H */