OSDN Git Service

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