While all modern machines use 2's complement representation for integers, there are a variety of representations for floating point numbers. This means that in a cross-compiler the representation of floating point numbers in the compiled program may be different from that used in the machine doing the compilation.
Because different representation systems may offer different amounts of
range and precision, the cross compiler cannot safely use the host
machine's floating point arithmetic. Therefore, floating point constants
must be represented in the target machine's format. This means that the
cross compiler cannot use atof
to parse a floating point constant;
it must have its own special routine to use instead. Also, constant
folding must emulate the target machine's arithmetic (or must not be done
at all).
The macros in the following table should be defined only if you are cross compiling between different floating point formats.
Otherwise, don't define them. Then default definitions will be set up which
use double
as the data type, ==
to test for equality, etc.
You don't need to worry about how many times you use an operand of any of these macros. The compiler never uses operands which have side effects.
REAL_VALUE_TYPE
struct
containing an array of int
.
REAL_VALUES_EQUAL (x, y)
REAL_VALUE_TYPE
.
REAL_VALUES_LESS (x, y)
REAL_VALUE_TYPE
and
interpreted as floating point numbers in the target machine's
representation.
REAL_VALUE_LDEXP (x, scale)
ldexp
, but using the target machine's floating point
representation. Both x and the value of the expression have
type REAL_VALUE_TYPE
. The second argument, scale, is an
integer.
REAL_VALUE_FIX (x)
REAL_VALUE_TYPE
.
REAL_VALUE_UNSIGNED_FIX (x)
REAL_VALUE_TYPE
.
REAL_VALUE_RNDZINT (x)
REAL_VALUE_TYPE
,
and so does the value.
REAL_VALUE_UNSIGNED_RNDZINT (x)
REAL_VALUE_TYPE
, and so does the value.
REAL_VALUE_ATOF (string, mode)
char *
, into a floating point number in the target machine's
representation for mode mode. The value has type
REAL_VALUE_TYPE
.
REAL_INFINITY
REAL_VALUE_ISINF (x)
int
.
By default, this is defined to call isinf
.
REAL_VALUE_ISNAN (x)
int
. By default, this is defined to call isnan
.
Define the following additional macros if you want to make floating point constant folding work while cross compiling. If you don't define them, cross compilation is still possible, but constant folding will not happen for floating point values.
REAL_ARITHMETIC (output, code, x, y)
REAL_VALUE_TYPE
in the target machine's representation, to
produce a result of the same type and representation which is stored
in output (which will be a variable).
The operation to be performed is specified by code, a tree code
which will always be one of the following: PLUS_EXPR
,
MINUS_EXPR
, MULT_EXPR
, RDIV_EXPR
,
MAX_EXPR
, MIN_EXPR
.
The expansion of this macro is responsible for checking for overflow.
If overflow happens, the macro expansion should execute the statement
return 0;
, which indicates the inability to perform the
arithmetic operation requested.
REAL_VALUE_NEGATE (x)
REAL_VALUE_TYPE
and are in the target machine's
floating point representation.
There is no way for this macro to report overflow, since overflow
can't happen in the negation operation.
REAL_VALUE_TRUNCATE (mode, x)
REAL_VALUE_TYPE
.
However, the value should have an appropriate bit pattern to be output
properly as a floating constant whose precision accords with mode
mode.
There is no way for this macro to report overflow.
REAL_VALUE_TO_INT (low, high, x)
REAL_VALUE_FROM_INT (x, low, high, mode)
REAL_VALUE_TYPE
.
Go to the first, previous, next, last section, table of contents.