source: driver/acc.ml @ 3014

Last change on this file since 3014 was 3014, checked in by tranquil, 7 years ago

ERTL to ERTLptr pass suppressed (it introduced a bug in the later ERTLptr to LTL), and integrated in a single ERTToLTL pass like before

File size: 3.1 KB
Line 
1open Extracted.Errors
2open ClightPrinter
3
4let string_of_pos n = string_of_int (Extracted.Glue.int_of_matitapos n)
5
6let string_of_intensional_event =
7 function
8    Extracted.StructuredTraces.IEVcost cl ->
9     "COST(k_" ^ string_of_pos cl ^") "
10  | Extracted.StructuredTraces.IEVcall id ->
11     "CALL(fun_" ^ string_of_pos id ^ ") "
12  | Extracted.StructuredTraces.IEVtailcall _ -> assert false
13  | Extracted.StructuredTraces.IEVret id ->
14     "RET(fun_" ^ string_of_pos id ^ ") "
15;;
16
17let string_of_pass =
18 function
19 | Extracted.Compiler.Clight_pass                -> "Clight_pass               "
20 | Extracted.Compiler.Clight_switch_removed_pass -> "Clight_switch_removed_pass"
21 | Extracted.Compiler.Clight_label_pass          -> "Clight_label_pass         "
22 | Extracted.Compiler.Clight_simplified_pass     -> "Clight_simplified_pass    "
23 | Extracted.Compiler.Cminor_pass                -> "Cminor_pass               "
24 | Extracted.Compiler.Rtlabs_pass                -> "Rtlabs_pass               "
25 | Extracted.Compiler.Rtl_separate_pass          -> "Rtl_separate_pass         "
26 | Extracted.Compiler.Rtl_uniq_pass              -> "Rtl_uniq_pass             "
27 | Extracted.Compiler.Ertl_pass                  -> "Ertl_pass                 "
28 | Extracted.Compiler.Ltl_pass                   -> "Ltl_pass                  "
29 | Extracted.Compiler.Lin_pass                   -> "Lin_pass                  "
30 | Extracted.Compiler.Assembly_pass              -> "Assembly_pass             "
31 | Extracted.Compiler.Object_code_pass           -> "Object_code_pass          "
32;;
33
34(*
35let argv1 = Sys.argv.(1) in
36let do_exec,filename =
37 if argv1 = "-exec" then
38  true,Sys.argv.(2)
39 else
40  false,argv1 in
41*)
42List.iter (fun filename ->
43let do_exec = Options.interpretations_requested () in
44let cl = ClightParser.process filename in
45let observe =
46 let rec infinity = Extracted.Nat.S infinity in
47 (fun pass prog ->
48   if do_exec || pass = Extracted.Compiler.Object_code_pass then
49    Printer.print_program filename pass prog;
50   if do_exec then
51    Extracted.Semantics.run_and_print pass prog infinity
52     (fun p -> print_string ("\n" ^ string_of_pass p ^ ": "); flush stdout;
53       Extracted.Types.It)
54     (fun evn -> print_string (string_of_intensional_event evn); flush stdout;
55       Extracted.Types.It)
56     (fun msg -> print_endline (Error.errormsg msg); flush stdout;
57       Extracted.Types.It)
58     (fun n-> print_endline (string_of_int(Extracted.Glue.int_of_bitvector n));
59       flush stdout; Extracted.Types.It)
60   else
61    Extracted.Types.It)
62in
63let output = 
64  match Extracted.Compiler.compile observe cl with
65  | OK o -> o
66  | Error m -> failwith (Error.errormsg m)
67in
68let labelled = output.Extracted.Compiler.c_labelled_clight in
69let l_costmap = output.Extracted.Compiler.c_clight_cost_map in
70let s_costmap = output.Extracted.Compiler.c_stack_cost in
71let style = Cost_instrumented (l_costmap,s_costmap) in
72let instrumented = ClightPrinter.print_program style labelled in
73let filename = Filename.chop_extension filename ^ "-instrumented.c" in
74let och = open_out filename in
75output_string och instrumented;
76close_out och
77) (OptionsParsing.results ())
Note: See TracBrowser for help on using the repository browser.