Project

General

Profile

Revision eb9a8c3c src/machine_code.ml

View differences:

src/machine_code.ml
226 226
       assert false
227 227
     end
228 228

  
229
let find_eq xl eqs =
230
  let rec aux accu eqs =
231
      match eqs with
232
	| [] ->
233
	  begin
234
	    Format.eprintf "Looking for variables %a in the following equations@.%a@."
235
	      (Utils.fprintf_list ~sep:" , " (fun fmt v -> Format.fprintf fmt "%s" v)) xl
236
	      Printers.pp_node_eqs eqs;
237
	    assert false
238
	  end
239
	| hd::tl ->
240
	  if List.exists (fun x -> List.mem x hd.eq_lhs) xl then hd, accu@tl else aux (hd::accu) tl
241
    in
242
    aux [] eqs
243 229

  
244
(* Sort the set of equations of node [nd] according
245
   to the computed schedule [sch]
246
*)
247
let sort_equations_from_schedule nd sch =
248
  (* Format.eprintf "%s schedule: %a@." *)
249
  (* 		 nd.node_id *)
250
  (* 		 (Utils.fprintf_list ~sep:" ; " Scheduling.pp_eq_schedule) sch; *)
251
  let eqs, auts = get_node_eqs nd in
252
  assert (auts = []); (* Automata should be expanded by now *)
253
  let split_eqs = Splitting.tuple_split_eq_list eqs in
254
  let eqs_rev, remainder =
255
    List.fold_left
256
      (fun (accu, node_eqs_remainder) vl ->
257
       if List.exists (fun eq -> List.exists (fun v -> List.mem v eq.eq_lhs) vl) accu
258
       then
259
	 (accu, node_eqs_remainder)
260
       else
261
	 let eq_v, remainder = find_eq vl node_eqs_remainder in
262
	 eq_v::accu, remainder
263
      )
264
      ([], split_eqs)
265
      sch
266
  in
267
  begin
268
    if List.length remainder > 0 then (
269
      let eqs, auts = get_node_eqs nd in
270
      assert (auts = []); (* Automata should be expanded by now *)
271
      Format.eprintf "Equations not used are@.%a@.Full equation set is:@.%a@.@?"
272
		     Printers.pp_node_eqs remainder
273
      		     Printers.pp_node_eqs eqs;
274
      assert false);
275
    List.rev eqs_rev
276
  end
277 230

  
278 231
let constant_equations nd =
279 232
 List.fold_right (fun vdecl eqs ->
......
292 245
let translate_decl nd sch =
293 246
  (*Log.report ~level:1 (fun fmt -> Printers.pp_node fmt nd);*)
294 247
  let schedule = sch.Scheduling_type.schedule in
295
  let sorted_eqs = sort_equations_from_schedule nd schedule in
248
  let sorted_eqs = Scheduling.sort_equations_from_schedule nd schedule in
296 249
  let constant_eqs = constant_equations nd in
297 250

  
298 251
  (* In case of non functional backend (eg. C), additional local variables have

Also available in: Unified diff