libgcc2.h: New file.
[platform/upstream/gcc.git] / gcc / libgcc2.h
1 /* Header file for libgcc2.c.  */
2 /* Copyright (C) 2000
3    Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, 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 #ifndef __LIBGCC2_H__
30 #define __LIBGCC2_H__
31
32 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
33 extern void *__builtin_saveregs (void);
34 extern void __dummy (void);
35 extern void __clear_cache (char *, char *);
36 extern void __pure_virtual (void) __attribute__ ((__noreturn__));
37 extern void __terminate (void) __attribute__ ((__noreturn__));
38 extern void __default_terminate (void) __attribute__ ((__noreturn__));
39 extern void *__throw_type_match (void *, void *, void *);
40 extern void __empty (void);
41 extern void *__get_eh_context (void);
42 extern void **__get_eh_info (void);
43 extern void ***__get_dynamic_handler_chain (void);
44 extern int __eh_rtime_match (void *);
45 extern void __unwinding_cleanup (void);
46 extern void __rethrow (void *);
47 extern void __throw (void);
48 extern void __sjthrow (void) __attribute__ ((__noreturn__));
49 extern void __sjpopnthrow (void) __attribute__ ((__noreturn__));
50 extern void __eprintf (const char *, const char *, unsigned int, const char *)
51   __attribute__ ((__noreturn__));
52
53 struct bb;
54 extern void __bb_exit_func (void);
55 extern void __bb_init_func (struct bb *);
56 extern void __bb_fork_func (void);
57 extern void __bb_trace_func (void);
58 extern void __bb_trace_ret (void);
59 extern void __bb_init_trace_func (struct bb *, unsigned long);
60
61 struct exception_descriptor;
62 extern short int __get_eh_table_language (struct exception_descriptor *);
63 extern short int __get_eh_table_version (struct exception_descriptor *);
64
65 /* Permit the tm.h file to select the endianness to use just for this
66    file.  This is used when the endianness is determined when the
67    compiler is run.  */
68
69 #ifndef LIBGCC2_WORDS_BIG_ENDIAN
70 #define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
71 #endif
72
73 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
74 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
75 #endif
76
77 /* In the first part of this file, we are interfacing to calls generated
78    by the compiler itself.  These calls pass values into these routines
79    which have very specific modes (rather than very specific types), and
80    these compiler-generated calls also expect any return values to have
81    very specific modes (rather than very specific types).  Thus, we need
82    to avoid using regular C language type names in this part of the file
83    because the sizes for those types can be configured to be anything.
84    Instead we use the following special type names.  */
85
86 typedef          int QItype     __attribute__ ((mode (QI)));
87 typedef unsigned int UQItype    __attribute__ ((mode (QI)));
88 typedef          int HItype     __attribute__ ((mode (HI)));
89 typedef unsigned int UHItype    __attribute__ ((mode (HI)));
90 #if UNITS_PER_WORD > 1
91 /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1 */
92 typedef          int SItype     __attribute__ ((mode (SI)));
93 typedef unsigned int USItype    __attribute__ ((mode (SI)));
94 #if UNITS_PER_WORD > 2
95 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2 */
96 typedef          int DItype     __attribute__ ((mode (DI)));
97 typedef unsigned int UDItype    __attribute__ ((mode (DI)));
98 #endif
99 #endif
100
101 #if BITS_PER_UNIT == 8
102
103 typedef         float SFtype    __attribute__ ((mode (SF)));
104 typedef         float DFtype    __attribute__ ((mode (DF)));
105
106 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
107 typedef         float XFtype    __attribute__ ((mode (XF)));
108 #endif
109 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
110 typedef         float TFtype    __attribute__ ((mode (TF)));
111 #endif
112
113 #else /* BITS_PER_UNIT != 8 */
114
115 /* On dsp's there are usually qf/hf/tqf modes used instead of the above.
116    For now we don't support them in libgcc2.c.  */
117
118 #undef L_fixdfdi
119 #undef L_fixsfdi
120 #undef L_fixtfdi
121 #undef L_fixunsdfdi
122 #undef L_fixunsdfsi
123 #undef L_fixunssfdi
124 #undef L_fixunssfsi
125 #undef L_fixunstfdi
126 #undef L_fixunsxfdi
127 #undef L_fixunsxfsi
128 #undef L_fixxfdi
129 #undef L_floatdidf
130 #undef L_floatdisf
131 #undef L_floatditf
132 #undef L_floatdixf
133
134 #endif /* BITS_PER_UNIT != 8 */
135
136 typedef int word_type __attribute__ ((mode (__word__)));
137
138 /* Make sure that we don't accidentally use any normal C language built-in
139    type names in the first part of this file.  Instead we want to use *only*
140    the type names defined above.  The following macro definitions insure
141    that if we *do* accidentally use some normal C language built-in type name,
142    we will get a syntax error.  */
143
144 #define char bogus_type
145 #define short bogus_type
146 #define int bogus_type
147 #define long bogus_type
148 #define unsigned bogus_type
149 #define float bogus_type
150 #define double bogus_type
151
152 #if UNITS_PER_WORD > 2
153 #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
154 #define Wtype   SItype
155 #define UWtype  USItype
156 #define HWtype  SItype
157 #define UHWtype USItype
158 #define DWtype  DItype
159 #define UDWtype UDItype
160 #define __NW(a,b)       __ ## a ## si ## b
161 #define __NDW(a,b)      __ ## a ## di ## b
162 #elif UNITS_PER_WORD > 1
163 #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
164 #define Wtype   HItype
165 #define UWtype  UHItype
166 #define HWtype  HItype
167 #define UHWtype UHItype
168 #define DWtype  SItype
169 #define UDWtype USItype
170 #define __NW(a,b)       __ ## a ## hi ## b
171 #define __NDW(a,b)      __ ## a ## si ## b
172 #else
173 #define W_TYPE_SIZE BITS_PER_UNIT
174 #define Wtype   QItype
175 #define UWtype  UQItype
176 #define HWtype  QItype
177 #define UHWtype UQItype
178 #define DWtype  HItype
179 #define UDWtype UHItype
180 #define __NW(a,b)       __ ## a ## qi ## b
181 #define __NDW(a,b)      __ ## a ## hi ## b
182 #endif
183
184 #define __muldi3        __NDW(mul,3)
185 #define __divdi3        __NDW(div,3)
186 #define __udivdi3       __NDW(udiv,3)
187 #define __moddi3        __NDW(mod,3)
188 #define __umoddi3       __NDW(umod,3)
189 #define __negdi2        __NDW(neg,2)
190 #define __lshrdi3       __NDW(lshr,3)
191 #define __ashldi3       __NDW(ashl,3)
192 #define __ashrdi3       __NDW(ashr,3)
193 #define __ffsdi2        __NDW(ffs,2)
194 #define __cmpdi2        __NDW(cmp,2)
195 #define __ucmpdi2       __NDW(ucmp,2)
196 #define __udivmoddi4    __NDW(udivmod,4)
197 #define __fixunstfdi    __NDW(fixunstf,)
198 #define __fixtfdi       __NDW(fixtf,)
199 #define __fixunsxfdi    __NDW(fixunsxf,)
200 #define __fixxfdi       __NDW(fixxf,)
201 #define __fixunsdfdi    __NDW(fixunsdf,)
202 #define __fixdfdi       __NDW(fixdf,)
203 #define __fixunssfdi    __NDW(fixunssf,)
204 #define __fixsfdi       __NDW(fixsf,)
205 #define __floatdixf     __NDW(float,xf)
206 #define __floatditf     __NDW(float,tf)
207 #define __floatdidf     __NDW(float,df)
208 #define __floatdisf     __NDW(float,sf)
209 #define __fixunsxfsi    __NW(fixunsxf,)
210 #define __fixunstfsi    __NW(fixunstf,)
211 #define __fixunsdfsi    __NW(fixunsdf,)
212 #define __fixunssfsi    __NW(fixunssf,)
213
214 /* DWstructs are pairs of Wtype values in the order determined by
215    LIBGCC2_WORDS_BIG_ENDIAN.  */
216
217 #if LIBGCC2_WORDS_BIG_ENDIAN
218   struct DWstruct {Wtype high, low;};
219 #else
220   struct DWstruct {Wtype low, high;};
221 #endif
222
223 /* We need this union to unpack/pack DImode values, since we don't have
224    any arithmetic yet.  Incoming DImode parameters are stored into the
225    `ll' field, and the unpacked result is read from the struct `s'.  */
226
227 typedef union
228 {
229   struct DWstruct s;
230   DWtype ll;
231 } DWunion;
232
233 #if (defined (L_udivmoddi4) || defined (L_muldi3) || defined (L_udiv_w_sdiv)\
234      || defined (L_divdi3) || defined (L_udivdi3) \
235      || defined (L_moddi3) || defined (L_umoddi3))
236
237 #include "longlong.h"
238
239 #endif /* udiv or mul */
240
241 extern DWtype __muldi3 (DWtype, DWtype);
242 extern DWtype __divdi3 (DWtype, DWtype);
243 extern UDWtype __udivdi3 (UDWtype, UDWtype);
244 extern UDWtype __umoddi3 (UDWtype, UDWtype);
245 extern DWtype __moddi3 (DWtype, DWtype);
246 /* __udivmoddi4 is static inline when building other libgcc2 portions.  */
247 #if (!defined (L_udivdi3) && !defined (L_divdi3) && \
248      !defined (L_umoddi3) && !defined (L_moddi3))
249 extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
250 #endif
251
252 /* __negdi2 is static inline when building other libgcc2 portions.  */
253 #if !defined(L_divdi3) && !defined(L_moddi3)
254 extern DWtype __negdi2 (DWtype);
255 #endif
256
257 extern DWtype __lshrdi3 (DWtype, word_type);
258 extern DWtype __ashldi3 (DWtype, word_type);
259 extern DWtype __ashrdi3 (DWtype, word_type);
260 extern DWtype __ffsdi2 (DWtype);
261
262 /* __udiv_w_sdiv is static inline when building other libgcc2 portions.  */
263 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
264      !defined(L_umoddi3) && !defined(L_moddi3))
265 extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
266 #endif
267
268 extern word_type __cmpdi2 (DWtype, DWtype);
269 extern word_type __ucmpdi2 (DWtype, DWtype);
270 extern DFtype __floatdidf (DWtype);
271 extern SFtype __floatdisf (DWtype);
272 extern UWtype __fixunsdfsi (DFtype);
273 extern UWtype __fixunssfsi (SFtype);
274 extern DWtype __fixunsdfdi (DFtype);
275 extern DWtype __fixdfdi (DFtype);
276 extern DWtype __fixunssfdi (SFtype);
277 extern DWtype __fixsfdi (SFtype);
278
279 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
280 extern DWtype __fixxfdi (XFtype);
281 extern DWtype __fixunsxfdi (XFtype);
282 extern XFtype __floatdixf (DWtype);
283 extern UWtype __fixunsxfsi (XFtype);
284 #endif
285
286 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
287 extern DWtype __fixunstfdi (TFtype);
288 extern DWtype __fixtfdi (TFtype);
289 extern TFtype __floatditf (DWtype);
290 #endif
291
292 #endif /* __LIBGCC2_H__ */