]>
Commit | Line | Data |
---|---|---|
e9a25f70 JL |
1 | /* Definitions of floating-point access for GNU compiler. |
2 | Copyright (C) 1989, 1991, 1994, 1996, 1997 Free Software Foundation, Inc. | |
0694b47c RS |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
e99215a3 RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
0694b47c RS |
20 | |
21 | #ifndef REAL_H_INCLUDED | |
22 | #define REAL_H_INCLUDED | |
23 | ||
24 | /* Define codes for all the float formats that we know of. */ | |
25 | #define UNKNOWN_FLOAT_FORMAT 0 | |
26 | #define IEEE_FLOAT_FORMAT 1 | |
27 | #define VAX_FLOAT_FORMAT 2 | |
fd76a739 | 28 | #define IBM_FLOAT_FORMAT 3 |
0694b47c RS |
29 | |
30 | /* Default to IEEE float if not specified. Nearly all machines use it. */ | |
31 | ||
32 | #ifndef TARGET_FLOAT_FORMAT | |
33 | #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT | |
34 | #endif | |
35 | ||
36 | #ifndef HOST_FLOAT_FORMAT | |
37 | #define HOST_FLOAT_FORMAT IEEE_FLOAT_FORMAT | |
38 | #endif | |
39 | ||
40 | #if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT | |
41 | #define REAL_INFINITY | |
42 | #endif | |
43 | ||
91d61207 RK |
44 | /* If FLOAT_WORDS_BIG_ENDIAN and HOST_FLOAT_WORDS_BIG_ENDIAN are not defined |
45 | in the header files, then this implies the word-endianness is the same as | |
46 | for integers. */ | |
47 | ||
48 | /* This is defined 0 or 1, like WORDS_BIG_ENDIAN. */ | |
49 | #ifndef FLOAT_WORDS_BIG_ENDIAN | |
50 | #define FLOAT_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN | |
51 | #endif | |
52 | ||
53 | /* This is defined 0 or 1, unlike HOST_WORDS_BIG_ENDIAN. */ | |
54 | #ifndef HOST_FLOAT_WORDS_BIG_ENDIAN | |
55 | #ifdef HOST_WORDS_BIG_ENDIAN | |
56 | #define HOST_FLOAT_WORDS_BIG_ENDIAN 1 | |
57 | #else | |
58 | #define HOST_FLOAT_WORDS_BIG_ENDIAN 0 | |
59 | #endif | |
60 | #endif | |
61 | ||
fd76a739 RS |
62 | /* Defining REAL_ARITHMETIC invokes a floating point emulator |
63 | that can produce a target machine format differing by more | |
64 | than just endian-ness from the host's format. The emulator | |
65 | is also used to support extended real XFmode. */ | |
66 | #ifndef LONG_DOUBLE_TYPE_SIZE | |
67 | #define LONG_DOUBLE_TYPE_SIZE 64 | |
68 | #endif | |
7bb5d01e JW |
69 | #if (LONG_DOUBLE_TYPE_SIZE == 96) || (LONG_DOUBLE_TYPE_SIZE == 128) |
70 | #ifndef REAL_ARITHMETIC | |
71 | #define REAL_ARITHMETIC | |
72 | #endif | |
73 | #endif | |
74 | #ifdef REAL_ARITHMETIC | |
fd76a739 RS |
75 | /* **** Start of software floating point emulator interface macros **** */ |
76 | ||
77 | /* Support 80-bit extended real XFmode if LONG_DOUBLE_TYPE_SIZE | |
78 | has been defined to be 96 in the tm.h machine file. */ | |
79 | #if (LONG_DOUBLE_TYPE_SIZE == 96) | |
80 | #define REAL_IS_NOT_DOUBLE | |
81 | #define REAL_ARITHMETIC | |
82 | typedef struct { | |
83 | HOST_WIDE_INT r[(11 + sizeof (HOST_WIDE_INT))/(sizeof (HOST_WIDE_INT))]; | |
84 | } realvaluetype; | |
85 | #define REAL_VALUE_TYPE realvaluetype | |
86 | ||
87 | #else /* no XFmode support */ | |
88 | ||
7bb5d01e JW |
89 | #if (LONG_DOUBLE_TYPE_SIZE == 128) |
90 | ||
91 | #define REAL_IS_NOT_DOUBLE | |
92 | #define REAL_ARITHMETIC | |
93 | typedef struct { | |
94 | HOST_WIDE_INT r[(19 + sizeof (HOST_WIDE_INT))/(sizeof (HOST_WIDE_INT))]; | |
95 | } realvaluetype; | |
96 | #define REAL_VALUE_TYPE realvaluetype | |
97 | ||
98 | #else /* not TFmode */ | |
99 | ||
fd76a739 RS |
100 | #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT |
101 | /* If no XFmode support, then a REAL_VALUE_TYPE is 64 bits wide | |
102 | but it is not necessarily a host machine double. */ | |
103 | #define REAL_IS_NOT_DOUBLE | |
104 | typedef struct { | |
105 | HOST_WIDE_INT r[(7 + sizeof (HOST_WIDE_INT))/(sizeof (HOST_WIDE_INT))]; | |
106 | } realvaluetype; | |
107 | #define REAL_VALUE_TYPE realvaluetype | |
108 | #else | |
109 | /* If host and target formats are compatible, then a REAL_VALUE_TYPE | |
110 | is actually a host machine double. */ | |
111 | #define REAL_VALUE_TYPE double | |
112 | #endif | |
7bb5d01e JW |
113 | |
114 | #endif /* no TFmode support */ | |
fd76a739 RS |
115 | #endif /* no XFmode support */ |
116 | ||
84f9b8e9 RK |
117 | extern int significand_size PROTO((enum machine_mode)); |
118 | ||
fd76a739 | 119 | /* If emulation has been enabled by defining REAL_ARITHMETIC or by |
7bb5d01e | 120 | setting LONG_DOUBLE_TYPE_SIZE to 96 or 128, then define macros so that |
fd76a739 RS |
121 | they invoke emulator functions. This will succeed only if the machine |
122 | files have been updated to use these macros in place of any | |
123 | references to host machine `double' or `float' types. */ | |
124 | #ifdef REAL_ARITHMETIC | |
125 | #undef REAL_ARITHMETIC | |
126 | #define REAL_ARITHMETIC(value, code, d1, d2) \ | |
127 | earith (&(value), (code), &(d1), &(d2)) | |
128 | ||
fca04441 RK |
129 | /* Declare functions in real.c. */ |
130 | extern void earith PROTO((REAL_VALUE_TYPE *, int, | |
131 | REAL_VALUE_TYPE *, REAL_VALUE_TYPE *)); | |
132 | extern REAL_VALUE_TYPE etrunci PROTO((REAL_VALUE_TYPE)); | |
133 | extern REAL_VALUE_TYPE etruncui PROTO((REAL_VALUE_TYPE)); | |
134 | extern REAL_VALUE_TYPE ereal_atof PROTO((char *, enum machine_mode)); | |
135 | extern REAL_VALUE_TYPE ereal_negate PROTO((REAL_VALUE_TYPE)); | |
136 | extern HOST_WIDE_INT efixi PROTO((REAL_VALUE_TYPE)); | |
137 | extern unsigned HOST_WIDE_INT efixui PROTO((REAL_VALUE_TYPE)); | |
138 | extern void ereal_from_int PROTO((REAL_VALUE_TYPE *, | |
7efc32fd RK |
139 | HOST_WIDE_INT, HOST_WIDE_INT, |
140 | enum machine_mode)); | |
fca04441 RK |
141 | extern void ereal_from_uint PROTO((REAL_VALUE_TYPE *, |
142 | unsigned HOST_WIDE_INT, | |
7efc32fd RK |
143 | unsigned HOST_WIDE_INT, |
144 | enum machine_mode)); | |
fca04441 RK |
145 | extern void ereal_to_int PROTO((HOST_WIDE_INT *, HOST_WIDE_INT *, |
146 | REAL_VALUE_TYPE)); | |
147 | extern REAL_VALUE_TYPE ereal_ldexp PROTO((REAL_VALUE_TYPE, int)); | |
148 | ||
149 | extern void etartdouble PROTO((REAL_VALUE_TYPE, long *)); | |
150 | extern void etarldouble PROTO((REAL_VALUE_TYPE, long *)); | |
151 | extern void etardouble PROTO((REAL_VALUE_TYPE, long *)); | |
152 | extern long etarsingle PROTO((REAL_VALUE_TYPE)); | |
153 | extern void ereal_to_decimal PROTO((REAL_VALUE_TYPE, char *)); | |
154 | extern int ereal_cmp PROTO((REAL_VALUE_TYPE, REAL_VALUE_TYPE)); | |
155 | extern int ereal_isneg PROTO((REAL_VALUE_TYPE)); | |
7bb6fbd1 JL |
156 | extern REAL_VALUE_TYPE ereal_unto_float PROTO((long)); |
157 | extern REAL_VALUE_TYPE ereal_unto_double PROTO((long *)); | |
403cd5d7 RK |
158 | extern REAL_VALUE_TYPE ereal_from_float PROTO((HOST_WIDE_INT)); |
159 | extern REAL_VALUE_TYPE ereal_from_double PROTO((HOST_WIDE_INT *)); | |
fd76a739 RS |
160 | |
161 | #define REAL_VALUES_EQUAL(x, y) (ereal_cmp ((x), (y)) == 0) | |
162 | /* true if x < y : */ | |
265b1bae | 163 | #define REAL_VALUES_LESS(x, y) (ereal_cmp ((x), (y)) == -1) |
fd76a739 RS |
164 | #define REAL_VALUE_LDEXP(x, n) ereal_ldexp (x, n) |
165 | ||
166 | /* These return REAL_VALUE_TYPE: */ | |
167 | #define REAL_VALUE_RNDZINT(x) (etrunci (x)) | |
168 | #define REAL_VALUE_UNSIGNED_RNDZINT(x) (etruncui (x)) | |
e9576d2c L |
169 | extern REAL_VALUE_TYPE real_value_truncate PROTO ((enum machine_mode, |
170 | REAL_VALUE_TYPE)); | |
fd76a739 RS |
171 | #define REAL_VALUE_TRUNCATE(mode, x) real_value_truncate (mode, x) |
172 | ||
91d61207 | 173 | /* These return HOST_WIDE_INT: */ |
7bb5d01e JW |
174 | /* Convert a floating-point value to integer, rounding toward zero. */ |
175 | #define REAL_VALUE_FIX(x) (efixi (x)) | |
176 | /* Convert a floating-point value to unsigned integer, rounding | |
177 | toward zero. */ | |
178 | #define REAL_VALUE_UNSIGNED_FIX(x) (efixui (x)) | |
fd76a739 RS |
179 | |
180 | #define REAL_VALUE_ATOF ereal_atof | |
181 | #define REAL_VALUE_NEGATE ereal_negate | |
182 | ||
183 | #define REAL_VALUE_MINUS_ZERO(x) \ | |
184 | ((ereal_cmp (x, dconst0) == 0) && (ereal_isneg (x) != 0 )) | |
185 | ||
186 | #define REAL_VALUE_TO_INT ereal_to_int | |
91d61207 RK |
187 | |
188 | /* Here the cast to HOST_WIDE_INT sign-extends arguments such as ~0. */ | |
7efc32fd RK |
189 | #define REAL_VALUE_FROM_INT(d, lo, hi, mode) \ |
190 | ereal_from_int (&d, (HOST_WIDE_INT) (lo), (HOST_WIDE_INT) (hi), mode) | |
91d61207 | 191 | |
7efc32fd RK |
192 | #define REAL_VALUE_FROM_UNSIGNED_INT(d, lo, hi, mode) \ |
193 | ereal_from_uint (&d, lo, hi, mode) | |
fd76a739 RS |
194 | |
195 | /* IN is a REAL_VALUE_TYPE. OUT is an array of longs. */ | |
7bb5d01e | 196 | #if LONG_DOUBLE_TYPE_SIZE == 96 |
fd76a739 | 197 | #define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT) (etarldouble ((IN), (OUT))) |
7bb5d01e JW |
198 | #else |
199 | #define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT) (etartdouble ((IN), (OUT))) | |
200 | #endif | |
fd76a739 | 201 | #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) (etardouble ((IN), (OUT))) |
7bb5d01e | 202 | |
fd76a739 RS |
203 | /* IN is a REAL_VALUE_TYPE. OUT is a long. */ |
204 | #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) ((OUT) = etarsingle ((IN))) | |
7bb5d01e | 205 | |
7bb6fbd1 JL |
206 | /* Inverse of REAL_VALUE_TO_TARGET_DOUBLE. */ |
207 | #define REAL_VALUE_UNTO_TARGET_DOUBLE(d) (ereal_unto_double (d)) | |
208 | ||
209 | /* Inverse of REAL_VALUE_TO_TARGET_SINGLE. */ | |
210 | #define REAL_VALUE_UNTO_TARGET_SINGLE(f) (ereal_unto_float (f)) | |
211 | ||
403cd5d7 RK |
212 | /* d is an array of HOST_WIDE_INT that holds a double precision |
213 | value in the target computer's floating point format. */ | |
7bb5d01e JW |
214 | #define REAL_VALUE_FROM_TARGET_DOUBLE(d) (ereal_from_double (d)) |
215 | ||
403cd5d7 | 216 | /* f is a HOST_WIDE_INT containing a single precision target float value. */ |
543758c6 | 217 | #define REAL_VALUE_FROM_TARGET_SINGLE(f) (ereal_from_float (f)) |
fd76a739 RS |
218 | |
219 | /* Conversions to decimal ASCII string. */ | |
220 | #define REAL_VALUE_TO_DECIMAL(r, fmt, s) (ereal_to_decimal (r, s)) | |
221 | ||
222 | #endif /* REAL_ARITHMETIC defined */ | |
223 | ||
224 | /* **** End of software floating point emulator interface macros **** */ | |
7bb5d01e | 225 | #else /* No XFmode or TFmode and REAL_ARITHMETIC not defined */ |
fd76a739 RS |
226 | |
227 | /* old interface */ | |
0694b47c RS |
228 | #ifdef REAL_ARITHMETIC |
229 | /* Defining REAL_IS_NOT_DOUBLE breaks certain initializations | |
230 | when REAL_ARITHMETIC etc. are not defined. */ | |
231 | ||
232 | /* Now see if the host and target machines use the same format. | |
233 | If not, define REAL_IS_NOT_DOUBLE (even if we end up representing | |
234 | reals as doubles because we have no better way in this cross compiler.) | |
235 | This turns off various optimizations that can happen when we know the | |
236 | compiler's float format matches the target's float format. | |
237 | */ | |
238 | #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT | |
239 | #define REAL_IS_NOT_DOUBLE | |
240 | #ifndef REAL_VALUE_TYPE | |
fd76a739 RS |
241 | typedef struct { |
242 | HOST_WIDE_INT r[sizeof (double)/sizeof (HOST_WIDE_INT)]; | |
243 | } realvaluetype; | |
244 | #define REAL_VALUE_TYPE realvaluetype | |
0694b47c RS |
245 | #endif /* no REAL_VALUE_TYPE */ |
246 | #endif /* formats differ */ | |
247 | #endif /* 0 */ | |
248 | ||
fd76a739 RS |
249 | #endif /* emulator not used */ |
250 | ||
0694b47c RS |
251 | /* If we are not cross-compiling, use a `double' to represent the |
252 | floating-point value. Otherwise, use some other type | |
253 | (probably a struct containing an array of longs). */ | |
254 | #ifndef REAL_VALUE_TYPE | |
255 | #define REAL_VALUE_TYPE double | |
256 | #else | |
257 | #define REAL_IS_NOT_DOUBLE | |
258 | #endif | |
259 | ||
f9250555 RS |
260 | #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT |
261 | ||
262 | /* Convert a type `double' value in host format first to a type `float' | |
263 | value in host format and then to a single type `long' value which | |
264 | is the bitwise equivalent of the `float' value. */ | |
fd76a739 | 265 | #ifndef REAL_VALUE_TO_TARGET_SINGLE |
f9250555 RS |
266 | #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \ |
267 | do { float f = (float) (IN); \ | |
268 | (OUT) = *(long *) &f; \ | |
fd76a739 RS |
269 | } while (0) |
270 | #endif | |
f9250555 RS |
271 | |
272 | /* Convert a type `double' value in host format to a pair of type `long' | |
273 | values which is its bitwise equivalent, but put the two words into | |
274 | proper word order for the target. */ | |
fd76a739 | 275 | #ifndef REAL_VALUE_TO_TARGET_DOUBLE |
f9250555 RS |
276 | #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \ |
277 | do { REAL_VALUE_TYPE in = (IN); /* Make sure it's not in a register. */\ | |
f76b9db2 ILT |
278 | if (HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN) \ |
279 | { \ | |
280 | (OUT)[0] = ((long *) &in)[0]; \ | |
281 | (OUT)[1] = ((long *) &in)[1]; \ | |
282 | } \ | |
283 | else \ | |
284 | { \ | |
285 | (OUT)[1] = ((long *) &in)[0]; \ | |
286 | (OUT)[0] = ((long *) &in)[1]; \ | |
287 | } \ | |
f9250555 | 288 | } while (0) |
fd76a739 | 289 | #endif |
f9250555 RS |
290 | #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */ |
291 | ||
fd76a739 RS |
292 | /* In this configuration, double and long double are the same. */ |
293 | #ifndef REAL_VALUE_TO_TARGET_LONG_DOUBLE | |
294 | #define REAL_VALUE_TO_TARGET_LONG_DOUBLE(a, b) REAL_VALUE_TO_TARGET_DOUBLE (a, b) | |
295 | #endif | |
296 | ||
0694b47c RS |
297 | /* Compare two floating-point values for equality. */ |
298 | #ifndef REAL_VALUES_EQUAL | |
fd76a739 | 299 | #define REAL_VALUES_EQUAL(x, y) ((x) == (y)) |
0694b47c RS |
300 | #endif |
301 | ||
302 | /* Compare two floating-point values for less than. */ | |
303 | #ifndef REAL_VALUES_LESS | |
fd76a739 | 304 | #define REAL_VALUES_LESS(x, y) ((x) < (y)) |
0694b47c RS |
305 | #endif |
306 | ||
fd76a739 RS |
307 | /* Truncate toward zero to an integer floating-point value. */ |
308 | #ifndef REAL_VALUE_RNDZINT | |
309 | #define REAL_VALUE_RNDZINT(x) ((double) ((int) (x))) | |
0694b47c RS |
310 | #endif |
311 | ||
fd76a739 RS |
312 | /* Truncate toward zero to an unsigned integer floating-point value. */ |
313 | #ifndef REAL_VALUE_UNSIGNED_RNDZINT | |
314 | #define REAL_VALUE_UNSIGNED_RNDZINT(x) ((double) ((unsigned int) (x))) | |
0694b47c RS |
315 | #endif |
316 | ||
7bb5d01e | 317 | /* Convert a floating-point value to integer, rounding toward zero. */ |
0694b47c RS |
318 | #ifndef REAL_VALUE_FIX |
319 | #define REAL_VALUE_FIX(x) ((int) (x)) | |
320 | #endif | |
321 | ||
7bb5d01e JW |
322 | /* Convert a floating-point value to unsigned integer, rounding |
323 | toward zero. */ | |
0694b47c RS |
324 | #ifndef REAL_VALUE_UNSIGNED_FIX |
325 | #define REAL_VALUE_UNSIGNED_FIX(x) ((unsigned int) (x)) | |
326 | #endif | |
327 | ||
328 | /* Scale X by Y powers of 2. */ | |
329 | #ifndef REAL_VALUE_LDEXP | |
fd76a739 | 330 | #define REAL_VALUE_LDEXP(x, y) ldexp (x, y) |
0694b47c RS |
331 | extern double ldexp (); |
332 | #endif | |
333 | ||
334 | /* Convert the string X to a floating-point value. */ | |
335 | #ifndef REAL_VALUE_ATOF | |
fd76a739 RS |
336 | #if 1 |
337 | /* Use real.c to convert decimal numbers to binary, ... */ | |
338 | REAL_VALUE_TYPE ereal_atof (); | |
339 | #define REAL_VALUE_ATOF(x, s) ereal_atof (x, s) | |
340 | #else | |
341 | /* ... or, if you like the host computer's atof, go ahead and use it: */ | |
342 | #define REAL_VALUE_ATOF(x, s) atof (x) | |
0694b47c RS |
343 | #if defined (MIPSEL) || defined (MIPSEB) |
344 | /* MIPS compiler can't handle parens around the function name. | |
345 | This problem *does not* appear to be connected with any | |
346 | macro definition for atof. It does not seem there is one. */ | |
347 | extern double atof (); | |
348 | #else | |
349 | extern double (atof) (); | |
350 | #endif | |
351 | #endif | |
fd76a739 | 352 | #endif |
0694b47c RS |
353 | |
354 | /* Negate the floating-point value X. */ | |
355 | #ifndef REAL_VALUE_NEGATE | |
356 | #define REAL_VALUE_NEGATE(x) (- (x)) | |
357 | #endif | |
358 | ||
359 | /* Truncate the floating-point value X to mode MODE. This is correct only | |
360 | for the most common case where the host and target have objects of the same | |
361 | size and where `float' is SFmode. */ | |
362 | ||
5352b11a | 363 | /* Don't use REAL_VALUE_TRUNCATE directly--always call real_value_truncate. */ |
e9a25f70 | 364 | extern REAL_VALUE_TYPE real_value_truncate PROTO((enum machine_mode, REAL_VALUE_TYPE)); |
5352b11a | 365 | |
0694b47c RS |
366 | #ifndef REAL_VALUE_TRUNCATE |
367 | #define REAL_VALUE_TRUNCATE(mode, x) \ | |
161ca48c RS |
368 | (GET_MODE_BITSIZE (mode) == sizeof (float) * HOST_BITS_PER_CHAR \ |
369 | ? (float) (x) : (x)) | |
0694b47c RS |
370 | #endif |
371 | ||
372 | /* Determine whether a floating-point value X is infinite. */ | |
373 | #ifndef REAL_VALUE_ISINF | |
374 | #define REAL_VALUE_ISINF(x) (target_isinf (x)) | |
375 | #endif | |
376 | ||
3dd4b517 TW |
377 | /* Determine whether a floating-point value X is a NaN. */ |
378 | #ifndef REAL_VALUE_ISNAN | |
379 | #define REAL_VALUE_ISNAN(x) (target_isnan (x)) | |
380 | #endif | |
381 | ||
11030a60 RS |
382 | /* Determine whether a floating-point value X is negative. */ |
383 | #ifndef REAL_VALUE_NEGATIVE | |
384 | #define REAL_VALUE_NEGATIVE(x) (target_negative (x)) | |
385 | #endif | |
386 | ||
e9a25f70 JL |
387 | extern int target_isnan PROTO ((REAL_VALUE_TYPE)); |
388 | extern int target_isinf PROTO ((REAL_VALUE_TYPE)); | |
389 | extern int target_negative PROTO ((REAL_VALUE_TYPE)); | |
390 | ||
0694b47c RS |
391 | /* Determine whether a floating-point value X is minus 0. */ |
392 | #ifndef REAL_VALUE_MINUS_ZERO | |
11030a60 | 393 | #define REAL_VALUE_MINUS_ZERO(x) ((x) == 0 && REAL_VALUE_NEGATIVE (x)) |
0694b47c RS |
394 | #endif |
395 | \f | |
396 | /* Constant real values 0, 1, 2, and -1. */ | |
397 | ||
398 | extern REAL_VALUE_TYPE dconst0; | |
399 | extern REAL_VALUE_TYPE dconst1; | |
400 | extern REAL_VALUE_TYPE dconst2; | |
401 | extern REAL_VALUE_TYPE dconstm1; | |
402 | ||
403 | /* Union type used for extracting real values from CONST_DOUBLEs | |
404 | or putting them in. */ | |
405 | ||
406 | union real_extract | |
407 | { | |
408 | REAL_VALUE_TYPE d; | |
3245eea0 | 409 | HOST_WIDE_INT i[sizeof (REAL_VALUE_TYPE) / sizeof (HOST_WIDE_INT)]; |
0694b47c RS |
410 | }; |
411 | ||
412 | /* For a CONST_DOUBLE: | |
413 | The usual two ints that hold the value. | |
414 | For a DImode, that is all there are; | |
415 | and CONST_DOUBLE_LOW is the low-order word and ..._HIGH the high-order. | |
416 | For a float, the number of ints varies, | |
417 | and CONST_DOUBLE_LOW is the one that should come first *in memory*. | |
418 | So use &CONST_DOUBLE_LOW(r) as the address of an array of ints. */ | |
3245eea0 CH |
419 | #define CONST_DOUBLE_LOW(r) XWINT (r, 2) |
420 | #define CONST_DOUBLE_HIGH(r) XWINT (r, 3) | |
0694b47c RS |
421 | |
422 | /* Link for chain of all CONST_DOUBLEs in use in current function. */ | |
423 | #define CONST_DOUBLE_CHAIN(r) XEXP (r, 1) | |
424 | /* The MEM which represents this CONST_DOUBLE's value in memory, | |
425 | or const0_rtx if no MEM has been made for it yet, | |
426 | or cc0_rtx if it is not on the chain. */ | |
427 | #define CONST_DOUBLE_MEM(r) XEXP (r, 0) | |
428 | ||
e9576d2c | 429 | /* Given a CONST_DOUBLE in FROM, store into TO the value it represents. */ |
0694b47c RS |
430 | /* Function to return a real value (not a tree node) |
431 | from a given integer constant. */ | |
e9576d2c L |
432 | union tree_node; |
433 | REAL_VALUE_TYPE real_value_from_int_cst PROTO ((union tree_node *, | |
434 | union tree_node *)); | |
0694b47c RS |
435 | |
436 | #define REAL_VALUE_FROM_CONST_DOUBLE(to, from) \ | |
437 | do { union real_extract u; \ | |
4c9a05bc | 438 | bcopy ((char *) &CONST_DOUBLE_LOW ((from)), (char *) &u, sizeof u); \ |
0694b47c RS |
439 | to = u.d; } while (0) |
440 | ||
441 | /* Return a CONST_DOUBLE with value R and mode M. */ | |
442 | ||
fd76a739 | 443 | #define CONST_DOUBLE_FROM_REAL_VALUE(r, m) immed_real_const_1 (r, m) |
fca04441 RK |
444 | extern struct rtx_def *immed_real_const_1 PROTO((REAL_VALUE_TYPE, |
445 | enum machine_mode)); | |
446 | ||
fd76a739 RS |
447 | |
448 | /* Convert a floating point value `r', that can be interpreted | |
449 | as a host machine float or double, to a decimal ASCII string `s' | |
450 | using printf format string `fmt'. */ | |
451 | #ifndef REAL_VALUE_TO_DECIMAL | |
452 | #define REAL_VALUE_TO_DECIMAL(r, fmt, s) (sprintf (s, fmt, r)) | |
453 | #endif | |
0694b47c | 454 | |
ebc8186b RK |
455 | /* Replace R by 1/R in the given machine mode, if the result is exact. */ |
456 | extern int exact_real_inverse PROTO((enum machine_mode, REAL_VALUE_TYPE *)); | |
457 | ||
e9576d2c L |
458 | extern void debug_real PROTO ((REAL_VALUE_TYPE)); |
459 | ||
460 | /* In varasm.c */ | |
461 | extern void assemble_real PROTO ((REAL_VALUE_TYPE, | |
462 | enum machine_mode)); | |
0694b47c | 463 | #endif /* Not REAL_H_INCLUDED */ |