/* Definitions of floating-point access for GNU compiler.
- Copyright (C) 1989-2015 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];
};
or -1 for a complex encoding. */
int signbit_rw;
+ /* If this is an IEEE interchange format, the number of bits in the
+ format; otherwise, if it is an IEEE extended format, one more
+ than the greatest number of bits in an interchange format it
+ extends; otherwise 0. Formats need not follow the IEEE 754-2008
+ recommended practice regarding how signaling NaNs are identified,
+ and may vary in the choice of default NaN, but must follow other
+ IEEE practice regarding having NaNs, infinities and subnormal
+ values, and the relation of minimum and maximum exponents, and,
+ for interchange formats, the details of the encoding. */
+ int ieee_bits;
+
/* Default rounding mode for operations on this format. */
bool round_towards_zero;
bool has_sign_dependent_rounding;
: (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);
+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 */