Clean-up of verbose output

Leave only comments about compilation passes.
Remove output of intermediate code on standard output: added
generation of <module>.log containing all intermediate code.
This commit is contained in:
Gwenaël Delaval 2017-05-23 11:37:30 +02:00
parent 63e090633c
commit 028c564a31
7 changed files with 49 additions and 38 deletions

View file

@ -30,9 +30,10 @@
open Compiler_options
open Compiler_utils
let pp p = if !verbose then Hept_printer.print stdout p
let compile_program p log_c =
let pp p = if !verbose then Hept_printer.print log_c p in
let compile_program p =
(* Typing *)
let p = silent_pass "Statefulness check" true Stateful.program p in
let p = silent_pass "Unsafe check" true Unsafe.program p in

View file

@ -31,8 +31,6 @@ open Compiler_options
open Compiler_utils
open Location
let pp p = if !verbose then Hept_printer.print stdout p
let parse parsing_fun lexbuf =
try
parsing_fun Hept_lexer.token lexbuf
@ -46,7 +44,10 @@ let parse parsing_fun lexbuf =
syntax_error l
(** Parse an implementation [lexbuf] *)
let parse_program modname lexbuf =
let parse_program modname lexbuf out_log =
let pp p = if !verbose then Hept_printer.print out_log p in
(* Parsing of the file *)
let p = do_silent_pass "Parsing" (parse Hept_parser.program) lexbuf in
let p = { p with Hept_parsetree.p_modname = modname } in

View file

@ -67,12 +67,19 @@ let compile_program modname source_f =
let output = String.uncapitalize_ascii modname in
let epci_f = output ^ ".epci" in
let mls_f = output ^ ".mls" in
let log_f = output ^ ".log" in
(* input/output channels *)
let source_c, lexbuf = lexbuf_from_file source_f in
let epci_c = open_out_bin epci_f in
let mls_c = open_out mls_f in
let close_all_files () = close_in source_c; close_out epci_c; close_out mls_c in
let log_c = open_out log_f in
let close_all_files () =
close_in source_c;
close_out epci_c;
close_out mls_c;
close_out log_c
in
try
(* Activates passes according to the backend used *)
@ -80,19 +87,20 @@ let compile_program modname source_f =
(* Record timing information *)
Compiler_timings.start_compiling modname;
(* Process the [lexbuf] to an Heptagon AST *)
let p = Hept_parser_scoper.parse_program modname lexbuf in
let p = Hept_parser_scoper.parse_program modname lexbuf log_c in
(* Process the Heptagon AST *)
let p = Hept_compiler.compile_program p in
let p = Hept_compiler.compile_program p log_c in
(* Compile Heptagon to MiniLS *)
let p = do_pass "Translation into MiniLS" Hept2mls.program p Mls_compiler.pp in
let p = do_pass "Translation into MiniLS"
Hept2mls.program p (Mls_compiler.pp log_c) in
(* Output the .mls *)
do_silent_pass "MiniLS serialization" (fun () -> Mls_printer.print mls_c p) ();
(* Process the MiniLS AST *)
let p = Mls_compiler.compile_program p in
let p = Mls_compiler.compile_program p log_c in
(* Output the .epci *)
output_value epci_c (Modules.current_module ());
(* Generate the sequential code *)
Mls2seq.program p;
Mls2seq.program p log_c;
close_all_files ();
Compiler_timings.report_statistics ()
with x -> close_all_files (); raise x

View file

