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.
This commit is contained in:
Cédric Pasteur 2010-06-30 13:46:46 +02:00
parent b4419a6760
commit 01d0cd02c3
8 changed files with 10 additions and 13 deletions

View file

@ -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] ->

View file

@ -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)

View file

@ -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,

View file

@ -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) ->

View file

@ -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) ->

View file

@ -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

View file

@ -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

View file

@ -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