Project

General

Profile

Revision 15003796 src/machine_code.ml

View differences:

src/machine_code.ml
425 425
      assert false
426 426
    end
427 427

  
428
let find_eq xl eqs =
429
  let rec aux accu eqs =
430
      match eqs with
431
	| [] ->
432
	  begin
433
	    Format.eprintf "Looking for variables %a in the following equations@.%a@."
434
	      (Utils.fprintf_list ~sep:" , " (fun fmt v -> Format.fprintf fmt "%s" v)) xl
435
	      Printers.pp_node_eqs eqs;
436
	    assert false
437
	  end
438
	| hd::tl ->
439
	  if List.exists (fun x -> List.mem x hd.eq_lhs) xl then hd, accu@tl else aux (hd::accu) tl
440
    in
441
    aux [] eqs
442

  
443
(* Sort the set of equations of node [nd] according
444
   to the computed schedule [sch]
445
*)
446
let sort_equations_from_schedule nd sch =
447
(*Format.eprintf "%s schedule: %a@."
448
		 nd.node_id
449
		 (Utils.fprintf_list ~sep:" ; " Scheduling.pp_eq_schedule) sch;*)
450
  let split_eqs = Splitting.tuple_split_eq_list (get_node_eqs nd) in
451
  let eqs_rev, remainder =
452
    List.fold_left
453
      (fun (accu, node_eqs_remainder) vl ->
454
       if List.exists (fun eq -> List.exists (fun v -> List.mem v eq.eq_lhs) vl) accu
455
       then
456
	 (accu, node_eqs_remainder)
457
       else
458
	 let eq_v, remainder = find_eq vl node_eqs_remainder in
459
	 eq_v::accu, remainder
460
      )
461
      ([], split_eqs)
462
      sch
463
  in
464
  begin
465
    if List.length remainder > 0 then (
466
      Format.eprintf "Equations not used are@.%a@.Full equation set is:@.%a@.@?"
467
		     Printers.pp_node_eqs remainder
468
      		     Printers.pp_node_eqs (get_node_eqs nd);
469
      assert false);
470
    List.rev eqs_rev
471
  end
428

  
472 429

  
473 430
let constant_equations nd =
474 431
 List.fold_right (fun vdecl eqs ->
......
487 444
let translate_decl nd sch =
488 445
  (*Log.report ~level:1 (fun fmt -> Printers.pp_node fmt nd);*)
489 446

  
490
  let sorted_eqs = sort_equations_from_schedule nd sch in
447
  let sorted_eqs = Scheduling.sort_equations_from_schedule nd sch in
491 448
  let constant_eqs = constant_equations nd in
492 449
  
493 450
  let init_args = ISet.empty, [], Utils.IMap.empty, List.fold_right (fun l -> ISet.add l) nd.node_locals ISet.empty, [] in

Also available in: Unified diff