GCC Middle and Back End API Reference
real.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "realmpfr.h"
#include "dfp.h"
Include dependency graph for real.cc:

Macros

#define CLASS2(A, B)
 
#define M_LOG10_2   0.30102999566398119521
 
#define CACHED_FRACTION(NAME, N)
 

Functions

static void get_zero (REAL_VALUE_TYPE *, int)
 
static void get_canonical_qnan (REAL_VALUE_TYPE *, int)
 
static void get_canonical_snan (REAL_VALUE_TYPE *, int)
 
static void get_inf (REAL_VALUE_TYPE *, int)
 
static bool sticky_rshift_significand (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, unsigned int)
 
static void rshift_significand (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, unsigned int)
 
static void lshift_significand (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, unsigned int)
 
static void lshift_significand_1 (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static bool add_significands (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static bool sub_significands (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int)
 
static void neg_significand (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static int cmp_significands (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static int cmp_significand_0 (const REAL_VALUE_TYPE *)
 
static void set_significand_bit (REAL_VALUE_TYPE *, unsigned int)
 
static void clear_significand_bit (REAL_VALUE_TYPE *, unsigned int)
 
static bool test_significand_bit (REAL_VALUE_TYPE *, unsigned int)
 
static void clear_significand_below (REAL_VALUE_TYPE *, unsigned int)
 
static bool div_significands (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static void normalize (REAL_VALUE_TYPE *)
 
static bool do_add (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int)
 
static bool do_multiply (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static bool do_divide (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static int do_compare (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int)
 
static void do_fix_trunc (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
 
static unsigned long rtd_divmod (REAL_VALUE_TYPE *, REAL_VALUE_TYPE *)
 
static void decimal_from_integer (REAL_VALUE_TYPE *)
 
static void decimal_integer_string (char *, const REAL_VALUE_TYPE *, size_t)
 
static const REAL_VALUE_TYPEten_to_ptwo (int)
 
static const REAL_VALUE_TYPEten_to_mptwo (int)
 
static const REAL_VALUE_TYPEreal_digit (int)
 
static void times_pten (REAL_VALUE_TYPE *, int)
 
static void round_for_format (const struct real_format *, REAL_VALUE_TYPE *)
 
static bool real_isdenormal (const REAL_VALUE_TYPE *r)
 
bool real_arithmetic (REAL_VALUE_TYPE *r, int icode, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
 
REAL_VALUE_TYPE real_value_negate (const REAL_VALUE_TYPE *op0)
 
REAL_VALUE_TYPE real_value_abs (const REAL_VALUE_TYPE *op0)
 
bool real_equal (const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
 
bool real_less (const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
 
bool real_compare (int icode, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
 
int real_exponent (const REAL_VALUE_TYPE *r)
 
void real_ldexp (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *op0, int exp)
 
bool real_isinf (const REAL_VALUE_TYPE *r)
 
bool real_isinf (const REAL_VALUE_TYPE *r, bool sign)
 
bool real_isnan (const REAL_VALUE_TYPE *r)
 
bool real_issignaling_nan (const REAL_VALUE_TYPE *r)
 
bool real_isfinite (const REAL_VALUE_TYPE *r)
 
bool real_isneg (const REAL_VALUE_TYPE *r)
 
bool real_iszero (const REAL_VALUE_TYPE *r)
 
bool real_iszero (const REAL_VALUE_TYPE *r, bool sign)
 
bool real_isnegzero (const REAL_VALUE_TYPE *r)
 
bool real_identical (const REAL_VALUE_TYPE *a, const REAL_VALUE_TYPE *b)
 
bool exact_real_inverse (format_helper fmt, REAL_VALUE_TYPE *r)
 
bool real_can_shorten_arithmetic (machine_mode imode, machine_mode tmode)
 
HOST_WIDE_INT real_to_integer (const REAL_VALUE_TYPE *r)
 
wide_int real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
 
void real_to_decimal_for_mode (char *str, const REAL_VALUE_TYPE *r_orig, size_t buf_size, size_t digits, int crop_trailing_zeros, machine_mode mode)
 
void real_to_decimal (char *str, const REAL_VALUE_TYPE *r_orig, size_t buf_size, size_t digits, int crop_trailing_zeros)
 
DEBUG_FUNCTION void debug (const REAL_VALUE_TYPE &r)
 
void real_to_hexadecimal (char *str, const REAL_VALUE_TYPE *r, size_t buf_size, size_t digits, int crop_trailing_zeros)
 
int real_from_string (REAL_VALUE_TYPE *r, const char *str)
 
REAL_VALUE_TYPE real_from_string2 (const char *s, format_helper fmt)
 
void real_from_string3 (REAL_VALUE_TYPE *r, const char *s, format_helper fmt)
 
void real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt, const wide_int_ref &val_in, signop sgn)
 
const REAL_VALUE_TYPEdconst_e_ptr (void)
 
const REAL_VALUE_TYPEdconst_pi_ptr (void)
 
const REAL_VALUE_TYPEdconst_sqrt2_ptr (void)
 
void real_inf (REAL_VALUE_TYPE *r, bool sign)
 
bool real_nan (REAL_VALUE_TYPE *r, const char *str, int quiet, format_helper fmt)
 
void real_maxval (REAL_VALUE_TYPE *r, int sign, machine_mode mode)
 
void real_2expN (REAL_VALUE_TYPE *r, int n, format_helper fmt)
 
void real_convert (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *a)
 
REAL_VALUE_TYPE real_value_truncate (format_helper fmt, REAL_VALUE_TYPE a)
 
bool exact_real_truncate (format_helper fmt, const REAL_VALUE_TYPE *a)
 
long real_to_target (long *buf, const REAL_VALUE_TYPE *r_orig, format_helper fmt)
 
void real_from_target (REAL_VALUE_TYPE *r, const long *buf, format_helper fmt)
 
int significand_size (format_helper fmt)
 
unsigned int real_hash (const REAL_VALUE_TYPE *r)
 
static void encode_ieee_single (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_ieee_single (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_ieee_double (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_ieee_double (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_ieee_extended (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void encode_ieee_extended_motorola (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void encode_ieee_extended_intel_96 (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void encode_ieee_extended_intel_128 (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void decode_ieee_extended (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void decode_ieee_extended_motorola (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void decode_ieee_extended_intel_96 (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void decode_ieee_extended_intel_128 (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void encode_ibm_extended (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_ibm_extended (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_ieee_quad (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_ieee_quad (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_vax_f (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_vax_f (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_vax_d (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_vax_d (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_vax_g (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_vax_g (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
static void encode_decimal_single (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void decode_decimal_single (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void encode_decimal_double (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void decode_decimal_double (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void encode_decimal_quad (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void decode_decimal_quad (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void encode_ieee_half (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void decode_ieee_half (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void encode_arm_bfloat_half (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
 
static void decode_arm_bfloat_half (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
 
static void encode_internal (const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
 
static void decode_internal (const struct real_format *, REAL_VALUE_TYPE *, const long *)
 
bool real_powi (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x, HOST_WIDE_INT n)
 
void real_trunc (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x)
 
void real_floor (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x)
 
void real_ceil (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x)
 
void real_round (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x)
 
static bool is_even (REAL_VALUE_TYPE *r)
 
static bool is_halfway_below (const REAL_VALUE_TYPE *r)
 
void real_roundeven (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x)
 
void real_copysign (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *x)
 
bool real_isinteger (const REAL_VALUE_TYPE *c, format_helper fmt)
 
bool real_isinteger (const REAL_VALUE_TYPE *c, HOST_WIDE_INT *int_out)
 
bool real_nextafter (REAL_VALUE_TYPE *r, format_helper fmt, const REAL_VALUE_TYPE *x, const REAL_VALUE_TYPE *y)
 
void get_max_float (const struct real_format *fmt, char *buf, size_t len, bool norm_max)
 
bool HONOR_NANS (machine_mode m)
 
bool HONOR_NANS (const_tree t)
 
bool HONOR_NANS (const_rtx x)
 
bool HONOR_SNANS (machine_mode m)
 
bool HONOR_SNANS (const_tree t)
 
bool HONOR_SNANS (const_rtx x)
 
bool HONOR_INFINITIES (machine_mode m)
 
bool HONOR_INFINITIES (const_tree t)
 
bool HONOR_INFINITIES (const_rtx x)
 
bool HONOR_SIGNED_ZEROS (machine_mode m)
 
bool HONOR_SIGNED_ZEROS (const_tree t)
 
bool HONOR_SIGNED_ZEROS (const_rtx x)
 
bool HONOR_SIGN_DEPENDENT_ROUNDING (machine_mode m)
 
bool HONOR_SIGN_DEPENDENT_ROUNDING (const_tree t)
 
bool HONOR_SIGN_DEPENDENT_ROUNDING (const_rtx x)
 
void build_sinatan_real (REAL_VALUE_TYPE *r, tree type)
 

Variables

const struct real_format ieee_single_format
 
const struct real_format mips_single_format
 
const struct real_format motorola_single_format
 
const struct real_format spu_single_format
 
const struct real_format ieee_double_format
 
const struct real_format mips_double_format
 
const struct real_format motorola_double_format
 
const struct real_format ieee_extended_motorola_format
 
const struct real_format ieee_extended_intel_96_format
 
const struct real_format ieee_extended_intel_128_format
 
const struct real_format ieee_extended_intel_96_round_53_format
 
const struct real_format ibm_extended_format
 
const struct real_format mips_extended_format
 
const struct real_format ieee_quad_format
 
const struct real_format mips_quad_format
 
const struct real_format vax_f_format
 
const struct real_format vax_d_format
 
const struct real_format vax_g_format
 
const struct real_format decimal_single_format
 
const struct real_format decimal_double_format
 
const struct real_format decimal_quad_format
 
const struct real_format ieee_half_format
 
const struct real_format arm_half_format
 
const struct real_format arm_bfloat_half_format
 
const struct real_format real_internal_format
 

Macro Definition Documentation

◆ CACHED_FRACTION

#define CACHED_FRACTION ( NAME,
N )
Value:
const REAL_VALUE_TYPE * \
NAME (void) \
{ \
static REAL_VALUE_TYPE value; \
\
/* Initialize mathematical constants for constant folding builtins. \
These constants need to be given to at least 160 bits \
precision. @endverbatim */ \
if (value.cl == rvc_zero) \
real_arithmetic (&value, RDIV_EXPR, &dconst1, real_digit (N)); \
return &value; \
}
REAL_VALUE_TYPE dconst1
Definition emit-rtl.cc:107
#define N
Definition gensupport.cc:202
static const REAL_VALUE_TYPE * real_digit(int)
Definition real.cc:2423
#define REAL_VALUE_TYPE
Definition real.h:68
@ rvc_zero
Definition real.h:27
Returns a cached REAL_VALUE_TYPE corresponding to 1/n, for various n.   

◆ CLASS2

#define CLASS2 ( A,
B )
Value:
((A) << 2 | (B))
real.cc - software floating point emulation.
Copyright (C) 1993-2024 Free Software Foundation, Inc.
Contributed by Stephen L. Moshier (moshier@world.std.com).
Re-written by Richard Henderson <rth@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
The floating point model used internally is not exactly IEEE 754
compliant, and close to the description in the ISO C99 standard,
section 5.2.4.2.2 Characteristics of floating types.

Specifically

     x = s * b^e * \sum_{k=1}^p f_k * b^{-k}

     where
        s = sign (+- 1)
        b = base or radix, here always 2
        e = exponent
        p = precision (the number of base-b digits in the significand)
        f_k = the digits of the significand.

We differ from typical IEEE 754 encodings in that the entire
significand is fractional.  Normalized significands are in the
range [0.5, 1.0).

A requirement of the model is that P be larger than the largest
supported target floating-point type by at least 2 bits.  This gives
us proper rounding when we truncate to the target type.  In addition,
E must be large enough to hold the smallest supported denormal number
in a normalized form.

Both of these requirements are easily satisfied.  The largest target
significand is 113 bits; we store at least 160.  The smallest
denormal number fits in 17 exponent bits; we store 26.   
Used to classify two numbers simultaneously.   

Referenced by do_add(), do_compare(), do_divide(), and do_multiply().

◆ M_LOG10_2

#define M_LOG10_2   0.30102999566398119521
Render R as a decimal floating point constant.  Emit DIGITS significant
digits in the result, bounded by BUF_SIZE.  If DIGITS is 0, choose the
maximum for the representation.  If CROP_TRAILING_ZEROS, strip trailing
zeros.  If MODE is VOIDmode, round to nearest value.  Otherwise, round
to a string that, when parsed back in mode MODE, yields the same value.   

Referenced by decimal_integer_string(), and real_to_decimal_for_mode().

Function Documentation

◆ add_significands()

static bool add_significands ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
const REAL_VALUE_TYPE * b )
inlinestatic
Add the significands of A and B, placing the result in R.  Return
true if there was carry out of the most significant word.   

References a, b, i, r, and SIGSZ.

Referenced by do_add(), real_nan(), real_nextafter(), and round_for_format().

◆ build_sinatan_real()

void build_sinatan_real ( REAL_VALUE_TYPE * r,
tree type )
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.  

References dconst1, mpfr_from_real(), NULL, r, real_from_mpfr(), real_maxval(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, and TYPE_MODE.

◆ clear_significand_below()

static void clear_significand_below ( REAL_VALUE_TYPE * r,
unsigned int n )
static
Clear bits 0..N-1 of the significand of R.   

References HOST_BITS_PER_LONG, i, and r.

Referenced by do_fix_trunc(), real_maxval(), real_nextafter(), real_roundeven(), and round_for_format().

◆ clear_significand_bit()

static void clear_significand_bit ( REAL_VALUE_TYPE * r,
unsigned int n )
inlinestatic
Clear bit N of the significand of R.   

References HOST_BITS_PER_LONG, and r.

Referenced by real_maxval(), and real_nextafter().

◆ cmp_significand_0()

static int cmp_significand_0 ( const REAL_VALUE_TYPE * a)
inlinestatic
Return true if A is nonzero.   

References a, i, and SIGSZ.

Referenced by real_from_string(), and real_to_decimal_for_mode().

◆ cmp_significands()

static int cmp_significands ( const REAL_VALUE_TYPE * a,
const REAL_VALUE_TYPE * b )
inlinestatic
Compare significands.  Return tri-state vs zero.   

References a, b, i, and SIGSZ.

Referenced by div_significands(), do_compare(), real_to_decimal_for_mode(), and rtd_divmod().

◆ dconst_e_ptr()

const REAL_VALUE_TYPE * dconst_e_ptr ( void )
Returns the special REAL_VALUE_TYPE corresponding to 'e'.   

References NULL_TREE, real_from_mpfr(), REAL_VALUE_TYPE, rvc_zero, and SIGNIFICAND_BITS.

◆ dconst_pi_ptr()

const REAL_VALUE_TYPE * dconst_pi_ptr ( void )
Returns the special REAL_VALUE_TYPE corresponding to 'pi'.   

References NULL_TREE, real_from_mpfr(), REAL_VALUE_TYPE, rvc_zero, and SIGNIFICAND_BITS.

◆ dconst_sqrt2_ptr()

const REAL_VALUE_TYPE * dconst_sqrt2_ptr ( void )
Returns the special REAL_VALUE_TYPE corresponding to sqrt(2).   

References REAL_VALUE_TYPE, and rvc_zero.

◆ debug()

DEBUG_FUNCTION void debug ( const REAL_VALUE_TYPE & r)

References r, and real_to_hexadecimal().

◆ decimal_from_integer()

static void decimal_from_integer ( REAL_VALUE_TYPE * r)
static
Convert a real with an integral value to decimal float.   

References decimal_integer_string(), decimal_real_from_string(), and r.

Referenced by real_from_integer().

◆ decimal_integer_string()

static void decimal_integer_string ( char * str,
const REAL_VALUE_TYPE * r_orig,
size_t buf_size )
static
Render R, an integral value, as a floating point constant with no
specified exponent.   

References gcc_assert, M_LOG10_2, real_format::p, r, real_digit(), REAL_EXP, REAL_VALUE_TYPE, rtd_divmod(), rvc_zero, and times_pten().

Referenced by decimal_from_integer().

◆ decode_arm_bfloat_half()

static void decode_arm_bfloat_half ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static

◆ decode_decimal_double()

static void decode_decimal_double ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Decode a double precision DFP value in BUF into a real R.   

References decode_decimal64(), and r.

◆ decode_decimal_quad()

static void decode_decimal_quad ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Decode a quad precision DFP value in BUF into a real R.   

References decode_decimal128(), and r.

◆ decode_decimal_single()

static void decode_decimal_single ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Decode a single precision DFP value in BUF into a real R.   

References decode_decimal32(), and r.

◆ decode_ibm_extended()

static void decode_ibm_extended ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static

◆ decode_ieee_double()

◆ decode_ieee_extended()

static void decode_ieee_extended ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
As above, we have a helper function which converts from 12-byte
little-endian Intel format to internal format.  Functions below
adjust for the other possible formats.   

References real_format::emin, exp(), real_format::has_denorm, real_format::has_inf, real_format::has_nans, real_format::has_signed_zero, HOST_BITS_PER_LONG, normalize(), real_format::qnan_msb_set, r, rvc_inf, rvc_nan, rvc_normal, SET_REAL_EXP, and SIGSZ.

Referenced by decode_ieee_extended_intel_96(), and decode_ieee_extended_motorola().

◆ decode_ieee_extended_intel_128()

static void decode_ieee_extended_intel_128 ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Convert from the internal format to the 16-byte Intel format for
an IEEE extended real.   

References decode_ieee_extended_intel_96(), and r.

◆ decode_ieee_extended_intel_96()

static void decode_ieee_extended_intel_96 ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Convert from the internal format to the 12-byte Intel format for
an IEEE extended real.   

References decode_ieee_extended(), FLOAT_WORDS_BIG_ENDIAN, and r.

Referenced by decode_ieee_extended_intel_128().

◆ decode_ieee_extended_motorola()

static void decode_ieee_extended_motorola ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Convert from the internal format to the 12-byte Motorola format
for an IEEE extended real.   

References decode_ieee_extended(), and r.

◆ decode_ieee_half()

static void decode_ieee_half ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static
Decode half-precision floats.  This routine is used both for the IEEE
ARM alternative encodings.   

References exp(), real_format::has_denorm, real_format::has_inf, real_format::has_nans, real_format::has_signed_zero, HOST_BITS_PER_LONG, normalize(), real_format::qnan_msb_set, r, rvc_inf, rvc_nan, rvc_normal, SET_REAL_EXP, SIG_MSB, and SIGSZ.

◆ decode_ieee_quad()

◆ decode_ieee_single()

◆ decode_internal()

static void decode_internal ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static

References r.

◆ decode_vax_d()

static void decode_vax_d ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static

◆ decode_vax_f()

static void decode_vax_f ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static

◆ decode_vax_g()

static void decode_vax_g ( const struct real_format * fmt,
REAL_VALUE_TYPE * r,
const long * buf )
static

◆ div_significands()

static bool div_significands ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
const REAL_VALUE_TYPE * b )
inlinestatic
Divide the significands of A and B, placing the result in R.  Return
true if the division was inexact.   

References a, b, cmp_significands(), i, lshift_significand_1(), r, REAL_VALUE_TYPE, set_significand_bit(), SIG_MSB, SIGNIFICAND_BITS, SIGSZ, and sub_significands().

Referenced by do_divide().

◆ do_add()

◆ do_compare()

static int do_compare ( const REAL_VALUE_TYPE * a,
const REAL_VALUE_TYPE * b,
int nan_result )
static
Return a tri-state comparison of A vs B.  Return NAN_RESULT if
one of the two operands is a NaN.   

References a, b, CLASS2, cmp_significands(), decimal_do_compare(), gcc_unreachable, REAL_EXP, rvc_inf, rvc_nan, rvc_normal, and rvc_zero.

Referenced by real_arithmetic(), real_compare(), real_equal(), real_less(), real_nextafter(), and real_to_decimal_for_mode().

◆ do_divide()

◆ do_fix_trunc()

static void do_fix_trunc ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a )
static

◆ do_multiply()

static bool do_multiply ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
const REAL_VALUE_TYPE * b )
static

◆ encode_arm_bfloat_half()

static void encode_arm_bfloat_half ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static

◆ encode_decimal_double()

static void encode_decimal_double ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Encode real R into a double precision DFP value in BUF.   

References encode_decimal64(), and r.

◆ encode_decimal_quad()

static void encode_decimal_quad ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Encode real R into a quad precision DFP value in BUF.   

References encode_decimal128(), and r.

◆ encode_decimal_single()

static void encode_decimal_single ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Encode real R into a single precision DFP value in BUF.   

References encode_decimal32(), and r.

◆ encode_ibm_extended()

static void encode_ibm_extended ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
IBM 128-bit extended precision format: a pair of IEEE double precision
numbers whose sum is equal to the extended precision value.  The number
with greater magnitude is first.  This format has the same magnitude
range as an IEEE double precision value, but effectively 106 bits of
significand precision.  Infinity and NaN are represented by their IEEE
double precision value stored in the first number, the second number is
+0.0 or -0.0 for Infinity and don't-care for NaN.   

References do_add(), encode_ieee_double(), ieee_double_format, mips_double_format, normalize(), real_format::qnan_msb_set, r, REAL_VALUE_TYPE, round_for_format(), and rvc_normal.

◆ encode_ieee_double()

static void encode_ieee_double ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static

◆ encode_ieee_extended()

static void encode_ieee_extended ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
IEEE extended real format.  This comes in three flavors: Intel's as
a 12 byte image, Intel's as a 16 byte image, and Motorola's.  Intel
12- and 16-byte images may be big- or little endian; Motorola's is
always big endian.   
Helper subroutine which converts from the internal format to the
12-byte little-endian Intel format.  Functions below adjust this
for the other possible formats.   

References real_format::canonical_nan_lsbs_set, exp(), gcc_assert, gcc_unreachable, real_format::has_inf, real_format::has_nans, HOST_BITS_PER_LONG, real_format::qnan_msb_set, r, REAL_EXP, real_isdenormal(), rvc_inf, rvc_nan, rvc_normal, rvc_zero, and SIGSZ.

Referenced by encode_ieee_extended_intel_96(), and encode_ieee_extended_motorola().

◆ encode_ieee_extended_intel_128()

static void encode_ieee_extended_intel_128 ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Convert from the internal format to the 16-byte Intel format for
an IEEE extended real.   

References encode_ieee_extended_intel_96(), and r.

◆ encode_ieee_extended_intel_96()

static void encode_ieee_extended_intel_96 ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Convert from the internal format to the 12-byte Intel format for
an IEEE extended real.   

References encode_ieee_extended(), FLOAT_WORDS_BIG_ENDIAN, and r.

Referenced by encode_ieee_extended_intel_128().

◆ encode_ieee_extended_motorola()

static void encode_ieee_extended_motorola ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Convert from the internal format to the 12-byte Motorola format
for an IEEE extended real.   

References encode_ieee_extended(), r, and rvc_inf.

◆ encode_ieee_half()

static void encode_ieee_half ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Encode half-precision floats.  This routine is used both for the IEEE
ARM alternative encodings.   

References real_format::canonical_nan_lsbs_set, exp(), gcc_unreachable, real_format::has_inf, real_format::has_nans, HOST_BITS_PER_LONG, real_format::qnan_msb_set, r, REAL_EXP, real_isdenormal(), rvc_inf, rvc_nan, rvc_normal, rvc_zero, and SIGSZ.

◆ encode_ieee_quad()

◆ encode_ieee_single()

static void encode_ieee_single ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static

◆ encode_internal()

static void encode_internal ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
A synthetic "format" for internal arithmetic.  It's the size of the
internal significand minus the two bits needed for proper rounding.
The encode and decode routines exist only to satisfy our paranoia
harness.   

References r.

◆ encode_vax_d()

static void encode_vax_d ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static

◆ encode_vax_f()

static void encode_vax_f ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static
Descriptions of VAX floating point formats can be found beginning at

http://h71000.www7.hp.com/doc/73FINAL/4515/4515pro_013.html#f_floating_point_format

The thing to remember is that they're almost IEEE, except for word
order, exponent bias, and the lack of infinities, nans, and denormals.

We don't implement the H_floating format here, simply because neither
the VAX or Alpha ports use it.   

References exp(), gcc_unreachable, HOST_BITS_PER_LONG, r, REAL_EXP, rvc_inf, rvc_nan, rvc_normal, rvc_zero, and SIGSZ.

◆ encode_vax_g()

static void encode_vax_g ( const struct real_format * fmt,
long * buf,
const REAL_VALUE_TYPE * r )
static

◆ exact_real_inverse()

bool exact_real_inverse ( format_helper fmt,
REAL_VALUE_TYPE * r )
Try to change R into its exact multiplicative inverse in format FMT.
Return true if successful.   

References do_divide(), i, r, real_convert(), real_digit(), REAL_VALUE_TYPE, rvc_normal, SIG_MSB, and SIGSZ.

Referenced by exact_inverse().

◆ exact_real_truncate()

◆ get_canonical_qnan()

static void get_canonical_qnan ( REAL_VALUE_TYPE * r,
int sign )
inlinestatic
Initialize R with the canonical quiet NaN.   

References r, and rvc_nan.

Referenced by do_add(), do_divide(), do_multiply(), real_from_string(), real_nan(), and real_nextafter().

◆ get_canonical_snan()

static void get_canonical_snan ( REAL_VALUE_TYPE * r,
int sign )
inlinestatic

References r, and rvc_nan.

Referenced by real_from_string(), and real_nan().

◆ get_inf()

static void get_inf ( REAL_VALUE_TYPE * r,
int sign )
inlinestatic

◆ get_max_float()

void get_max_float ( const struct real_format * fmt,
char * buf,
size_t len,
bool norm_max )
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.  LEN is the size of BUF, and the buffer must be large
enough to contain the resulting string.  If NORM_MAX, instead write
the maximum representable finite normalized floating-point number,
defined to be such that all choices of digits for that exponent are
representable in the format (this only makes a difference for IBM
long double).   

References real_format::b, real_format::emax, gcc_assert, i, real_format::p, and real_format::pnan.

Referenced by fold_builtin_interclass_mathfn(), and real_max_representable().

◆ get_zero()

static void get_zero ( REAL_VALUE_TYPE * r,
int sign )
inlinestatic

◆ HONOR_INFINITIES() [1/3]

bool HONOR_INFINITIES ( const_rtx x)

References GET_MODE, and HONOR_INFINITIES().

◆ HONOR_INFINITIES() [2/3]

bool HONOR_INFINITIES ( const_tree t)

◆ HONOR_INFINITIES() [3/3]

bool HONOR_INFINITIES ( machine_mode m)
As for HONOR_NANS, but true if the mode can represent infinity and
the treatment of infinite values is important.   

References MODE_HAS_INFINITIES.

Referenced by frange_val_max(), frange_val_min(), HONOR_INFINITIES(), HONOR_INFINITIES(), omp_reduction_init_op(), frange::set(), tree_expr_finite_p(), tree_expr_infinite_p(), and tree_expr_maybe_infinite_p().

◆ HONOR_NANS() [1/3]

bool HONOR_NANS ( const_rtx x)

References GET_MODE, and HONOR_NANS().

◆ HONOR_NANS() [2/3]

bool HONOR_NANS ( const_tree t)

References element_mode(), and HONOR_NANS().

◆ HONOR_NANS() [3/3]

bool HONOR_NANS ( machine_mode m)
True if mode M has a NaN representation and
the treatment of NaN operands is important.   

References MODE_HAS_NANS.

Referenced by ipa_predicate::add_clause(), bitwise_inverted_equal_p(), build_gt(), build_lt(), combine_comparisons(), cond_stmts_equal_p(), convert_mode_scalar(), do_compare_rtx_and_jump(), eliminate_using_constants(), emit_store_flag(), emit_store_flag_force(), expand_builtin_issignaling(), expand_complex_multiplication(), fold_binary_loc(), fold_cond_expr_with_comparison(), fold_ternary_loc(), fold_truth_not_expr(), gen_one_condition(), frange_storage::get_frange(), gimple_bitwise_inverted_equal_p(), gimple_equal_p(), gimple_expand_builtin_pow(), gimple_simplify_phiopt(), HONOR_NANS(), HONOR_NANS(), HONOR_SNANS(), ifcombine_ifandif(), insert_predicates_for_cond(), frange::internal_singleton_p(), inverse_conditions_p(), may_trap_p_1(), merge_truthop_with_opposite_arm(), minmax_from_comparison(), minmax_replacement(), noce_try_minmax(), noce_try_move(), frange::normalize_kind(), optimize_spaceship(), parloops_is_simple_reduction(), parse_predicate(), fold_using_range::relation_fold_and_or(), reversed_comparison_code_parts(), frange::set(), set_cond_stmt_execution_predicate(), frange::set_nan(), frange::set_varying(), avail_exprs_stack::simplify_binary_operation(), simplify_context::simplify_binary_operation_1(), simplify_const_binary_operation(), simplify_const_relational_operation(), simplify_if_then_else(), simplify_context::simplify_ternary_operation(), spaceship_replacement(), split_comparison(), tree_expr_finite_p(), tree_expr_maybe_nan_p(), tree_expr_nan_p(), ubsan_instrument_float_cast(), frange::update_nan(), valid_lattice_transition(), vect_build_slp_tree_1(), vectorizable_condition(), and frange::verify_range().

◆ HONOR_SIGN_DEPENDENT_ROUNDING() [1/3]

bool HONOR_SIGN_DEPENDENT_ROUNDING ( const_rtx x)

◆ HONOR_SIGN_DEPENDENT_ROUNDING() [2/3]

bool HONOR_SIGN_DEPENDENT_ROUNDING ( const_tree t)

◆ HONOR_SIGN_DEPENDENT_ROUNDING() [3/3]

◆ HONOR_SIGNED_ZEROS() [1/3]

bool HONOR_SIGNED_ZEROS ( const_rtx x)

References GET_MODE, and HONOR_SIGNED_ZEROS().

◆ HONOR_SIGNED_ZEROS() [2/3]

bool HONOR_SIGNED_ZEROS ( const_tree t)

◆ HONOR_SIGNED_ZEROS() [3/3]

◆ HONOR_SNANS() [1/3]

bool HONOR_SNANS ( const_rtx x)

References GET_MODE, and HONOR_SNANS().

◆ HONOR_SNANS() [2/3]

bool HONOR_SNANS ( const_tree t)

References element_mode(), and HONOR_SNANS().

◆ HONOR_SNANS() [3/3]

◆ is_even()

static bool is_even ( REAL_VALUE_TYPE * r)
static
Return true (including 0) if integer part of R is even, else return
false.  The function is not valid for rvc_inf and rvc_nan classes.   

References gcc_assert, HOST_BITS_PER_LONG, r, REAL_EXP, rvc_inf, rvc_nan, rvc_zero, and SIGNIFICAND_BITS.

Referenced by real_roundeven().

◆ is_halfway_below()

static bool is_halfway_below ( const REAL_VALUE_TYPE * r)
static
Return true if R is halfway between two integers, else return
false.   

References HOST_BITS_PER_LONG, i, r, REAL_EXP, rvc_normal, and SIGNIFICAND_BITS.

Referenced by real_roundeven().

◆ lshift_significand()

static void lshift_significand ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
unsigned int n )
static
Left-shift the significand of A by N bits; put the result in the
significand of R.   

References a, HOST_BITS_PER_LONG, i, r, and SIGSZ.

Referenced by decode_ieee_quad(), decode_vax_d(), decode_vax_g(), normalize(), and real_nan().

◆ lshift_significand_1()

static void lshift_significand_1 ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a )
inlinestatic
Likewise, but N is specialized to 1.   

References a, HOST_BITS_PER_LONG, i, r, and SIGSZ.

Referenced by div_significands(), real_nan(), and rtd_divmod().

◆ neg_significand()

static void neg_significand ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a )
inlinestatic
Negate the significand A, placing the result in R.   

References a, i, r, and SIGSZ.

Referenced by do_add().

◆ normalize()

static void normalize ( REAL_VALUE_TYPE * r)
static
Adjust the exponent and significand of R such that the most
significant bit is set.  We underflow to zero and overflow to
infinity here, without denormals.  (The intermediate representation
exponent is large enough to handle target denormals normalized.)   

References exp(), get_inf(), get_zero(), HOST_BITS_PER_LONG, i, lshift_significand(), MAX_EXP, r, REAL_EXP, rvc_zero, SET_REAL_EXP, and SIGSZ.

Referenced by decode_arm_bfloat_half(), decode_ieee_double(), decode_ieee_extended(), decode_ieee_half(), decode_ieee_quad(), decode_ieee_single(), do_add(), do_divide(), do_multiply(), encode_ibm_extended(), make_range_step(), noce_emit_store_flag(), noce_try_addcc(), noce_try_store_flag_constants(), predicate::normalize(), predicate::normalize(), real_convert(), real_from_integer(), real_from_string(), real_nextafter(), and rtd_divmod().

◆ real_2expN()

◆ real_arithmetic()

◆ real_can_shorten_arithmetic()

bool real_can_shorten_arithmetic ( machine_mode imode,
machine_mode tmode )
Return true if arithmetic on values in IMODE that were promoted
from values in TMODE is equivalent to direct arithmetic on values
in TMODE.   

References real_format::b, real_format::emax, real_format::emin, real_format::has_inf, real_format::has_nans, real_format::has_sign_dependent_rounding, real_format::has_signed_zero, MODE_COMPOSITE_P, real_format::p, REAL_MODE_FORMAT, and real_format::round_towards_zero.

◆ real_ceil()

void real_ceil ( REAL_VALUE_TYPE * r,
format_helper fmt,
const REAL_VALUE_TYPE * x )
Round X to the smallest integer not less then argument, i.e. round
up, placing the result in R in format FMT.   

References dconst1, do_add(), do_fix_trunc(), r, real_convert(), real_identical(), and REAL_VALUE_TYPE.

Referenced by expand_pow_as_sqrts(), fold_const_call_ss(), and fold_const_call_ss().

◆ real_compare()

◆ real_convert()

◆ real_copysign()

void real_copysign ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * x )
Set the sign of R to the sign of X.   

References r.

Referenced by fold_const_call_sss(), and simplify_const_binary_operation().

◆ real_digit()

◆ real_equal()

◆ real_exponent()

int real_exponent ( const REAL_VALUE_TYPE * r)
Return floor log2(R).   

References gcc_unreachable, r, REAL_EXP, rvc_inf, rvc_nan, rvc_normal, and rvc_zero.

◆ real_floor()

void real_floor ( REAL_VALUE_TYPE * r,
format_helper fmt,
const REAL_VALUE_TYPE * x )
Round X to the largest integer not greater in value, i.e. round
down, placing the result in R in format FMT.   

References dconstm1, do_add(), do_fix_trunc(), r, real_convert(), real_identical(), and REAL_VALUE_TYPE.

Referenced by expand_pow_as_sqrts(), fold_const_call_ss(), and fold_const_call_ss().

◆ real_from_integer()

◆ real_from_string()

int real_from_string ( REAL_VALUE_TYPE * r,
const char * str )

◆ real_from_string2()

REAL_VALUE_TYPE real_from_string2 ( const char * s,
format_helper fmt )
Legacy.  Similar, but return the result directly.   

References r, real_convert(), real_from_string(), and REAL_VALUE_TYPE.

◆ real_from_string3()

void real_from_string3 ( REAL_VALUE_TYPE * r,
const char * s,
format_helper fmt )

◆ real_from_target()

void real_from_target ( REAL_VALUE_TYPE * r,
const long * buf,
format_helper fmt )
Read R from the given target format.  Read the words of the result
in target word order in BUF.  There are always 32 bits in each
long, no matter the size of the host long.   

References real_format::decode, and r.

Referenced by native_decode_rtx(), native_interpret_real(), simplify_const_binary_operation(), simplify_const_unary_operation(), vect_build_all_ones_mask(), and vect_build_zero_merge_argument().

◆ real_hash()

unsigned int real_hash ( const REAL_VALUE_TYPE * r)
Return a hash value for the given real value.   
??? The "unsigned int" return value is intended to be hashval_t,
but I didn't want to pull hashtab.h into real.h.   

References gcc_unreachable, HOST_BITS_PER_LONG, i, r, REAL_EXP, rvc_inf, rvc_nan, rvc_normal, rvc_zero, and SIGSZ.

Referenced by const_hash_1(), const_rtx_hash_1(), cselib_hash_rtx(), const_double_hasher::hash(), operand_compare::hash_operand(), and hash_rtx().

◆ real_identical()

◆ real_inf()

void real_inf ( REAL_VALUE_TYPE * r,
bool sign )
Fills R with Inf with SIGN.   

References get_inf(), and r.

Referenced by init_emit_once(), and foperator_div::rv_fold().

◆ real_isdenormal()

static bool real_isdenormal ( const REAL_VALUE_TYPE * r)
inlinestatic
Determine whether a floating-point value X is a denormal.  R is
expected to be in denormal form, so this function is only
meaningful after a call to round_for_format.   

References r, rvc_normal, SIG_MSB, and SIGSZ.

Referenced by encode_arm_bfloat_half(), encode_ieee_double(), encode_ieee_extended(), encode_ieee_half(), encode_ieee_quad(), encode_ieee_single(), frange::flush_denormals_to_zero(), frange_arithmetic(), frange_nextafter(), frange::known_isdenormal_or_zero(), and frange::known_isnormal().

◆ real_isfinite()

◆ real_isinf() [1/2]

◆ real_isinf() [2/2]

bool real_isinf ( const REAL_VALUE_TYPE * r,
bool sign )
Determine whether a floating-point value X is infinite with SIGN.   

References r, and real_isinf().

◆ real_isinteger() [1/2]

bool real_isinteger ( const REAL_VALUE_TYPE * c,
format_helper fmt )
Check whether the real constant value given is an integer.
Returns false for signaling NaN.   

References real_identical(), real_trunc(), and REAL_VALUE_TYPE.

Referenced by do_mpfr_lgamma_r(), integer_valued_real_single_p(), and optimize_pow_to_exp().

◆ real_isinteger() [2/2]

bool real_isinteger ( const REAL_VALUE_TYPE * c,
HOST_WIDE_INT * int_out )
Check whether C is an integer that fits in a HOST_WIDE_INT,
storing it in *INT_OUT if so.   

References real_from_integer(), real_identical(), real_to_integer(), REAL_VALUE_TYPE, and SIGNED.

◆ real_isnan()

◆ real_isneg()

◆ real_isnegzero()

bool real_isnegzero ( const REAL_VALUE_TYPE * r)
Determine whether a floating-point value X is minus zero.   

References r, and rvc_zero.

Referenced by find_range().

◆ real_issignaling_nan()

bool real_issignaling_nan ( const REAL_VALUE_TYPE * r)
Determine whether a floating-point value X is a signaling NaN.   

References r, and real_isnan().

Referenced by fold_const_call_ss(), tree_expr_maybe_signaling_nan_p(), and tree_expr_signaling_nan_p().

◆ real_iszero() [1/2]

◆ real_iszero() [2/2]

bool real_iszero ( const REAL_VALUE_TYPE * r,
bool sign )
Determine whether a floating-point value X is zero with SIGN.   

References r, and real_iszero().

◆ real_ldexp()

void real_ldexp ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * op0,
int exp )

◆ real_less()

◆ real_maxval()

void real_maxval ( REAL_VALUE_TYPE * r,
int sign,
machine_mode mode )
Fills R with the largest finite value representable in mode MODE.
If SIGN is nonzero, R is set to the most negative finite value.   

References real_format::b, clear_significand_below(), clear_significand_bit(), decimal_real_maxval(), real_format::emax, gcc_assert, real_format::p, real_format::pnan, r, REAL_MODE_FORMAT, rvc_normal, SET_REAL_EXP, SIGNIFICAND_BITS, and SIGSZ.

Referenced by build_sinatan_real(), and omp_reduction_init_op().

◆ real_nan()

bool real_nan ( REAL_VALUE_TYPE * r,
const char * str,
int quiet,
format_helper fmt )
Fills R with a NaN whose significand is described by STR.  If QUIET,
we force a QNaN, else we force an SNaN.  The string, if not empty,
is parsed as a number and placed in the significand.  Return true
if the string was successfully parsed.   

References add_significands(), gcc_unreachable, get_canonical_qnan(), get_canonical_snan(), get_zero(), lshift_significand(), lshift_significand_1(), real_format::pnan, r, REAL_VALUE_TYPE, rvc_nan, SIGNIFICAND_BITS, and SIGSZ.

Referenced by fold_const_builtin_nan(), and real_from_mpfr().

◆ real_nextafter()

◆ real_powi()

bool real_powi ( REAL_VALUE_TYPE * r,
format_helper fmt,
const REAL_VALUE_TYPE * x,
HOST_WIDE_INT n )
Calculate X raised to the integer exponent N in format FMT and store
the result in R.  Return true if the result may be inexact due to
loss of precision.  The algorithm is the classic "left-to-right binary
method" described in section 4.6.3 of Donald Knuth's "Seminumerical
Algorithms", "The Art of Computer Programming", Volume 2.   

References dconst1, do_divide(), do_multiply(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_1U, i, r, real_convert(), and REAL_VALUE_TYPE.

Referenced by fold_const_call_sss(), and fold_const_pow().

◆ real_round()

void real_round ( REAL_VALUE_TYPE * r,
format_helper fmt,
const REAL_VALUE_TYPE * x )
Round X to the nearest integer, but round halfway cases away from
zero.   

References dconsthalf, do_add(), do_fix_trunc(), r, and real_convert().

Referenced by fold_const_call_ss(), fold_const_call_ss(), gimple_expand_builtin_pow(), and real_roundeven().

◆ real_roundeven()

void real_roundeven ( REAL_VALUE_TYPE * r,
format_helper fmt,
const REAL_VALUE_TYPE * x )
Round X to nearest integer, rounding halfway cases towards even.   

References clear_significand_below(), dconsthalf, dconstm1, do_add(), is_even(), is_halfway_below(), r, real_convert(), REAL_EXP, real_round(), and SIGNIFICAND_BITS.

Referenced by fold_const_call_ss().

◆ real_to_decimal()

void real_to_decimal ( char * str,
const REAL_VALUE_TYPE * r_orig,
size_t buf_size,
size_t digits,
int crop_trailing_zeros )

◆ real_to_decimal_for_mode()

void real_to_decimal_for_mode ( char * str,
const REAL_VALUE_TYPE * r_orig,
size_t buf_size,
size_t digits,
int crop_trailing_zeros,
machine_mode mode )

◆ real_to_hexadecimal()

void real_to_hexadecimal ( char * str,
const REAL_VALUE_TYPE * r,
size_t buf_size,
size_t digits,
int crop_trailing_zeros )
Render R as a hexadecimal floating point constant.  Emit DIGITS
significant digits in the result, bounded by BUF_SIZE.  If DIGITS is 0,
choose the maximum for the representation.  If CROP_TRAILING_ZEROS,
strip trailing zeros.   

References exp(), gcc_assert, gcc_unreachable, HOST_BITS_PER_LONG, i, real_format::p, r, REAL_EXP, rvc_inf, rvc_nan, rvc_normal, rvc_zero, SIGNIFICAND_BITS, and SIGSZ.

Referenced by debug(), mpfr_from_real(), vrange_printer::print_real_value(), and rtx_writer::print_rtx().

◆ real_to_integer() [1/2]

◆ real_to_integer() [2/2]

wide_int real_to_integer ( const REAL_VALUE_TYPE * r,
bool * fail,
int precision )

◆ real_to_target()

long real_to_target ( long * buf,
const REAL_VALUE_TYPE * r_orig,
format_helper fmt )
Write R to the given target format.  Place the words of the result
in target word order in BUF.  There are always 32 bits in each
long, no matter the size of the host long.

Legacy: return word 0 for implementing REAL_VALUE_TO_TARGET_SINGLE.   

References real_format::encode, r, REAL_VALUE_TYPE, and round_for_format().

Referenced by assemble_real(), insert_float(), native_encode_real(), native_encode_rtx(), simplify_const_binary_operation(), and simplify_const_unary_operation().

◆ real_trunc()

void real_trunc ( REAL_VALUE_TYPE * r,
format_helper fmt,
const REAL_VALUE_TYPE * x )
Round X to the nearest integer not larger in absolute value, i.e.
towards zero, placing the result in R in format FMT.   

References do_fix_trunc(), r, and real_convert().

Referenced by fold_builtin_modf(), fold_const_call_ss(), fold_convert_const_int_from_real(), and real_isinteger().

◆ real_value_abs()

◆ real_value_negate()

◆ real_value_truncate()

REAL_VALUE_TYPE real_value_truncate ( format_helper fmt,
REAL_VALUE_TYPE a )
Legacy.  Likewise, except return the struct directly.   

References a, r, real_convert(), and REAL_VALUE_TYPE.

Referenced by build_real_truncate(), fold_const_builtin_load_exponent(), gimple_expand_builtin_pow(), and simplify_const_unary_operation().

◆ round_for_format()

◆ rshift_significand()

static void rshift_significand ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
unsigned int n )
static
Right-shift the significand of A by N bits; put the result in the
significand of R.   

References a, HOST_BITS_PER_LONG, i, r, and SIGSZ.

Referenced by encode_ieee_quad().

◆ rtd_divmod()

static unsigned long rtd_divmod ( REAL_VALUE_TYPE * num,
REAL_VALUE_TYPE * den )
static
A subroutine of real_to_decimal.  Compute the quotient and remainder
of NUM / DEN.  Return the quotient and place the remainder in NUM.
It is expected that NUM / DEN are close enough that the quotient is
small.   

References cmp_significands(), lshift_significand_1(), normalize(), REAL_EXP, SET_REAL_EXP, SIG_MSB, SIGSZ, and sub_significands().

Referenced by decimal_integer_string(), and real_to_decimal_for_mode().

◆ set_significand_bit()

static void set_significand_bit ( REAL_VALUE_TYPE * r,
unsigned int n )
inlinestatic
Set bit N of the significand of R.   

References HOST_BITS_PER_LONG, and r.

Referenced by div_significands(), real_nextafter(), and round_for_format().

◆ significand_size()

int significand_size ( format_helper fmt)
Return the number of bits of the largest binary value that the
significand of FMT will hold.   
??? Legacy.  Should get access to real_format directly.   

References real_format::b, NULL, and real_format::p.

Referenced by format_helper::can_represent_integral_type_p(), exact_int_to_float_conversion_p(), and expand_float().

◆ sticky_rshift_significand()

static bool sticky_rshift_significand ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
unsigned int n )
static
Right-shift the significand of A by N bits; put the result in the
significand of R.  If any one bits are shifted out, return true.   

References a, HOST_BITS_PER_LONG, i, r, and SIGSZ.

Referenced by do_add(), and round_for_format().

◆ sub_significands()

static bool sub_significands ( REAL_VALUE_TYPE * r,
const REAL_VALUE_TYPE * a,
const REAL_VALUE_TYPE * b,
int carry )
inlinestatic
Subtract the significands of A and B, placing the result in R.  CARRY is
true if there's a borrow incoming to the least significant word.
Return true if there was borrow out of the most significant word.   

References a, b, i, r, and SIGSZ.

Referenced by div_significands(), do_add(), real_nextafter(), and rtd_divmod().

◆ ten_to_mptwo()

static const REAL_VALUE_TYPE * ten_to_mptwo ( int n)
static

◆ ten_to_ptwo()

◆ test_significand_bit()

static bool test_significand_bit ( REAL_VALUE_TYPE * r,
unsigned int n )
inlinestatic
Test bit N of the significand of R.   

References HOST_BITS_PER_LONG, and r.

Referenced by round_for_format().

◆ times_pten()

static void times_pten ( REAL_VALUE_TYPE * r,
int exp )
static
Multiply R by 10**EXP.   

References do_divide(), do_multiply(), exp(), i, r, real_digit(), REAL_VALUE_TYPE, and ten_to_ptwo().

Referenced by decimal_integer_string().

Variable Documentation

◆ arm_bfloat_half_format

const struct real_format arm_bfloat_half_format
Initial value:
=
{
2,
8,
8,
-125,
128,
15,
15,
0,
false,
true,
true,
true,
true,
true,
true,
false,
"arm_bfloat_half"
}
static void decode_arm_bfloat_half(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:4914
static void encode_arm_bfloat_half(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:4856
ARM Bfloat half-precision format.  This format resembles a truncated
(16-bit) version of the 32-bit IEEE 754 single-precision floating-point
format.   

Referenced by build_common_tree_nodes(), convert_mode_scalar(), expand_fix(), and gen_trunc_conv_libfunc().

◆ arm_half_format

const struct real_format arm_half_format
Initial value:
=
{
2,
11,
11,
-13,
17,
15,
15,
0,
false,
true,
false,
false,
true,
true,
false,
false,
"arm_half"
}
static void decode_ieee_half(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:4805
static void encode_ieee_half(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:4743
ARM's alternative half-precision format, similar to IEEE but with
no reserved exponent value for NaNs and infinities; rather, it just
extends the range of exponents by one.   

◆ decimal_double_format

const struct real_format decimal_double_format
Initial value:
=
{
10,
16,
16,
-382,
385,
63,
63,
64,
false,
true,
true,
true,
true,
true,
true,
false,
"decimal_double"
}
static void decode_decimal_double(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:4643
static void encode_decimal_double(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:4634
Double precision decimal floating point (IEEE 754).  

Referenced by decimal_round_for_format().

◆ decimal_quad_format

const struct real_format decimal_quad_format
Initial value:
=
{
10,
34,
34,
-6142,
6145,
127,
127,
128,
false,
true,
true,
true,
true,
true,
true,
false,
"decimal_quad"
}
static void encode_decimal_quad(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:4652
static void decode_decimal_quad(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:4661
Quad precision decimal floating point (IEEE 754).  

Referenced by decimal_round_for_format().

◆ decimal_single_format

const struct real_format decimal_single_format
Initial value:
=
{
10,
7,
7,
-94,
97,
31,
31,
32,
false,
true,
true,
true,
true,
true,
true,
false,
"decimal_single"
}
static void decode_decimal_single(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:4625
static void encode_decimal_single(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:4616
Single precision decimal floating point (IEEE 754).  

Referenced by decimal_round_for_format().

◆ ibm_extended_format

const struct real_format ibm_extended_format
Initial value:
=
{
2,
53 + 53,
53,
-1021 + 53,
1024,
127,
-1,
0,
false,
true,
true,
true,
true,
true,
true,
false,
"ibm_extended"
}
static void encode_ibm_extended(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:3879
static void decode_ibm_extended(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:3914

Referenced by convert_mode_scalar(), and gen_trunc_conv_libfunc().

◆ ieee_double_format

const struct real_format ieee_double_format
Initial value:
=
{
2,
53,
53,
-1021,
1024,
63,
63,
64,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_double"
}
static void decode_ieee_double(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:3296
static void encode_ieee_double(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:3200

Referenced by check_target_format(), decode_ibm_extended(), encode_ibm_extended(), and glibc_linux_libm_function_max_error().

◆ ieee_extended_intel_128_format

const struct real_format ieee_extended_intel_128_format
Initial value:
=
{
2,
64,
64,
-16381,
16384,
79,
79,
65,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_extended_intel_128"
}
static void decode_ieee_extended_intel_128(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:3764
static void encode_ieee_extended_intel_128(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:3623

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ ieee_extended_intel_96_format

const struct real_format ieee_extended_intel_96_format
Initial value:
=
{
2,
64,
64,
-16381,
16384,
79,
79,
65,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_extended_intel_96"
}
static void encode_ieee_extended_intel_96(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:3601
static void decode_ieee_extended_intel_96(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:3740

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ ieee_extended_intel_96_round_53_format

const struct real_format ieee_extended_intel_96_round_53_format
Initial value:
=
{
2,
53,
53,
-16381,
16384,
79,
79,
33,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_extended_intel_96_round_53"
}
The following caters to i386 systems that set the rounding precision
to 53 bits instead of 64, e.g. FreeBSD.   

Referenced by check_target_format().

◆ ieee_extended_motorola_format

const struct real_format ieee_extended_motorola_format
Initial value:
=
{
2,
64,
64,
-16382,
16384,
95,
95,
0,
false,
true,
true,
true,
true,
true,
true,
true,
"ieee_extended_motorola"
}
static void encode_ieee_extended_motorola(const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
Definition real.cc:3576
static void decode_ieee_extended_motorola(const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
Definition real.cc:3722

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ ieee_half_format

const struct real_format ieee_half_format
Initial value:
=
{
2,
11,
11,
-13,
16,
15,
15,
16,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_half"
}
Half-precision format, as specified in IEEE 754R.   

Referenced by convert_mode_scalar(), and gen_trunc_conv_libfunc().

◆ ieee_quad_format

const struct real_format ieee_quad_format
Initial value:
=
{
2,
113,
113,
-16381,
16384,
127,
127,
128,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_quad"
}
static void decode_ieee_quad(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:4112
static void encode_ieee_quad(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:3987

Referenced by check_target_format(), convert_mode_scalar(), gen_trunc_conv_libfunc(), and glibc_linux_libm_function_max_error().

◆ ieee_single_format

const struct real_format ieee_single_format
Initial value:
=
{
2,
24,
24,
-125,
128,
31,
31,
32,
false,
true,
true,
true,
true,
true,
true,
false,
"ieee_single"
}
static void encode_ieee_single(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:2980
static void decode_ieee_single(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:3040
Target formats defined in real.cc.   

Referenced by check_target_format(), convert_mode_scalar(), expand_fix(), and glibc_linux_libm_function_max_error().

◆ mips_double_format

const struct real_format mips_double_format
Initial value:
=
{
2,
53,
53,
-1021,
1024,
63,
63,
64,
false,
true,
true,
true,
true,
true,
false,
true,
"mips_double"
}

Referenced by check_target_format(), decode_ibm_extended(), encode_ibm_extended(), and glibc_linux_libm_function_max_error().

◆ mips_extended_format

const struct real_format mips_extended_format
Initial value:
=
{
2,
53 + 53,
53,
-1021 + 53,
1024,
127,
-1,
0,
false,
true,
true,
true,
true,
true,
false,
true,
"mips_extended"
}

◆ mips_quad_format

const struct real_format mips_quad_format
Initial value:
=
{
2,
113,
113,
-16381,
16384,
127,
127,
128,
false,
true,
true,
true,
true,
true,
false,
true,
"mips_quad"
}

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ mips_single_format

const struct real_format mips_single_format
Initial value:
=
{
2,
24,
24,
-125,
128,
31,
31,
32,
false,
true,
true,
true,
true,
true,
false,
true,
"mips_single"
}

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ motorola_double_format

const struct real_format motorola_double_format
Initial value:
=
{
2,
53,
53,
-1021,
1024,
63,
63,
64,
false,
true,
true,
true,
true,
true,
true,
true,
"motorola_double"
}

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ motorola_single_format

const struct real_format motorola_single_format
Initial value:
=
{
2,
24,
24,
-125,
128,
31,
31,
32,
false,
true,
true,
true,
true,
true,
true,
true,
"motorola_single"
}

Referenced by check_target_format(), and glibc_linux_libm_function_max_error().

◆ real_internal_format

const struct real_format real_internal_format
Initial value:
=
{
2,
-1,
-1,
0,
false,
false,
true,
true,
false,
true,
true,
false,
"real_internal"
}
static void encode_internal(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:5051
static void decode_internal(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:5058
#define SIGNIFICAND_BITS
Definition real.h:33
#define MAX_EXP
Definition real.h:35

◆ spu_single_format

const struct real_format spu_single_format
Initial value:
=
{
2,
24,
24,
-125,
129,
31,
31,
0,
true,
false,
false,
false,
true,
true,
false,
false,
"spu_single"
}
SPU Single Precision (Extended-Range Mode) format is the same as IEEE
single precision with the following differences:
  - Infinities are not supported.  Instead MAX_FLOAT or MIN_FLOAT
    are generated.
  - NaNs are not supported.
  - The range of non-zero numbers in binary is
    (001)[1.]000...000 to (255)[1.]111...111.
  - Denormals can be represented, but are treated as +0.0 when
    used as an operand and are never generated as a result.
  - -0.0 can be represented, but a zero result is always +0.0.
  - the only supported rounding mode is trunction (towards zero).   

◆ vax_d_format

const struct real_format vax_d_format
Initial value:
=
{
2,
56,
56,
-127,
127,
15,
15,
0,
false,
false,
false,
false,
false,
false,
false,
false,
"vax_d"
}
static void decode_vax_d(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:4400
static void encode_vax_d(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:4346

◆ vax_f_format

const struct real_format vax_f_format
Initial value:
=
{
2,
24,
24,
-127,
127,
15,
15,
0,
false,
false,
false,
false,
false,
false,
false,
false,
"vax_f"
}
static void decode_vax_f(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:4326
static void encode_vax_f(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:4290

◆ vax_g_format

const struct real_format vax_g_format
Initial value:
=
{
2,
53,
53,
-1023,
1023,
15,
15,
0,
false,
false,
false,
false,
false,
false,
false,
false,
"vax_g"
}
static void decode_vax_g(const struct real_format *, REAL_VALUE_TYPE *, const long *)
Definition real.cc:4500
static void encode_vax_g(const struct real_format *fmt, long *, const REAL_VALUE_TYPE *)
Definition real.cc:4446