OSDN Git Service

97452c425af5f08b89aa5039faf254df11ef3a8f
[pf3gnuchains/gcc-fork.git] / gcc / libgcc1.c
1 /* Subroutines needed by GCC output code on some machines.  */
2 /* Compile this file with the Unix C compiler!  */
3 /* Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.
4
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file with other programs, and to distribute
13 those programs without any restriction coming from the use of this
14 file.  (The General Public License restrictions do apply in other
15 respects; for example, they cover modification of the file, and
16 distribution when not linked into another program.)
17
18 This file is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; see the file COPYING.  If not, write to
25 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
26
27 /* As a special exception, if you link this library with other files,
28    some of which are compiled with GCC, to produce an executable,
29    this library does not by itself cause the resulting executable
30    to be covered by the GNU General Public License.
31    This exception does not however invalidate any other reasons why
32    the executable file might be covered by the GNU General Public License.  */
33
34 #include "config.h"
35
36 /* Don't use `fancy_abort' here even if config.h says to use it.  */
37 #ifdef abort
38 #undef abort
39 #endif
40
41 /* On some machines, cc is really GCC.  For these machines, we can't
42    expect these functions to be properly compiled unless GCC open codes
43    the operation (which is precisely when the function won't be used).
44    So allow tm.h to specify ways of accomplishing the operations
45    by defining the macros perform_*.
46
47    On a machine where cc is some other compiler, there is usually no
48    reason to define perform_*.  The other compiler normally has other ways
49    of implementing all of these operations.
50
51    In some cases a certain machine may come with GCC installed as cc
52    or may have some other compiler.  Then it may make sense for tm.h
53    to define perform_* only if __GNUC__ is defined.  */
54
55 #ifndef perform_mulsi3
56 #define perform_mulsi3(a, b) return a * b
57 #endif
58
59 #ifndef perform_divsi3
60 #define perform_divsi3(a, b) return a / b
61 #endif
62
63 #ifndef perform_udivsi3
64 #define perform_udivsi3(a, b) return a / b
65 #endif
66
67 #ifndef perform_modsi3
68 #define perform_modsi3(a, b) return a % b
69 #endif
70
71 #ifndef perform_umodsi3
72 #define perform_umodsi3(a, b) return a % b
73 #endif
74
75 #ifndef perform_lshrsi3
76 #define perform_lshrsi3(a, b) return a >> b
77 #endif
78
79 #ifndef perform_ashrsi3
80 #define perform_ashrsi3(a, b) return a >> b
81 #endif
82
83 #ifndef perform_ashlsi3
84 #define perform_ashlsi3(a, b) return a << b
85 #endif
86
87 #ifndef perform_adddf3
88 #define perform_adddf3(a, b) return a + b
89 #endif
90
91 #ifndef perform_subdf3
92 #define perform_subdf3(a, b) return a - b
93 #endif
94
95 #ifndef perform_muldf3
96 #define perform_muldf3(a, b) return a * b
97 #endif
98
99 #ifndef perform_divdf3
100 #define perform_divdf3(a, b) return a / b
101 #endif
102
103 #ifndef perform_addsf3
104 #define perform_addsf3(a, b) return INTIFY (a + b)
105 #endif
106
107 #ifndef perform_subsf3
108 #define perform_subsf3(a, b) return INTIFY (a - b)
109 #endif
110
111 #ifndef perform_mulsf3
112 #define perform_mulsf3(a, b) return INTIFY (a * b)
113 #endif
114
115 #ifndef perform_divsf3
116 #define perform_divsf3(a, b) return INTIFY (a / b)
117 #endif
118
119 #ifndef perform_negdf2
120 #define perform_negdf2(a) return -a
121 #endif
122
123 #ifndef perform_negsf2
124 #define perform_negsf2(a) return INTIFY (-a)
125 #endif
126
127 #ifndef perform_fixdfsi
128 #define perform_fixdfsi(a) return (nongcc_SI_type) a;
129 #endif
130
131 #ifndef perform_fixsfsi
132 #define perform_fixsfsi(a) return (nongcc_SI_type) a
133 #endif
134
135 #ifndef perform_floatsidf
136 #define perform_floatsidf(a) return (double) a
137 #endif
138
139 #ifndef perform_floatsisf
140 #define perform_floatsisf(a)  return INTIFY ((float) a)
141 #endif
142
143 #ifndef perform_extendsfdf2
144 #define perform_extendsfdf2(a)  return a
145 #endif
146
147 #ifndef perform_truncdfsf2
148 #define perform_truncdfsf2(a)  return INTIFY (a)
149 #endif
150
151 /* Note that eqdf2 returns a value for "true" that is == 0,
152    nedf2 returns a value for "true" that is != 0,
153    gtdf2 returns a value for "true" that is > 0,
154    and so on.  */
155
156 #ifndef perform_eqdf2
157 #define perform_eqdf2(a, b) return !(a == b)
158 #endif
159
160 #ifndef perform_nedf2
161 #define perform_nedf2(a, b) return a != b
162 #endif
163
164 #ifndef perform_gtdf2
165 #define perform_gtdf2(a, b) return a > b
166 #endif
167
168 #ifndef perform_gedf2
169 #define perform_gedf2(a, b) return (a >= b) - 1
170 #endif
171
172 #ifndef perform_ltdf2
173 #define perform_ltdf2(a, b) return -(a < b)
174 #endif
175
176 #ifndef perform_ledf2
177 #define perform_ledf2(a, b) return 1 - (a <= b)
178 #endif
179
180 #ifndef perform_eqsf2
181 #define perform_eqsf2(a, b) return !(a == b)
182 #endif
183
184 #ifndef perform_nesf2
185 #define perform_nesf2(a, b) return a != b
186 #endif
187
188 #ifndef perform_gtsf2
189 #define perform_gtsf2(a, b) return a > b
190 #endif
191
192 #ifndef perform_gesf2
193 #define perform_gesf2(a, b) return (a >= b) - 1
194 #endif
195
196 #ifndef perform_ltsf2
197 #define perform_ltsf2(a, b) return -(a < b)
198 #endif
199
200 #ifndef perform_lesf2
201 #define perform_lesf2(a, b) return 1 - (a <= b);
202 #endif
203 \f
204 /* Define the C data type to use for an SImode value.  */
205
206 #ifndef nongcc_SI_type
207 #define nongcc_SI_type long int
208 #endif
209
210 /* Define the C data type to use for a value of word size */
211 #ifndef nongcc_word_type
212 #define nongcc_word_type nongcc_SI_type
213 #endif
214
215 /* Define the type to be used for returning an SF mode value
216    and the method for turning a float into that type.
217    These definitions work for machines where an SF value is
218    returned in the same register as an int.  */
219
220 #ifndef FLOAT_VALUE_TYPE  
221 #define FLOAT_VALUE_TYPE int
222 #endif
223
224 #ifndef INTIFY
225 #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
226 #endif
227
228 #ifndef FLOATIFY
229 #define FLOATIFY(INTVAL)  ((INTVAL).f)
230 #endif
231
232 #ifndef FLOAT_ARG_TYPE
233 #define FLOAT_ARG_TYPE union flt_or_int
234 #endif
235
236 union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
237
238 union flt_or_int { int i; float f; };
239
240
241 #ifdef L_mulsi3
242 nongcc_SI_type
243 __mulsi3 (a, b)
244      nongcc_SI_type a, b;
245 {
246   perform_mulsi3 (a, b);
247 }
248 #endif
249
250 #ifdef L_udivsi3
251 nongcc_SI_type
252 __udivsi3 (a, b)
253      unsigned nongcc_SI_type a, b;
254 {
255   perform_udivsi3 (a, b);
256 }
257 #endif
258
259 #ifdef L_divsi3
260 nongcc_SI_type
261 __divsi3 (a, b)
262      nongcc_SI_type a, b;
263 {
264   perform_divsi3 (a, b);
265 }
266 #endif
267
268 #ifdef L_umodsi3
269 nongcc_SI_type
270 __umodsi3 (a, b)
271      unsigned nongcc_SI_type a, b;
272 {
273   perform_umodsi3 (a, b);
274 }
275 #endif
276
277 #ifdef L_modsi3
278 nongcc_SI_type
279 __modsi3 (a, b)
280      nongcc_SI_type a, b;
281 {
282   perform_modsi3 (a, b);
283 }
284 #endif
285
286 #ifdef L_lshrsi3
287 nongcc_SI_type
288 __lshrsi3 (a, b)
289      unsigned nongcc_SI_type a, b;
290 {
291   perform_lshrsi3 (a, b);
292 }
293 #endif
294
295 #ifdef L_ashrsi3
296 nongcc_SI_type
297 __ashrsi3 (a, b)
298      nongcc_SI_type a, b;
299 {
300   perform_ashrsi3 (a, b);
301 }
302 #endif
303
304 #ifdef L_ashlsi3
305 nongcc_SI_type
306 __ashlsi3 (a, b)
307      nongcc_SI_type a, b;
308 {
309   perform_ashlsi3 (a, b);
310 }
311 #endif
312 \f
313 #ifdef L_divdf3
314 double
315 __divdf3 (a, b)
316      double a, b;
317 {
318   perform_divdf3 (a, b);
319 }
320 #endif
321
322 #ifdef L_muldf3
323 double
324 __muldf3 (a, b)
325      double a, b;
326 {
327   perform_muldf3 (a, b);
328 }
329 #endif
330
331 #ifdef L_negdf2
332 double
333 __negdf2 (a)
334      double a;
335 {
336   perform_negdf2 (a);
337 }
338 #endif
339
340 #ifdef L_adddf3
341 double
342 __adddf3 (a, b)
343      double a, b;
344 {
345   perform_adddf3 (a, b);
346 }
347 #endif
348
349 #ifdef L_subdf3
350 double
351 __subdf3 (a, b)
352      double a, b;
353 {
354   perform_subdf3 (a, b);
355 }
356 #endif
357
358 /* Note that eqdf2 returns a value for "true" that is == 0,
359    nedf2 returns a value for "true" that is != 0,
360    gtdf2 returns a value for "true" that is > 0,
361    and so on.  */
362
363 #ifdef L_eqdf2
364 nongcc_word_type
365 __eqdf2 (a, b)
366      double a, b;
367 {
368   /* Value == 0 iff a == b.  */
369   perform_eqdf2 (a, b);
370 }
371 #endif
372
373 #ifdef L_nedf2
374 nongcc_word_type
375 __nedf2 (a, b)
376      double a, b;
377 {
378   /* Value != 0 iff a != b.  */
379   perform_nedf2 (a, b);
380 }
381 #endif
382
383 #ifdef L_gtdf2
384 nongcc_word_type
385 __gtdf2 (a, b)
386      double a, b;
387 {
388   /* Value > 0 iff a > b.  */
389   perform_gtdf2 (a, b);
390 }
391 #endif
392
393 #ifdef L_gedf2
394 nongcc_word_type
395 __gedf2 (a, b)
396      double a, b;
397 {
398   /* Value >= 0 iff a >= b.  */
399   perform_gedf2 (a, b);
400 }
401 #endif
402
403 #ifdef L_ltdf2
404 nongcc_word_type
405 __ltdf2 (a, b)
406      double a, b;
407 {
408   /* Value < 0 iff a < b.  */
409   perform_ltdf2 (a, b);
410 }
411 #endif
412
413 #ifdef L_ledf2
414 nongcc_word_type
415 __ledf2 (a, b)
416      double a, b;
417 {
418   /* Value <= 0 iff a <= b.  */
419   perform_ledf2 (a, b);
420 }
421 #endif
422 \f
423 #ifdef L_fixdfsi
424 nongcc_SI_type
425 __fixdfsi (a)
426      double a;
427 {
428   perform_fixdfsi (a);
429 }
430 #endif
431
432 #ifdef L_fixsfsi
433 nongcc_SI_type
434 __fixsfsi (a)
435      FLOAT_ARG_TYPE a;
436 {
437   union flt_or_value intify;
438   perform_fixsfsi (FLOATIFY (a));
439 }
440 #endif
441
442 #ifdef L_floatsidf
443 double
444 __floatsidf (a)
445      nongcc_SI_type a;
446 {
447   perform_floatsidf (a);
448 }
449 #endif
450
451 #ifdef L_floatsisf
452 FLOAT_VALUE_TYPE
453 __floatsisf (a)
454      nongcc_SI_type a;
455 {
456   union flt_or_value intify;
457   perform_floatsisf (a);
458 }
459 #endif
460 \f
461 #ifdef L_addsf3
462 FLOAT_VALUE_TYPE
463 __addsf3 (a, b)
464      FLOAT_ARG_TYPE a, b;
465 {
466   union flt_or_value intify;
467   perform_addsf3 (FLOATIFY (a), FLOATIFY (b));
468 }
469 #endif
470
471 #ifdef L_negsf2
472 FLOAT_VALUE_TYPE
473 __negsf2 (a)
474      FLOAT_ARG_TYPE a;
475 {
476   union flt_or_value intify;
477   perform_negsf2 (FLOATIFY (a));
478 }
479 #endif
480
481 #ifdef L_subsf3
482 FLOAT_VALUE_TYPE
483 __subsf3 (a, b)
484      FLOAT_ARG_TYPE a, b;
485 {
486   union flt_or_value intify;
487   perform_subsf3 (FLOATIFY (a), FLOATIFY (b));
488 }
489 #endif
490
491 #ifdef L_eqsf2
492 nongcc_word_type
493 __eqsf2 (a, b)
494      FLOAT_ARG_TYPE a, b;
495 {
496   union flt_or_int intify;
497   /* Value == 0 iff a == b.  */
498   perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
499 }
500 #endif
501
502 #ifdef L_nesf2
503 nongcc_word_type
504 __nesf2 (a, b)
505      FLOAT_ARG_TYPE a, b;
506 {
507   union flt_or_int intify;
508   /* Value != 0 iff a != b.  */
509   perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
510 }
511 #endif
512
513 #ifdef L_gtsf2
514 nongcc_word_type
515 __gtsf2 (a, b)
516      FLOAT_ARG_TYPE a, b;
517 {
518   union flt_or_int intify;
519   /* Value > 0 iff a > b.  */
520   perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
521 }
522 #endif
523
524 #ifdef L_gesf2
525 nongcc_word_type
526 __gesf2 (a, b)
527      FLOAT_ARG_TYPE a, b;
528 {
529   union flt_or_int intify;
530   /* Value >= 0 iff a >= b.  */
531   perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
532 }
533 #endif
534
535 #ifdef L_ltsf2
536 nongcc_word_type
537 __ltsf2 (a, b)
538      FLOAT_ARG_TYPE a, b;
539 {
540   union flt_or_int intify;
541   /* Value < 0 iff a < b.  */
542   perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
543 }
544 #endif
545
546 #ifdef L_lesf2
547 nongcc_word_type
548 __lesf2 (a, b)
549      FLOAT_ARG_TYPE a, b;
550 {
551   union flt_or_int intify;
552   /* Value <= 0 iff a <= b.  */
553   perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
554 }
555 #endif
556
557 #ifdef L_mulsf3
558 FLOAT_VALUE_TYPE
559 __mulsf3 (a, b)
560      FLOAT_ARG_TYPE a, b;
561 {
562   union flt_or_value intify;
563   perform_mulsf3 (FLOATIFY (a), FLOATIFY (b));
564 }
565 #endif
566
567 #ifdef L_divsf3
568 FLOAT_VALUE_TYPE
569 __divsf3 (a, b)
570      FLOAT_ARG_TYPE a, b;
571 {
572   union flt_or_value intify;
573   perform_divsf3 (FLOATIFY (a), FLOATIFY (b));
574 }
575 #endif
576
577 #ifdef L_truncdfsf2
578 FLOAT_VALUE_TYPE
579 __truncdfsf2 (a)
580      double a;
581 {
582   union flt_or_value intify;
583   perform_truncdfsf2 (a);
584 }
585 #endif
586
587 #ifdef L_extendsfdf2
588 double
589 __extendsfdf2 (a)
590      FLOAT_ARG_TYPE a;
591 {
592   union flt_or_value intify;
593   perform_extendsfdf2 (FLOATIFY (a));
594 }
595 #endif