libgcc2.h revision 90075
190075Sobrien/* Header file for libgcc2.c.  */
290075Sobrien/* Copyright (C) 2000, 2001
390075Sobrien   Free Software Foundation, Inc.
490075Sobrien
590075SobrienThis file is part of GCC.
690075Sobrien
790075SobrienGCC is free software; you can redistribute it and/or modify it under
890075Sobrienthe terms of the GNU General Public License as published by the Free
990075SobrienSoftware Foundation; either version 2, or (at your option) any later
1090075Sobrienversion.
1190075Sobrien
1290075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY
1390075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or
1490075SobrienFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1590075Sobrienfor more details.
1690075Sobrien
1790075SobrienYou should have received a copy of the GNU General Public License
1890075Sobrienalong with GCC; see the file COPYING.  If not, write to the Free
1990075SobrienSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA
2090075Sobrien02111-1307, USA.  */
2190075Sobrien
2290075Sobrien#ifndef GCC_LIBGCC2_H
2390075Sobrien#define GCC_LIBGCC2_H
2490075Sobrien
2590075Sobrienextern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
2690075Sobrienextern void __clear_cache (char *, char *);
2790075Sobrienextern void __eprintf (const char *, const char *, unsigned int, const char *)
2890075Sobrien  __attribute__ ((__noreturn__));
2990075Sobrien
3090075Sobrienstruct bb;
3190075Sobrienextern void __bb_exit_func (void);
3290075Sobrienextern void __bb_init_func (struct bb *);
3390075Sobrienextern void __bb_fork_func (void);
3490075Sobrienextern void __bb_trace_func (void);
3590075Sobrienextern void __bb_trace_ret (void);
3690075Sobrienextern void __bb_init_trace_func (struct bb *, unsigned long);
3790075Sobrien
3890075Sobrienstruct exception_descriptor;
3990075Sobrienextern short int __get_eh_table_language (struct exception_descriptor *);
4090075Sobrienextern short int __get_eh_table_version (struct exception_descriptor *);
4190075Sobrien
4290075Sobrien/* Permit the tm.h file to select the endianness to use just for this
4390075Sobrien   file.  This is used when the endianness is determined when the
4490075Sobrien   compiler is run.  */
4590075Sobrien
4690075Sobrien#ifndef LIBGCC2_WORDS_BIG_ENDIAN
4790075Sobrien#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
4890075Sobrien#endif
4990075Sobrien
5090075Sobrien#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
5190075Sobrien#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
5290075Sobrien#endif
5390075Sobrien
5490075Sobrien#ifndef MIN_UNITS_PER_WORD
5590075Sobrien#define MIN_UNITS_PER_WORD UNITS_PER_WORD
5690075Sobrien#endif
5790075Sobrien
5890075Sobrien/* In the first part of this file, we are interfacing to calls generated
5990075Sobrien   by the compiler itself.  These calls pass values into these routines
6090075Sobrien   which have very specific modes (rather than very specific types), and
6190075Sobrien   these compiler-generated calls also expect any return values to have
6290075Sobrien   very specific modes (rather than very specific types).  Thus, we need
6390075Sobrien   to avoid using regular C language type names in this part of the file
6490075Sobrien   because the sizes for those types can be configured to be anything.
6590075Sobrien   Instead we use the following special type names.  */
6690075Sobrien
6790075Sobrientypedef		 int QItype	__attribute__ ((mode (QI)));
6890075Sobrientypedef unsigned int UQItype	__attribute__ ((mode (QI)));
6990075Sobrientypedef		 int HItype	__attribute__ ((mode (HI)));
7090075Sobrientypedef unsigned int UHItype	__attribute__ ((mode (HI)));
7190075Sobrien#if MIN_UNITS_PER_WORD > 1
7290075Sobrien/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1 */
7390075Sobrientypedef 	 int SItype	__attribute__ ((mode (SI)));
7490075Sobrientypedef unsigned int USItype	__attribute__ ((mode (SI)));
7590075Sobrien#if LONG_LONG_TYPE_SIZE > 32
7690075Sobrien/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2 */
7790075Sobrientypedef		 int DItype	__attribute__ ((mode (DI)));
7890075Sobrientypedef unsigned int UDItype	__attribute__ ((mode (DI)));
7990075Sobrien#if MIN_UNITS_PER_WORD > 4
8090075Sobrien/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4 */
8190075Sobrientypedef		 int TItype	__attribute__ ((mode (TI)));
8290075Sobrientypedef unsigned int UTItype	__attribute__ ((mode (TI)));
8390075Sobrien#endif
8490075Sobrien#endif
8590075Sobrien#endif
8690075Sobrien
8790075Sobrien#if BITS_PER_UNIT == 8
8890075Sobrien
8990075Sobrientypedef 	float SFtype	__attribute__ ((mode (SF)));
9090075Sobrientypedef		float DFtype	__attribute__ ((mode (DF)));
9190075Sobrien
9290075Sobrien#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
9390075Sobrientypedef		float XFtype	__attribute__ ((mode (XF)));
9490075Sobrien#endif
9590075Sobrien#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
9690075Sobrientypedef		float TFtype	__attribute__ ((mode (TF)));
9790075Sobrien#endif
9890075Sobrien
9990075Sobrien#else /* BITS_PER_UNIT != 8 */
10090075Sobrien
10190075Sobrien/* On dsp's there are usually qf/hf/tqf modes used instead of the above.
10290075Sobrien   For now we don't support them in libgcc2.c.  */
10390075Sobrien
10490075Sobrien#undef L_fixdfdi
10590075Sobrien#undef L_fixsfdi
10690075Sobrien#undef L_fixtfdi
10790075Sobrien#undef L_fixunsdfdi
10890075Sobrien#undef L_fixunsdfsi
10990075Sobrien#undef L_fixunssfdi
11090075Sobrien#undef L_fixunssfsi
11190075Sobrien#undef L_fixunstfdi
11290075Sobrien#undef L_fixunsxfdi
11390075Sobrien#undef L_fixunsxfsi
11490075Sobrien#undef L_fixxfdi
11590075Sobrien#undef L_floatdidf
11690075Sobrien#undef L_floatdisf
11790075Sobrien#undef L_floatditf
11890075Sobrien#undef L_floatdixf
11990075Sobrien
12090075Sobrien#endif /* BITS_PER_UNIT != 8 */
12190075Sobrien
12290075Sobrientypedef int word_type __attribute__ ((mode (__word__)));
12390075Sobrien
12490075Sobrien/* Make sure that we don't accidentally use any normal C language built-in
12590075Sobrien   type names in the first part of this file.  Instead we want to use *only*
12690075Sobrien   the type names defined above.  The following macro definitions insure
12790075Sobrien   that if we *do* accidentally use some normal C language built-in type name,
12890075Sobrien   we will get a syntax error.  */
12990075Sobrien
13090075Sobrien#define char bogus_type
13190075Sobrien#define short bogus_type
13290075Sobrien#define int bogus_type
13390075Sobrien#define long bogus_type
13490075Sobrien#define unsigned bogus_type
13590075Sobrien#define float bogus_type
13690075Sobrien#define double bogus_type
13790075Sobrien
13890075Sobrien#if MIN_UNITS_PER_WORD > 4
13990075Sobrien#define W_TYPE_SIZE (8 * BITS_PER_UNIT)
14090075Sobrien#define Wtype	DItype
14190075Sobrien#define UWtype	UDItype
14290075Sobrien#define HWtype	DItype
14390075Sobrien#define UHWtype	UDItype
14490075Sobrien#define DWtype	TItype
14590075Sobrien#define UDWtype	UTItype
14690075Sobrien#define __NW(a,b)	__ ## a ## di ## b
14790075Sobrien#define __NDW(a,b)	__ ## a ## ti ## b
14890075Sobrien#elif MIN_UNITS_PER_WORD > 2 \
14990075Sobrien      || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
15090075Sobrien#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
15190075Sobrien#define Wtype	SItype
15290075Sobrien#define UWtype	USItype
15390075Sobrien#define HWtype	SItype
15490075Sobrien#define UHWtype	USItype
15590075Sobrien#define DWtype	DItype
15690075Sobrien#define UDWtype	UDItype
15790075Sobrien#define __NW(a,b)	__ ## a ## si ## b
15890075Sobrien#define __NDW(a,b)	__ ## a ## di ## b
15990075Sobrien#elif MIN_UNITS_PER_WORD > 1
16090075Sobrien#define W_TYPE_SIZE (2 * BITS_PER_UNIT)
16190075Sobrien#define Wtype	HItype
16290075Sobrien#define UWtype	UHItype
16390075Sobrien#define HWtype	HItype
16490075Sobrien#define UHWtype	UHItype
16590075Sobrien#define DWtype	SItype
16690075Sobrien#define UDWtype	USItype
16790075Sobrien#define __NW(a,b)	__ ## a ## hi ## b
16890075Sobrien#define __NDW(a,b)	__ ## a ## si ## b
16990075Sobrien#else
17090075Sobrien#define W_TYPE_SIZE BITS_PER_UNIT
17190075Sobrien#define Wtype	QItype
17290075Sobrien#define UWtype  UQItype
17390075Sobrien#define HWtype	QItype
17490075Sobrien#define UHWtype	UQItype
17590075Sobrien#define DWtype	HItype
17690075Sobrien#define UDWtype	UHItype
17790075Sobrien#define __NW(a,b)	__ ## a ## qi ## b
17890075Sobrien#define __NDW(a,b)	__ ## a ## hi ## b
17990075Sobrien#endif
18090075Sobrien
18190075Sobrien#define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
18290075Sobrien#define Wtype_MIN (- Wtype_MAX - 1)
18390075Sobrien
18490075Sobrien#define __muldi3	__NDW(mul,3)
18590075Sobrien#define __divdi3	__NDW(div,3)
18690075Sobrien#define __udivdi3	__NDW(udiv,3)
18790075Sobrien#define __moddi3	__NDW(mod,3)
18890075Sobrien#define __umoddi3	__NDW(umod,3)
18990075Sobrien#define __negdi2	__NDW(neg,2)
19090075Sobrien#define __lshrdi3	__NDW(lshr,3)
19190075Sobrien#define __ashldi3	__NDW(ashl,3)
19290075Sobrien#define __ashrdi3	__NDW(ashr,3)
19390075Sobrien#define __ffsdi2	__NDW(ffs,2)
19490075Sobrien#define __cmpdi2	__NDW(cmp,2)
19590075Sobrien#define __ucmpdi2	__NDW(ucmp,2)
19690075Sobrien#define __udivmoddi4	__NDW(udivmod,4)
19790075Sobrien#define __fixunstfDI	__NDW(fixunstf,)
19890075Sobrien#define __fixtfdi	__NDW(fixtf,)
19990075Sobrien#define __fixunsxfDI	__NDW(fixunsxf,)
20090075Sobrien#define __fixxfdi	__NDW(fixxf,)
20190075Sobrien#define __fixunsdfDI	__NDW(fixunsdf,)
20290075Sobrien#define __fixdfdi	__NDW(fixdf,)
20390075Sobrien#define __fixunssfDI	__NDW(fixunssf,)
20490075Sobrien#define __fixsfdi	__NDW(fixsf,)
20590075Sobrien#define __floatdixf	__NDW(float,xf)
20690075Sobrien#define __floatditf	__NDW(float,tf)
20790075Sobrien#define __floatdidf	__NDW(float,df)
20890075Sobrien#define __floatdisf	__NDW(float,sf)
20990075Sobrien#define __fixunsxfSI	__NW(fixunsxf,)
21090075Sobrien#define __fixunstfSI	__NW(fixunstf,)
21190075Sobrien#define __fixunsdfSI	__NW(fixunsdf,)
21290075Sobrien#define __fixunssfSI	__NW(fixunssf,)
21390075Sobrien
21490075Sobrienextern DWtype __muldi3 (DWtype, DWtype);
21590075Sobrienextern DWtype __divdi3 (DWtype, DWtype);
21690075Sobrienextern UDWtype __udivdi3 (UDWtype, UDWtype);
21790075Sobrienextern UDWtype __umoddi3 (UDWtype, UDWtype);
21890075Sobrienextern DWtype __moddi3 (DWtype, DWtype);
21990075Sobrien
22090075Sobrien/* __udivmoddi4 is static inline when building other libgcc2 portions.  */
22190075Sobrien#if (!defined (L_udivdi3) && !defined (L_divdi3) && \
22290075Sobrien     !defined (L_umoddi3) && !defined (L_moddi3))
22390075Sobrienextern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
22490075Sobrien#endif
22590075Sobrien
22690075Sobrien/* __negdi2 is static inline when building other libgcc2 portions.  */
22790075Sobrien#if !defined(L_divdi3) && !defined(L_moddi3)
22890075Sobrienextern DWtype __negdi2 (DWtype);
22990075Sobrien#endif
23090075Sobrien
23190075Sobrienextern DWtype __lshrdi3 (DWtype, word_type);
23290075Sobrienextern DWtype __ashldi3 (DWtype, word_type);
23390075Sobrienextern DWtype __ashrdi3 (DWtype, word_type);
23490075Sobrienextern DWtype __ffsdi2 (DWtype);
23590075Sobrien
23690075Sobrien/* __udiv_w_sdiv is static inline when building other libgcc2 portions.  */
23790075Sobrien#if (!defined(L_udivdi3) && !defined(L_divdi3) && \
23890075Sobrien     !defined(L_umoddi3) && !defined(L_moddi3))
23990075Sobrienextern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
24090075Sobrien#endif
24190075Sobrien
24290075Sobrienextern word_type __cmpdi2 (DWtype, DWtype);
24390075Sobrienextern word_type __ucmpdi2 (DWtype, DWtype);
24490075Sobrien
24590075Sobrienextern Wtype __absvsi2 (Wtype);
24690075Sobrienextern DWtype __absvdi2 (DWtype);
24790075Sobrienextern Wtype __addvsi3 (Wtype, Wtype);
24890075Sobrienextern DWtype __addvdi3 (DWtype, DWtype);
24990075Sobrienextern Wtype __subvsi3 (Wtype, Wtype);
25090075Sobrienextern DWtype __subvdi3 (DWtype, DWtype);
25190075Sobrienextern Wtype __mulvsi3 (Wtype, Wtype);
25290075Sobrienextern DWtype __mulvdi3 (DWtype, DWtype);
25390075Sobrienextern Wtype __negvsi2 (Wtype);
25490075Sobrienextern DWtype __negvdi2 (DWtype);
25590075Sobrien
25690075Sobrien#if BITS_PER_UNIT == 8
25790075Sobrienextern DWtype __fixdfdi (DFtype);
25890075Sobrienextern DWtype __fixsfdi (SFtype);
25990075Sobrienextern DFtype __floatdidf (DWtype);
26090075Sobrienextern SFtype __floatdisf (DWtype);
26190075Sobrienextern UWtype __fixunsdfSI (DFtype);
26290075Sobrienextern UWtype __fixunssfSI (SFtype);
26390075Sobrienextern DWtype __fixunsdfDI (DFtype);
26490075Sobrienextern DWtype __fixunssfDI (SFtype);
26590075Sobrien
26690075Sobrien#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
26790075Sobrienextern DWtype __fixxfdi (XFtype);
26890075Sobrienextern DWtype __fixunsxfDI (XFtype);
26990075Sobrienextern XFtype __floatdixf (DWtype);
27090075Sobrienextern UWtype __fixunsxfSI (XFtype);
27190075Sobrien#endif
27290075Sobrien
27390075Sobrien#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
27490075Sobrienextern DWtype __fixunstfDI (TFtype);
27590075Sobrienextern DWtype __fixtfdi (TFtype);
27690075Sobrienextern TFtype __floatditf (DWtype);
27790075Sobrien#endif
27890075Sobrien#endif /* BITS_PER_UNIT == 8 */
27990075Sobrien
28090075Sobrien/* DWstructs are pairs of Wtype values in the order determined by
28190075Sobrien   LIBGCC2_WORDS_BIG_ENDIAN.  */
28290075Sobrien
28390075Sobrien#if LIBGCC2_WORDS_BIG_ENDIAN
28490075Sobrien  struct DWstruct {Wtype high, low;};
28590075Sobrien#else
28690075Sobrien  struct DWstruct {Wtype low, high;};
28790075Sobrien#endif
28890075Sobrien
28990075Sobrien/* We need this union to unpack/pack DImode values, since we don't have
29090075Sobrien   any arithmetic yet.  Incoming DImode parameters are stored into the
29190075Sobrien   `ll' field, and the unpacked result is read from the struct `s'.  */
29290075Sobrien
29390075Sobrientypedef union
29490075Sobrien{
29590075Sobrien  struct DWstruct s;
29690075Sobrien  DWtype ll;
29790075Sobrien} DWunion;
29890075Sobrien
29990075Sobrien#include "longlong.h"
30090075Sobrien
30190075Sobrien#endif /* ! GCC_LIBGCC2_H */
302