Skip to content
Snippets Groups Projects
Commit eb9a8c3c authored by Pierre Loic Garoche's avatar Pierre Loic Garoche
Browse files

Moved find_eq from Machine_code to Corelang and sort_eqs from Machine_code to Scheduling

parent a703ed0c
No related branches found
No related tags found
No related merge requests found
......@@ -1199,6 +1199,22 @@ let mk_fresh_var node loc ty ck =
}
in aux ()
let find_eq xl eqs =
let rec aux accu eqs =
match eqs with
| [] ->
begin
Format.eprintf "Looking for variables %a in the following equations@.%a@."
(Utils.fprintf_list ~sep:" , " (fun fmt v -> Format.fprintf fmt "%s" v)) xl
Printers.pp_node_eqs eqs;
assert false
end
| hd::tl ->
if List.exists (fun x -> List.mem x hd.eq_lhs) xl then hd, accu@tl else aux (hd::accu) tl
in
aux [] eqs
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* End: *)
......@@ -165,6 +165,8 @@ val expr_contains_expr: tag -> expr -> bool
val reset_cpt_fresh: unit -> unit
val mk_fresh_var: node_desc -> Location.t -> Types.type_expr -> Clocks.clock_expr -> var_decl
(* Local Variables: *)
val find_eq: ident list -> eq list -> eq * eq list
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* End: *)
......@@ -226,54 +226,7 @@ let translate_eq node ((m, si, j, d, s) as args) eq =
assert false
end
let find_eq xl eqs =
let rec aux accu eqs =
match eqs with
| [] ->
begin
Format.eprintf "Looking for variables %a in the following equations@.%a@."
(Utils.fprintf_list ~sep:" , " (fun fmt v -> Format.fprintf fmt "%s" v)) xl
Printers.pp_node_eqs eqs;
assert false
end
| hd::tl ->
if List.exists (fun x -> List.mem x hd.eq_lhs) xl then hd, accu@tl else aux (hd::accu) tl
in
aux [] eqs
(* Sort the set of equations of node [nd] according
to the computed schedule [sch]
*)
let sort_equations_from_schedule nd sch =
(* Format.eprintf "%s schedule: %a@." *)
(* nd.node_id *)
(* (Utils.fprintf_list ~sep:" ; " Scheduling.pp_eq_schedule) sch; *)
let eqs, auts = get_node_eqs nd in
assert (auts = []); (* Automata should be expanded by now *)
let split_eqs = Splitting.tuple_split_eq_list eqs in
let eqs_rev, remainder =
List.fold_left
(fun (accu, node_eqs_remainder) vl ->
if List.exists (fun eq -> List.exists (fun v -> List.mem v eq.eq_lhs) vl) accu
then
(accu, node_eqs_remainder)
else
let eq_v, remainder = find_eq vl node_eqs_remainder in
eq_v::accu, remainder
)
([], split_eqs)
sch
in
begin
if List.length remainder > 0 then (
let eqs, auts = get_node_eqs nd in
assert (auts = []); (* Automata should be expanded by now *)
Format.eprintf "Equations not used are@.%a@.Full equation set is:@.%a@.@?"
Printers.pp_node_eqs remainder
Printers.pp_node_eqs eqs;
assert false);
List.rev eqs_rev
end
let constant_equations nd =
List.fold_right (fun vdecl eqs ->
......@@ -292,7 +245,7 @@ let translate_eqs node args eqs =
let translate_decl nd sch =
(*Log.report ~level:1 (fun fmt -> Printers.pp_node fmt nd);*)
let schedule = sch.Scheduling_type.schedule in
let sorted_eqs = sort_equations_from_schedule nd schedule in
let sorted_eqs = Scheduling.sort_equations_from_schedule nd schedule in
let constant_eqs = constant_equations nd in
(* In case of non functional backend (eg. C), additional local variables have
......
......@@ -245,6 +245,41 @@ let pp_warning_unused fmt node_schs =
node_schs
(* Sort eqs according to schedule *)
(* Sort the set of equations of node [nd] according
to the computed schedule [sch]
*)
let sort_equations_from_schedule nd sch =
(* Format.eprintf "%s schedule: %a@." *)
(* nd.node_id *)
(* (Utils.fprintf_list ~sep:" ; " Scheduling.pp_eq_schedule) sch; *)
let eqs, auts = get_node_eqs nd in
assert (auts = []); (* Automata should be expanded by now *)
let split_eqs = Splitting.tuple_split_eq_list eqs in
let eqs_rev, remainder =
List.fold_left
(fun (accu, node_eqs_remainder) vl ->
if List.exists (fun eq -> List.exists (fun v -> List.mem v eq.eq_lhs) vl) accu
then
(accu, node_eqs_remainder)
else
let eq_v, remainder = find_eq vl node_eqs_remainder in
eq_v::accu, remainder
)
([], split_eqs)
sch
in
begin
if List.length remainder > 0 then (
let eqs, auts = get_node_eqs nd in
assert (auts = []); (* Automata should be expanded by now *)
Format.eprintf "Equations not used are@.%a@.Full equation set is:@.%a@.@?"
Printers.pp_node_eqs remainder
Printers.pp_node_eqs eqs;
assert false);
List.rev eqs_rev
end
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* End: *)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment