Module Cmm_helpers.Scalar_type
This module defines the various kinds of scalars usable in Cmm. It also provides ways to generate expressions to cast between them.
type 'a static_cast :=
dbg:Debuginfo.t ->
src:'a ->
dst:'a ->
Cmm.expression ->
Cmm.expressionA static_cast from a larger integral type to a smaller one logically truncates the upper bits. Note that values are stored in registers sign- or zero- extended according to their signdness, so the result may be sign-extended.
A static_cast from a smaller integral type to an equal or larger sized-integral type sign- or zero-extends the input value according to the sign of the result.
A static_cast from an integral type to a float is pretty self-explanatory.
A static_cast from a float to an integral type always rounds toward zero. If the resulting integral does not fit in the destination type, the result is unspecified (although it's generally zero).
Casting floats to/from unsigned register-width integers is not implemented and will raise in the compiler.
type 'a conjugate :=
outer:'a ->
inner:'a ->
dbg:Debuginfo.t ->
f:(Cmm.expression -> Cmm.expression) ->
Cmm.expression ->
Cmm.expressionConjugate f by static_cast ~src:outer ~dst:inner.
Shorthand for:
static_castthe argument fromoutertoinner- apply
f static_castback frominnertoouter
module Float_width : sig ... endAn IEEE 754 floating-point number
module Signedness : sig ... endmodule type Integral_ops := sig ... endmodule Integer : sig ... endAn integer stored the lower bits bits of a register-width twos-complement integer, and sign- or zero-extended as needed, according to signedness.
module Tagged_integer : sig ... endAn Integer.t but with the additional stipulation that its lowest bit is always set to 1 and is not considered in mathematical operations on the numbers.
module Integral : sig ... endtype t = | Integral of Cmm_helpers.Scalar_type.Integral.t| Float of Cmm_helpers.Scalar_type.Float_width.t
val static_cast : Cmm_helpers.Scalar_type.t Cmm_helpers.Scalar_type.static_castval conjugate : Cmm_helpers.Scalar_type.t Cmm_helpers.Scalar_type.conjugatemodule Untagged : sig ... end