From 01d0cd02c3946912a56e526ca5a70dae49ca4cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Wed, 30 Jun 2010 13:46:46 +0200 Subject: [PATCH] Remove bounds hack in Eselect_dyn We no longer need to store the bounds as the bounds check expression is generated from MiniLS code where the type is directly available. --- compiler/main/hept2mls.ml | 6 +----- compiler/minils/analysis/clocking.ml | 2 +- compiler/minils/minils.ml | 2 +- compiler/minils/mls_printer.ml | 2 +- compiler/minils/mls_utils.ml | 2 +- compiler/minils/sequential/mls2obc.ml | 3 ++- compiler/minils/transformations/callgraph.ml | 2 +- compiler/minils/transformations/normalize.ml | 4 ++-- 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/compiler/main/hept2mls.ml b/compiler/main/hept2mls.ml index 09cbb93..138be14 100644 --- a/compiler/main/hept2mls.ml +++ b/compiler/main/hept2mls.ml @@ -225,12 +225,8 @@ and translate_array_op env op e_list = Erepeat (size_exp_of_exp idx, e) | Heptagon.Eselect idx_list, [e] -> Eselect (idx_list, e) - (*Little hack: we need the to access the type of the array being - accessed to store the bounds (which will be used at code generation - time, where the types are harder to find). *) | Heptagon.Eselect_dyn, e::defe::idx_list -> - let bounds = bounds_list e.e_ty in - Eselect_dyn (idx_list, bounds, e, defe) + Eselect_dyn (idx_list, e, defe) | Heptagon.Eupdate idx_list, [e1;e2] -> Eupdate (idx_list, e1, e2) | Heptagon.Eselect_slice, [e; idx1; idx2] -> diff --git a/compiler/minils/analysis/clocking.ml b/compiler/minils/analysis/clocking.ml index f2cd97e..5bbfc71 100644 --- a/compiler/minils/analysis/clocking.ml +++ b/compiler/minils/analysis/clocking.ml @@ -161,7 +161,7 @@ let rec typing h e = and typing_array_op h e = function | Erepeat (_, e) -> typing h e | Eselect (_, e) -> typing h e - | Eselect_dyn (e_list, _, e, defe) -> + | Eselect_dyn (e_list, e, defe) -> let ck = new_var () in let ct = skeleton ck e.e_ty in (expect h ct e; List.iter (expect h ct) e_list; ct) diff --git a/compiler/minils/minils.ml b/compiler/minils/minils.ml index 6d3b027..72bd178 100644 --- a/compiler/minils/minils.ml +++ b/compiler/minils/minils.ml @@ -61,7 +61,7 @@ and edesc = and array_op = | Erepeat of size_exp * exp | Eselect of size_exp list * exp (*indices, array*) - | Eselect_dyn of exp list * size_exp list * exp * exp (* indices, bounds, + | Eselect_dyn of exp list * exp * exp (* indices, array, default*) | Eupdate of size_exp list * exp * exp (*indices, array, value*) | Eselect_slice of size_exp * size_exp * exp (*lower bound, upper bound, diff --git a/compiler/minils/mls_printer.ml b/compiler/minils/mls_printer.ml index a7b4dfd..a29c825 100644 --- a/compiler/minils/mls_printer.ml +++ b/compiler/minils/mls_printer.ml @@ -118,7 +118,7 @@ and print_exp_desc ff = function and print_array_op ff = function | Erepeat (n, e) -> fprintf ff "%a^%a" print_exp e print_size_exp n | Eselect (idx, e) -> fprintf ff "%a%a" print_exp e print_index idx - | Eselect_dyn (idx, _, e1, e2) -> + | Eselect_dyn (idx, e1, e2) -> fprintf ff "%a%a default %a" print_exp e1 print_dyn_index idx print_exp e2 | Eupdate (idx, e1, e2) -> diff --git a/compiler/minils/mls_utils.ml b/compiler/minils/mls_utils.ml index 1a54c2b..0b3a95d 100644 --- a/compiler/minils/mls_utils.ml +++ b/compiler/minils/mls_utils.ml @@ -105,7 +105,7 @@ struct and read_array_op is_left acc = function | Erepeat (_,e) -> read is_left acc e | Eselect (_,e) -> read is_left acc e - | Eselect_dyn (e_list, _, e1, e2) -> + | Eselect_dyn (e_list, e1, e2) -> let acc = List.fold_left (read is_left) acc e_list in read is_left (read is_left acc e1) e2 | Eupdate (_, e1, e2) -> diff --git a/compiler/minils/sequential/mls2obc.ml b/compiler/minils/sequential/mls2obc.ml index 506e411..b9e32cb 100644 --- a/compiler/minils/sequential/mls2obc.ml +++ b/compiler/minils/sequential/mls2obc.ml @@ -203,8 +203,9 @@ let rec translate_eq const_env map { Minils.eq_lhs = pat; Minils.eq_rhs = e } m, si, j, (control map ck action) :: s | Minils.Evarpat x, - Minils.Earray_op (Minils.Eselect_dyn (idx, bounds, e1, e2)) -> + Minils.Earray_op (Minils.Eselect_dyn (idx, e1, e2)) -> let x = var_from_name map x in + let bounds = Mls_utils.bounds_list e1.Minils.e_ty in let e1 = translate const_env map (m, si, j, s) e1 in let bounds = List.map (int_of_size_exp const_env) bounds in let idx = List.map (translate const_env map (m, si, j, s)) idx in diff --git a/compiler/minils/transformations/callgraph.ml b/compiler/minils/transformations/callgraph.ml index b89c206..45edb29 100644 --- a/compiler/minils/transformations/callgraph.ml +++ b/compiler/minils/transformations/callgraph.ml @@ -63,7 +63,7 @@ let rec collect_exp nodes env e = collect_array_exp nodes env op and collect_array_exp nodes env = function - | Eselect_dyn (e_list, _, e1, e2) -> + | Eselect_dyn (e_list, e1, e2) -> List.iter (collect_exp nodes env) e_list; collect_exp nodes env e1; collect_exp nodes env e2 diff --git a/compiler/minils/transformations/normalize.ml b/compiler/minils/transformations/normalize.ml index 392ec26..61f2ac9 100644 --- a/compiler/minils/transformations/normalize.ml +++ b/compiler/minils/transformations/normalize.ml @@ -191,11 +191,11 @@ and translate_array_exp kind context op = | Eselect (idx,e') -> let context, e' = translate VRef context e' in context, Eselect(idx, e') - | Eselect_dyn (idx, bounds, e1, e2) -> + | Eselect_dyn (idx, e1, e2) -> let context, e1 = translate VRef context e1 in let context, idx = translate_list Exp context idx in let context, e2 = translate Exp context e2 in - context, Eselect_dyn(idx, bounds, e1, e2) + context, Eselect_dyn(idx, e1, e2) | Eupdate (idx, e1, e2) -> let context, e1 = translate VRef context e1 in let context, e2 = translate Exp context e2 in