gcc.info: Cross-compilation
Go forward to Misc
Go backward to Debugging Info
Go up to Target Macros
Go to the top op gcc
Cross Compilation and Floating Point
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'
A macro for the C data type to be used to hold a floating point
value in the target machine's format. Typically this would be a
`struct' containing an array of `int'.
`REAL_VALUES_EQUAL (X, Y)'
A macro for a C expression which compares for equality the two
values, X and Y, both of type `REAL_VALUE_TYPE'.
`REAL_VALUES_LESS (X, Y)'
A macro for a C expression which tests whether X is less than Y,
both values being of type `REAL_VALUE_TYPE' and interpreted as
floating point numbers in the target machine's representation.
`REAL_VALUE_LDEXP (X, SCALE)'
A macro for a C expression which performs the standard library
function `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)'
A macro whose definition is a C expression to convert the
target-machine floating point value X to a signed integer. X has
type `REAL_VALUE_TYPE'.
`REAL_VALUE_UNSIGNED_FIX (X)'
A macro whose definition is a C expression to convert the
target-machine floating point value X to an unsigned integer. X
has type `REAL_VALUE_TYPE'.
`REAL_VALUE_RNDZINT (X)'
A macro whose definition is a C expression to round the
target-machine floating point value X towards zero to an integer
value (but still as a floating point number). X has type
`REAL_VALUE_TYPE', and so does the value.
`REAL_VALUE_UNSIGNED_RNDZINT (X)'
A macro whose definition is a C expression to round the
target-machine floating point value X towards zero to an unsigned
integer value (but still represented as a floating point number).
X has type `REAL_VALUE_TYPE', and so does the value.
`REAL_VALUE_ATOF (STRING, MODE)'
A macro for a C expression which converts STRING, an expression of
type `char *', into a floating point number in the target machine's
representation for mode MODE. The value has type
`REAL_VALUE_TYPE'.
`REAL_INFINITY'
Define this macro if infinity is a possible floating point value,
and therefore division by 0 is legitimate.
`REAL_VALUE_ISINF (X)'
A macro for a C expression which determines whether X, a floating
point value, is infinity. The value has type `int'. By default,
this is defined to call `isinf'.
`REAL_VALUE_ISNAN (X)'
A macro for a C expression which determines whether X, a floating
point value, is a "nan" (not-a-number). The value has type `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)'
A macro for a C statement which calculates an arithmetic operation
of the two floating point values X and Y, both of type
`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)'
A macro for a C expression which returns the negative of the
floating point value X. Both X and the value of the expression
have type `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)'
A macro for a C expression which converts the floating point value
X to mode MODE.
Both X and the value of the expression are in the target machine's
floating point representation and have type `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)'
A macro for a C expression which converts a floating point value X
into a double-precision integer which is then stored into LOW and
HIGH, two variables of type INT.
`REAL_VALUE_FROM_INT (X, LOW, HIGH, MODE)'
A macro for a C expression which converts a double-precision
integer found in LOW and HIGH, two variables of type INT, into a
floating point value which is then stored into X. The value is in
the target machine's representation for mode MODE and has the type
`REAL_VALUE_TYPE'.
Created Wed Sep 1 16:42:26 2004 on bee with info_to_html version 0.9.6.