@ -102,7 +102,7 @@ let find_target s =
Not_found -> language_error s; raise Errors.Error
let generate_target p s =
let generate_target p out s =
(* let print_unfolded p_list =
comment "Unfolding";
if !Compiler_options.verbose
@ -116,7 +116,7 @@ let generate_target p s =
do_silent_pass "Code generation from MiniLS" convert_fun p
| Obc convert_fun ->
let o = mls2obc p in
let o = Obc_compiler.compile_program o in
let o = Obc_compiler.compile_program out o in
do_silent_pass "Code generation from Obc" convert_fun o
| Minils_no_params convert_fun ->
let p_list = callgraph p in
@ -124,7 +124,7 @@ let generate_target p s =
| Obc_no_params convert_fun ->
let p_list = callgraph p in
let o_list = mls2obc_list p_list in
let o_list = List.map Obc_compiler.compile_program o_list in
let o_list = List.map (Obc_compiler.compile_program out) o_list in
do_silent_pass "Code generation from Obc (w/o params)" List.iter convert_fun o_list
| Disabled_target ->
warn "ignoring unavailable target `%s'." name
@ -144,12 +144,12 @@ let load_conf () =
with Arg.Bad m -> raise (Arg.Bad ("After loading target configurations: "^m))
(** Translation into dataflow and sequential languages, defaults to obc. *)
let program p =
let program p out =
let targets = match !target_languages with
| [] -> ["obc"] (* by default, generate obc file *)
| l -> l in
let targets = if !create_object_file then "epo"::targets else targets in
List.iter (generate_target p) targets
List.iter (generate_target p out) targets
let interface i =
let targets = match !target_languages with

View file

@ -30,7 +30,7 @@
open Compiler_utils
open Compiler_options
let pp p = if !verbose then Mls_printer.print stdout p
let pp out p = if !verbose then Mls_printer.print out p
;; IFDEF ENABLE_CTRLN THEN
@ -58,17 +58,20 @@ let gen_n_output_ctrln p =
end nodes;
p
let maybe_ctrln_pass p =
let maybe_ctrln_pass p pp =
let ctrln = List.mem "ctrln" !target_languages in
pass "Controllable Nbac generation" ctrln gen_n_output_ctrln p pp
;; ELSE
let maybe_ctrln_pass p = p
let maybe_ctrln_pass p pp = p
;; END
let compile_program p =
let compile_program p log_c =
let pp p = pp log_c p in
(* Clocking *)
let p =
try pass "Clocking" true Clocking.program p pp
@ -113,7 +116,7 @@ let compile_program p =
if z3z && ctrln then
warn "ignoring target `ctrln' (incompatible with target `z3z').";
let p = maybe_ctrln_pass p in
let p = maybe_ctrln_pass p pp in
let p = pass "Sigali generation" z3z Sigalimain.program p pp in
(* Re-scheduling after generation *)

View file

@ -11,8 +11,6 @@ let mk_var ty name =
let program p =
(*Scalarize*)
let p = Compiler_utils.pass "Scalarize" true Scalarize.program p Obc_compiler.pp in
let p_java = Obc2java14.program p in
let dir = Compiler_utils.build_path "java" in
Compiler_utils.ensure_dir dir;
@ -68,7 +66,7 @@ let program p =
let jbool = Eclass(Names.qualname_of_string "Boolean") in
let jsys = Eclass(Names.qualname_of_string "java.lang.System") in
let jminus = pervasives_qn "-" in
let jplus = pervasives_qn "+" in
let jplus = pervasives_qn "+" in
(* parse arguments to give to the main *)
let rec parse_args t_l i = match t_l with
@ -91,16 +89,16 @@ let program p =
(* no more arg to give to main, the last one if it exists is the iteration nb *)
Aifelse(Efun(Names.pervasives_qn ">", [ Efield (exp_args, "length"); Sint t_size ]),
(* given max number of iterations *)
mk_block [Aassgn(pat_step,
Emethod_call(jint, "parseInt", [get_arg t_size]))],
mk_block [Aassgn(pat_step,
Emethod_call(jint, "parseInt", [get_arg t_size]))],
(* default max number of iterations *)
mk_block [Aassgn(pat_step, Evar id_step_dnb)]);
mk_block [Aassgn(pat_step, Evar id_step_dnb)]);
in
let ret = Emethod_call(e_main, "step", []) in
let main_for_loop _ =
(* [Aexp (Emethod_call(out, "printf", *)
(* [Sstring "%d => %s\\n"; Evar i; print_ret]))] *)
[Aexp ret]
(* [Sstring "%d => %s\\n"; Evar i; print_ret]))] *)
[Aexp ret]
in
let vd_t1, e_t1 =
let id = Idents.gen_var "java_main" "t" in
@ -111,11 +109,11 @@ let program p =
Anewvar(vd_t1, Emethod_call(jsys, "currentTimeMillis", []));
Obc2java14.fresh_for exp_step main_for_loop;
Aexp (Emethod_call(out, "print",
[ Efun(jplus,
[Sstring "time : %d\\n";
Efun(jminus,
[Emethod_call(jsys, "currentTimeMillis", []);
e_t1])])]))
[ Efun(jplus,
[Sstring "time : %d\\n";
Efun(jminus,
[Emethod_call(jsys, "currentTimeMillis", []);
e_t1])])]))
]
in
mk_block ~locals:[vd_step] acts

View file

@ -29,9 +29,9 @@
open Compiler_utils
open Compiler_options
let pp p = if !verbose then Obc_printer.print stdout p
let compile_program out p =
let compile_program p =
let pp p = if !verbose then Obc_printer.print out p in
(* Memory allocation application *)
let p = pass "Application of Memory Allocation"
@ -45,8 +45,8 @@ let compile_program p =
(*Dead code removal*)
let p = pass "Dead code removal"
(!do_mem_alloc || !do_linear_typing || !deadcode)
Deadcode.program p pp in
(!do_mem_alloc || !do_linear_typing || !deadcode)
Deadcode.program p pp in
(*Control optimization*)
let p = pass "Control optimization" true Control.program p pp in