From 09ccfadb11521d3bffeb6c227f16eb2937139c20 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 16 Apr 2014 13:46:44 +0200 Subject: [PATCH] further generalize compute_to_inner to support pet_scop_compute_outer_to_any In the previous commit, we generalized compute_to_inner to compute a mapping from either the outermost arrays or any array to the innermost arrays. Generalize compute_to_inner further to also support the computation of a mapping from outermosts arrays to any array. Signed-off-by: Sven Verdoolaege --- include/pet.h | 4 ++++ scop.c | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/pet.h b/include/pet.h index 8ba98f1..0c5c6d3 100644 --- a/include/pet.h +++ b/include/pet.h @@ -562,6 +562,10 @@ __isl_give isl_union_map *pet_scop_collect_schedule(struct pet_scop *scop); */ __isl_give isl_union_map *pet_scop_compute_outer_to_inner( struct pet_scop *scop); +/* Compute a mapping from all outermost arrays (of structs) in scop + * to their members, including the outermost arrays themselves. + */ +__isl_give isl_union_map *pet_scop_compute_outer_to_any(struct pet_scop *scop); #if defined(__cplusplus) } diff --git a/scop.c b/scop.c index 1bdc76e..49f35a7 100644 --- a/scop.c +++ b/scop.c @@ -2509,13 +2509,15 @@ static __isl_give isl_union_map *add_gisted(__isl_take isl_union_map *umap, } /* Compute a mapping from all arrays (of structs) in scop - * to their innermost members. + * to their members. * * If "from_outermost" is set, then the domain only consists * of outermost arrays. + * If "to_innermost" is set, then the range only consists + * of innermost arrays. */ static __isl_give isl_union_map *compute_to_inner(struct pet_scop *scop, - int from_outermost) + int from_outermost, int to_innermost) { int i; isl_union_map *to_inner; @@ -2530,7 +2532,7 @@ static __isl_give isl_union_map *compute_to_inner(struct pet_scop *scop, isl_set *set; isl_map *map; - if (array->element_is_record) + if (to_innermost && array->element_is_record) continue; set = isl_set_copy(array->extent); @@ -2570,7 +2572,7 @@ static __isl_give isl_union_map *compute_to_inner(struct pet_scop *scop, static __isl_give isl_union_map *pet_scop_compute_any_to_inner( struct pet_scop *scop) { - return compute_to_inner(scop, 0); + return compute_to_inner(scop, 0, 1); } /* Compute a mapping from all outermost arrays (of structs) in scop @@ -2578,7 +2580,15 @@ static __isl_give isl_union_map *pet_scop_compute_any_to_inner( */ __isl_give isl_union_map *pet_scop_compute_outer_to_inner(struct pet_scop *scop) { - return compute_to_inner(scop, 1); + return compute_to_inner(scop, 1, 1); +} + +/* Compute a mapping from all outermost arrays (of structs) in scop + * to their members, including the outermost arrays themselves. + */ +__isl_give isl_union_map *pet_scop_compute_outer_to_any(struct pet_scop *scop) +{ + return compute_to_inner(scop, 1, 0); } /* Collect and return all read access relations (if "read" is set) -- 2.11.4.GIT