OSDN Git Service

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