Module Bap_wp.Bil_to_bir

This module provides utilities to translate from a BIL Bil.t expression to a BIR subroutine, for which we can then invoke Precondition.visit_sub to get the weakest precondition.

This enables using the clean BIL embedded DSL syntax, e.g.

Bil.([
    v := src lsr i32 1;
    r := src;
    s := i32 31;
    while_ (var v <> i32 0) [
      r := var r lsl i32 1;
      r := var r lor (var v land i32 1);
      v := var v lsr i32 1;
      s := var s - i32 1;
    ];
    dst := var r lsl var s;
  ]) |> bil_to_sub

As in the BAP documentation, to build subroutines.

val mk_assert_fail : unit -> Bap.Std.sub Bap.Std.term * Bap.Std.exp

Create a pair of a subroutine with name __assert_fail and an expression which represents an invocation of that subroutine.

A subsequent call to bil_to_sub will correctly translate that expression to a BIR call expression.

val bil_to_sub : Bap.Std.bil -> Bap.Std.sub Bap.Std.term

Take a BIL program (a list of statements) and turn it into a subroutine.

val call : Bap.Std.sub Bap.Std.term -> Bap.Std.typ -> Bap.Std.Bil.Types.stmt

Take a sub term and a type for the term to build a BIL function-call