xref: /openbsd/gnu/usr.bin/gcc/gcc/libgcc2.h (revision c87b03e5)
1 /* Header file for libgcc2.c.  */
2 /* Copyright (C) 2000, 2001
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 extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
34 extern void __clear_cache (char *, char *);
35 extern void __eprintf (const char *, const char *, unsigned int, const char *)
36   __attribute__ ((__noreturn__));
37 
38 struct bb;
39 extern void __bb_exit_func (void);
40 extern void __bb_init_func (struct bb *);
41 extern void __bb_fork_func (void);
42 
43 #if LONG_TYPE_SIZE == GCOV_TYPE_SIZE
44 typedef long gcov_type;
45 #else
46 typedef long long gcov_type;
47 #endif
48 
49 extern gcov_type *__bb_find_arc_counters (void);
50 
51 struct exception_descriptor;
52 extern short int __get_eh_table_language (struct exception_descriptor *);
53 extern short int __get_eh_table_version (struct exception_descriptor *);
54 
55 /* Permit the tm.h file to select the endianness to use just for this
56    file.  This is used when the endianness is determined when the
57    compiler is run.  */
58 
59 #ifndef LIBGCC2_WORDS_BIG_ENDIAN
60 #define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
61 #endif
62 
63 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
64 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
65 #endif
66 
67 #ifndef MIN_UNITS_PER_WORD
68 #define MIN_UNITS_PER_WORD UNITS_PER_WORD
69 #endif
70 
71 /* In the first part of this file, we are interfacing to calls generated
72    by the compiler itself.  These calls pass values into these routines
73    which have very specific modes (rather than very specific types), and
74    these compiler-generated calls also expect any return values to have
75    very specific modes (rather than very specific types).  Thus, we need
76    to avoid using regular C language type names in this part of the file
77    because the sizes for those types can be configured to be anything.
78    Instead we use the following special type names.  */
79 
80 typedef		 int QItype	__attribute__ ((mode (QI)));
81 typedef unsigned int UQItype	__attribute__ ((mode (QI)));
82 typedef		 int HItype	__attribute__ ((mode (HI)));
83 typedef unsigned int UHItype	__attribute__ ((mode (HI)));
84 #if MIN_UNITS_PER_WORD > 1
85 /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1 */
86 typedef 	 int SItype	__attribute__ ((mode (SI)));
87 typedef unsigned int USItype	__attribute__ ((mode (SI)));
88 #if LONG_LONG_TYPE_SIZE > 32
89 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2 */
90 typedef		 int DItype	__attribute__ ((mode (DI)));
91 typedef unsigned int UDItype	__attribute__ ((mode (DI)));
92 #if MIN_UNITS_PER_WORD > 4
93 /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4 */
94 typedef		 int TItype	__attribute__ ((mode (TI)));
95 typedef unsigned int UTItype	__attribute__ ((mode (TI)));
96 #endif
97 #endif
98 #endif
99 
100 #if BITS_PER_UNIT == 8
101 
102 typedef 	float SFtype	__attribute__ ((mode (SF)));
103 typedef		float DFtype	__attribute__ ((mode (DF)));
104 
105 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
106 typedef		float XFtype	__attribute__ ((mode (XF)));
107 #endif
108 #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
109 typedef		float TFtype	__attribute__ ((mode (TF)));
110 #endif
111 
112 #else /* BITS_PER_UNIT != 8 */
113 
114 /* On dsp's there are usually qf/hf/tqf modes used instead of the above.
115    For now we don't support them in libgcc2.c.  */
116 
117 #undef L_fixdfdi
118 #undef L_fixsfdi
119 #undef L_fixtfdi
120 #undef L_fixunsdfdi
121 #undef L_fixunsdfsi
122 #undef L_fixunssfdi
123 #undef L_fixunssfsi
124 #undef L_fixunstfdi
125 #undef L_fixunsxfdi
126 #undef L_fixunsxfsi
127 #undef L_fixxfdi
128 #undef L_floatdidf
129 #undef L_floatdisf
130 #undef L_floatditf
131 #undef L_floatdixf
132 
133 #endif /* BITS_PER_UNIT != 8 */
134 
135 typedef int word_type __attribute__ ((mode (__word__)));
136 
137 /* Make sure that we don't accidentally use any normal C language built-in
138    type names in the first part of this file.  Instead we want to use *only*
139    the type names defined above.  The following macro definitions insure
140    that if we *do* accidentally use some normal C language built-in type name,
141    we will get a syntax error.  */
142 
143 #define char bogus_type
144 #define short bogus_type
145 #define int bogus_type
146 #define long bogus_type
147 #define unsigned bogus_type
148 #define float bogus_type
149 #define double bogus_type
150 
151 #if MIN_UNITS_PER_WORD > 4
152 #define W_TYPE_SIZE (8 * BITS_PER_UNIT)
153 #define Wtype	DItype
154 #define UWtype	UDItype
155 #define HWtype	DItype
156 #define UHWtype	UDItype
157 #define DWtype	TItype
158 #define UDWtype	UTItype
159 #define __NW(a,b)	__ ## a ## di ## b
160 #define __NDW(a,b)	__ ## a ## ti ## b
161 #elif MIN_UNITS_PER_WORD > 2 \
162       || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
163 #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
164 #define Wtype	SItype
165 #define UWtype	USItype
166 #define HWtype	SItype
167 #define UHWtype	USItype
168 #define DWtype	DItype
169 #define UDWtype	UDItype
170 #define __NW(a,b)	__ ## a ## si ## b
171 #define __NDW(a,b)	__ ## a ## di ## b
172 #elif MIN_UNITS_PER_WORD > 1
173 #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
174 #define Wtype	HItype
175 #define UWtype	UHItype
176 #define HWtype	HItype
177 #define UHWtype	UHItype
178 #define DWtype	SItype
179 #define UDWtype	USItype
180 #define __NW(a,b)	__ ## a ## hi ## b
181 #define __NDW(a,b)	__ ## a ## si ## b
182 #else
183 #define W_TYPE_SIZE BITS_PER_UNIT
184 #define Wtype	QItype
185 #define UWtype  UQItype
186 #define HWtype	QItype
187 #define UHWtype	UQItype
188 #define DWtype	HItype
189 #define UDWtype	UHItype
190 #define __NW(a,b)	__ ## a ## qi ## b
191 #define __NDW(a,b)	__ ## a ## hi ## b
192 #endif
193 
194 #define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
195 #define Wtype_MIN (- Wtype_MAX - 1)
196 
197 #define __muldi3	__NDW(mul,3)
198 #define __divdi3	__NDW(div,3)
199 #define __udivdi3	__NDW(udiv,3)
200 #define __moddi3	__NDW(mod,3)
201 #define __umoddi3	__NDW(umod,3)
202 #define __negdi2	__NDW(neg,2)
203 #define __lshrdi3	__NDW(lshr,3)
204 #define __ashldi3	__NDW(ashl,3)
205 #define __ashrdi3	__NDW(ashr,3)
206 #define __ffsdi2	__NDW(ffs,2)
207 #define __cmpdi2	__NDW(cmp,2)
208 #define __ucmpdi2	__NDW(ucmp,2)
209 #define __udivmoddi4	__NDW(udivmod,4)
210 #define __fixunstfDI	__NDW(fixunstf,)
211 #define __fixtfdi	__NDW(fixtf,)
212 #define __fixunsxfDI	__NDW(fixunsxf,)
213 #define __fixxfdi	__NDW(fixxf,)
214 #define __fixunsdfDI	__NDW(fixunsdf,)
215 #define __fixdfdi	__NDW(fixdf,)
216 #define __fixunssfDI	__NDW(fixunssf,)
217 #define __fixsfdi	__NDW(fixsf,)
218 #define __floatdixf	__NDW(float,xf)
219 #define __floatditf	__NDW(float,tf)
220 #define __floatdidf	__NDW(float,df)
221 #define __floatdisf	__NDW(float,sf)
222 #define __fixunsxfSI	__NW(fixunsxf,)
223 #define __fixunstfSI	__NW(fixunstf,)
224 #define __fixunsdfSI	__NW(fixunsdf,)
225 #define __fixunssfSI	__NW(fixunssf,)
226 
227 extern DWtype __muldi3 (DWtype, DWtype);
228 extern DWtype __divdi3 (DWtype, DWtype);
229 extern UDWtype __udivdi3 (UDWtype, UDWtype);
230 extern UDWtype __umoddi3 (UDWtype, UDWtype);
231 extern DWtype __moddi3 (DWtype, DWtype);
232 
233 /* __udivmoddi4 is static inline when building other libgcc2 portions.  */
234 #if (!defined (L_udivdi3) && !defined (L_divdi3) && \
235      !defined (L_umoddi3) && !defined (L_moddi3))
236 extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
237 #endif
238 
239 /* __negdi2 is static inline when building other libgcc2 portions.  */
240 #if !defined(L_divdi3) && !defined(L_moddi3)
241 extern DWtype __negdi2 (DWtype);
242 #endif
243 
244 extern DWtype __lshrdi3 (DWtype, word_type);
245 extern DWtype __ashldi3 (DWtype, word_type);
246 extern DWtype __ashrdi3 (DWtype, word_type);
247 extern DWtype __ffsdi2 (DWtype);
248 
249 /* __udiv_w_sdiv is static inline when building other libgcc2 portions.  */
250 #if (!defined(L_udivdi3) && !defined(L_divdi3) && \
251      !defined(L_umoddi3) && !defined(L_moddi3))
252 extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
253 #endif
254 
255 extern word_type __cmpdi2 (DWtype, DWtype);
256 extern word_type __ucmpdi2 (DWtype, DWtype);
257 
258 extern Wtype __absvsi2 (Wtype);
259 extern DWtype __absvdi2 (DWtype);
260 extern Wtype __addvsi3 (Wtype, Wtype);
261 extern DWtype __addvdi3 (DWtype, DWtype);
262 extern Wtype __subvsi3 (Wtype, Wtype);
263 extern DWtype __subvdi3 (DWtype, DWtype);
264 extern Wtype __mulvsi3 (Wtype, Wtype);
265 extern DWtype __mulvdi3 (DWtype, DWtype);
266 extern Wtype __negvsi2 (Wtype);
267 extern DWtype __negvdi2 (DWtype);
268 
269 #if BITS_PER_UNIT == 8
270 extern DWtype __fixdfdi (DFtype);
271 extern DWtype __fixsfdi (SFtype);
272 extern DFtype __floatdidf (DWtype);
273 extern SFtype __floatdisf (DWtype);
274 extern UWtype __fixunsdfSI (DFtype);
275 extern UWtype __fixunssfSI (SFtype);
276 extern DWtype __fixunsdfDI (DFtype);
277 extern DWtype __fixunssfDI (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 #endif /* BITS_PER_UNIT == 8 */
292 
293 /* DWstructs are pairs of Wtype values in the order determined by
294    LIBGCC2_WORDS_BIG_ENDIAN.  */
295 
296 #if LIBGCC2_WORDS_BIG_ENDIAN
297   struct DWstruct {Wtype high, low;};
298 #else
299   struct DWstruct {Wtype low, high;};
300 #endif
301 
302 /* We need this union to unpack/pack DImode values, since we don't have
303    any arithmetic yet.  Incoming DImode parameters are stored into the
304    `ll' field, and the unpacked result is read from the struct `s'.  */
305 
306 typedef union
307 {
308   struct DWstruct s;
309   DWtype ll;
310 } DWunion;
311 
312 #include "longlong.h"
313 
314 #endif /* ! GCC_LIBGCC2_H */
315