OSDN Git Service

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