jon.recoil.org

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.expression

A 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.expression

Conjugate f by static_cast ~src:outer ~dst:inner.

Shorthand for:

  • static_cast the argument from outer to inner
  • apply f
  • static_cast back from inner to outer
module Float_width : sig ... end

An IEEE 754 floating-point number

module Signedness : sig ... end
module type Integral_ops := sig ... end
module Integer : sig ... end

An 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 ... end

An 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 ... end
module Untagged : sig ... end