Skip to content

Commit

Permalink
Add bitvector library (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Feb 15, 2025
1 parent 9805061 commit 9c62a6a
Show file tree
Hide file tree
Showing 77 changed files with 82 additions and 10 deletions.
1 change: 1 addition & 0 deletions bin/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(executable
(package smtml)
(name main)
(public_name smtml)
(libraries cmdliner smtml)
Expand Down
39 changes: 39 additions & 0 deletions bitvector.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Another Arbitrary-Width Bitvectors using the Zarith Library"
description: "Arbitrary-Width Bitvectors using the Zarith Library"
maintainer: ["Filipe Marques <[email protected]>"]
authors: [
"João Pereira <[email protected]>"
"Filipe Marques <[email protected]>"
"Hichem Rami Ait El Hara <[email protected]>"
"Léo Andrès <[email protected]>"
"Arthur Carcano <[email protected]>"
"Pierre Chambart <[email protected]>"
"José Fragoso Santos <[email protected]>"
]
license: "MIT"
homepage: "https://github.com/formalsec/smtml"
doc: "https://formalsec.github.io/smtml/smtml/index.html"
bug-reports: "https://github.com/formalsec/smtml/issues"
depends: [
"dune" {>= "3.10"}
"ocaml" {>= "4.14.0"}
"zartih"
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/formalsec/smtml.git"
9 changes: 9 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@

(license "MIT")

(package
(name bitvector)
(synopsis "Another Arbitrary-Width Bitvectors using the Zarith Library")
(description "Arbitrary-Width Bitvectors using the Zarith Library")
(depends
(ocaml
(>= "4.14.0"))
zartih))

(package
(name smtml)
(synopsis "An SMT solver frontend for OCaml")
Expand Down
6 changes: 3 additions & 3 deletions src/bisect.exclude
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file "src/colibri2_mappings.ml"
file "src/bitwuzla_mappings.ml"
file "src/cvc5_mappings.ml"
file "src/smtml/colibri2_mappings.ml"
file "src/smtml/bitwuzla_mappings.ml"
file "src/smtml/cvc5_mappings.ml"
10 changes: 10 additions & 0 deletions src/bitvector/bitv.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type t =
{ value : Z.t
; width : int
}

let make v m = { value = v; width = m }

let view { value; _ } = value

let numbits { width; _ } = width
7 changes: 7 additions & 0 deletions src/bitvector/bitv.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type t

val make : Z.t -> int -> t

val view : t -> Z.t

val numbits : t -> int
5 changes: 5 additions & 0 deletions src/bitvector/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(name bitvector)
(public_name bitvector)
(modules bitv)
(libraries zarith))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions src/dune → src/smtml/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
(library
(name smtml_prelude)
(public_name smtml.prelude)
(modules smtml_prelude)
(libraries prelude))

(ocamllex
(modules lexer))

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion src/expr.ml → src/smtml/expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ let concat (msb : t) (lsb : t) : t =
let rec simplify_expr ?(rm_extract = true) (hte : t) : t =
match view hte with
| Val _ | Symbol _ -> hte
| Ptr { base; offset } -> ptr base (simplify_expr offset)
| Ptr { base; offset } ->
(* FIXME: *)
binop (Ty_bitv 32) Add (value (Num (I32 base))) offset
| List es -> make @@ List (List.map simplify_expr es)
| App (x, es) -> make @@ App (x, List.map simplify_expr es)
| Unop (ty, op, e) ->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/smtml_prelude/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(name smtml_prelude)
(public_name smtml.prelude)
(modules smtml_prelude)
(libraries prelude))
File renamed without changes.

0 comments on commit 9c62a6a

Please sign in to comment.