Conversions#
All conversions between machine modes must be represented by
explicit conversion operations. For example, an expression
which is the sum of a byte and a full word cannot be written as
(plus:SI (reg:QI 34) (reg:SI 80))
because the plus
operation requires two operands of the same machine mode.
Therefore, the byte-sized operand is enclosed in a conversion
operation, as in
(plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
The conversion operation is not a mere placeholder, because there may be more than one way of converting from a given starting mode to the desired final mode. The conversion operation code says how to do it.
For all conversion operations, x
must not be VOIDmode
because the mode in which to do the conversion would not be known.
The conversion must either be done at compile-time or x
must be placed into a register.
(sign_extend:m x)
Represents the result of sign-extending the value
x
to machine modem
.m
must be a fixed-point mode andx
a fixed-point value of a mode narrower thanm
.(zero_extend:m x)
Represents the result of zero-extending the value
x
to machine modem
.m
must be a fixed-point mode andx
a fixed-point value of a mode narrower thanm
.(float_extend:m x)
Represents the result of extending the value
x
to machine modem
.m
must be a floating point mode andx
a floating point value of a mode narrower thanm
.(truncate:m x)
Represents the result of truncating the value
x
to machine modem
.m
must be a fixed-point mode andx
a fixed-point value of a mode wider thanm
.(ss_truncate:m x)
Represents the result of truncating the value
x
to machine modem
, using signed saturation in the case of overflow. Bothm
and the mode ofx
must be fixed-point modes.(us_truncate:m x)
Represents the result of truncating the value
x
to machine modem
, using unsigned saturation in the case of overflow. Bothm
and the mode ofx
must be fixed-point modes.(float_truncate:m x)
Represents the result of truncating the value
x
to machine modem
.m
must be a floating point mode andx
a floating point value of a mode wider thanm
.(float:m x)
Represents the result of converting fixed point value
x
, regarded as signed, to floating point modem
.(unsigned_float:m x)
Represents the result of converting fixed point value
x
, regarded as unsigned, to floating point modem
.(fix:m x)
When
m
is a floating-point mode, represents the result of converting floating point valuex
(valid for modem
) to an integer, still represented in floating point modem
, by rounding towards zero.When
m
is a fixed-point mode, represents the result of converting floating point valuex
to modem
, regarded as signed. How rounding is done is not specified, so this operation may be used validly in compiling C code only for integer-valued operands.(unsigned_fix:m x)
Represents the result of converting floating point value
x
to fixed point modem
, regarded as unsigned. How rounding is done is not specified.(fract_convert:m x)
Represents the result of converting fixed-point value
x
to fixed-point modem
, signed integer valuex
to fixed-point modem
, floating-point valuex
to fixed-point modem
, fixed-point valuex
to integer modem
regarded as signed, or fixed-point valuex
to floating-point modem
. When overflows or underflows happen, the results are undefined.(sat_fract:m x)
Represents the result of converting fixed-point value
x
to fixed-point modem
, signed integer valuex
to fixed-point modem
, or floating-point valuex
to fixed-point modem
. When overflows or underflows happen, the results are saturated to the maximum or the minimum.(unsigned_fract_convert:m x)
Represents the result of converting fixed-point value
x
to integer modem
regarded as unsigned, or unsigned integer valuex
to fixed-point modem
. When overflows or underflows happen, the results are undefined.(unsigned_sat_fract:m x)
Represents the result of converting unsigned integer value
x
to fixed-point modem
. When overflows or underflows happen, the results are saturated to the maximum or the minimum.