libgcc2.h revision 146895
1272343Sngie/* Header file for libgcc2.c.  */
2272343Sngie/* Copyright (C) 2000, 2001
3272343Sngie   Free Software Foundation, Inc.
4272343Sngie
5272343SngieThis file is part of GCC.
6272343Sngie
7272343SngieGCC is free software; you can redistribute it and/or modify it under
8272343Sngiethe terms of the GNU General Public License as published by the Free
9272343SngieSoftware Foundation; either version 2, or (at your option) any later
10272343Sngieversion.
11272343Sngie
12272343SngieGCC is distributed in the hope that it will be useful, but WITHOUT ANY
13272343SngieWARRANTY; without even the implied warranty of MERCHANTABILITY or
14272343SngieFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15272343Sngiefor more details.
16272343Sngie
17272343SngieYou should have received a copy of the GNU General Public License
18272343Sngiealong with GCC; see the file COPYING.  If not, write to the Free
19272343SngieSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA
20272343Sngie02111-1307, USA.  */
21272343Sngie
22272343Sngie/* As a special exception, if you link this library with other files,
23272343Sngie   some of which are compiled with GCC, to produce an executable,
24272343Sngie   this library does not by itself cause the resulting executable
25272343Sngie   to be covered by the GNU General Public License.
26272343Sngie   This exception does not however invalidate any other reasons why
27272343Sngie   the executable file might be covered by the GNU General Public License.  */
28272343Sngie
29272343Sngie
30272343Sngie#ifndef GCC_LIBGCC2_H
31272343Sngie#define GCC_LIBGCC2_H
32272343Sngie
33272343Sngieextern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
34272343Sngieextern void __clear_cache (char *, char *);
35272343Sngieextern void __eprintf (const char *, const char *, unsigned int, const char *)
36272343Sngie  __attribute__ ((__noreturn__));
37272343Sngie
38272343Sngiestruct exception_descriptor;
39272343Sngieextern short int __get_eh_table_language (struct exception_descriptor *);
40272343Sngieextern short int __get_eh_table_version (struct exception_descriptor *);
41272343Sngie
42272343Sngie/* Permit the tm.h file to select the endianness to use just for this
43272343Sngie   file.  This is used when the endianness is determined when the
44272343Sngie   compiler is run.  */
45272343Sngie
46272343Sngie#ifndef LIBGCC2_WORDS_BIG_ENDIAN
47272343Sngie#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
48272343Sngie#endif
49272343Sngie
50272343Sngie#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
51272343Sngie#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
52272343Sngie#endif
53272343Sngie
54272343Sngie#ifndef MIN_UNITS_PER_WORD
55272343Sngie#define MIN_UNITS_PER_WORD UNITS_PER_WORD
56272343Sngie#endif
57272343Sngie
58272343Sngie/* In the first part of this file, we are interfacing to calls generated
59272343Sngie   by the compiler itself.  These calls pass values into these routines
60272343Sngie   which have very specific modes (rather than very specific types), and
61272343Sngie   these compiler-generated calls also expect any return values to have
62272343Sngie   very specific modes (rather than very specific types).  Thus, we need
63272343Sngie   to avoid using regular C language type names in this part of the file
64272343Sngie   because the sizes for those types can be configured to be anything.
65272343Sngie   Instead we use the following special type names.  */
66272343Sngie
67272343Sngietypedef		 int QItype	__attribute__ ((mode (QI)));
68272343Sngietypedef unsigned int UQItype	__attribute__ ((mode (QI)));
69272343Sngietypedef		 int HItype	__attribute__ ((mode (HI)));
70272343Sngietypedef unsigned int UHItype	__attribute__ ((mode (HI)));
71272343Sngie#if MIN_UNITS_PER_WORD > 1
72272343Sngie/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
73272343Sngietypedef 	 int SItype	__attribute__ ((mode (SI)));
74272343Sngietypedef unsigned int USItype	__attribute__ ((mode (SI)));
75272343Sngie#if LONG_LONG_TYPE_SIZE > 32
76272343Sngie/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
77272343Sngietypedef		 int DItype	__attribute__ ((mode (DI)));
78272343Sngietypedef unsigned int UDItype	__attribute__ ((mode (DI)));
79272343Sngie#if MIN_UNITS_PER_WORD > 4
80272343Sngie/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
81272343Sngietypedef		 int TItype	__attribute__ ((mode (TI)));
82typedef unsigned int UTItype	__attribute__ ((mode (TI)));
83#endif
84#endif
85#endif
86
87#if BITS_PER_UNIT == 8
88
89typedef 	float SFtype	__attribute__ ((mode (SF)));
90typedef		float DFtype	__attribute__ ((mode (DF)));
91
92#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
93typedef		float XFtype	__attribute__ ((mode (XF)));
94#endif
95#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
96typedef		float TFtype	__attribute__ ((mode (TF)));
97#endif
98
99#else /* BITS_PER_UNIT != 8 */
100
101/* On dsp's there are usually qf/hf/tqf modes used instead of the above.
102   For now we don't support them in libgcc2.c.  */
103
104#undef L_fixdfdi
105#undef L_fixsfdi
106#undef L_fixtfdi
107#undef L_fixunsdfdi
108#undef L_fixunsdfsi
109#undef L_fixunssfdi
110#undef L_fixunssfsi
111#undef L_fixunstfdi
112#undef L_fixunsxfdi
113#undef L_fixunsxfsi
114#undef L_fixxfdi
115#undef L_floatdidf
116#undef L_floatdisf
117#undef L_floatditf
118#undef L_floatdixf
119
120#endif /* BITS_PER_UNIT != 8 */
121
122typedef int word_type __attribute__ ((mode (__word__)));
123
124/* Make sure that we don't accidentally use any normal C language built-in
125   type names in the first part of this file.  Instead we want to use *only*
126   the type names defined above.  The following macro definitions insure
127   that if we *do* accidentally use some normal C language built-in type name,
128   we will get a syntax error.  */
129
130#define char bogus_type
131#define short bogus_type
132#define int bogus_type
133#define long bogus_type
134#define unsigned bogus_type
135#define float bogus_type
136#define double bogus_type
137
138/* Versions prior to 3.4.4 were not taking into account the word size for
139   the 5 trapping arithmetic functions absv, addv, subv, mulv and negv.  As
140   a consequence, the si and di variants were always and the only ones emitted.
141   To maintain backward compatibility, COMPAT_SIMODE_TRAPPING_ARITHMETIC is
142   defined on platforms where it makes sense to still have the si variants
143   emitted.  As a bonus, their implementation is now correct.  Note that the
144   same mechanism should have been implemented for the di variants, but it
145   turns out that no platform would define COMPAT_DIMODE_TRAPPING_ARITHMETIC
146   if it existed.  */
147
148#if MIN_UNITS_PER_WORD > 4
149#define W_TYPE_SIZE (8 * BITS_PER_UNIT)
150#define Wtype	DItype
151#define UWtype	UDItype
152#define HWtype	DItype
153#define UHWtype	UDItype
154#define DWtype	TItype
155#define UDWtype	UTItype
156#define __NW(a,b)	__ ## a ## di ## b
157#define __NDW(a,b)	__ ## a ## ti ## b
158#define COMPAT_SIMODE_TRAPPING_ARITHMETIC
159#elif MIN_UNITS_PER_WORD > 2 \
160      || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
161#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
162#define Wtype	SItype
163#define UWtype	USItype
164#define HWtype	SItype
165#define UHWtype	USItype
166#define DWtype	DItype
167#define UDWtype	UDItype
168#define __NW(a,b)	__ ## a ## si ## b
169#define __NDW(a,b)	__ ## a ## di ## b
170#elif MIN_UNITS_PER_WORD > 1
171#define W_TYPE_SIZE (2 * BITS_PER_UNIT)
172#define Wtype	HItype
173#define UWtype	UHItype
174#define HWtype	HItype
175#define UHWtype	UHItype
176#define DWtype	SItype
177#define UDWtype	USItype
178#define __NW(a,b)	__ ## a ## hi ## b
179#define __NDW(a,b)	__ ## a ## si ## b
180#else
181#define W_TYPE_SIZE BITS_PER_UNIT
182#define Wtype	QItype
183#define UWtype  UQItype
184#define HWtype	QItype
185#define UHWtype	UQItype
186#define DWtype	HItype
187#define UDWtype	UHItype
188#define __NW(a,b)	__ ## a ## qi ## b
189#define __NDW(a,b)	__ ## a ## hi ## b
190#endif
191
192#define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
193#define Wtype_MIN (- Wtype_MAX - 1)
194
195#define __muldi3	__NDW(mul,3)
196#define __divdi3	__NDW(div,3)
197#define __udivdi3	__NDW(udiv,3)
198#define __moddi3	__NDW(mod,3)
199#define __umoddi3	__NDW(umod,3)
200#define __negdi2	__NDW(neg,2)
201#define __lshrdi3	__NDW(lshr,3)
202#define __ashldi3	__NDW(ashl,3)
203#define __ashrdi3	__NDW(ashr,3)
204#define __cmpdi2	__NDW(cmp,2)
205#define __ucmpdi2	__NDW(ucmp,2)
206#define __udivmoddi4	__NDW(udivmod,4)
207#define __fixunstfDI	__NDW(fixunstf,)
208#define __fixtfdi	__NDW(fixtf,)
209#define __fixunsxfDI	__NDW(fixunsxf,)
210#define __fixxfdi	__NDW(fixxf,)
211#define __fixunsdfDI	__NDW(fixunsdf,)
212#define __fixdfdi	__NDW(fixdf,)
213#define __fixunssfDI	__NDW(fixunssf,)
214#define __fixsfdi	__NDW(fixsf,)
215#define __floatdixf	__NDW(float,xf)
216#define __floatditf	__NDW(float,tf)
217#define __floatdidf	__NDW(float,df)
218#define __floatdisf	__NDW(float,sf)
219#define __fixunsxfSI	__NW(fixunsxf,)
220#define __fixunstfSI	__NW(fixunstf,)
221#define __fixunsdfSI	__NW(fixunsdf,)
222#define __fixunssfSI	__NW(fixunssf,)
223
224#define __absvSI2	__NW(absv,2)
225#define __addvSI3	__NW(addv,3)
226#define __subvSI3	__NW(subv,3)
227#define __mulvSI3	__NW(mulv,3)
228#define __negvSI2	__NW(negv,2)
229#define __absvDI2	__NDW(absv,2)
230#define __addvDI3	__NDW(addv,3)
231#define __subvDI3	__NDW(subv,3)
232#define __mulvDI3	__NDW(mulv,3)
233#define __negvDI2	__NDW(negv,2)
234
235#define __ffsSI2	__NW(ffs,2)
236#define __clzSI2	__NW(clz,2)
237#define __ctzSI2	__NW(ctz,2)
238#define __popcountSI2	__NW(popcount,2)
239#define __paritySI2	__NW(parity,2)
240#define __ffsDI2	__NDW(ffs,2)
241#define __clzDI2	__NDW(clz,2)
242#define __ctzDI2	__NDW(ctz,2)
243#define __popcountDI2	__NDW(popcount,2)
244#define __parityDI2	__NDW(parity,2)
245
246extern DWtype __muldi3 (DWtype, DWtype);
247extern DWtype __divdi3 (DWtype, DWtype);
248extern UDWtype __udivdi3 (UDWtype, UDWtype);
249extern UDWtype __umoddi3 (UDWtype, UDWtype);
250extern DWtype __moddi3 (DWtype, DWtype);
251
252/* __udivmoddi4 is static inline when building other libgcc2 portions.  */
253#if (!defined (L_udivdi3) && !defined (L_divdi3) && \
254     !defined (L_umoddi3) && !defined (L_moddi3))
255extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
256#endif
257
258/* __negdi2 is static inline when building other libgcc2 portions.  */
259#if !defined(L_divdi3) && !defined(L_moddi3)
260extern DWtype __negdi2 (DWtype);
261#endif
262
263extern DWtype __lshrdi3 (DWtype, word_type);
264extern DWtype __ashldi3 (DWtype, word_type);
265extern DWtype __ashrdi3 (DWtype, word_type);
266
267/* __udiv_w_sdiv is static inline when building other libgcc2 portions.  */
268#if (!defined(L_udivdi3) && !defined(L_divdi3) && \
269     !defined(L_umoddi3) && !defined(L_moddi3))
270extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
271#endif
272
273extern word_type __cmpdi2 (DWtype, DWtype);
274extern word_type __ucmpdi2 (DWtype, DWtype);
275
276extern Wtype __absvSI2 (Wtype);
277extern Wtype __addvSI3 (Wtype, Wtype);
278extern Wtype __subvSI3 (Wtype, Wtype);
279extern Wtype __mulvSI3 (Wtype, Wtype);
280extern Wtype __negvSI2 (Wtype);
281extern DWtype __absvDI2 (DWtype);
282extern DWtype __addvDI3 (DWtype, DWtype);
283extern DWtype __subvDI3 (DWtype, DWtype);
284extern DWtype __mulvDI3 (DWtype, DWtype);
285extern DWtype __negvDI2 (DWtype);
286
287#ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
288extern SItype __absvsi2 (SItype);
289extern SItype __addvsi3 (SItype, SItype);
290extern SItype __subvsi3 (SItype, SItype);
291extern SItype __mulvsi3 (SItype, SItype);
292extern SItype __negvsi2 (SItype);
293#endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
294
295#if BITS_PER_UNIT == 8
296extern DWtype __fixdfdi (DFtype);
297extern DWtype __fixsfdi (SFtype);
298extern DFtype __floatdidf (DWtype);
299extern SFtype __floatdisf (DWtype);
300extern UWtype __fixunsdfSI (DFtype);
301extern UWtype __fixunssfSI (SFtype);
302extern DWtype __fixunsdfDI (DFtype);
303extern DWtype __fixunssfDI (SFtype);
304
305#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
306extern DWtype __fixxfdi (XFtype);
307extern DWtype __fixunsxfDI (XFtype);
308extern XFtype __floatdixf (DWtype);
309extern UWtype __fixunsxfSI (XFtype);
310#endif
311
312#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
313extern DWtype __fixunstfDI (TFtype);
314extern DWtype __fixtfdi (TFtype);
315extern TFtype __floatditf (DWtype);
316#endif
317#endif /* BITS_PER_UNIT == 8 */
318
319/* DWstructs are pairs of Wtype values in the order determined by
320   LIBGCC2_WORDS_BIG_ENDIAN.  */
321
322#if LIBGCC2_WORDS_BIG_ENDIAN
323  struct DWstruct {Wtype high, low;};
324#else
325  struct DWstruct {Wtype low, high;};
326#endif
327
328/* We need this union to unpack/pack DImode values, since we don't have
329   any arithmetic yet.  Incoming DImode parameters are stored into the
330   `ll' field, and the unpacked result is read from the struct `s'.  */
331
332typedef union
333{
334  struct DWstruct s;
335  DWtype ll;
336} DWunion;
337
338#include "longlong.h"
339
340#endif /* ! GCC_LIBGCC2_H */
341