From 7a10ba028a24cfc2b4a3386958067965c70a485d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Wed, 20 Jun 2012 17:09:17 +0200 Subject: [PATCH] Fixed disjoint clock computation --- compiler/global/clocks.ml | 16 ++++++++++++++++ compiler/minils/analysis/interference.ml | 16 +--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/compiler/global/clocks.ml b/compiler/global/clocks.ml index dd8216a..2185bee 100644 --- a/compiler/global/clocks.ml +++ b/compiler/global/clocks.ml @@ -143,3 +143,19 @@ let rec first_ck ct = match ct with | Ck ck -> ck | Cprod [] -> assert false | Cprod (ct::_) -> first_ck ct + +let are_disjoint ck1 ck2 = + let rec list_of_samplers acc ck = match ck with + | Cbase | Cvar _ -> acc + | Con(ck, c, x) -> list_of_samplers ((c, x)::acc) ck + in + let rec disjoint_samplers s_ck1 s_ck2 = match s_ck1, s_ck2 with + | [], _ -> false + | _ , [] -> false + | (c1, x1)::s_ck1, (c2, x2)::s_ck2 -> + if Idents.ident_compare x1 x2 <> 0 then + false + else + c1 <> c2 || disjoint_samplers s_ck1 s_ck2 + in + disjoint_samplers (list_of_samplers [] ck1) (list_of_samplers [] ck2) diff --git a/compiler/minils/analysis/interference.ml b/compiler/minils/analysis/interference.ml index 52eb8d5..ef577b3 100644 --- a/compiler/minils/analysis/interference.ml +++ b/compiler/minils/analysis/interference.ml @@ -325,20 +325,6 @@ let compute_live_vars eqs = let _, res = List.fold_left aux (VarEnv.empty, []) (List.rev eqs) in res -let rec disjoint_clock ck1 ck2 = - match Clocks.ck_repr ck1, Clocks.ck_repr ck2 with - | Cbase, Cbase -> false - | Con(ck1, c1, n1), Con(ck2,c2,n2) -> - if ck1 = ck2 & n1 = n2 & c1 <> c2 then - true - else - disjoint_clock ck1 ck2 - (*let separated_by_reset = - (match x_is_mem, y_is_mem with - | true, true -> are_separated_by_reset c1 c2 - | _, _ -> true) in *) - | _ -> false - (** [should_interfere x y] returns whether variables x and y can interfere. *) let should_interfere (ivx, ivy) = @@ -360,7 +346,7 @@ let should_interfere (ivx, ivy) = that the value of the register will be done at the end of the step. *) let disjoint_clocks = - not ((x_is_mem && not x_is_when) || (y_is_mem && not y_is_when)) && disjoint_clock ckx cky + not ((x_is_mem && not x_is_when) || (y_is_mem && not y_is_when)) && Clocks.are_disjoint ckx cky in not (disjoint_clocks or are_copies) )