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
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_ashrsi3
80 #define perform_ashrsi3(a, b) return a >> b
83 #ifndef perform_ashlsi3
84 #define perform_ashlsi3(a, b) return a << b
87 #ifndef perform_adddf3
88 #define perform_adddf3(a, b) return a + b
91 #ifndef perform_subdf3
92 #define perform_subdf3(a, b) return a - b
95 #ifndef perform_muldf3
96 #define perform_muldf3(a, b) return a * b
99 #ifndef perform_divdf3
100 #define perform_divdf3(a, b) return a / b
103 #ifndef perform_addsf3
104 #define perform_addsf3(a, b) return INTIFY (a + b)
107 #ifndef perform_subsf3
108 #define perform_subsf3(a, b) return INTIFY (a - b)
111 #ifndef perform_mulsf3
112 #define perform_mulsf3(a, b) return INTIFY (a * b)
115 #ifndef perform_divsf3
116 #define perform_divsf3(a, b) return INTIFY (a / b)
119 #ifndef perform_negdf2
120 #define perform_negdf2(a) return -a
123 #ifndef perform_negsf2
124 #define perform_negsf2(a) return INTIFY (-a)
127 #ifndef perform_fixdfsi
128 #define perform_fixdfsi(a) return (nongcc_SI_type) a;
131 #ifndef perform_fixsfsi
132 #define perform_fixsfsi(a) return (nongcc_SI_type) a
135 #ifndef perform_floatsidf
136 #define perform_floatsidf(a) return (double) a
139 #ifndef perform_floatsisf
140 #define perform_floatsisf(a) return INTIFY ((float) a)
143 #ifndef perform_extendsfdf2
144 #define perform_extendsfdf2(a) return a
147 #ifndef perform_truncdfsf2
148 #define perform_truncdfsf2(a) return INTIFY (a)
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,
156 #ifndef perform_eqdf2
157 #define perform_eqdf2(a, b) return !(a == b)
160 #ifndef perform_nedf2
161 #define perform_nedf2(a, b) return a != b
164 #ifndef perform_gtdf2
165 #define perform_gtdf2(a, b) return a > b
168 #ifndef perform_gedf2
169 #define perform_gedf2(a, b) return (a >= b) - 1
172 #ifndef perform_ltdf2
173 #define perform_ltdf2(a, b) return -(a < b)
176 #ifndef perform_ledf2
177 #define perform_ledf2(a, b) return 1 - (a <= b)
180 #ifndef perform_eqsf2
181 #define perform_eqsf2(a, b) return !(a == b)
184 #ifndef perform_nesf2
185 #define perform_nesf2(a, b) return a != b
188 #ifndef perform_gtsf2
189 #define perform_gtsf2(a, b) return a > b
192 #ifndef perform_gesf2
193 #define perform_gesf2(a, b) return (a >= b) - 1
196 #ifndef perform_ltsf2
197 #define perform_ltsf2(a, b) return -(a < b)
200 #ifndef perform_lesf2
201 #define perform_lesf2(a, b) return 1 - (a <= b);
204 /* Define the C data type to use for an SImode value. */
206 #ifndef nongcc_SI_type
207 #define nongcc_SI_type long int
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
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. */
220 #ifndef FLOAT_VALUE_TYPE
221 #define FLOAT_VALUE_TYPE int
225 #define INTIFY(FLOATVAL) (intify.f = (FLOATVAL), intify.i)
229 #define FLOATIFY(INTVAL) ((INTVAL).f)
232 #ifndef FLOAT_ARG_TYPE
233 #define FLOAT_ARG_TYPE union flt_or_int
236 union flt_or_value
{ FLOAT_VALUE_TYPE i
; float f
; };
238 union flt_or_int
{ int i
; float f
; };
246 perform_mulsi3 (a
, b
);
253 unsigned nongcc_SI_type a
, b
;
255 perform_udivsi3 (a
, b
);
264 perform_divsi3 (a
, b
);
271 unsigned nongcc_SI_type a
, b
;
273 perform_umodsi3 (a
, b
);
282 perform_modsi3 (a
, b
);
289 unsigned nongcc_SI_type a
, b
;
291 perform_lshrsi3 (a
, b
);
300 perform_ashrsi3 (a
, b
);
309 perform_ashlsi3 (a
, b
);
318 perform_divdf3 (a
, b
);
327 perform_muldf3 (a
, b
);
345 perform_adddf3 (a
, b
);
354 perform_subdf3 (a
, b
);
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,
368 /* Value == 0 iff a == b. */
369 perform_eqdf2 (a
, b
);
378 /* Value != 0 iff a != b. */
379 perform_nedf2 (a
, b
);
388 /* Value > 0 iff a > b. */
389 perform_gtdf2 (a
, b
);
398 /* Value >= 0 iff a >= b. */
399 perform_gedf2 (a
, b
);
408 /* Value < 0 iff a < b. */
409 perform_ltdf2 (a
, b
);
418 /* Value <= 0 iff a <= b. */
419 perform_ledf2 (a
, b
);
437 union flt_or_value intify
;
438 perform_fixsfsi (FLOATIFY (a
));
447 perform_floatsidf (a
);
456 union flt_or_value intify
;
457 perform_floatsisf (a
);
466 union flt_or_value intify
;
467 perform_addsf3 (FLOATIFY (a
), FLOATIFY (b
));
476 union flt_or_value intify
;
477 perform_negsf2 (FLOATIFY (a
));
486 union flt_or_value intify
;
487 perform_subsf3 (FLOATIFY (a
), FLOATIFY (b
));
496 union flt_or_int intify
;
497 /* Value == 0 iff a == b. */
498 perform_eqsf2 (FLOATIFY (a
), FLOATIFY (b
));
507 union flt_or_int intify
;
508 /* Value != 0 iff a != b. */
509 perform_nesf2 (FLOATIFY (a
), FLOATIFY (b
));
518 union flt_or_int intify
;
519 /* Value > 0 iff a > b. */
520 perform_gtsf2 (FLOATIFY (a
), FLOATIFY (b
));
529 union flt_or_int intify
;
530 /* Value >= 0 iff a >= b. */
531 perform_gesf2 (FLOATIFY (a
), FLOATIFY (b
));
540 union flt_or_int intify
;
541 /* Value < 0 iff a < b. */
542 perform_ltsf2 (FLOATIFY (a
), FLOATIFY (b
));
551 union flt_or_int intify
;
552 /* Value <= 0 iff a <= b. */
553 perform_lesf2 (FLOATIFY (a
), FLOATIFY (b
));
562 union flt_or_value intify
;
563 perform_mulsf3 (FLOATIFY (a
), FLOATIFY (b
));
572 union flt_or_value intify
;
573 perform_divsf3 (FLOATIFY (a
), FLOATIFY (b
));
582 union flt_or_value intify
;
583 perform_truncdfsf2 (a
);
592 union flt_or_value intify
;
593 perform_extendsfdf2 (FLOATIFY (a
));