35 #define SIGNIFICAND_BITS (128 + HOST_BITS_PER_LONG)
36 #define EXP_BITS (32 - 6)
37 #define MAX_EXP ((1 << (EXP_BITS - 1)) - 1)
38 #define SIGSZ (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
39 #define SIG_MSB ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
46 unsigned int decimal : 1;
47 unsigned int sign : 1;
48 unsigned int signalling : 1;
49 unsigned int canonical : 1;
50 unsigned int uexp : EXP_BITS;
51 unsigned long sig[SIGSZ];
54 #define REAL_EXP(REAL) \
55 ((int)((REAL)->uexp ^ (unsigned int)(1 << (EXP_BITS - 1))) \
56 - (1 << (EXP_BITS - 1)))
57 #define SET_REAL_EXP(REAL, EXP) \
58 ((REAL)->uexp = ((unsigned int)(EXP) & (unsigned int)((1 << EXP_BITS) - 1)))
63 #define REAL_VALUE_TYPE struct real_value
69 #define REAL_VALUE_TYPE_SIZE (SIGNIFICAND_BITS + 32)
71 (REAL_VALUE_TYPE_SIZE/HOST_BITS_PER_WIDE_INT \
72 + (REAL_VALUE_TYPE_SIZE%HOST_BITS_PER_WIDE_INT ? 1 : 0))
76 [
sizeof(REAL_VALUE_TYPE) <= REAL_WIDTH*
sizeof(
HOST_WIDE_INT) ? 1 : -1];
86 # define CONST_DOUBLE_FORMAT "ww"
89 # define CONST_DOUBLE_FORMAT "ww"
92 # define CONST_DOUBLE_FORMAT "www"
95 # define CONST_DOUBLE_FORMAT "wwww"
98 # define CONST_DOUBLE_FORMAT "wwwww"
101 # define CONST_DOUBLE_FORMAT "wwwwww"
103 #error "REAL_WIDTH > 6 not supported"
117 const REAL_VALUE_TYPE *);
165 + MAX_MODE_DECIMAL_FLOAT - MIN_MODE_DECIMAL_FLOAT + 1];
167 #define REAL_MODE_FORMAT(MODE) \
168 (real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \
169 ? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \
170 + (MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1)) \
171 : ((MODE) - MIN_MODE_FLOAT)])
173 #define FLOAT_MODE_FORMAT(MODE) \
174 (REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \
175 : GET_MODE_INNER (MODE)))
180 #define MODE_COMPOSITE_P(MODE) \
181 (FLOAT_MODE_P (MODE) \
182 && FLOAT_MODE_FORMAT (MODE)->pnan < FLOAT_MODE_FORMAT (MODE)->p)
185 #define MODE_HAS_NANS(MODE) \
186 (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_nans)
187 #define MODE_HAS_INFINITIES(MODE) \
188 (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_inf)
189 #define MODE_HAS_SIGNED_ZEROS(MODE) \
190 (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_signed_zero)
191 #define MODE_HAS_SIGN_DEPENDENT_ROUNDING(MODE) \
192 (FLOAT_MODE_P (MODE) \
193 && FLOAT_MODE_FORMAT (MODE)->has_sign_dependent_rounding)
200 #define HONOR_NANS(MODE) \
201 (MODE_HAS_NANS (MODE) && !flag_finite_math_only)
204 #define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE))
208 #define HONOR_INFINITIES(MODE) \
209 (MODE_HAS_INFINITIES (MODE) && !flag_finite_math_only)
213 #define HONOR_SIGNED_ZEROS(MODE) \
214 (MODE_HAS_SIGNED_ZEROS (MODE) && flag_signed_zeros)
218 #define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \
219 (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && flag_rounding_math)
224 extern bool real_arithmetic (REAL_VALUE_TYPE *,
int,
const REAL_VALUE_TYPE *,
225 const REAL_VALUE_TYPE *);
228 extern bool real_compare (
int,
const REAL_VALUE_TYPE *,
const REAL_VALUE_TYPE *);
231 extern bool real_isinf (
const REAL_VALUE_TYPE *);
234 extern bool real_isnan (
const REAL_VALUE_TYPE *);
240 extern bool real_isneg (
const REAL_VALUE_TYPE *);
246 extern bool real_identical (
const REAL_VALUE_TYPE *,
const REAL_VALUE_TYPE *);
249 extern void real_convert (REAL_VALUE_TYPE *,
enum machine_mode,
250 const REAL_VALUE_TYPE *);
262 size_t,
int,
enum machine_mode);
266 size_t,
size_t,
int);
271 const REAL_VALUE_TYPE *);
277 extern void real_from_string3 (REAL_VALUE_TYPE *,
const char *,
enum machine_mode);
285 extern long real_to_target (
long *,
const REAL_VALUE_TYPE *,
enum machine_mode);
292 extern void real_inf (REAL_VALUE_TYPE *);
294 extern bool real_nan (REAL_VALUE_TYPE *,
const char *,
int,
enum machine_mode);
296 extern void real_maxval (REAL_VALUE_TYPE *,
int,
enum machine_mode);
298 extern void real_2expN (REAL_VALUE_TYPE *,
int,
enum machine_mode);
300 extern unsigned int real_hash (
const REAL_VALUE_TYPE *);
333 #define REAL_ARITHMETIC(value, code, d1, d2) \
334 real_arithmetic (&(value), code, &(d1), &(d2))
336 #define REAL_VALUES_IDENTICAL(x, y) real_identical (&(x), &(y))
337 #define REAL_VALUES_EQUAL(x, y) real_compare (EQ_EXPR, &(x), &(y))
338 #define REAL_VALUES_LESS(x, y) real_compare (LT_EXPR, &(x), &(y))
341 #define REAL_VALUE_ISINF(x) real_isinf (&(x))
344 #define REAL_VALUE_ISNAN(x) real_isnan (&(x))
347 #define REAL_VALUE_NEGATIVE(x) real_isneg (&(x))
350 #define REAL_VALUE_MINUS_ZERO(x) real_isnegzero (&(x))
353 #define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT) \
354 real_to_target (OUT, &(IN), \
355 mode_for_size (LONG_DOUBLE_TYPE_SIZE, MODE_FLOAT, 0))
357 #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
358 real_to_target (OUT, &(IN), mode_for_size (64, MODE_FLOAT, 0))
361 #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
362 ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_FLOAT, 0)))
364 #define REAL_VALUE_FROM_INT(r, lo, hi, mode) \
365 real_from_integer (&(r), mode, lo, hi, 0)
367 #define REAL_VALUE_FROM_UNSIGNED_INT(r, lo, hi, mode) \
368 real_from_integer (&(r), mode, lo, hi, 1)
373 #define REAL_VALUE_TO_TARGET_DECIMAL128(IN, OUT) \
374 real_to_target (OUT, &(IN), mode_for_size (128, MODE_DECIMAL_FLOAT, 0))
376 #define REAL_VALUE_TO_TARGET_DECIMAL64(IN, OUT) \
377 real_to_target (OUT, &(IN), mode_for_size (64, MODE_DECIMAL_FLOAT, 0))
380 #define REAL_VALUE_TO_TARGET_DECIMAL32(IN, OUT) \
381 ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_DECIMAL_FLOAT, 0)))
386 #define REAL_VALUE_TO_INT(plow, phigh, r) \
387 real_to_integer2 (plow, phigh, &(r))
396 #define REAL_VALUE_ATOF(s, m) \
397 real_from_string2 (s, m)
399 #define CONST_DOUBLE_ATOF(s, m) \
400 CONST_DOUBLE_FROM_REAL_VALUE (real_from_string2 (s, m), m)
402 #define REAL_VALUE_FIX(r) \
403 real_to_integer (&(r))
406 #define REAL_VALUE_UNSIGNED_FIX(r) \
407 real_to_integer (&(r))
415 extern void real_ldexp (REAL_VALUE_TYPE *,
const REAL_VALUE_TYPE *,
int);
421 extern REAL_VALUE_TYPE
dconst0;
422 extern REAL_VALUE_TYPE
dconst1;
423 extern REAL_VALUE_TYPE
dconst2;
427 #define dconst_e() (*dconst_e_ptr ())
428 #define dconst_third() (*dconst_third_ptr ())
429 #define dconst_sqrt2() (*dconst_sqrt2_ptr ())
445 #define REAL_VALUE_FROM_CONST_DOUBLE(to, from) \
446 ((to) = *CONST_DOUBLE_REAL_VALUE (from))
449 #define CONST_DOUBLE_FROM_REAL_VALUE(r, m) \
450 const_double_from_real_value (r, m)
465 extern bool real_sqrt (REAL_VALUE_TYPE *,
enum machine_mode,
466 const REAL_VALUE_TYPE *);
469 extern bool real_powi (REAL_VALUE_TYPE *,
enum machine_mode,
473 extern void real_trunc (REAL_VALUE_TYPE *,
enum machine_mode,
474 const REAL_VALUE_TYPE *);
475 extern void real_floor (REAL_VALUE_TYPE *,
enum machine_mode,
476 const REAL_VALUE_TYPE *);
477 extern void real_ceil (REAL_VALUE_TYPE *,
enum machine_mode,
478 const REAL_VALUE_TYPE *);
479 extern void real_round (REAL_VALUE_TYPE *,
enum machine_mode,
480 const REAL_VALUE_TYPE *);
483 extern void real_copysign (REAL_VALUE_TYPE *,
const REAL_VALUE_TYPE *);
486 extern bool real_isinteger (
const REAL_VALUE_TYPE *c,
enum machine_mode mode);