PR target/16201
[official-gcc.git] / gcc / libgcc2.h
blobf6b8fa43aef382957c813851b2b5d46c5627fbb7
1 /* Header file for libgcc2.c. */
2 /* Copyright (C) 2000, 2001, 2004
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
10 version.
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
15 for more details.
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
20 02111-1307, USA. */
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. */
30 #ifndef GCC_LIBGCC2_H
31 #define GCC_LIBGCC2_H
33 #ifndef HIDE_EXPORTS
34 #pragma GCC visibility push(default)
35 #endif
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
48 compiler is run. */
50 #ifndef LIBGCC2_WORDS_BIG_ENDIAN
51 #define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
52 #endif
54 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
55 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
56 #endif
58 #ifndef MIN_UNITS_PER_WORD
59 #define MIN_UNITS_PER_WORD UNITS_PER_WORD
60 #endif
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)));
87 #endif
88 #endif
89 #endif
91 #if BITS_PER_UNIT == 8
93 typedef float SFtype __attribute__ ((mode (SF)));
94 typedef float DFtype __attribute__ ((mode (DF)));
96 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
97 typedef float XFtype __attribute__ ((mode (XF)));
98 #endif
99 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
100 typedef float TFtype __attribute__ ((mode (TF)));
101 #endif
103 #else /* BITS_PER_UNIT != 8 */
105 /* On dsp's there are usually qf/hf/tqf modes used instead of the above.
106 For now we don't support them in libgcc2.c. */
108 #undef L_fixdfdi
109 #undef L_fixsfdi
110 #undef L_fixtfdi
111 #undef L_fixunsdfdi
112 #undef L_fixunsdfsi
113 #undef L_fixunssfdi
114 #undef L_fixunssfsi
115 #undef L_fixunstfdi
116 #undef L_fixunsxfdi
117 #undef L_fixunsxfsi
118 #undef L_fixxfdi
119 #undef L_floatdidf
120 #undef L_floatdisf
121 #undef L_floatditf
122 #undef L_floatdixf
124 #endif /* BITS_PER_UNIT != 8 */
126 typedef int word_type __attribute__ ((mode (__word__)));
128 /* Make sure that we don't accidentally use any normal C language built-in
129 type names in the first part of this file. Instead we want to use *only*
130 the type names defined above. The following macro definitions insure
131 that if we *do* accidentally use some normal C language built-in type name,
132 we will get a syntax error. */
134 #define char bogus_type
135 #define short bogus_type
136 #define int bogus_type
137 #define long bogus_type
138 #define unsigned bogus_type
139 #define float bogus_type
140 #define double bogus_type
142 /* Versions prior to 3.4.4 were not taking into account the word size for
143 the 5 trapping arithmetic functions absv, addv, subv, mulv and negv. As
144 a consequence, the si and di variants were always and the only ones emitted.
145 To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
146 defined on platforms where it makes sense to still have the si variants
147 emitted. As a bonus, their implementation is now correct. Note that the
148 same mechanism should have been implemented for the di variants, but it
149 turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
150 if it existed. */
152 #if MIN_UNITS_PER_WORD > 4
153 #define W_TYPE_SIZE (8 * BITS_PER_UNIT)
154 #define Wtype DItype
155 #define UWtype UDItype
156 #define HWtype DItype
157 #define UHWtype UDItype
158 #define DWtype TItype
159 #define UDWtype UTItype
160 #define __NW(a,b) __ ## a ## di ## b
161 #define __NDW(a,b) __ ## a ## ti ## b
162 #define COMPAT_SIMODE_TRAPPING_ARITHMETIC
163 #elif MIN_UNITS_PER_WORD > 2 \
164 || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
165 #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
166 #define Wtype SItype
167 #define UWtype USItype
168 #define HWtype SItype
169 #define UHWtype USItype
170 #define DWtype DItype
171 #define UDWtype UDItype
172 #define __NW(a,b) __ ## a ## si ## b
173 #define __NDW(a,b) __ ## a ## di ## b
174 #elif MIN_UNITS_PER_WORD > 1
175 #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
176 #define Wtype HItype
177 #define UWtype UHItype
178 #define HWtype HItype
179 #define UHWtype UHItype
180 #define DWtype SItype
181 #define UDWtype USItype
182 #define __NW(a,b) __ ## a ## hi ## b
183 #define __NDW(a,b) __ ## a ## si ## b
184 #else
185 #define W_TYPE_SIZE BITS_PER_UNIT
186 #define Wtype QItype
187 #define UWtype UQItype
188 #define HWtype QItype
189 #define UHWtype UQItype
190 #define DWtype HItype
191 #define UDWtype UHItype
192 #define __NW(a,b) __ ## a ## qi ## b
193 #define __NDW(a,b) __ ## a ## hi ## b
194 #endif
196 #define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
197 #define Wtype_MIN (- Wtype_MAX - 1)
199 #define __muldi3 __NDW(mul,3)
200 #define __divdi3 __NDW(div,3)
201 #define __udivdi3 __NDW(udiv,3)
202 #define __moddi3 __NDW(mod,3)
203 #define __umoddi3 __NDW(umod,3)
204 #define __negdi2 __NDW(neg,2)
205 #define __lshrdi3 __NDW(lshr,3)
206 #define __ashldi3 __NDW(ashl,3)
207 #define __ashrdi3 __NDW(ashr,3)
208 #define __cmpdi2 __NDW(cmp,2)
209 #define __ucmpdi2 __NDW(ucmp,2)
210 #define __udivmoddi4 __NDW(udivmod,4)
211 #define __fixunstfDI __NDW(fixunstf,)
212 #define __fixtfdi __NDW(fixtf,)
213 #define __fixunsxfDI __NDW(fixunsxf,)
214 #define __fixxfdi __NDW(fixxf,)
215 #define __fixunsdfDI __NDW(fixunsdf,)
216 #define __fixdfdi __NDW(fixdf,)
217 #define __fixunssfDI __NDW(fixunssf,)
218 #define __fixsfdi __NDW(fixsf,)
219 #define __floatdixf __NDW(float,xf)
220 #define __floatditf __NDW(float,tf)
221 #define __floatdidf __NDW(float,df)
222 #define __floatdisf __NDW(float,sf)
223 #define __fixunsxfSI __NW(fixunsxf,)
224 #define __fixunstfSI __NW(fixunstf,)
225 #define __fixunsdfSI __NW(fixunsdf,)
226 #define __fixunssfSI __NW(fixunssf,)
228 #define __absvSI2 __NW(absv,2)
229 #define __addvSI3 __NW(addv,3)
230 #define __subvSI3 __NW(subv,3)
231 #define __mulvSI3 __NW(mulv,3)
232 #define __negvSI2 __NW(negv,2)
233 #define __absvDI2 __NDW(absv,2)
234 #define __addvDI3 __NDW(addv,3)
235 #define __subvDI3 __NDW(subv,3)
236 #define __mulvDI3 __NDW(mulv,3)
237 #define __negvDI2 __NDW(negv,2)
239 #define __ffsSI2 __NW(ffs,2)
240 #define __clzSI2 __NW(clz,2)
241 #define __ctzSI2 __NW(ctz,2)
242 #define __popcountSI2 __NW(popcount,2)
243 #define __paritySI2 __NW(parity,2)
244 #define __ffsDI2 __NDW(ffs,2)
245 #define __clzDI2 __NDW(clz,2)
246 #define __ctzDI2 __NDW(ctz,2)
247 #define __popcountDI2 __NDW(popcount,2)
248 #define __parityDI2 __NDW(parity,2)
250 extern DWtype __muldi3 (DWtype, DWtype);
251 extern DWtype __divdi3 (DWtype, DWtype);
252 extern UDWtype __udivdi3 (UDWtype, UDWtype);
253 extern UDWtype __umoddi3 (UDWtype, UDWtype);
254 extern DWtype __moddi3 (DWtype, DWtype);
256 /* __udivmoddi4 is static inline when building other libgcc2 portions. */
257 #if (!defined (L_udivdi3) && !defined (L_divdi3) && \
258 !defined (L_umoddi3) && !defined (L_moddi3))
259 extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
260 #endif
262 /* __negdi2 is static inline when building other libgcc2 portions. */
263 #if !defined(L_divdi3) && !defined(L_moddi3)
264 extern DWtype __negdi2 (DWtype);
265 #endif
267 extern DWtype __lshrdi3 (DWtype, word_type);
268 extern DWtype __ashldi3 (DWtype, word_type);
269 extern DWtype __ashrdi3 (DWtype, word_type);
271 /* __udiv_w_sdiv is static inline when building other libgcc2 portions. */
272 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
273 !defined(L_umoddi3) && !defined(L_moddi3))
274 extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
275 #endif
277 extern word_type __cmpdi2 (DWtype, DWtype);
278 extern word_type __ucmpdi2 (DWtype, DWtype);
280 extern Wtype __absvSI2 (Wtype);
281 extern Wtype __addvSI3 (Wtype, Wtype);
282 extern Wtype __subvSI3 (Wtype, Wtype);
283 extern Wtype __mulvSI3 (Wtype, Wtype);
284 extern Wtype __negvSI2 (Wtype);
285 extern DWtype __absvDI2 (DWtype);
286 extern DWtype __addvDI3 (DWtype, DWtype);
287 extern DWtype __subvDI3 (DWtype, DWtype);
288 extern DWtype __mulvDI3 (DWtype, DWtype);
289 extern DWtype __negvDI2 (DWtype);
291 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
292 extern SItype __absvsi2 (SItype);
293 extern SItype __addvsi3 (SItype, SItype);
294 extern SItype __subvsi3 (SItype, SItype);
295 extern SItype __mulvsi3 (SItype, SItype);
296 extern SItype __negvsi2 (SItype);
297 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
299 #if BITS_PER_UNIT == 8
300 extern DWtype __fixdfdi (DFtype);
301 extern DWtype __fixsfdi (SFtype);
302 extern DFtype __floatdidf (DWtype);
303 extern SFtype __floatdisf (DWtype);
304 extern UWtype __fixunsdfSI (DFtype);
305 extern UWtype __fixunssfSI (SFtype);
306 extern DWtype __fixunsdfDI (DFtype);
307 extern DWtype __fixunssfDI (SFtype);
309 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
310 extern DWtype __fixxfdi (XFtype);
311 extern DWtype __fixunsxfDI (XFtype);
312 extern XFtype __floatdixf (DWtype);
313 extern UWtype __fixunsxfSI (XFtype);
314 #endif
316 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
317 extern DWtype __fixunstfDI (TFtype);
318 extern DWtype __fixtfdi (TFtype);
319 extern TFtype __floatditf (DWtype);
320 #endif
321 #endif /* BITS_PER_UNIT == 8 */
323 /* DWstructs are pairs of Wtype values in the order determined by
324 LIBGCC2_WORDS_BIG_ENDIAN. */
326 #if LIBGCC2_WORDS_BIG_ENDIAN
327 struct DWstruct {Wtype high, low;};
328 #else
329 struct DWstruct {Wtype low, high;};
330 #endif
332 /* We need this union to unpack/pack DImode values, since we don't have
333 any arithmetic yet. Incoming DImode parameters are stored into the
334 `ll' field, and the unpacked result is read from the struct `s'. */
336 typedef union
338 struct DWstruct s;
339 DWtype ll;
340 } DWunion;
342 #include "longlong.h"
344 #undef int
345 extern int __clzDI2 (UDWtype);
346 extern int __clzSI2 (UWtype);
347 extern int __ctzSI2 (UWtype);
348 extern int __ffsSI2 (UWtype);
349 extern int __ffsDI2 (DWtype);
350 extern int __ctzDI2 (UDWtype);
351 extern int __popcountSI2 (UWtype);
352 extern int __popcountDI2 (UDWtype);
353 extern int __paritySI2 (UWtype);
354 extern int __parityDI2 (UDWtype);
355 #define int bogus_type
357 extern void __enable_execute_stack (void *);
359 #ifndef HIDE_EXPORTS
360 #pragma GCC visibility pop
361 #endif
363 #endif /* ! GCC_LIBGCC2_H */