GCC Middle and Back End API Reference
|
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_TYPE * | ten_to_ptwo (int) |
static const REAL_VALUE_TYPE * | ten_to_mptwo (int) |
static const REAL_VALUE_TYPE * | real_digit (int) |
static void | times_pten (REAL_VALUE_TYPE *, int) |
static void | round_for_format (const struct real_format *, REAL_VALUE_TYPE *) |
static void | get_zero () |
static void | get_canonical_qnan () |
static void | get_canonical_snan () |
static void | get_inf () |
static void | lshift_significand_1 () |
static void | neg_significand () |
static int | cmp_significands () |
static int | cmp_significand_0 () |
static void | set_significand_bit () |
static void | clear_significand_bit () |
static bool | test_significand_bit () |
static void | clear_significand_below () |
static void | normalize () |
static void | do_fix_trunc () |
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 () |
REAL_VALUE_TYPE | real_value_abs () |
bool | real_compare (int icode, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1) |
int | real_exponent () |
void | real_ldexp () |
bool | real_isinf () |
bool | real_isnan () |
bool | real_isfinite () |
bool | real_isneg () |
bool | real_isnegzero () |
bool | real_identical () |
bool | exact_real_inverse () |
bool | real_can_shorten_arithmetic () |
HOST_WIDE_INT | real_to_integer () |
void | real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh, const REAL_VALUE_TYPE *r) |
static unsigned long | rtd_divmod () |
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, enum 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) |
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 | real_from_string2 () |
void | real_from_string3 () |
void | real_from_integer (REAL_VALUE_TYPE *r, enum machine_mode mode, unsigned HOST_WIDE_INT low, HOST_WIDE_INT high, int unsigned_p) |
static void | decimal_from_integer () |
static const REAL_VALUE_TYPE * | ten_to_ptwo () |
static const REAL_VALUE_TYPE * | ten_to_mptwo () |
static const REAL_VALUE_TYPE * | real_digit () |
static void | times_pten () |
const REAL_VALUE_TYPE * | dconst_e_ptr () |
const REAL_VALUE_TYPE * | dconst_third_ptr () |
const REAL_VALUE_TYPE * | dconst_sqrt2_ptr () |
void | real_inf () |
bool | real_nan (REAL_VALUE_TYPE *r, const char *str, int quiet, enum machine_mode mode) |
void | real_maxval () |
void | real_2expN () |
static void | round_for_format () |
void | real_convert (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *a) |
REAL_VALUE_TYPE | real_value_truncate () |
bool | exact_real_truncate () |
long | real_to_target_fmt (long *buf, const REAL_VALUE_TYPE *r_orig, const struct real_format *fmt) |
long | real_to_target () |
void | real_from_target_fmt (REAL_VALUE_TYPE *r, const long *buf, const struct real_format *fmt) |
void | real_from_target () |
int | significand_size () |
unsigned int | real_hash () |
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_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_sqrt (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *x) |
bool | real_powi (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *x, HOST_WIDE_INT n) |
void | real_trunc (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *x) |
void | real_floor (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *x) |
void | real_ceil (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *x) |
void | real_round (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *x) |
void | real_copysign () |
bool | real_isinteger () |
void | get_max_float () |
Variables | |
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_128_format |
struct real_format | ieee_extended_intel_96_round_53_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 | 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 |
struct real_format | real_internal_format |
|
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.
|
static |
Referenced by do_compare().
|
static |
Clear bits 0..N-1 of the significand of R.
|
static |
|
inlinestatic |
Clear bit N of the significand of R.
|
static |
|
inlinestatic |
Return true if A is nonzero.
References HOST_BITS_PER_LONG.
|
static |
Referenced by real_to_integer2().
|
inlinestatic |
Compare significands. Return tri-state vs zero.
const REAL_VALUE_TYPE* dconst_e_ptr | ( | void | ) |
Returns the special REAL_VALUE_TYPE corresponding to 'e'.
Initialize mathematical constants for constant folding builtins. These constants need to be given to at least 160 bits precision.
const REAL_VALUE_TYPE* dconst_sqrt2_ptr | ( | void | ) |
Returns the special REAL_VALUE_TYPE corresponding to sqrt(2).
Initialize mathematical constants for constant folding builtins. These constants need to be given to at least 160 bits precision.
const REAL_VALUE_TYPE* dconst_third_ptr | ( | void | ) |
Returns the special REAL_VALUE_TYPE corresponding to 1/3.
Initialize mathematical constants for constant folding builtins. These constants need to be given to at least 160 bits precision.
Referenced by integer_valued_real_p().
|
static |
|
static |
Convert a real with an integral value to decimal float.
References real_from_mpfr().
|
static |
Render R, an integral value, as a floating point constant with no specified exponent.
|
static |
Decode a double precision DFP value in BUF into a real R.
|
static |
Decode a quad precision DFP value in BUF into a real R.
|
static |
Decode a single precision DFP value in BUF into a real R.
|
static |
|
static |
References real_format::canonical_nan_lsbs_set.
|
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.
When the IEEE format contains a hidden bit, we know that it's zero at this point, and so shift up the significand and decrease the exponent to match. In this case, Motorola defines the explicit integer bit to be valid, so we don't know whether the msb is set or not.
See above re "pseudo-infinities" and "pseudo-nans". Short summary is that the MSB will likely always be set, and that we don't care about it.
|
static |
Convert from the internal format to the 16-byte Intel format for an IEEE extended real.
All the padding in an Intel-format extended real goes at the high end.
References exp().
|
static |
Convert from the internal format to the 12-byte Intel format for an IEEE extended real.
All the padding in an Intel-format extended real goes at the high end, which in this case is after the mantissa, not the exponent. Therefore we must shift everything up 16 bits.
decode_ieee_extended produces what we want directly.
|
static |
Convert from the internal format to the 12-byte Motorola format for an IEEE extended real.
Motorola chips are assumed always to be big-endian. Also, the padding in a Motorola extended real goes between the exponent and the mantissa; remove it.
|
static |
Decode half-precision floats. This routine is used both for the IEEE ARM alternative encodings.
|
static |
|
static |
References real_format::canonical_nan_lsbs_set, and real_format::qnan_msb_set.
Referenced by significand_size().
|
static |
References real_format::p.
|
static |
Rearrange the half-words of the external format into proper ascending order.
References encode_decimal64().
|
static |
|
static |
Rearrange the half-words of the external format into proper ascending order.
References real_format::canonical_nan_lsbs_set, exp(), real_format::has_inf, real_format::has_nans, HOST_BITS_PER_LONG, real_format::qnan_msb_set, rvc_inf, rvc_nan, rvc_normal, and rvc_zero.
|
inlinestatic |
Divide the significands of A and B, placing the result in R. Return true if the division was inexact.
|
static |
Calculate R = A + (SUBTRACT_P ? -B : B). Return true if the result may be inexact due to a loss of precision.
Determine if we need to add or subtract.
-0 + -0 = -0, -0 - +0 = -0; all other cases yield +0.
0 + ANY = ANY.
ANY + NaN = NaN.
R + Inf = Inf.
ANY + 0 = ANY.
NaN + ANY = NaN.
Inf + R = Inf.
Inf - Inf = NaN.
Inf + Inf = Inf.
Swap the arguments such that A has the larger exponent.
If the exponents are not identical, we need to shift the significand of B down.
If the exponents are too far apart, the significands do not overlap, which makes the subtraction a noop.
We got a borrow out of the subtraction. That means that A and B had the same exponent, and B had the larger significand. We need to swap the sign and negate the significand.
We got carry out of the addition. This means we need to shift the significand back down one bit and increase the exponent.
Zero out the remaining fields.
Re-normalize the result.
Special case: if the subtraction results in zero, the result is positive.
Referenced by encode_ieee_half(), and real_from_string().
|
static |
Return a tri-state comparison of A vs B. Return NAN_RESULT if one of the two operands is a NaN.
Sign of zero doesn't matter for compares.
Decimal float zero is special and uses rvc_normal, not rvc_zero.
Fall through.
Decimal float zero is special and uses rvc_normal, not rvc_zero.
Fall through.
References clear_significand_below(), decimal_do_fix_trunc(), get_zero(), rvc_inf, rvc_nan, rvc_normal, and rvc_zero.
|
static |
Calculate R = A / B. Return true if the result may be inexact.
0 / 0 = NaN.
Inf / Inf = NaN.
0 / ANY = 0.
R / Inf = 0.
R / 0 = Inf.
Inf / 0 = Inf.
ANY / NaN = NaN.
NaN / ANY = NaN.
Inf / R = Inf.
Make sure all fields in the result are initialized.
Re-normalize the result.
|
static |
|
static |
Return A truncated to an integral value toward zero.
|
static |
Calculate R = A * B. Return true if the result may be inexact.
+-0 * ANY = 0 with appropriate sign.
ANY * NaN = NaN.
NaN * ANY = NaN.
0 * Inf = NaN
Inf * Inf = Inf, R * Inf = Inf
Collect all the partial products. Since we don't have sure access to a widening multiply, we split each long into two half-words. Consider the long-hand form of a four half-word multiplication: A B C D * E F G H -------------- DE DF DG DH CE CF CG CH BE BF BG BH AE AF AG AH We construct partial products of the widened half-word products that are known to not overlap, e.g. DF+DH. Each such partial product is given its proper exponent, which allows us to sum them and obtain the finished product.
Would underflow to zero, which we shouldn't bother adding.
Referenced by real_from_string(), and real_from_string3().
|
static |
Encode real R into a double precision DFP value in BUF.
|
static |
Encode real R into a quad precision DFP value in BUF.
|
static |
Encode real R into a single precision DFP value in BUF.
|
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.
Renormalize R before doing any arithmetic on it.
u = IEEE double precision portion of significand.
Call round_for_format since we might need to denormalize.
Inf, NaN, 0 are all representable as doubles, so the least-significant part can be 0.0.
|
static |
IEEE double-precision format.
Recall that IEEE numbers are interpreted as 1.F x 2**exp, whereas the intermediate representation is 0.F x 2**exp. Which means we're off by one.
|
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.
Intel requires the explicit integer bit to be set, otherwise it considers the value a "pseudo-infinity". Motorola docs say it doesn't care.
Intel requires the explicit integer bit to be set, otherwise it considers the value a "pseudo-nan". Motorola docs say it doesn't care.
Recall that IEEE numbers are interpreted as 1.F x 2**exp, whereas the intermediate representation is 0.F x 2**exp. Which means we're off by one. Except for Motorola, which consider exp=0 and explicit integer bit set to continue to be normalized. In theory this discrepancy has been taken care of by the difference in fmt->emin in round_for_format.
References real_format::emin, HOST_BITS_PER_LONG, normalize(), and rvc_normal.
|
static |
Convert from the internal format to the 16-byte Intel format for an IEEE extended real.
All the padding in an Intel-format extended real goes at the high end.
|
static |
Convert from the internal format to the 12-byte Intel format for an IEEE extended real.
All the padding in an Intel-format extended real goes at the high end, which in this case is after the mantissa, not the exponent. Therefore we must shift everything down 16 bits.
encode_ieee_extended produces what we want directly.
|
static |
Convert from the internal format to the 12-byte Motorola format for an IEEE extended real.
Motorola chips are assumed always to be big-endian. Also, the padding in a Motorola extended real goes between the exponent and the mantissa. At this point the mantissa is entirely within elements 0 and 1 of intermed, and the exponent entirely within element 2, so all we have to do is swap the order around, and shift element 2 left 16 bits.
|
static |
Encode half-precision floats. This routine is used both for the IEEE ARM alternative encodings.
Recall that IEEE numbers are interpreted as 1.F x 2**exp, whereas the intermediate representation is 0.F x 2**exp. Which means we're off by one.
References dconst1, dconsthalf, and do_add().
|
static |
IEEE quad precision format.
Recall that IEEE numbers are interpreted as 1.F x 2**exp, whereas the intermediate representation is 0.F x 2**exp. Which means we're off by one.
|
static |
IEEE single-precision format.
Recall that IEEE numbers are interpreted as 1.F x 2**exp, whereas the intermediate representation is 0.F x 2**exp. Which means we're off by one.
Referenced by significand_size().
|
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.
|
static |
Extract the significand into straight hi:lo.
Rearrange the half-words of the significand to match the external format.
Add the sign and exponent.
|
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.
|
static |
Extract the significand into straight hi:lo.
Rearrange the half-words of the significand to match the external format.
Add the sign and exponent.
bool exact_real_inverse | ( | ) |
Try to change R into its exact multiplicative inverse in machine mode MODE. Return true if successful.
Check for a power of two: all significand bits zero except the MSB.
Find the inverse and truncate to the required mode.
The rounding may have overflowed.
bool exact_real_truncate | ( | ) |
Return true if truncating to MODE is exact.
Don't allow conversion to denormals.
After conversion to the new mode, the value must be identical.
References real_format::canonical_nan_lsbs_set, and real_format::qnan_msb_set.
|
static |
|
inlinestatic |
Initialize R with the canonical quiet NaN.
|
static |
|
inlinestatic |
|
static |
|
inlinestatic |
void get_max_float | ( | ) |
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.
This is an IBM extended double format made up of two IEEE doubles. The value of the long double is the sum of the values of the two parts. The most significant part is required to be the value of the long double rounded to the nearest double. Rounding means we need a slightly smaller value for LDBL_MAX.
|
static |
Referenced by do_compare().
|
inlinestatic |
Initialize R with a positive zero.
|
static |
Left-shift the significand of A by N bits; put the result in the significand of R.
|
static |
Referenced by real_to_integer2().
|
inlinestatic |
Likewise, but N is specialized to 1.
|
static |
|
inlinestatic |
Negate the significand A, placing the result in R.
|
static |
Referenced by encode_ieee_extended().
|
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.)
Find the first word that is nonzero.
Zero significand flushes to zero.
Find the first bit that is nonzero.
void real_2expN | ( | ) |
Fills R with 2**N.
Referenced by expand_float().
bool real_arithmetic | ( | REAL_VALUE_TYPE * | r, |
int | icode, | ||
const REAL_VALUE_TYPE * | op0, | ||
const REAL_VALUE_TYPE * | op1 | ||
) |
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.
Clear any padding areas in *r if it isn't equal to one of the operands so that we can later do bitwise comparisons later on.
References real_arithmetic().
Referenced by integer_valued_real_p(), maybe_lookup_ctx(), and real_arithmetic().
bool real_can_shorten_arithmetic | ( | ) |
Return true if arithmetic on values in IMODE that were promoted from values in TMODE is equivalent to direct arithmetic on values in TMODE.
These conditions are conservative rather than trying to catch the exact boundary conditions; the main case to allow is IEEE float and double.
References decimal_real_to_integer2(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, rvc_inf, rvc_nan, rvc_normal, and rvc_zero.
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.
bool real_compare | ( | int | , |
const REAL_VALUE_TYPE * | , | ||
const REAL_VALUE_TYPE * | |||
) |
Compare reals by tree_code.
Referenced by fold_builtin_strncat_chk().
void real_convert | ( | REAL_VALUE_TYPE * | r, |
enum machine_mode | mode, | ||
const REAL_VALUE_TYPE * | a | ||
) |
Extend or truncate to a new mode.
round_for_format de-normalizes denormals. Undo just that part.
void real_copysign | ( | ) |
Set the sign of R to the sign of X.
|
static |
Referenced by real_from_string(), and real_isnan().
|
static |
Returns N.
int real_exponent | ( | ) |
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.
Referenced by build_complex_cproj().
void real_from_integer | ( | REAL_VALUE_TYPE * | r, |
enum machine_mode | mode, | ||
unsigned HOST_WIDE_INT | low, | ||
HOST_WIDE_INT | high, | ||
int | unsigned_p | ||
) |
Initialize R from the integer pair HIGH+LOW.
Referenced by fold_builtin_sincos().
int real_from_string | ( | ) |
Initialize R from a decimal or hexadecimal string. The string is assumed to have been syntax checked already. Return -1 if the value underflows, +1 if overflows, and 0 otherwise.
Hexadecimal floating point.
Ensure correct rounding by setting last bit if there is a subsequent nonzero digit.
Ensure correct rounding by setting last bit if there is a subsequent nonzero digit.
If the mantissa is zero, ignore the exponent.
Overflowed the exponent.
Decimal floating point.
If the mantissa is zero, ignore the exponent.
Overflowed the exponent.
References do_add(), do_multiply(), real_digit(), rvc_zero, ten_to_ptwo(), and times_pten().
REAL_VALUE_TYPE real_from_string2 | ( | ) |
Legacy. Similar, but return the result directly.
void real_from_string3 | ( | ) |
Initialize R from string S and desired MODE.
References do_multiply(), and ten_to_ptwo().
void real_from_target | ( | ) |
Similar, but look up the format from 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.
unsigned int real_hash | ( | ) |
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.
Referenced by default_assemble_integer().
bool real_identical | ( | ) |
Compare two floating-point objects for bitwise identity.
The significand is ignored for canonical NaNs.
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, real_format::p, and real_format::round_towards_zero.
void real_inf | ( | ) |
Fills R with +Inf.
Referenced by fold_builtin_fabs(), fold_builtin_strncpy(), maybe_lookup_ctx(), and real_from_mpfr().
bool real_isfinite | ( | ) |
Determine whether a floating-point value X is finite.
Referenced by fold_builtin_snprintf_chk(), fold_builtin_sprintf_chk_1(), and fold_builtin_strncat_chk().
bool real_isinf | ( | ) |
Determine whether a floating-point value X is infinite.
Referenced by fold_builtin_strncpy().
bool real_isinteger | ( | ) |
Check whether the real constant value given is an integer.
bool real_isnan | ( | ) |
Determine whether a floating-point value X is a NaN.
References real_digit(), and rvc_normal.
Referenced by fold_builtin_isascii().
bool real_isneg | ( | ) |
Determine whether a floating-point value X is negative.
Referenced by fold_builtin_strncpy().
bool real_isnegzero | ( | ) |
Determine whether a floating-point value X is minus zero.
void real_ldexp | ( | ) |
R = OP0 * 2**EXP.
References rvc_inf, rvc_nan, rvc_normal, and rvc_zero.
void real_maxval | ( | ) |
Fills R with the largest finite value representable in mode MODE. If SIGN is nonzero, R is set to the most negative finite value.
This is an IBM extended double format made up of two IEEE doubles. The value of the long double is the sum of the values of the two parts. The most significant part is required to be the value of the long double rounded to the nearest double. Rounding means we need a slightly smaller value for LDBL_MAX.
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.
Parse akin to strtol into the significand of R.
Must have consumed the entire string for success.
Shift the significand into place such that the bits are in the most significant bits for the format.
Our MSB is always unset for NaNs.
Force quiet or signalling NaN.
References real_format::b, decimal_real_convert(), and decimal_round_for_format().
bool real_powi | ( | REAL_VALUE_TYPE * | r, |
enum machine_mode | mode, | ||
const REAL_VALUE_TYPE * | x, | ||
HOST_WIDE_INT | n | ||
) |
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.
Don't worry about overflow, from now on n is unsigned.
Referenced by fold_builtin_ceil().
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.
bool real_sqrt | ( | REAL_VALUE_TYPE * | r, |
enum machine_mode | mode, | ||
const REAL_VALUE_TYPE * | x | ||
) |
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.
sqrt(-0.0) is -0.0.
Negative arguments return NaN.
Infinity and NaN return themselves.
Initial guess for reciprocal sqrt, i.
Newton's iteration for reciprocal sqrt, i.
i(n+1) = i(n) * (1.5 - 0.5*i(n)*i(n)*x).
Check for early convergence.
??? Unroll loop to avoid copying.
Final iteration: r = i*x + 0.5*i*x*(1.0 - i*(i*x)).
??? We need a Tuckerman test to get the last bit.
void real_to_decimal | ( | char * | str, |
const REAL_VALUE_TYPE * | r_orig, | ||
size_t | buf_size, | ||
size_t | digits, | ||
int | crop_trailing_zeros | ||
) |
Likewise, except always uses round-to-nearest.
References HOST_BITS_PER_LONG.
Referenced by decimal_to_binary(), dump_pointer(), and print_value().
void real_to_decimal_for_mode | ( | char * | , |
const REAL_VALUE_TYPE * | , | ||
size_t | , | ||
size_t | , | ||
int | , | ||
enum | machine_mode | ||
) |
Render R as a decimal floating point constant, rounded so as to be parsed back to the same value when interpreted in mode MODE.
??? Print the significand as well, if not canonical?
Bound the number of digits printed by the size of the representation.
Estimate the decimal exponent, and compute the length of the string it will print as. Be conservative and add one to account for possible overflow or rounding error.
Bound the number of digits printed by the size of the output buffer.
Number is greater than one. Convert significand to an integer and strip trailing decimal zeros.
Largest M, such that 10**2**M fits within SIGNIFICAND_BITS.
Iterate over the bits of the possible powers of 10 that might be present in U and eliminate them. That is, if we find that 10**2**M divides U evenly, keep the division and increase DEC_EXP by 2**M.
Revert the scaling to integer that we performed earlier.
Find power of 10. Do this by dividing out 10**2**M when this is larger than the current remainder. Fill PTEN with the power of 10 that we compute.
We managed to divide off enough tens in the above reduction loop that we've now got a negative exponent. Fall into the less-than-one code to compute the proper value for PTEN.
Number is less than one. Pad significand with leading decimal zeros.
Stop if we'd shift bits off the bottom.
Stop if we're now >= 1.
Find power of 10. Do this by multiplying in P=10**2**M when the current remainder is smaller than 1/P. Fill PTEN with the power of 10 that we compute.
Invert the positive power of 10 that we've collected so far.
At this point, PTEN should contain the nearest power of 10 smaller than R, such that this division produces the first digit. Using a divide-step primitive that returns the complete integral remainder avoids the rounding error that would be produced if we were to use do_divide here and then simply multiply by 10 for each subsequent digit.
Be prepared for error in that division via underflow ...
Multiply by 10 and try again.
... or overflow.
Generate subsequent digits.
Generate one more digit with which to do rounding.
Round the result.
If the format uses round towards zero when parsing the string back in, we need to always round away from zero here.
Round to nearest. If R is nonzero there are additional nonzero digits to be extracted.
Round to even.
Carry out of the first digit. This means we had all 9's and now have all 0's. "Prepend" a 1 by overwriting the first 0.
Insert the decimal point.
If requested, drop trailing zeros. Never crop past "1.0".
Append the exponent.
Verify that we can read the original value back in.
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.
??? Print the significand as well, if not canonical?
Hexadecimal format for decimal floats is not interesting.
Bound the number of digits printed by the size of the output buffer.
HOST_WIDE_INT real_to_integer | ( | ) |
Render R as an integer.
Only force overflow for unsigned overflow. Signed overflow is undefined, so it doesn't matter what we return, and some callers expect to be able to use this routine for both signed and unsigned conversions.
void real_to_integer2 | ( | HOST_WIDE_INT * | plow, |
HOST_WIDE_INT * | phigh, | ||
const REAL_VALUE_TYPE * | r | ||
) |
Likewise, but to an integer pair, HI+LOW.
Only force overflow for unsigned overflow. Signed overflow is undefined, so it doesn't matter what we return, and some callers expect to be able to use this routine for both signed and unsigned conversions.
References cmp_significands(), lshift_significand_1(), and sub_significands().
long real_to_target | ( | ) |
Similar, but look up the format from MODE.
Referenced by assemble_static_space().
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.
void real_trunc | ( | REAL_VALUE_TYPE * | r, |
enum machine_mode | mode, | ||
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 mode MODE.
REAL_VALUE_TYPE real_value_negate | ( | ) |
Referenced by real_from_mpfr(), and tree_unary_nonnegative_warnv_p().
REAL_VALUE_TYPE real_value_truncate | ( | ) |
Legacy. Likewise, except return the struct directly.
References real_format::has_inf, rvc_inf, and rvc_zero.
Referenced by fold_builtin_constant_p(), fold_builtin_sincos(), and integer_valued_real_p().
|
static |
|
static |
FIXME. We can come here via fp_easy_constant (e.g. -O0 on '_Decimal32 x = 1.0 + 2.0dd'), but have not investigated whether this convert needs to be here, or something else is missing.
Check the range of the exponent. If we're out of range, either underflow or overflow.
Don't underflow completely until we've had a chance to round.
De-normalize the significand.
There are P2 true significand bits, followed by one guard bit, followed by one sticky bit, followed by stuff. Fold nonzero stuff into the sticky bit.
Round to even.
Overflow. Means the significand had been all ones, and is now all zeros. Need to increase the exponent, and possibly re-normalize it.
Catch underflow that we deferred until after rounding.
Clear out trailing garbage.
|
static |
Right-shift the significand of A by N bits; put the result in the significand of R.
References HOST_BITS_PER_LONG.
|
static |
|
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.
|
static |
|
inlinestatic |
Set bit N of the significand of R.
References HOST_BITS_PER_LONG.
int significand_size | ( | ) |
Return the number of bits of the largest binary value that the significand of MODE will hold.
??? Legacy. Should get access to real_format directly.
Return the size in bits of the largest binary value that can be held by the decimal coefficient for this mode. This is one more than the number of bits required to hold the largest coefficient of this mode.
References decode_ieee_single(), and encode_ieee_single().
Referenced by have_add2_insn(), and have_sub2_insn().
|
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 HOST_BITS_PER_LONG.
|
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.
Referenced by real_to_integer2().
|
static |
|
static |
Returns 10**(-2**N).
|
static |
Referenced by real_from_string(), and real_from_string3().
|
static |
Returns 10**2**N.
|
static |
|
inlinestatic |
Test bit N of the significand of R.
??? Compiler bug here if we return this expression directly. The conversion to bool strips the "&1" and we wind up testing e.g. 2 != 0 -> true. Seen in gcc version 3.2 20020520.
|
static |
Referenced by real_from_string().
|
static |
Multiply R by 10**EXP.
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).
struct real_format decimal_quad_format |
Quad precision decimal floating point (IEEE 754).
struct real_format decimal_single_format |
Single precision decimal floating point (IEEE 754).
struct real_format ibm_extended_format |
struct real_format ieee_double_format |
struct real_format ieee_extended_intel_128_format |
struct real_format ieee_extended_intel_96_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.
struct real_format ieee_extended_motorola_format |
struct real_format ieee_half_format |
Half-precision format, as specified in IEEE 754R.
struct real_format ieee_quad_format |
struct real_format ieee_single_format |
Target formats defined in real.c.
struct real_format mips_double_format |
struct real_format mips_extended_format |
struct real_format mips_quad_format |
struct real_format mips_single_format |
struct real_format motorola_double_format |
struct real_format motorola_single_format |
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).
struct real_format vax_d_format |
struct real_format vax_f_format |
struct real_format vax_g_format |