Module Llair.Exp

Expressions

Pure (heap-independent) expressions are complex arithmetic, bitwise-logical, etc. operations over literal values and registers.

type op1 =
  1. | Signed of {
    1. bits : int;
    }
    (*

    Ap1 (Signed {bits= n}, dst, arg) is arg interpreted as an n-bit signed integer and injected into the dst type. That is, it two's-complement--decodes the low n bits of the infinite two's-complement encoding of arg. The injection into dst is a no-op, so dst must be an integer type with bitwidth at least n. This expression can also be lifted to operate element-wise over arrays. When dst is an array arg must also be an array of the same length, with element types satisfying the aforementioned constraints on integer types.

    *)
  2. | Unsigned of {
    1. bits : int;
    }
    (*

    Ap1 (Unsigned {bits= n}, dst, arg) is arg interpreted as an n-bit unsigned integer and injected into the dst type. That is, it unsigned-binary--decodes the low n bits of the infinite two's-complement encoding of arg. The injection into dst is a no-op, so dst must be an integer type with bitwidth greater than n. This expression can be lifted to arrays, as described for Signed just above.

    *)
  3. | Splat
    (*

    Iterated concatenation of a single byte

    *)
  4. | Select of int
    (*

    Select an index from a record

    *)
val compare_op1 : op1 -> op1 -> int
val equal_op1 : op1 -> op1 -> bool
val sexp_of_op1 : op1 -> Sexplib0.Sexp.t
val op1_of_sexp : Sexplib0.Sexp.t -> op1
type op2 =
  1. | Eq
    (*

    Equal test

    *)
  2. | Dq
    (*

    Disequal test

    *)
  3. | Gt
    (*

    Greater-than test

    *)
  4. | Ge
    (*

    Greater-than-or-equal test

    *)
  5. | Lt
    (*

    Less-than test

    *)
  6. | Le
    (*

    Less-than-or-equal test

    *)
  7. | Ugt
    (*

    Unsigned greater-than test

    *)
  8. | Uge
    (*

    Unsigned greater-than-or-equal test

    *)
  9. | Ult
    (*

    Unsigned less-than test

    *)
  10. | Ule
    (*

    Unsigned less-than-or-equal test

    *)
  11. | Ord
    (*

    Ordered test (neither arg is nan)

    *)
  12. | Uno
    (*

    Unordered test (some arg is nan)

    *)
  13. | Add
    (*

    Addition

    *)
  14. | Sub
    (*

    Subtraction

    *)
  15. | Mul
    (*

    Multiplication

    *)
  16. | Div
    (*

    Division, for integers result is truncated toward zero

    *)
  17. | Rem
    (*

    Remainder of division, satisfies a = b * div a b + rem a b and for integers rem a b has same sign as a, and |rem a b| < |b|

    *)
  18. | Udiv
    (*

    Unsigned division

    *)
  19. | Urem
    (*

    Remainder of unsigned division

    *)
  20. | And
    (*

    Conjunction, boolean or bitwise

    *)
  21. | Or
    (*

    Disjunction, boolean or bitwise

    *)
  22. | Xor
    (*

    Exclusive-or, bitwise

    *)
  23. | Shl
    (*

    Shift left, bitwise

    *)
  24. | Lshr
    (*

    Logical shift right, bitwise

    *)
  25. | Ashr
    (*

    Arithmetic shift right, bitwise

    *)
  26. | Update of int
    (*

    Constant record with updated index

    *)
val compare_op2 : op2 -> op2 -> int
val equal_op2 : op2 -> op2 -> bool
val sexp_of_op2 : op2 -> Sexplib0.Sexp.t
val op2_of_sexp : Sexplib0.Sexp.t -> op2
type op3 =
  1. | Conditional
    (*

    If-then-else

    *)
val compare_op3 : op3 -> op3 -> int
val equal_op3 : op3 -> op3 -> bool
val sexp_of_op3 : op3 -> Sexplib0.Sexp.t
val op3_of_sexp : Sexplib0.Sexp.t -> op3
type opN =
  1. | Record
    (*

    Record (array / struct) constant

    *)
val compare_opN : opN -> opN -> int
val equal_opN : opN -> opN -> bool
val sexp_of_opN : opN -> Sexplib0.Sexp.t
val opN_of_sexp : Sexplib0.Sexp.t -> opN
type t = private
  1. | Label of {
    1. parent : string;
    2. name : string;
    }
    (*

    Address of named code block within parent function

    *)
include Ppx_compare_lib.Comparable.S with type t := t
val compare : t Base__Ppx_compare_lib.compare
include Ppx_compare_lib.Equal.S with type t := t
val equal : t Base__Ppx_compare_lib.equal
include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
val pp : t NS.pp
include NS.Invariant.S with type t := t
val invariant : t -> unit
val demangle : (string -> string option) Stdlib.ref
module Reg : sig ... end

Exp.Reg is re-exported as Reg

module Global : sig ... end

Exp.Global is re-exported as Global

module FuncName : sig ... end

Exp.FuncName is re-exported as FuncName

Construct

val reg : Reg.t -> t
val funcname : FuncName.t -> t
val global : Global.t -> t
val label : parent:string -> name:string -> t
val null : t
val bool : bool -> t
val true_ : t
val false_ : t
val integer : Llair__.LlairTyp.t -> NS.Z.t -> t
val float : Llair__.LlairTyp.t -> string -> t
val signed : int -> t -> to_:Llair__.LlairTyp.t -> t
val unsigned : int -> t -> to_:Llair__.LlairTyp.t -> t
val convert : Llair__.LlairTyp.t -> to_:Llair__.LlairTyp.t -> t -> t
val eq : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val dq : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val gt : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val ge : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val lt : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val le : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val ugt : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val uge : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val ult : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val ule : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val ord : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val uno : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val add : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val sub : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val mul : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val div : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val rem : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val udiv : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val urem : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val and_ : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val or_ : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val xor : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val shl : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val lshr : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val ashr : ?typ:Llair__.LlairTyp.t -> t -> t -> t
val conditional : Llair__.LlairTyp.t -> cnd:t -> thn:t -> els:t -> t
val splat : Llair__.LlairTyp.t -> t -> t
val record : Llair__.LlairTyp.t -> t NS.iarray -> t
val select : Llair__.LlairTyp.t -> t -> int -> t
val update : Llair__.LlairTyp.t -> rcd:t -> int -> elt:t -> t

Traverse

val fold_exps : t -> 's -> f:(t -> 's -> 's) -> 's
val fold_regs : t -> 's -> f:(Reg.t -> 's -> 's) -> 's

Query

val is_true : t -> bool
val is_false : t -> bool
val typ_of : t -> Llair__.LlairTyp.t