OSDN Git Service

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