GCC Middle and Back End API Reference
real.h File Reference

Go to the source code of this file.

Data Structures

struct  real_value
struct  real_format

Enumerations

enum  real_value_class { rvc_zero, rvc_normal, rvc_inf, rvc_nan }

Functions

bool real_arithmetic (REAL_VALUE_TYPE *, int, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
bool real_compare (int, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
bool real_isinf (const REAL_VALUE_TYPE *)
bool real_isnan (const REAL_VALUE_TYPE *)
bool real_isfinite (const REAL_VALUE_TYPE *)
bool real_isneg (const REAL_VALUE_TYPE *)
bool real_isnegzero (const REAL_VALUE_TYPE *)
bool real_identical (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
void real_convert (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *)
bool exact_real_truncate (enum machine_mode, const REAL_VALUE_TYPE *)
void real_to_decimal (char *, const REAL_VALUE_TYPE *, size_t, size_t, int)
void real_to_decimal_for_mode (char *, const REAL_VALUE_TYPE *, size_t, size_t, int, enum machine_mode)
void real_to_hexadecimal (char *, const REAL_VALUE_TYPE *, size_t, size_t, int)
HOST_WIDE_INT real_to_integer (const REAL_VALUE_TYPE *)
void real_to_integer2 (HOST_WIDE_INT *, HOST_WIDE_INT *, const REAL_VALUE_TYPE *)
int real_from_string (REAL_VALUE_TYPE *, const char *)
void real_from_string3 (REAL_VALUE_TYPE *, const char *, enum machine_mode)
void real_from_integer (REAL_VALUE_TYPE *, enum machine_mode, unsigned HOST_WIDE_INT, HOST_WIDE_INT, int)
long real_to_target_fmt (long *, const REAL_VALUE_TYPE *, const struct real_format *)
long real_to_target (long *, const REAL_VALUE_TYPE *, enum machine_mode)
void real_from_target_fmt (REAL_VALUE_TYPE *, const long *, const struct real_format *)
void real_from_target (REAL_VALUE_TYPE *, const long *, enum machine_mode)
void real_inf (REAL_VALUE_TYPE *)
bool real_nan (REAL_VALUE_TYPE *, const char *, int, enum machine_mode)
void real_maxval (REAL_VALUE_TYPE *, int, enum machine_mode)
void real_2expN (REAL_VALUE_TYPE *, int, enum machine_mode)
unsigned int real_hash (const REAL_VALUE_TYPE *)
REAL_VALUE_TYPE real_value_truncate (enum machine_mode, REAL_VALUE_TYPE)
REAL_VALUE_TYPE real_value_negate (const REAL_VALUE_TYPE *)
REAL_VALUE_TYPE real_value_abs (const REAL_VALUE_TYPE *)
int significand_size (enum machine_mode)
REAL_VALUE_TYPE real_from_string2 (const char *, enum machine_mode)
int real_exponent (const REAL_VALUE_TYPE *)
void real_ldexp (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int)
const REAL_VALUE_TYPE * dconst_e_ptr (void)
const REAL_VALUE_TYPE * dconst_third_ptr (void)
const REAL_VALUE_TYPE * dconst_sqrt2_ptr (void)
REAL_VALUE_TYPE real_value_from_int_cst (const_tree, const_tree)
rtx const_double_from_real_value (REAL_VALUE_TYPE, enum machine_mode)
bool exact_real_inverse (enum machine_mode, REAL_VALUE_TYPE *)
bool real_can_shorten_arithmetic (enum machine_mode, enum machine_mode)
tree build_real (tree, REAL_VALUE_TYPE)
bool real_sqrt (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *)
bool real_powi (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *, HOST_WIDE_INT)
void real_trunc (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *)
void real_floor (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *)
void real_ceil (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *)
void real_round (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALUE_TYPE *)
void real_copysign (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *)
bool real_isinteger (const REAL_VALUE_TYPE *c, enum machine_mode mode)
void get_max_float (const struct real_format *, char *, size_t)

Variables

char test_real_width [sizeof(REAL_VALUE_TYPE)<=REAL_WIDTH *sizeof(HOST_WIDE_INT)?1:-1]
struct real_formatreal_format_for_mode [MAX_MODE_FLOAT-MIN_MODE_FLOAT+1+MAX_MODE_DECIMAL_FLOAT-MIN_MODE_DECIMAL_FLOAT+1]
struct real_format ieee_single_format
struct real_format mips_single_format
struct real_format motorola_single_format
struct real_format spu_single_format
struct real_format ieee_double_format
struct real_format mips_double_format
struct real_format motorola_double_format
struct real_format ieee_extended_motorola_format
struct real_format ieee_extended_intel_96_format
struct real_format ieee_extended_intel_96_round_53_format
struct real_format ieee_extended_intel_128_format
struct real_format ibm_extended_format
struct real_format mips_extended_format
struct real_format ieee_quad_format
struct real_format mips_quad_format
struct real_format vax_f_format
struct real_format vax_d_format
struct real_format vax_g_format
struct real_format real_internal_format
struct real_format decimal_single_format
struct real_format decimal_double_format
struct real_format decimal_quad_format
struct real_format ieee_half_format
struct real_format arm_half_format
REAL_VALUE_TYPE dconst0
REAL_VALUE_TYPE dconst1
REAL_VALUE_TYPE dconst2
REAL_VALUE_TYPE dconstm1
REAL_VALUE_TYPE dconsthalf

Enumeration Type Documentation

An expanded form of the represented number.   
Enumerate the special cases of numbers that we encounter.   
Enumerator:
rvc_zero 
rvc_normal 
rvc_inf 
rvc_nan 

Function Documentation

tree build_real ( tree  ,
REAL_VALUE_TYPE   
)
rtx const_double_from_real_value ( REAL_VALUE_TYPE  ,
enum  machine_mode 
)
const REAL_VALUE_TYPE* dconst_e_ptr ( void  )
Function to return the real value special constant 'e'.   
Returns the special REAL_VALUE_TYPE corresponding to 'e'.   

References real_from_mpfr(), and rvc_zero.

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

References real_from_mpfr(), and rvc_zero.

const REAL_VALUE_TYPE* dconst_third_ptr ( void  )
Returns the special REAL_VALUE_TYPE corresponding to 1/3.   

References dconst1, real_arithmetic(), real_digit(), and rvc_zero.

Referenced by fold_builtin_cbrt().

bool exact_real_inverse ( enum  machine_mode,
REAL_VALUE_TYPE *   
)
Replace R by 1/R in the given machine mode, if the result is exact.   
bool exact_real_truncate ( enum  machine_mode,
const REAL_VALUE_TYPE *   
)
Return true if truncating to NEW is exact.   
void get_max_float ( const struct real_format ,
char *  ,
size_t   
)
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.   
void real_2expN ( REAL_VALUE_TYPE *  ,
int  ,
enum  machine_mode 
)
bool real_arithmetic ( REAL_VALUE_TYPE *  r,
int  icode,
const REAL_VALUE_TYPE *  op0,
const REAL_VALUE_TYPE *  op1 
)
Declare functions in real.c.   
Binary or unary arithmetic on tree_code.   
Perform the binary or unary operation described by CODE.
   For a unary operation, leave OP1 NULL.  This function returns
   true if the result may be inexact due to loss of precision.   

References decimal_real_arithmetic(), do_add(), do_compare(), do_divide(), do_fix_trunc(), do_multiply(), memset(), and rvc_nan.

Referenced by check_real_for_fixed_mode(), const_binop(), dconst_third_ptr(), distribute_real_division(), fixed_convert_from_real(), fixed_from_string(), fixed_to_decimal(), fold_binary_loc(), fold_builtin_cbrt(), fold_builtin_modf(), gimple_expand_builtin_pow(), omp_reduction_init(), real_convert_from_fixed(), real_value_abs(), real_value_negate(), simplify_const_binary_operation(), and simplify_const_unary_operation().

bool real_can_shorten_arithmetic ( enum  machine_mode,
enum  machine_mode 
)
Return true if arithmetic on values in IMODE that were promoted
   from values in TMODE is equivalent to direct arithmetic on values
   in TMODE.   
void real_ceil ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
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 mode MODE.   

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

Referenced by fold_builtin_ceil(), and fold_builtin_int_roundingfn().

bool real_compare ( int  ,
const REAL_VALUE_TYPE *  ,
const REAL_VALUE_TYPE *   
)
void real_copysign ( REAL_VALUE_TYPE *  ,
const REAL_VALUE_TYPE *   
)
Set the sign of R to the sign of X.   
int real_exponent ( const REAL_VALUE_TYPE *  )
??? These were added for Paranoia support.   
Return floor log2(R).   
void real_floor ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
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 mode MODE.   

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

Referenced by fold_builtin_floor(), and fold_builtin_int_roundingfn().

int real_from_string ( REAL_VALUE_TYPE *  ,
const char *   
)
Initialize R from a decimal or hexadecimal string.  Return -1 if
   the value underflows, +1 if overflows, and 0 otherwise.   
REAL_VALUE_TYPE real_from_string2 ( const char *  ,
enum  machine_mode 
)
void real_from_string3 ( REAL_VALUE_TYPE *  ,
const char *  ,
enum  machine_mode 
)
Wrapper to allow different internal representation for decimal floats.  
void real_from_target ( REAL_VALUE_TYPE *  ,
const long *  ,
enum  machine_mode 
)
void real_from_target_fmt ( REAL_VALUE_TYPE *  r,
const long *  buf,
const struct real_format 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.

unsigned int real_hash ( const REAL_VALUE_TYPE *  )
bool real_identical ( const REAL_VALUE_TYPE *  ,
const REAL_VALUE_TYPE *   
)
Compare two floating-point objects for bitwise identity.   
void real_inf ( REAL_VALUE_TYPE *  )
bool real_isfinite ( const REAL_VALUE_TYPE *  )
Determine whether a floating-point value X is finite.   
bool real_isinf ( const REAL_VALUE_TYPE *  )
Determine whether a floating-point value X is infinite.   
bool real_isinteger ( const REAL_VALUE_TYPE *  c,
enum machine_mode  mode 
)
Check whether the real constant value given is an integer.   
bool real_isnan ( const REAL_VALUE_TYPE *  )
Determine whether a floating-point value X is a NaN.   
bool real_isneg ( const REAL_VALUE_TYPE *  )
Determine whether a floating-point value X is negative.   
bool real_isnegzero ( const REAL_VALUE_TYPE *  )
Determine whether a floating-point value X is minus zero.   
void real_ldexp ( REAL_VALUE_TYPE *  ,
const REAL_VALUE_TYPE *  ,
int   
)
R = A * 2**EXP.   
void real_maxval ( REAL_VALUE_TYPE *  ,
int  ,
enum  machine_mode 
)
bool real_nan ( REAL_VALUE_TYPE *  r,
const char *  str,
int  quiet,
enum machine_mode  mode 
)
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(), get_canonical_qnan(), get_canonical_snan(), get_zero(), lshift_significand(), lshift_significand_1(), memset(), real_format::pnan, and rvc_nan.

Referenced by fold_builtin_nan(), real_from_mpfr(), and reg_to_stack().

bool real_powi ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
const REAL_VALUE_TYPE *  x,
HOST_WIDE_INT  n 
)
Calculate R as X raised to the integer exponent N in mode MODE.   
Calculate X raised to the integer exponent N in mode MODE 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, and real_convert().

Referenced by fold_builtin_pow(), and fold_builtin_powi().

void real_round ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
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(), and real_convert().

Referenced by fold_builtin_int_roundingfn(), fold_builtin_round(), and gimple_expand_builtin_pow().

bool real_sqrt ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
const REAL_VALUE_TYPE *  x 
)
Calculate R as the square root of X in the given machine mode.   
Calculate the square root of X in mode MODE, and store the result
   in R.  Return TRUE if the operation does not raise an exception.
   For details see "High Precision Division and Square Root",
   Alan H. Karp and Peter Markstein, HP Lab Report 93-93-42, June
   1993.  http://www.hpl.hp.com/techreports/93/HPL-93-42.pdf.   

References dconst1, dconsthalf, do_add(), do_multiply(), exp(), get_canonical_qnan(), real_convert(), real_exponent(), real_identical(), real_isfinite(), real_isneg(), real_isnegzero(), and real_ldexp().

Referenced by simplify_const_unary_operation().

void real_to_decimal ( char *  str,
const REAL_VALUE_TYPE *  r_orig,
size_t  buf_size,
size_t  digits,
int  crop_trailing_zeros 
)
Render R as a decimal floating point constant.   
Likewise, except always uses round-to-nearest.   

References real_to_decimal_for_mode().

Referenced by decimal_from_binary(), dump_generic_node(), dump_real(), fixed_to_decimal(), print_node(), print_node_brief(), print_rtx(), and print_value().

void real_to_decimal_for_mode ( char *  ,
const REAL_VALUE_TYPE *  ,
size_t  ,
size_t  ,
int  ,
enum  machine_mode 
)
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.   
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(), first, HOST_BITS_PER_LONG, real_format::p, rvc_inf, rvc_nan, rvc_normal, rvc_zero, and strlen().

Referenced by mpfr_from_real(), and print_rtx().

HOST_WIDE_INT real_to_integer ( const REAL_VALUE_TYPE *  )
Render R as an integer.   
long real_to_target ( long *  ,
const REAL_VALUE_TYPE *  ,
enum  machine_mode 
)
long real_to_target_fmt ( long *  buf,
const REAL_VALUE_TYPE *  r_orig,
const struct real_format 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, and round_for_format().

Referenced by real_to_target().

void real_trunc ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
const REAL_VALUE_TYPE *  x 
)
Standard round to integer value functions.   
Round X to the nearest integer not larger in absolute value, i.e.
   towards zero, placing the result in R in mode MODE.   

References do_fix_trunc(), and real_convert().

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

REAL_VALUE_TYPE real_value_abs ( const REAL_VALUE_TYPE *  )
REAL_VALUE_TYPE real_value_from_int_cst ( const_tree  ,
const_tree   
)
Function to return a real value (not a tree node)
   from a given integer constant.   

Referenced by build_real_from_int_cst(), and fold_convert_const_int_from_real().

REAL_VALUE_TYPE real_value_negate ( const REAL_VALUE_TYPE *  )
REAL_VALUE_TYPE real_value_truncate ( enum  machine_mode,
REAL_VALUE_TYPE   
)
int significand_size ( enum  machine_mode)

Variable Documentation

struct real_format arm_half_format
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.   
struct real_format decimal_double_format
Double precision decimal floating point (IEEE 754).  

Referenced by decimal_round_for_format().

struct real_format decimal_quad_format
Quad precision decimal floating point (IEEE 754).  

Referenced by decimal_round_for_format().

struct real_format decimal_single_format
Single precision decimal floating point (IEEE 754).  

Referenced by decimal_round_for_format().

struct real_format ibm_extended_format
struct real_format ieee_double_format

Referenced by check_target_format().

struct real_format ieee_extended_intel_128_format

Referenced by check_target_format().

struct real_format ieee_extended_intel_96_format

Referenced by check_target_format().

struct real_format ieee_extended_intel_96_round_53_format
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().

struct real_format ieee_extended_motorola_format

Referenced by check_target_format().

struct real_format ieee_half_format
Half-precision format, as specified in IEEE 754R.   
struct real_format ieee_quad_format

Referenced by check_target_format().

struct real_format ieee_single_format
Target formats defined in real.c.   

Referenced by check_target_format().

struct real_format mips_double_format
struct real_format mips_extended_format
struct real_format mips_quad_format

Referenced by check_target_format().

struct real_format mips_single_format

Referenced by check_target_format().

struct real_format motorola_double_format

Referenced by check_target_format().

struct real_format motorola_single_format

Referenced by check_target_format().

struct real_format* real_format_for_mode[MAX_MODE_FLOAT-MIN_MODE_FLOAT+1+MAX_MODE_DECIMAL_FLOAT-MIN_MODE_DECIMAL_FLOAT+1]
The target format used for each floating point mode.
   Float modes are followed by decimal float modes, with entries for
   float modes indexed by (MODE - first float mode), and entries for
   decimal float modes indexed by (MODE - first decimal float mode) +
   the number of float modes.   
struct real_format real_internal_format
struct real_format spu_single_format
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).   
char test_real_width[sizeof(REAL_VALUE_TYPE)<=REAL_WIDTH *sizeof(HOST_WIDE_INT)?1:-1]
Verify the guess.   
struct real_format vax_d_format
struct real_format vax_f_format
struct real_format vax_g_format