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