[sledge] Add Exp.true_ and Exp.false_

Summary: Convenience wrappers for Exp.integer.

Reviewed By: bennostein

Differential Revision: D17665234

fbshipit-source-id: 0cf440861
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent 37d1904bd3
commit ad5d5dd89e

@ -412,8 +412,7 @@ module Make (Dom : Domain_sig.Dom) = struct
~init: ~init:
( match ( match
Dom.exec_assume state Dom.exec_assume state
(Vector.fold tbl ~init:(Exp.bool true) (Vector.fold tbl ~init:Exp.true_ ~f:(fun b (case, _) ->
~f:(fun b (case, _) ->
Exp.and_ Typ.bool (Exp.dq (Exp.typ key) key case) b Exp.and_ Typ.bool (Exp.dq (Exp.typ key) key case) b
)) ))
with with

@ -389,6 +389,8 @@ let integer typ data =
let null = integer Typ.ptr Z.zero let null = integer Typ.ptr Z.zero
let bool b = integer Typ.bool (Z.of_bool b) let bool b = integer Typ.bool (Z.of_bool b)
let true_ = bool true
let false_ = bool false
let float typ data = let float typ data =
{desc= Float {data; typ}; term= Term.float data} |> check invariant {desc= Float {data; typ}; term= Term.float data} |> check invariant

@ -132,6 +132,8 @@ val nondet : Typ.t -> string -> t
val label : parent:string -> name:string -> t val label : parent:string -> name:string -> t
val null : t val null : t
val bool : bool -> t val bool : bool -> t
val true_ : t
val false_ : t
val integer : Typ.t -> Z.t -> t val integer : Typ.t -> Z.t -> t
val float : Typ.t -> string -> t val float : Typ.t -> string -> t

@ -484,7 +484,7 @@ and xlate_opcode : x -> Llvm.llvalue -> Llvm.Opcode.t -> Exp.t =
| Ule -> binary Exp.ule ) | Ule -> binary Exp.ule )
| FCmp -> ( | FCmp -> (
match Llvm.fcmp_predicate llv with match Llvm.fcmp_predicate llv with
| None | Some False -> binary (fun _ _ _ -> Exp.bool false) | None | Some False -> binary (fun _ _ _ -> Exp.false_)
| Some Oeq -> binary Exp.eq | Some Oeq -> binary Exp.eq
| Some Ogt -> binary Exp.gt | Some Ogt -> binary Exp.gt
| Some Oge -> binary Exp.ge | Some Oge -> binary Exp.ge
@ -499,7 +499,7 @@ and xlate_opcode : x -> Llvm.llvalue -> Llvm.Opcode.t -> Exp.t =
| Some Ult -> unordered_or Exp.lt | Some Ult -> unordered_or Exp.lt
| Some Ule -> unordered_or Exp.le | Some Ule -> unordered_or Exp.le
| Some Une -> unordered_or Exp.dq | Some Une -> unordered_or Exp.dq
| Some True -> binary (fun _ _ _ -> Exp.bool true) ) | Some True -> binary (fun _ _ _ -> Exp.true_) )
| Add | FAdd -> binary Exp.add | Add | FAdd -> binary Exp.add
| Sub | FSub -> binary Exp.sub | Sub | FSub -> binary Exp.sub
| Mul | FMul -> binary Exp.mul | Mul | FMul -> binary Exp.mul

@ -324,11 +324,11 @@ module Term = struct
| Throw _ | Unreachable -> assert true | Throw _ | Unreachable -> assert true
let goto ~dst ~loc = let goto ~dst ~loc =
Switch {key= Exp.bool false; tbl= Vector.empty; els= dst; loc} Switch {key= Exp.false_; tbl= Vector.empty; els= dst; loc}
|> check invariant |> check invariant
let branch ~key ~nzero ~zero ~loc = let branch ~key ~nzero ~zero ~loc =
let tbl = Vector.of_array [|(Exp.bool false, zero)|] in let tbl = Vector.of_array [|(Exp.false_, zero)|] in
let els = nzero in let els = nzero in
Switch {key; tbl; els; loc} |> check invariant Switch {key; tbl; els; loc} |> check invariant

Loading…
Cancel
Save