Schedule with clocks first

First optimize clocks and then look at life ranges
This commit is contained in:
Cédric Pasteur 2012-01-24 15:33:54 +01:00
parent 06e997e0c8
commit 3f80f844c7

View file

@ -65,18 +65,20 @@ struct
nb_def_vars - nb_killed_vars + b
in
let eqs_wcost = List.map (fun eq -> (eq, cost eq)) rem_eqs in
let compare_eqs_wcost (_,c1) (_,c2) = compare c1 c2 in
let sorted_eqs_wcost = List.stable_sort compare_eqs_wcost eqs_wcost in
let rec min_same_ck sorted_eqs = match sorted_eqs with
| [] -> Misc.internal_error "no next equation to schedule"
| [(eq,_)] -> eq
| (eq1,c1)::(eq2,c2)::l ->
if (c2 > c1) || (Clocks.same_control (eq_clock eq1) ck)
then eq1 (* choosen since either the last with min cost or min and right clock *)
else min_same_ck ((eq2,c2)::l)
(* returns the minimum element of the list with same_ctrl = true. If there is no such element,
return the minimum of the list. *)
let rec min_same_ck (min_eq, min_c, min_same_ctrl) l = match l with
| [] -> min_eq
| (eq, c, same_ctrl)::l ->
if (c < min_c && (same_ctrl = min_same_ctrl)) or (same_ctrl && not min_same_ctrl) then
min_same_ck (eq, c, same_ctrl) l
else
min_same_ck (min_eq, min_c, min_same_ctrl) l
in
min_same_ck sorted_eqs_wcost
let eqs_wcost =
List.map (fun eq -> (eq, cost eq, Clocks.same_control (eq_clock eq) ck)) rem_eqs in
let (eq, c, same_ctrl), eqs_wcost = Misc.assert_1min eqs_wcost in
min_same_ck (eq, c, same_ctrl) eqs_wcost
end
(** Returns the list of 'free' nodes in the dependency graph (nodes without
@ -140,9 +142,6 @@ let node _ () f =
f, ()
let program p =
let mall = !Compiler_options.interf_all in
(* Compiler_options.interf_all := false; *)
let funs = { Mls_mapfold.defaults with Mls_mapfold.node_dec = node } in
let p, () = Mls_mapfold.program_it funs () p in
Compiler_options.interf_all := mall;
p