Project

General

Profile

Revision 264a4844 src/inliner.ml

View differences:

src/inliner.ml
229 229
						    as arguments nodes *)
230 230
      (not selection_on_annotation || is_inline_expr expr) (* and if selection on annotation is activated, 
231 231
							      it is explicitely inlined here *)
232
    then 
232
    then (
233
      (* Format.eprintf "Inlining call to %s in expression %a@." id Printers.pp_expr expr; *)
233 234
      (* The node should be inlined *)
234 235
      (* let _ =     Format.eprintf "Inlining call to %s@." id in *)
235 236
      let called = try List.find (check_node_name id) nodes 
......
239 240
      let expr, locals', eqs'', asserts'', annots'' = 
240 241
	inline_call called' expr.expr_loc expr.expr_tag args' reset locals' node in
241 242
      expr, locals', eqs'@eqs'', asserts'@asserts'', annots'@annots''
243
    )
242 244
    else 
243 245
      (* let _ =     Format.eprintf "Not inlining call to %s@." id in *)
244 246
      { expr with expr_desc = Expr_appl(id, args', reset)}, 
......
458 460
*)
459 461
  res
460 462

  
461
let local_inline basename prog type_env clock_env =
463
let pp_inline_calls fmt prog =
462 464
  let local_anns = Annotations.get_expr_annotations keyword in
463
  if local_anns != [] then (
464
    let nodes_with_anns = List.fold_left (fun accu (k, _) -> ISet.add k accu) ISet.empty local_anns in
465
    ISet.iter (fun node_id -> Format.eprintf "Node %s has local expression annotations@." node_id) nodes_with_anns;
466
    List.fold_right (fun top accu -> 
467
      ( match top.top_decl_desc with
468
      | Node nd when ISet.mem nd.node_id nodes_with_anns ->
469
	{ top with top_decl_desc = Node (inline_node ~selection_on_annotation:true nd prog) }
470
      | _ -> top
471
      )::accu) prog []
472
    
473
)
474
 else
465
  let nodes_with_anns = List.fold_left (fun accu (k, _) -> ISet.add k accu) ISet.empty local_anns in
466
  Format.fprintf fmt "@[<v 0>Inlined expresssions in node (by tags):@ %a@]"
467
    (fprintf_list ~sep:""
468
       (fun fmt top ->
469
	 match top.top_decl_desc with
470
	 | Node nd when ISet.mem nd.node_id nodes_with_anns ->
471
	    Format.fprintf fmt "%s: {@[<v 0>%a}@]@ "
472
	      nd.node_id
473
	      (fprintf_list ~sep:"@ " (fun fmt tag -> Format.fprintf fmt "%i" tag))
474
	      (List.fold_left
475
		 (fun accu (id, tag) -> if id = nd.node_id then tag::accu else accu)
476
		 []
477
		 local_anns
478
	      )	      
479
	 (* | Node nd -> Format.fprintf fmt "%s: no inline annotations" nd.node_id *)
480
	 | _ -> ()
481
     ))
482
    prog
483
  
484
  
485
let local_inline prog (* type_env clock_env *) =
486
  Log.report ~level:2 (fun fmt -> Format.fprintf fmt ".. @[<v 2>Inlining@,");
487
  let local_anns = Annotations.get_expr_annotations keyword in
488
  let prog = 
489
    if local_anns != [] then (
490
      let nodes_with_anns = List.fold_left (fun accu (k, _) -> ISet.add k accu) ISet.empty local_anns in
491
      ISet.iter (fun node_id -> Log.report ~level:2 (fun fmt -> Format.fprintf fmt "Node %s has local expression annotations@ " node_id))
492
	nodes_with_anns;
493
      List.fold_right (fun top accu -> 
494
	( match top.top_decl_desc with
495
	| Node nd when ISet.mem nd.node_id nodes_with_anns ->
496
	   Log.report ~level:2 (fun fmt -> Format.fprintf fmt "[local inline] Processing node %s@ " nd.node_id);
497
	  let inlined_node = inline_node ~selection_on_annotation:true nd prog in
498
	  (* Format.eprintf "Before inline@.%a@.After:@.%a@." *)
499
	  (*   Printers.pp_node nd *)
500
	  (*   Printers.pp_node inlined_node; *)
501
	  { top with top_decl_desc = Node inlined_node }
502
	    
503
	| _ -> top
504
	)::accu) prog []
505
	
506
    )
507
    else (
508
      Log.report ~level:2 (fun fmt -> Format.fprintf fmt "No local inline information!@ ");
509
      prog
510
    )
511
  in
512
  Log.report ~level:2 (fun fmt -> Format.fprintf fmt "@]@,");
475 513
  prog
476 514

  
477

  
478 515
(* Local Variables: *)
479 516
(* compile-command:"make -C .." *)
480 517
(* End: *)

Also available in: Unified diff