Project

General

Profile

Revision b84a138e

View differences:

src/main_lustre_compiler.ml
253 253

  
254 254
  (* Normalization phase *)
255 255
  report ~level:1 (fun fmt -> fprintf fmt ".. normalization@,");
256
  (* Special treatment of arrows in lustre backend. We want to keep them *)
257
  if !Options.output = "lustre" then
258
    Normalization.unfold_arrow_active := false;
256 259
  let prog = Normalization.normalize_prog prog in
257 260
  report ~level:2 (fun fmt -> fprintf fmt "@[<v 2>@ %a@]@," Printers.pp_prog prog);
258 261

  
......
350 353
	let fmt = formatter_of_out_channel source_out in
351 354
	Horn_backend.translate fmt basename prog machine_code
352 355
      end
353
    | "lustre" -> assert false (*
356
    | "lustre" -> 
354 357
      begin
355 358
	let source_file = destname ^ ".lustrec.lus" in (* Could be changed *)
356 359
	let source_out = open_out source_file in
357 360
	let fmt = formatter_of_out_channel source_out in
361
	Printers.pp_prog fmt prog;
358 362
(*	Lustre_backend.translate fmt basename normalized_prog machine_code *)
359 363
	()
360
      end*)
364
      end
361 365

  
362 366
    | _ -> assert false
363 367
  in
src/normalization.ml
69 69
    { expr with expr_desc = Expr_ite (expr_once loc ck, e1, e2) }
70 70
 | _                   -> assert false
71 71

  
72
let unfold_arrow_active = ref true 
72 73
let cpt_fresh = ref 0
73 74

  
74 75
(* Generate a new local [node] variable *)
......
210 211
      normalize_expr ~alias:alias node offsets defvars norm_expr
211 212
    else
212 213
      mk_expr_alias_opt (alias && not (Basic_library.is_internal_fun id)) node defvars norm_expr
213
  | Expr_arrow (e1,e2) when not (is_expr_once expr) -> (* Here we differ from Colaco paper: arrows are pushed to the top *)
214
  | Expr_arrow (e1,e2) when !unfold_arrow_active && not (is_expr_once expr) -> (* Here we differ from Colaco paper: arrows are pushed to the top *)
214 215
    normalize_expr ~alias:alias node offsets defvars (unfold_arrow expr)
215 216
  | Expr_arrow (e1,e2) ->
216 217
    let defvars, norm_e1 = normalize_expr node offsets defvars e1 in
src/printers.ml
223 223
  ()
224 224

  
225 225
let pp_node fmt nd = 
226
fprintf fmt "@[<v 0>%a%t%s %s (%a) returns (%a)@.%a%alet@.@[<h 2>   @ @[%a@]@ @]@.tel@]@."
226
fprintf fmt "@[<v 0>%a%t%s %s (%a) returns (%a)@.%a%alet@.@[<h 2>   @ @[<v>%a@]@ @]@.tel@]@."
227 227
  (fun fmt s -> match s with Some s -> pp_spec fmt s | _ -> ()) nd.node_spec
228 228
  (fun fmt -> match nd.node_spec with None -> () | Some _ -> Format.fprintf fmt "@.")
229 229
  (if nd.node_dec_stateless then "function" else "node")
src/scheduling.ml
47 47
  let succs_v = IdentDepGraph.succ g v in
48 48
  begin
49 49
    IdentDepGraph.remove_vertex g v;
50
    List.iter (fun v' -> if is_graph_root v' g then (if eq_equiv v v' then pending := ISet.add v' !pending else frontier := ISet.add v' !frontier)) succs_v;
50
    List.iter 
51
      (fun v' -> 
52
	if is_graph_root v' g then 
53
	  (if eq_equiv v v' then 
54
	      pending := ISet.add v' !pending 
55
	   else
56
	      frontier := ISet.add v' !frontier)
57
      ) succs_v;
51 58
  end
52 59

  
53 60
(* Chooses the next var to be sorted, taking priority into account.
......
106 113
	Hashtbl.find eq_equiv v1 = Hashtbl.find eq_equiv v2
107 114
      with Not_found -> false in
108 115
    let n', g = global_dependency n in
109
    Log.report ~level:5 (fun fmt -> Format.eprintf "dependency graph for node %s: %a" n'.node_id pp_dep_graph g);
116
    Log.report ~level:5 
117
      (fun fmt -> 
118
	Format.eprintf 
119
	  "dependency graph for node %s: %a" 
120
	  n'.node_id
121
	  pp_dep_graph g
122
      );
110 123
    let gg = IdentDepGraph.copy g in
111 124
    let sort = topological_sort eq_equiv g in
112 125

  
113 126
    let death = Liveness.death_table n gg sort in
114
    Log.report ~level:5 (fun fmt -> Format.eprintf "death table for node %s: %a" n'.node_id Liveness.pp_death_table death);
127
    Log.report ~level:5 
128
      (fun fmt -> 
129
	Format.eprintf 
130
	  "death table for node %s: %a" 
131
	  n'.node_id
132
	  Liveness.pp_death_table death
133
      );
115 134

  
116 135
    let disjoint = Disjunction.clock_disjoint_map (node_vars n) in
117
    Log.report ~level:5 (fun fmt -> Format.eprintf "clock disjoint map for node %s: %a" n'.node_id Disjunction.pp_disjoint_map disjoint);
136
    
137
    Log.report ~level:5 
138
      (fun fmt -> 
139
	Format.eprintf 
140
	  "clock disjoint map for node %s: %a" 
141
	  n'.node_id
142
	  Disjunction.pp_disjoint_map disjoint
143
      );
118 144

  
119 145
    let reuse = Liveness.reuse_policy n sort death in
120
    Log.report ~level:5 (fun fmt -> Format.eprintf "reuse policy for node %s: %a" n'.node_id Liveness.pp_reuse_policy reuse);
146
    Log.report ~level:5 
147
      (fun fmt -> 
148
	Format.eprintf 
149
	  "reuse policy for node %s: %a" 
150
	  n'.node_id
151
	  Liveness.pp_reuse_policy reuse
152
      );
121 153
 
122 154
    n', sort
123 155
(* let sorted = TopologicalDepGraph.fold (fun x res -> if ExprDep.is_instance_var x then res else x::res) g []*)

Also available in: Unified diff