* dwarfout.c (field_byte_offset): Correctly compute the object's
[official-gcc.git] / gcc / libgcc1.c
blobbece50034222089253e85a662c52845ccf17c52a
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.
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.
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.)
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.
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, 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. */
28 /* As a special exception, if you link this library with other files,
29 some of which are compiled with GCC, to produce an executable,
30 this library does not by itself cause the resulting executable
31 to be covered by the GNU General Public License.
32 This exception does not however invalidate any other reasons why
33 the executable file might be covered by the GNU General Public License. */
35 #include "config.h"
37 /* Don't use `fancy_abort' here even if config.h says to use it. */
38 #ifdef abort
39 #undef abort
40 #endif
42 /* On some machines, cc is really GCC. For these machines, we can't
43 expect these functions to be properly compiled unless GCC open codes
44 the operation (which is precisely when the function won't be used).
45 So allow tm.h to specify ways of accomplishing the operations
46 by defining the macros perform_*.
48 On a machine where cc is some other compiler, there is usually no
49 reason to define perform_*. The other compiler normally has other ways
50 of implementing all of these operations.
52 In some cases a certain machine may come with GCC installed as cc
53 or may have some other compiler. Then it may make sense for tm.h
54 to define perform_* only if __GNUC__ is defined. */
56 #ifndef perform_mulsi3
57 #define perform_mulsi3(a, b) return a * b
58 #endif
60 #ifndef perform_divsi3
61 #define perform_divsi3(a, b) return a / b
62 #endif
64 #ifndef perform_udivsi3
65 #define perform_udivsi3(a, b) return a / b
66 #endif
68 #ifndef perform_modsi3
69 #define perform_modsi3(a, b) return a % b
70 #endif
72 #ifndef perform_umodsi3
73 #define perform_umodsi3(a, b) return a % b
74 #endif
76 #ifndef perform_lshrsi3
77 #define perform_lshrsi3(a, b) return a >> b
78 #endif
80 #ifndef perform_ashrsi3
81 #define perform_ashrsi3(a, b) return a >> b
82 #endif
84 #ifndef perform_ashlsi3
85 #define perform_ashlsi3(a, b) return a << b
86 #endif
88 #ifndef perform_adddf3
89 #define perform_adddf3(a, b) return a + b
90 #endif
92 #ifndef perform_subdf3
93 #define perform_subdf3(a, b) return a - b
94 #endif
96 #ifndef perform_muldf3
97 #define perform_muldf3(a, b) return a * b
98 #endif
100 #ifndef perform_divdf3
101 #define perform_divdf3(a, b) return a / b
102 #endif
104 #ifndef perform_addsf3
105 #define perform_addsf3(a, b) return INTIFY (a + b)
106 #endif
108 #ifndef perform_subsf3
109 #define perform_subsf3(a, b) return INTIFY (a - b)
110 #endif
112 #ifndef perform_mulsf3
113 #define perform_mulsf3(a, b) return INTIFY (a * b)
114 #endif
116 #ifndef perform_divsf3
117 #define perform_divsf3(a, b) return INTIFY (a / b)
118 #endif
120 #ifndef perform_negdf2
121 #define perform_negdf2(a) return -a
122 #endif
124 #ifndef perform_negsf2
125 #define perform_negsf2(a) return INTIFY (-a)
126 #endif
128 #ifndef perform_fixdfsi
129 #define perform_fixdfsi(a) return (nongcc_SI_type) a;
130 #endif
132 #ifndef perform_fixsfsi
133 #define perform_fixsfsi(a) return (nongcc_SI_type) a
134 #endif
136 #ifndef perform_floatsidf
137 #define perform_floatsidf(a) return (double) a
138 #endif
140 #ifndef perform_floatsisf
141 #define perform_floatsisf(a) return INTIFY ((float) a)
142 #endif
144 #ifndef perform_extendsfdf2
145 #define perform_extendsfdf2(a) return a
146 #endif
148 #ifndef perform_truncdfsf2
149 #define perform_truncdfsf2(a) return INTIFY (a)
150 #endif
152 /* Note that eqdf2 returns a value for "true" that is == 0,
153 nedf2 returns a value for "true" that is != 0,
154 gtdf2 returns a value for "true" that is > 0,
155 and so on. */
157 #ifndef perform_eqdf2
158 #define perform_eqdf2(a, b) return !(a == b)
159 #endif
161 #ifndef perform_nedf2
162 #define perform_nedf2(a, b) return a != b
163 #endif
165 #ifndef perform_gtdf2
166 #define perform_gtdf2(a, b) return a > b
167 #endif
169 #ifndef perform_gedf2
170 #define perform_gedf2(a, b) return (a >= b) - 1
171 #endif
173 #ifndef perform_ltdf2
174 #define perform_ltdf2(a, b) return -(a < b)
175 #endif
177 #ifndef perform_ledf2
178 #define perform_ledf2(a, b) return 1 - (a <= b)
179 #endif
181 #ifndef perform_eqsf2
182 #define perform_eqsf2(a, b) return !(a == b)
183 #endif
185 #ifndef perform_nesf2
186 #define perform_nesf2(a, b) return a != b
187 #endif
189 #ifndef perform_gtsf2
190 #define perform_gtsf2(a, b) return a > b
191 #endif
193 #ifndef perform_gesf2
194 #define perform_gesf2(a, b) return (a >= b) - 1
195 #endif
197 #ifndef perform_ltsf2
198 #define perform_ltsf2(a, b) return -(a < b)
199 #endif
201 #ifndef perform_lesf2
202 #define perform_lesf2(a, b) return 1 - (a <= b);
203 #endif
205 /* Define the C data type to use for an SImode value. */
207 #ifndef nongcc_SI_type
208 #define nongcc_SI_type long int
209 #endif
211 /* Define the C data type to use for a value of word size */
212 #ifndef nongcc_word_type
213 #define nongcc_word_type nongcc_SI_type
214 #endif
216 /* Define the type to be used for returning an SF mode value
217 and the method for turning a float into that type.
218 These definitions work for machines where an SF value is
219 returned in the same register as an int. */
221 #ifndef FLOAT_VALUE_TYPE
222 #define FLOAT_VALUE_TYPE int
223 #endif
225 #ifndef INTIFY
226 #define INTIFY(FLOATVAL) (intify.f = (FLOATVAL), intify.i)
227 #endif
229 #ifndef FLOATIFY
230 #define FLOATIFY(INTVAL) ((INTVAL).f)
231 #endif
233 #ifndef FLOAT_ARG_TYPE
234 #define FLOAT_ARG_TYPE union flt_or_int
235 #endif
237 union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
239 union flt_or_int { int i; float f; };
242 #ifdef L_mulsi3
243 nongcc_SI_type
244 __mulsi3 (a, b)
245 nongcc_SI_type a, b;
247 perform_mulsi3 (a, b);
249 #endif
251 #ifdef L_udivsi3
252 nongcc_SI_type
253 __udivsi3 (a, b)
254 unsigned nongcc_SI_type a, b;
256 perform_udivsi3 (a, b);
258 #endif
260 #ifdef L_divsi3
261 nongcc_SI_type
262 __divsi3 (a, b)
263 nongcc_SI_type a, b;
265 perform_divsi3 (a, b);
267 #endif
269 #ifdef L_umodsi3
270 nongcc_SI_type
271 __umodsi3 (a, b)
272 unsigned nongcc_SI_type a, b;
274 perform_umodsi3 (a, b);
276 #endif
278 #ifdef L_modsi3
279 nongcc_SI_type
280 __modsi3 (a, b)
281 nongcc_SI_type a, b;
283 perform_modsi3 (a, b);
285 #endif
287 #ifdef L_lshrsi3
288 nongcc_SI_type
289 __lshrsi3 (a, b)
290 unsigned nongcc_SI_type a, b;
292 perform_lshrsi3 (a, b);
294 #endif
296 #ifdef L_ashrsi3
297 nongcc_SI_type
298 __ashrsi3 (a, b)
299 nongcc_SI_type a, b;
301 perform_ashrsi3 (a, b);
303 #endif
305 #ifdef L_ashlsi3
306 nongcc_SI_type
307 __ashlsi3 (a, b)
308 nongcc_SI_type a, b;
310 perform_ashlsi3 (a, b);
312 #endif
314 #ifdef L_divdf3
315 double
316 __divdf3 (a, b)
317 double a, b;
319 perform_divdf3 (a, b);
321 #endif
323 #ifdef L_muldf3
324 double
325 __muldf3 (a, b)
326 double a, b;
328 perform_muldf3 (a, b);
330 #endif
332 #ifdef L_negdf2
333 double
334 __negdf2 (a)
335 double a;
337 perform_negdf2 (a);
339 #endif
341 #ifdef L_adddf3
342 double
343 __adddf3 (a, b)
344 double a, b;
346 perform_adddf3 (a, b);
348 #endif
350 #ifdef L_subdf3
351 double
352 __subdf3 (a, b)
353 double a, b;
355 perform_subdf3 (a, b);
357 #endif
359 /* Note that eqdf2 returns a value for "true" that is == 0,
360 nedf2 returns a value for "true" that is != 0,
361 gtdf2 returns a value for "true" that is > 0,
362 and so on. */
364 #ifdef L_eqdf2
365 nongcc_word_type
366 __eqdf2 (a, b)
367 double a, b;
369 /* Value == 0 iff a == b. */
370 perform_eqdf2 (a, b);
372 #endif
374 #ifdef L_nedf2
375 nongcc_word_type
376 __nedf2 (a, b)
377 double a, b;
379 /* Value != 0 iff a != b. */
380 perform_nedf2 (a, b);
382 #endif
384 #ifdef L_gtdf2
385 nongcc_word_type
386 __gtdf2 (a, b)
387 double a, b;
389 /* Value > 0 iff a > b. */
390 perform_gtdf2 (a, b);
392 #endif
394 #ifdef L_gedf2
395 nongcc_word_type
396 __gedf2 (a, b)
397 double a, b;
399 /* Value >= 0 iff a >= b. */
400 perform_gedf2 (a, b);
402 #endif
404 #ifdef L_ltdf2
405 nongcc_word_type
406 __ltdf2 (a, b)
407 double a, b;
409 /* Value < 0 iff a < b. */
410 perform_ltdf2 (a, b);
412 #endif
414 #ifdef L_ledf2
415 nongcc_word_type
416 __ledf2 (a, b)
417 double a, b;
419 /* Value <= 0 iff a <= b. */
420 perform_ledf2 (a, b);
422 #endif
424 #ifdef L_fixdfsi
425 nongcc_SI_type
426 __fixdfsi (a)
427 double a;
429 perform_fixdfsi (a);
431 #endif
433 #ifdef L_fixsfsi
434 nongcc_SI_type
435 __fixsfsi (a)
436 FLOAT_ARG_TYPE a;
438 union flt_or_value intify;
439 perform_fixsfsi (FLOATIFY (a));
441 #endif
443 #ifdef L_floatsidf
444 double
445 __floatsidf (a)
446 nongcc_SI_type a;
448 perform_floatsidf (a);
450 #endif
452 #ifdef L_floatsisf
453 FLOAT_VALUE_TYPE
454 __floatsisf (a)
455 nongcc_SI_type a;
457 union flt_or_value intify;
458 perform_floatsisf (a);
460 #endif
462 #ifdef L_addsf3
463 FLOAT_VALUE_TYPE
464 __addsf3 (a, b)
465 FLOAT_ARG_TYPE a, b;
467 union flt_or_value intify;
468 perform_addsf3 (FLOATIFY (a), FLOATIFY (b));
470 #endif
472 #ifdef L_negsf2
473 FLOAT_VALUE_TYPE
474 __negsf2 (a)
475 FLOAT_ARG_TYPE a;
477 union flt_or_value intify;
478 perform_negsf2 (FLOATIFY (a));
480 #endif
482 #ifdef L_subsf3
483 FLOAT_VALUE_TYPE
484 __subsf3 (a, b)
485 FLOAT_ARG_TYPE a, b;
487 union flt_or_value intify;
488 perform_subsf3 (FLOATIFY (a), FLOATIFY (b));
490 #endif
492 #ifdef L_eqsf2
493 nongcc_word_type
494 __eqsf2 (a, b)
495 FLOAT_ARG_TYPE a, b;
497 union flt_or_int intify;
498 /* Value == 0 iff a == b. */
499 perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
501 #endif
503 #ifdef L_nesf2
504 nongcc_word_type
505 __nesf2 (a, b)
506 FLOAT_ARG_TYPE a, b;
508 union flt_or_int intify;
509 /* Value != 0 iff a != b. */
510 perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
512 #endif
514 #ifdef L_gtsf2
515 nongcc_word_type
516 __gtsf2 (a, b)
517 FLOAT_ARG_TYPE a, b;
519 union flt_or_int intify;
520 /* Value > 0 iff a > b. */
521 perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
523 #endif
525 #ifdef L_gesf2
526 nongcc_word_type
527 __gesf2 (a, b)
528 FLOAT_ARG_TYPE a, b;
530 union flt_or_int intify;
531 /* Value >= 0 iff a >= b. */
532 perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
534 #endif
536 #ifdef L_ltsf2
537 nongcc_word_type
538 __ltsf2 (a, b)
539 FLOAT_ARG_TYPE a, b;
541 union flt_or_int intify;
542 /* Value < 0 iff a < b. */
543 perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
545 #endif
547 #ifdef L_lesf2
548 nongcc_word_type
549 __lesf2 (a, b)
550 FLOAT_ARG_TYPE a, b;
552 union flt_or_int intify;
553 /* Value <= 0 iff a <= b. */
554 perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
556 #endif
558 #ifdef L_mulsf3
559 FLOAT_VALUE_TYPE
560 __mulsf3 (a, b)
561 FLOAT_ARG_TYPE a, b;
563 union flt_or_value intify;
564 perform_mulsf3 (FLOATIFY (a), FLOATIFY (b));
566 #endif
568 #ifdef L_divsf3
569 FLOAT_VALUE_TYPE
570 __divsf3 (a, b)
571 FLOAT_ARG_TYPE a, b;
573 union flt_or_value intify;
574 perform_divsf3 (FLOATIFY (a), FLOATIFY (b));
576 #endif
578 #ifdef L_truncdfsf2
579 FLOAT_VALUE_TYPE
580 __truncdfsf2 (a)
581 double a;
583 union flt_or_value intify;
584 perform_truncdfsf2 (a);
586 #endif
588 #ifdef L_extendsfdf2
589 double
590 __extendsfdf2 (a)
591 FLOAT_ARG_TYPE a;
593 union flt_or_value intify;
594 perform_extendsfdf2 (FLOATIFY (a));
596 #endif