Project

General

Profile

« Previous | Next » 

Revision 4c945dde

Added by Pierre-Loïc Garoche over 1 year ago

Improved tiny backend

View differences:

src/tools/tiny/tiny_verifier.ml
5 5
let descending = ref 1
6 6
let unrolling = ref 0
7 7
let output = ref false
8

  
8
let reachtube = ref false (* used to produce a list of set iterates *)
9 9
              
10 10
let quiet () = Tiny.Report.verbosity := 0
11 11
let report = Tiny_utils.report
......
55 55
  (* TODO: deal woth contracts, asserts, ... *)
56 56
  let bounds_inputs = [] in
57 57
  let ast = Tiny_utils.machine_to_ast bounds_inputs m in
58
  let mems = m.mmemory in
58
  (* let mems = m.mmemory in *)
59 59
  if !output then (
60 60
    let destname = !Options.dest_dir ^ "/" ^ basename ^ "_" ^ node_name ^ ".tiny" in
61 61
    report ~level:2 (fun fmt -> Format.fprintf fmt "Exporting resulting tiny source as %s@ " destname);
......
64 64
    Format.fprintf fmt "%a@." Tiny.Ast.Var.Set.pp env; 
65 65
    Format.fprintf fmt "%a@." Tiny.Ast.fprint_stm ast; 
66 66
    close_out out;
67
  
68
  
67
    
68
    
69 69
  );
70 70
  report ~level:1 (fun fmt -> Format.fprintf fmt "%a@." Tiny.Ast.fprint_stm ast); 
71 71
  
72 72
  let dom =
73
     let open Tiny.Load_domains in
74
     prepare_domains (List.map get_domain !domains)
75
   in
76
   let results = Tiny.Analyze.analyze dom !descending !unrolling env ast in
77
   let module Results = (val results: Tiny.Analyze.Results) in
78
   let module Dom = Results.Dom in
79
   let module PrintResults = Tiny.PrintResults.Make (Dom) in
80
   let m = Results.results in
81
   (* if !Tiny.Report.verbosity > 1 then *)
82
   report ~level:1 (PrintResults.print m env ast)
83
   (* no !output_file *);
84
        (* else PrintResults.print_invariants m ast !output_file *)
73
    let open Tiny.Load_domains in
74
    prepare_domains (List.map get_domain !domains)
75
  in
76
  let results = Tiny.Analyze.analyze
77
                  dom
78
                  (not !reachtube) (* when this argument is false, a
79
                                      simulation is performed*)
80
                  !descending
81
                  !unrolling
82
                  env
83
                  ast
84
  in
85
  (* if !Tiny.Report.verbosity > 1 then *)
86
  if !reachtube then (
87
    (* Print preamble *)
88
    report ~level:1 (Tiny_tube.export_to_csv env ast results);
89
    (* We produce in a folder: the csv file, the tiny file *)
90
    let destname = !Options.dest_dir ^ "/" ^ basename ^ "_" ^ node_name ^ ".csv" in
91
    report ~level:1 (fun fmt -> Format.fprintf fmt "Exporting resulting tube as %s@ " destname);
92
    let out = open_out destname in
93
    let fmt = Format.formatter_of_out_channel out in
94
    Format.fprintf fmt "%t@." (Tiny_tube.export_to_csv env ast results); 
95
    close_out out;
96
    
97
  )
98
  else
99
    let module Results = (val results: Tiny.Analyze.Results) in
100
    let module Dom = Results.Dom in
101
    let module PrintResults = Tiny.PrintResults.Make (Dom) in
102
    let m = Results.results in
103
    report ~level:1 (PrintResults.print m env ast)
104
    (* no !output_file *);
105
    (* else PrintResults.print_invariants m ast !output_file *)
85 106

  
86
   ()
107
    ()
87 108
  
88 109
  
89 110
module Verifier =
90 111
  (struct
91 112
    include VerifierType.Default
113

  
114
    (* Enforce global inline from top node *)
115
    let get_normalization_params () =
116
      Options.global_inline := true;
117
      get_normalization_params ()
118
      
92 119
    let name = "tiny"
93 120
    let options =
94 121
      [
......
128 155
         * is reached (default is 1)"); *)
129 156
      ("-unrolling", Arg.Set_int unrolling,
130 157
       "<n>  Unroll loops <n> times before computing fixpoint (default is 0)");
158
      ("-reachtube", Arg.Int (fun n -> unrolling :=n; reachtube:=true),
159
       "<n>  Unroll main loop <n> times to compute finite horizon analysis (default is invariant, with 0)");
131 160
      ("-output", Arg.Set output,
132 161
       "<n>  Export resulting tiny file as <name>_<mainnode>.tiny");
133 162
      (* (\* ("-u", Arg.Set_int unrolling,

Also available in: Unified diff