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 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
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
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. */
36 /* Don't use `fancy_abort' here even if config.h says to use it. */
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_*.
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.
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. */
55 #ifndef perform_mulsi3
56 #define perform_mulsi3(a, b) return a * b
59 #ifndef perform_divsi3
60 #define perform_divsi3(a, b) return a / b
63 #ifndef perform_udivsi3
64 #define perform_udivsi3(a, b) return a / b
67 #ifndef perform_modsi3
68 #define perform_modsi3(a, b) return a % b
71 #ifndef perform_umodsi3
72 #define perform_umodsi3(a, b) return a % b
75 #ifndef perform_lshrsi3
76 #define perform_lshrsi3(a, b) return a >> b
79 #ifndef perform_lshlsi3
80 #define perform_lshlsi3(a, b) return a << b
83 #ifndef perform_ashrsi3
84 #define perform_ashrsi3(a, b) return a >> b
87 #ifndef perform_ashlsi3
88 #define perform_ashlsi3(a, b) return a << b
91 #ifndef perform_adddf3
92 #define perform_adddf3(a, b) return a + b
95 #ifndef perform_subdf3
96 #define perform_subdf3(a, b) return a - b
99 #ifndef perform_muldf3
100 #define perform_muldf3(a, b) return a * b
103 #ifndef perform_divdf3
104 #define perform_divdf3(a, b) return a / b
107 #ifndef perform_addsf3
108 #define perform_addsf3(a, b) return INTIFY (a + b)
111 #ifndef perform_subsf3
112 #define perform_subsf3(a, b) return INTIFY (a - b)
115 #ifndef perform_mulsf3
116 #define perform_mulsf3(a, b) return INTIFY (a * b)
119 #ifndef perform_divsf3
120 #define perform_divsf3(a, b) return INTIFY (a / b)
123 #ifndef perform_negdf2
124 #define perform_negdf2(a) return -a
127 #ifndef perform_negsf2
128 #define perform_negsf2(a) return INTIFY (-a)
131 #ifndef perform_fixdfsi
132 #define perform_fixdfsi(a) return (nongcc_SI_type) a;
135 #ifndef perform_fixsfsi
136 #define perform_fixsfsi(a) return (nongcc_SI_type) a
139 #ifndef perform_floatsidf
140 #define perform_floatsidf(a) return (double) a
143 #ifndef perform_floatsisf
144 #define perform_floatsisf(a) return INTIFY ((float) a)
147 #ifndef perform_extendsfdf2
148 #define perform_extendsfdf2(a) return a
151 #ifndef perform_truncdfsf2
152 #define perform_truncdfsf2(a) return INTIFY (a)
155 /* Note that eqdf2 returns a value for "true" that is == 0,
156 nedf2 returns a value for "true" that is != 0,
157 gtdf2 returns a value for "true" that is > 0,
160 #ifndef perform_eqdf2
161 #define perform_eqdf2(a, b) return !(a == b)
164 #ifndef perform_nedf2
165 #define perform_nedf2(a, b) return a != b
168 #ifndef perform_gtdf2
169 #define perform_gtdf2(a, b) return a > b
172 #ifndef perform_gedf2
173 #define perform_gedf2(a, b) return (a >= b) - 1
176 #ifndef perform_ltdf2
177 #define perform_ltdf2(a, b) return -(a < b)
180 #ifndef perform_ledf2
181 #define perform_ledf2(a, b) return 1 - (a <= b)
184 #ifndef perform_eqsf2
185 #define perform_eqsf2(a, b) return !(a == b)
188 #ifndef perform_nesf2
189 #define perform_nesf2(a, b) return a != b
192 #ifndef perform_gtsf2
193 #define perform_gtsf2(a, b) return a > b
196 #ifndef perform_gesf2
197 #define perform_gesf2(a, b) return (a >= b) - 1
200 #ifndef perform_ltsf2
201 #define perform_ltsf2(a, b) return -(a < b)
204 #ifndef perform_lesf2
205 #define perform_lesf2(a, b) return 1 - (a <= b);
208 /* Define the C data type to use for an SImode value. */
210 #ifndef nongcc_SI_type
211 #define nongcc_SI_type long int
214 /* Define the C data type to use for a value of word size */
215 #ifndef nongcc_word_type
216 #define nongcc_word_type nongcc_SI_type
219 /* Define the type to be used for returning an SF mode value
220 and the method for turning a float into that type.
221 These definitions work for machines where an SF value is
222 returned in the same register as an int. */
224 #ifndef FLOAT_VALUE_TYPE
225 #define FLOAT_VALUE_TYPE int
229 #define INTIFY(FLOATVAL) (intify.f = (FLOATVAL), intify.i)
233 #define FLOATIFY(INTVAL) ((INTVAL).f)
236 #ifndef FLOAT_ARG_TYPE
237 #define FLOAT_ARG_TYPE union flt_or_int
240 union flt_or_value
{ FLOAT_VALUE_TYPE i
; float f
; };
242 union flt_or_int
{ int i
; float f
; };
250 perform_mulsi3 (a
, b
);
257 unsigned nongcc_SI_type a
, b
;
259 perform_udivsi3 (a
, b
);
268 perform_divsi3 (a
, b
);
275 unsigned nongcc_SI_type a
, b
;
277 perform_umodsi3 (a
, b
);
286 perform_modsi3 (a
, b
);
293 unsigned nongcc_SI_type a
, b
;
295 perform_lshrsi3 (a
, b
);
302 unsigned nongcc_SI_type a
, b
;
304 perform_lshlsi3 (a
, b
);
313 perform_ashrsi3 (a
, b
);
322 perform_ashlsi3 (a
, b
);
331 perform_divdf3 (a
, b
);
340 perform_muldf3 (a
, b
);
358 perform_adddf3 (a
, b
);
367 perform_subdf3 (a
, b
);
371 /* Note that eqdf2 returns a value for "true" that is == 0,
372 nedf2 returns a value for "true" that is != 0,
373 gtdf2 returns a value for "true" that is > 0,
381 /* Value == 0 iff a == b. */
382 perform_eqdf2 (a
, b
);
391 /* Value != 0 iff a != b. */
392 perform_nedf2 (a
, b
);
401 /* Value > 0 iff a > b. */
402 perform_gtdf2 (a
, b
);
411 /* Value >= 0 iff a >= b. */
412 perform_gedf2 (a
, b
);
421 /* Value < 0 iff a < b. */
422 perform_ltdf2 (a
, b
);
431 /* Value <= 0 iff a <= b. */
432 perform_ledf2 (a
, b
);
450 union flt_or_value intify
;
451 perform_fixsfsi (FLOATIFY (a
));
460 perform_floatsidf (a
);
469 union flt_or_value intify
;
470 perform_floatsisf (a
);
479 union flt_or_value intify
;
480 perform_addsf3 (FLOATIFY (a
), FLOATIFY (b
));
489 union flt_or_value intify
;
490 perform_negsf2 (FLOATIFY (a
));
499 union flt_or_value intify
;
500 perform_subsf3 (FLOATIFY (a
), FLOATIFY (b
));
509 union flt_or_int intify
;
510 /* Value == 0 iff a == b. */
511 perform_eqsf2 (FLOATIFY (a
), FLOATIFY (b
));
520 union flt_or_int intify
;
521 /* Value != 0 iff a != b. */
522 perform_nesf2 (FLOATIFY (a
), FLOATIFY (b
));
531 union flt_or_int intify
;
532 /* Value > 0 iff a > b. */
533 perform_gtsf2 (FLOATIFY (a
), FLOATIFY (b
));
542 union flt_or_int intify
;
543 /* Value >= 0 iff a >= b. */
544 perform_gesf2 (FLOATIFY (a
), FLOATIFY (b
));
553 union flt_or_int intify
;
554 /* Value < 0 iff a < b. */
555 perform_ltsf2 (FLOATIFY (a
), FLOATIFY (b
));
564 union flt_or_int intify
;
565 /* Value <= 0 iff a <= b. */
566 perform_lesf2 (FLOATIFY (a
), FLOATIFY (b
));
575 union flt_or_value intify
;
576 perform_mulsf3 (FLOATIFY (a
), FLOATIFY (b
));
585 union flt_or_value intify
;
586 perform_divsf3 (FLOATIFY (a
), FLOATIFY (b
));
595 union flt_or_value intify
;
596 perform_truncdfsf2 (a
);
605 union flt_or_value intify
;
606 perform_extendsfdf2 (FLOATIFY (a
));