/* Definitions of floating-point access for GNU compiler.
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2020 Free Software Foundation, Inc.
This file is part of GCC.
sure they're packed together, otherwise REAL_VALUE_TYPE_SIZE will
be miscomputed. */
unsigned int /* ENUM_BITFIELD (real_value_class) */ cl : 2;
+ /* 1 if number is decimal floating point. */
unsigned int decimal : 1;
+ /* 1 if number is negative. */
unsigned int sign : 1;
+ /* 1 if number is signalling. */
unsigned int signalling : 1;
+ /* 1 if number is canonical
+ All are generally used for handling cases in real.c. */
unsigned int canonical : 1;
+ /* unbiased exponent of the number. */
unsigned int uexp : EXP_BITS;
+ /* significand of the number. */
unsigned long sig[SIGSZ];
};
bool has_signed_zero;
bool qnan_msb_set;
bool canonical_nan_lsbs_set;
-
- /* This flag indicates whether the format is suitable for the optimized
- code paths for the __builtin_fpclassify function and friends. For
- this, the format must be a base 2 representation with the sign bit as
- the most-significant bit followed by (exp <= 32) exponent bits
- followed by the mantissa bits. It must be possible to interpret the
- bits of the floating-point representation as an integer. NaNs and
- INFs (if available) must be represented by the same schema used by
- IEEE 754. (NaNs must be represented by an exponent with all bits 1,
- any mantissa except all bits 0 and any sign bit. +INF and -INF must be
- represented by an exponent with all bits 1, a mantissa with all bits 0 and
- a sign bit of 0 and 1 respectively.) */
- bool is_binary_ieee_compatible;
const char *name;
};
: (gcc_unreachable (), 0)])
#define FLOAT_MODE_FORMAT(MODE) \
- (REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \
- : GET_MODE_INNER (MODE)))
+ (REAL_MODE_FORMAT (as_a <scalar_float_mode> (GET_MODE_INNER (MODE))))
/* The following macro determines whether the floating point format is
composite, i.e. may contain non-consecutive mantissa bits, in which
{
public:
format_helper (const real_format *format) : m_format (format) {}
- format_helper (machine_mode m);
+ template<typename T> format_helper (const T &);
const real_format *operator-> () const { return m_format; }
operator const real_format *() const { return m_format; }
bool decimal_p () const { return m_format && m_format->b == 10; }
+ bool can_represent_integral_type_p (tree type) const;
private:
const real_format *m_format;
};
-inline format_helper::format_helper (machine_mode m)
+template<typename T>
+inline format_helper::format_helper (const T &m)
: m_format (m == VOIDmode ? 0 : REAL_MODE_FORMAT (m))
{}
extern const struct real_format decimal_quad_format;
extern const struct real_format ieee_half_format;
extern const struct real_format arm_half_format;
+extern const struct real_format arm_bfloat_half_format;
/* ====================================================================== */
/* IN is a REAL_VALUE_TYPE. OUT is an array of longs. */
#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT) \
real_to_target (OUT, &(IN), \
- mode_for_size (LONG_DOUBLE_TYPE_SIZE, MODE_FLOAT, 0))
+ float_mode_for_size (LONG_DOUBLE_TYPE_SIZE).require ())
#define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
- real_to_target (OUT, &(IN), mode_for_size (64, MODE_FLOAT, 0))
+ real_to_target (OUT, &(IN), float_mode_for_size (64).require ())
/* IN is a REAL_VALUE_TYPE. OUT is a long. */
#define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
- ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_FLOAT, 0)))
+ ((OUT) = real_to_target (NULL, &(IN), float_mode_for_size (32).require ()))
/* Real values to IEEE 754 decimal floats. */
/* IN is a REAL_VALUE_TYPE. OUT is an array of longs. */
#define REAL_VALUE_TO_TARGET_DECIMAL128(IN, OUT) \
- real_to_target (OUT, &(IN), mode_for_size (128, MODE_DECIMAL_FLOAT, 0))
+ real_to_target (OUT, &(IN), decimal_float_mode_for_size (128).require ())
#define REAL_VALUE_TO_TARGET_DECIMAL64(IN, OUT) \
- real_to_target (OUT, &(IN), mode_for_size (64, MODE_DECIMAL_FLOAT, 0))
+ real_to_target (OUT, &(IN), decimal_float_mode_for_size (64).require ())
/* IN is a REAL_VALUE_TYPE. OUT is a long. */
#define REAL_VALUE_TO_TARGET_DECIMAL32(IN, OUT) \
- ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_DECIMAL_FLOAT, 0)))
+ ((OUT) = real_to_target (NULL, &(IN), \
+ decimal_float_mode_for_size (32).require ()))
extern REAL_VALUE_TYPE real_value_truncate (format_helper, REAL_VALUE_TYPE);
const REAL_VALUE_TYPE *);
extern void real_round (REAL_VALUE_TYPE *, format_helper,
const REAL_VALUE_TYPE *);
+extern void real_roundeven (REAL_VALUE_TYPE *, format_helper,
+ const REAL_VALUE_TYPE *);
/* Set the sign of R to the sign of X. */
extern void real_copysign (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
extern bool real_isinteger (const REAL_VALUE_TYPE *, format_helper);
extern bool real_isinteger (const REAL_VALUE_TYPE *, HOST_WIDE_INT *);
+/* Calculate nextafter (X, Y) in format FMT. */
+extern bool real_nextafter (REAL_VALUE_TYPE *, format_helper,
+ const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
+
/* Write into BUF the maximum representable finite floating-point
number, (1 - b**-p) * b**emax for a given FP format FMT as a hex
float string. BUF must be large enough to contain the result. */
-extern void get_max_float (const struct real_format *, char *, size_t);
-
-/* Write into BUF the smallest positive normalized number x,
- such that b**(x-1) is normalized. BUF must be large enough
- to contain the result. */
-extern void get_min_float (const struct real_format *, char *, size_t);
+extern void get_max_float (const struct real_format *, char *, size_t, bool);
#ifndef GENERATOR_FILE
/* real related routines. */
const wide_int_ref &, signop);
#endif
+/* Fills r with the largest value such that 1 + r*r won't overflow.
+ This is used in both sin (atan (x)) and cos (atan(x)) optimizations. */
+extern void build_sinatan_real (REAL_VALUE_TYPE *, tree);
+
#endif /* ! GCC_REAL_H */