Skip to content

Commit 834df31

Browse files
committed
Extract solvers to goblint_solver dune library
1 parent 07009f0 commit 834df31

File tree

9 files changed

+65
-42
lines changed

9 files changed

+65
-42
lines changed

scripts/goblint-lib-modules.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
goblint_lib_paths = [
1010
src_root_path / "goblint_lib.ml",
11+
src_root_path / "solvers" / "goblint_solver.ml",
1112
src_root_path / "util" / "std" / "goblint_std.ml",
1213
]
1314
goblint_lib_modules = set()
@@ -33,6 +34,7 @@
3334

3435
# libraries
3536
"Goblint_std",
37+
"Goblint_solver",
3638
"Goblint_timing",
3739
"Goblint_backtrace",
3840
"Goblint_tracing",

src/analyses/base.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ struct
28712871
| "once" ->
28722872
f (D.bot ())
28732873
| "fixpoint" ->
2874-
let module DFP = LocalFixpoint.Make (D) in
2874+
let module DFP = Goblint_solver.LocalFixpoint.Make (D) in
28752875
DFP.lfp f
28762876
| _ ->
28772877
assert false

src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(name goblint_lib)
88
(public_name goblint.lib)
99
(modules :standard \ goblint privPrecCompare apronPrecCompare messagesCompare)
10-
(libraries goblint.sites goblint.build-info goblint-cil.all-features batteries.unthreaded qcheck-core.runner sha json-data-encoding jsonrpc cpu arg-complete fpath yaml yaml.unix uuidm goblint_timing catapult goblint_backtrace fileutils goblint_std goblint_config goblint_common goblint_domain goblint_constraint goblint_library goblint_incremental goblint_tracing
10+
(libraries goblint.sites goblint.build-info goblint-cil.all-features batteries.unthreaded qcheck-core.runner sha json-data-encoding jsonrpc cpu arg-complete fpath yaml yaml.unix uuidm goblint_timing catapult goblint_backtrace fileutils goblint_std goblint_config goblint_common goblint_domain goblint_constraint goblint_solver goblint_library goblint_incremental goblint_tracing
1111
; Conditionally compile based on whether apron optional dependency is installed or not.
1212
; Alternative dependencies seem like the only way to optionally depend on optional dependencies.
1313
; See: https://dune.readthedocs.io/en/stable/concepts.html#alternative-dependencies.

src/framework/control.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct
8585
let save_run = let o = get_string "save_run" in if o = "" then (if gobview then "run" else "") else o in
8686
save_run <> ""
8787
end
88-
module Slvr = (GlobSolverFromEqSolver (Selector.Make (PostSolverArg))) (EQSys) (LHT) (GHT)
88+
module Slvr = (GlobSolverFromEqSolver (Goblint_solver.Selector.Make (PostSolverArg))) (EQSys) (LHT) (GHT)
8989
(* The comparator *)
9090
module CompareGlobSys = Constraints.CompareGlobSys (SpecSys)
9191

@@ -476,7 +476,7 @@ struct
476476
let save_run_str = let o = get_string "save_run" in if o = "" then (if gobview then "run" else "") else o in
477477

478478
let lh, gh = if load_run <> "" then (
479-
let module S2' = (GlobSolverFromEqSolver (Generic.LoadRunIncrSolver (PostSolverArg))) (EQSys) (LHT) (GHT) in
479+
let module S2' = (GlobSolverFromEqSolver (Goblint_solver.Generic.LoadRunIncrSolver (PostSolverArg))) (EQSys) (LHT) (GHT) in
480480
let (r2, _) = S2'.solve entrystates entrystates_global startvars' None in (* TODO: has incremental data? *)
481481
r2
482482
) else if compare_runs <> [] then (
@@ -582,7 +582,7 @@ struct
582582
let (r2, _) = S2'.solve entrystates entrystates_global startvars' None in (* TODO: has incremental data? *)
583583
CompareGlobSys.compare (get_string "solver", get_string "comparesolver") (lh,gh) (r2)
584584
in
585-
compare_with (Selector.choose_solver (get_string "comparesolver"))
585+
compare_with (Goblint_solver.Selector.choose_solver (get_string "comparesolver"))
586586
);
587587

588588
(* Most warnings happen before during postsolver, but some happen later (e.g. in finalize), so enable this for the rest (if required by option). *)

src/goblint_lib.ml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -288,41 +288,6 @@ module Serialize = Serialize
288288
module CilMaps = CilMaps
289289

290290

291-
(** {1 Solvers}
292-
293-
Generic solvers are used to solve {{!Analyses.MonSystem} (side-effecting) constraint systems}. *)
294-
295-
(** {2 Top-down}
296-
297-
The top-down solver family. *)
298-
299-
module Td3 = Td3
300-
module TopDown = TopDown
301-
module TopDown_term = TopDown_term
302-
module TopDown_space_cache_term = TopDown_space_cache_term
303-
module TopDown_deprecated = TopDown_deprecated
304-
305-
(** {2 SLR}
306-
307-
The SLR solver family. *)
308-
309-
module SLRphased = SLRphased
310-
module SLRterm = SLRterm
311-
module SLR = SLR
312-
313-
(** {2 Other} *)
314-
315-
module EffectWConEq = EffectWConEq
316-
module Worklist = Worklist
317-
module Generic = Generic
318-
module Selector = Selector
319-
320-
module PostSolver = PostSolver
321-
module LocalFixpoint = LocalFixpoint
322-
module SolverStats = SolverStats
323-
module SolverBox = SolverBox
324-
325-
326291
(** {1 I/O}
327292
328293
Various input/output interfaces and formats. *)

src/index.mld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ This {{!page-domain}unwrapped library} contains various domain modules extracted
1919
{2 Library goblint.constraint}
2020
This {{!page-constraint}unwrapped library} contains various constraint system modules extracted from {!Goblint_lib}.
2121

22+
{2 Library goblint.solver}
23+
{!modules:Goblint_solver}
24+
2225
{2 Library goblint.library}
2326
This {{!page-library}unwrapped library} contains various library specification modules extracted from {!Goblint_lib}.
2427

src/maingoblint.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,15 @@ let preprocess_parse_merge () =
513513
let do_stats () =
514514
if get_bool "dbg.timing.enabled" then (
515515
print_newline ();
516-
SolverStats.print ();
516+
Goblint_solver.SolverStats.print ();
517517
print_newline ();
518518
print_string "Timings:\n";
519519
Timing.Default.print (Stdlib.Format.formatter_of_out_channel @@ Messages.get_out "timing" Legacy.stderr);
520520
flush_all ()
521521
)
522522

523523
let reset_stats () =
524-
SolverStats.reset ();
524+
Goblint_solver.SolverStats.reset ();
525525
Timing.Default.reset ();
526526
Timing.Program.reset ()
527527

src/solvers/dune

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(include_subdirs no)
2+
3+
(library
4+
(name goblint_solver)
5+
(public_name goblint.solver)
6+
(libraries
7+
batteries.unthreaded
8+
goblint_std
9+
goblint_common
10+
goblint_domain
11+
goblint_constraint
12+
goblint_incremental
13+
goblint-cil)
14+
(flags :standard -open Goblint_std)
15+
(preprocess
16+
(pps
17+
ppx_deriving.std
18+
ppx_deriving_hash
19+
ppx_deriving_yojson))
20+
(instrumentation (backend bisect_ppx)))
21+
22+
(documentation)

src/solvers/goblint_solver.ml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(** Generic solvers for {{!ConstrSys.MonSystem} (side-effecting) constraint systems}. *)
2+
3+
(** {1 Top-down}
4+
5+
The top-down solver family. *)
6+
7+
module Td3 = Td3
8+
module TopDown = TopDown
9+
module TopDown_term = TopDown_term
10+
module TopDown_space_cache_term = TopDown_space_cache_term
11+
module TopDown_deprecated = TopDown_deprecated
12+
13+
(** {1 SLR}
14+
15+
The SLR solver family. *)
16+
17+
module SLRphased = SLRphased
18+
module SLRterm = SLRterm
19+
module SLR = SLR
20+
21+
(** {1 Other} *)
22+
23+
module EffectWConEq = EffectWConEq
24+
module Worklist = Worklist
25+
module Generic = Generic
26+
module Selector = Selector
27+
28+
module PostSolver = PostSolver
29+
module LocalFixpoint = LocalFixpoint
30+
module SolverStats = SolverStats
31+
module SolverBox = SolverBox

0 commit comments

Comments
 (0)