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