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