package libsail

  1. Overview
  2. Docs
Sail is a language for describing the instruction semantics of processors

Install

dune-project
 Dependency

Authors

Maintainers

Sources

sail-0.19.1.tbz
sha256=5e99698b6367c018133c90aaed2ceff173de20db6e61c33e2b19594a1d482a32
sha512=4de32379ae0a35a1e8ccb9ddd42147e5af88f595e18bde4c5ed635ccf511fffdcc203910732b818069e2c65e399223b79147a600f37aeb9df0f7779ba9ef323a

doc/libsail/Libsail/Smt_gen/index.html

Module Libsail.Smt_genSource

Compile Sail builtins to SMT bitvector expressions

Sourcetype checks

The main limitiation when converting Sail into pure SMT bitvectors is that Sail has arbitrary precision types, as well as types like real and string that are not very SMT friendly. We can add dynamic assertions that effectivly check at runtime that we never exceed some upper bound on bitvector size, and log if we ever use features like strings or real numbers.

Sourceval get_overflows : checks -> Smt_exp.smt_exp list
Sourcetype 'a check_writer

We generate primitives in a monad that accumulates any required dynamic checks, and contains the location information for any error messages.

Sourceval current_location : Parse_ast.l check_writer

The SMT generation monad contains the location of the expression or definition we are generating SMT for

Get the Jib context during SMT generation

Sourceval return : 'a -> 'a check_writer
Sourceval bind : 'a check_writer -> ('a -> 'b check_writer) -> 'b check_writer
Sourceval fmap : ('a -> 'b) -> 'a check_writer -> 'b check_writer
Sourceval (let*) : 'a check_writer -> ('a -> 'b check_writer) -> 'b check_writer
Sourceval (let+) : 'a check_writer -> ('a -> 'b) -> 'b check_writer
Sourceval mapM : ('a -> 'b check_writer) -> 'a list -> 'b list check_writer
Sourceval iterM : ('a -> unit check_writer) -> 'a list -> unit check_writer
Sourceval mk_check_writer : (Parse_ast.l -> Jib_compile.ctx -> 'a * checks) -> 'a check_writer
Sourceval string_used : unit check_writer
Sourceval real_used : unit check_writer
Sourceval signed_size : ?checked:bool -> into:int -> from:int -> Smt_exp.smt_exp -> Smt_exp.smt_exp check_writer

Convert a SMT bitvector expression of size from into a SMT bitvector expression of size into with the same signed value. When into < from inserts a dynamic check that the original value is representable at the new length.

Sourceval unsigned_size : ?max_value:int -> ?checked:bool -> into:int -> from:int -> Smt_exp.smt_exp -> Smt_exp.smt_exp check_writer

Similar to signed_size, except it assumes the bitvector is representing an unsigned value.

Sourceval bvint : int -> Libsail.Ast_util.Big_int.num -> Smt_exp.smt_exp

bvint sz n Create a (two's complement) SMT bitvector representing a the number n in a bitvector of length sz. Raises an error if this is not possible.

Sourcemodule type CONFIG = sig ... end
Sourcemodule type PRIMOP_GEN = sig ... end

Some Sail primitives we can't directly convert to pure SMT definitions, either because they don't exist in SMTLIB (like count_leading_zeros), or they involve input/output. In these cases we provide a module so the backend can provide callbacks to generate the required implementations for these primitives.

Sourcetype undefined_mode =
  1. | Undefined_zeros
  2. | Undefined_bits
  3. | Undefined_disable

We have various options for handling undefined bits for SMT generation, either we can treat them all as zero (which is consistent with the default emulator behavior), or generated undefined bits, or have the builtin generator skip these functions.

Sourcemodule Make (Config : CONFIG) (Primop_gen : PRIMOP_GEN) : sig ... end
OCaml

Innovation. Community. Security.