Project

General

Profile

Revision 521e2a6b src/main_lustre_compiler.ml

View differences:

src/main_lustre_compiler.ml
50 50
      (fun fmt -> fprintf fmt ".. generating compiled header file %sc@," (destname ^ extension));
51 51
    Lusic.write_lusic true header destname lusic_ext;
52 52
    Lusic.print_lusic_to_h destname lusic_ext;
53
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ @]@.")
53
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ @]@ ")
54 54
  end
55 55

  
56 56
(* check whether a source file has a compiled header,
......
91 91

  
92 92
(* From prog to prog *)
93 93
let stage1 prog dirname basename =
94
  (* Removing automata *) 
94
  (* Removing automata *)
95 95
  let prog = expand_automata prog in
96

  
97
  Log.report ~level:4 (fun fmt -> fprintf fmt ".. after automata expansion:@.@[<v 2>@ %a@]@," Printers.pp_prog prog);
96
  Log.report ~level:4 (fun fmt -> fprintf fmt ".. after automata expansion:@,  @[<v 2>@,%a@]@ " Printers.pp_prog prog);
98 97

  
99 98
  (* Importing source *)
100 99
  let _ = Modules.load_program ISet.empty prog in
......
247 246
     - introduce fresh local variables for each real pure subexpression
248 247
  *)
249 248
  (* DFS with modular code generation *)
250
  Log.report ~level:1 (fun fmt -> fprintf fmt ".. machines generation@ ");
249
  Log.report ~level:1 (fun fmt -> fprintf fmt ".. machines generation@,");
251 250
  let machine_code = Machine_code.translate_prog prog node_schs in
252 251

  
253
   (* Optimize machine code *)
252
  Log.report ~level:3 (fun fmt -> fprintf fmt ".. generated machines (unoptimized):@ %a@ "Machine_code.pp_machines machine_code);
253

  
254
  (* Optimize machine code *)
254 255
  let machine_code =
255 256
    if !Options.optimization >= 4 (* && !Options.output <> "horn" *) then
256 257
      begin
257 258
	Log.report ~level:1 
258 259
	  (fun fmt -> fprintf fmt ".. machines optimization: sub-expression elimination@,");
259
	Optimize_machine.machines_cse machine_code
260
	let machine_code = Optimize_machine.machines_cse machine_code in
261
	Log.report ~level:3 (fun fmt -> fprintf fmt ".. generated machines (sub-expr elim):@ %a@ "Machine_code.pp_machines machine_code);
262
	machine_code
260 263
      end
261 264
    else
262 265
      machine_code
......
266 269
    if !Options.optimization >= 2 (*&& !Options.output <> "horn"*) then
267 270
      begin
268 271
	Log.report ~level:1 (fun fmt -> fprintf fmt 
269
    ".. machines optimization: const. inlining (partial eval. with const)@,");
270
	Optimize_machine.machines_unfold (Corelang.get_consts prog) node_schs machine_code
272
	  ".. machines optimization: const. inlining (partial eval. with const)@,");
273
	let machine_code, removed_table = Optimize_machine.machines_unfold (Corelang.get_consts prog) node_schs machine_code in
274
	Log.report ~level:3 (fun fmt -> fprintf fmt "\t@[Eliminated constants: @[%a@]@]@ "
275
	  (pp_imap Optimize_machine.pp_elim) removed_table);
276
	Log.report ~level:3 (fun fmt -> fprintf fmt ".. generated machines (const inlining):@ %a@ "Machine_code.pp_machines machine_code);	
277
	machine_code, removed_table
271 278
      end
272 279
    else
273 280
      machine_code, IMap.empty
......
370 377
let rec compile_source dirname basename extension =
371 378
  let source_name = dirname ^ "/" ^ basename ^ extension in
372 379

  
373
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v>");
380
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 0>");
374 381

  
375 382
  (* Parsing source *)
376 383
  let prog = parse_source source_name in
......
382 389
      prog
383 390
  in
384 391
  let prog, dependencies = 
392
    Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 1 : Normalisation@,");
385 393
    try 
386 394
      stage1 prog dirname basename
387 395
    with StopPhase1 prog -> (
388 396
      if !Options.lusi then
389 397
	begin
390 398
	  let lusi_ext = extension ^ "i" in
391
	  Log.report ~level:1 (fun fmt -> fprintf fmt ".. generating interface file %s@," (basename ^ lusi_ext));
399
	  Log.report ~level:1 (fun fmt -> fprintf fmt ".. generating interface file %s@ " (basename ^ lusi_ext));
392 400
	  print_lusi prog dirname basename lusi_ext;
393 401
	  Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ @]@.");
394 402
	  exit 0
......
397 405
        assert false
398 406
    )
399 407
  in
408
  Log.report ~level:1 (fun fmt -> fprintf fmt "@]@,");
409
  Log.report ~level:3 (fun fmt -> fprintf fmt ".. Normalized program:@ %a@ "Printers.pp_prog prog);
410

  
411
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 2 : Machines generation@,");
400 412

  
401 413
  let machine_code = 
402 414
    stage2 prog 
403 415
  in
416

  
417
  Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ ");
418
  Log.report ~level:3 (fun fmt -> fprintf fmt ".. Generated machines:@ %a@ "Machine_code.pp_machines machine_code);
419

  
404 420
  if Scopes.Plugin.show_scopes () then
405 421
    begin
406 422
      let all_scopes = Scopes.compute_scopes prog !Options.main_node in
407 423
      (* Printing scopes *)
408 424
      if !Options.verbose_level >= 1 then
409 425
	Format.printf "Possible scopes are:@   ";
410
      Format.printf "@[<v>%a@ @]@.@?" Scopes.print_scopes all_scopes;
426
      Format.printf "@[<v>%a@ @]@ @?" Scopes.print_scopes all_scopes;
411 427
      exit 0
412 428
	
413 429
    end;

Also available in: Unified diff