From d348d0dea2eb4c2349942b8eaee9846b4a91c0ec Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 16 Oct 2011 16:00:38 +0200 Subject: [PATCH] add isl_union_map_gist_domain Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/union_map.h | 3 +++ isl_union_map.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 553935e7..f282bdab 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2392,6 +2392,9 @@ instead. __isl_give isl_union_map *isl_union_map_gist_params( __isl_take isl_union_map *umap, __isl_take isl_set *set); + __isl_give isl_union_map *isl_union_map_gist_domain( + __isl_take isl_union_map *umap, + __isl_take isl_union_set *uset); The gist operation returns a set or relation that has the same intersection with the context as the input set or relation. diff --git a/include/isl/union_map.h b/include/isl/union_map.h index 6e21dad0..c8642ab8 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -84,6 +84,9 @@ __isl_give isl_union_map *isl_union_map_gist(__isl_take isl_union_map *umap, __isl_export __isl_give isl_union_map *isl_union_map_gist_params( __isl_take isl_union_map *umap, __isl_take isl_set *set); +__isl_export +__isl_give isl_union_map *isl_union_map_gist_domain( + __isl_take isl_union_map *umap, __isl_take isl_union_set *uset); __isl_export __isl_give isl_union_map *isl_union_map_intersect_domain( diff --git a/isl_union_map.c b/isl_union_map.c index 810697c4..8e78e15d 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -646,6 +646,12 @@ static __isl_give isl_union_map *union_map_intersect_params( isl_set_from_union_set(uset)); } +static __isl_give isl_union_map *union_map_gist_params( + __isl_take isl_union_map *umap, __isl_take isl_union_set *uset) +{ + return isl_union_map_gist_params(umap, isl_set_from_union_set(uset)); +} + struct isl_union_map_match_bin_data { isl_union_map *umap2; isl_union_map *res; @@ -884,6 +890,50 @@ __isl_give isl_union_map *isl_union_map_intersect_domain( return gen_bin_op(umap, uset, &intersect_domain_entry); } +static int gist_domain_entry(void **entry, void *user) +{ + struct isl_union_map_gen_bin_data *data = user; + uint32_t hash; + struct isl_hash_table_entry *entry2; + isl_space *dim; + isl_map *map = *entry; + int empty; + + dim = isl_map_get_space(map); + dim = isl_space_domain(dim); + hash = isl_space_get_hash(dim); + entry2 = isl_hash_table_find(data->umap2->dim->ctx, &data->umap2->table, + hash, &has_dim, dim, 0); + isl_space_free(dim); + if (!entry2) + return 0; + + map = isl_map_copy(map); + map = isl_map_gist_domain(map, isl_set_copy(entry2->data)); + + empty = isl_map_is_empty(map); + if (empty < 0) { + isl_map_free(map); + return -1; + } + + data->res = isl_union_map_add_map(data->res, map); + + return 0; +} + +/* Compute the gist of "umap" with respect to the domain "uset". + * If "uset" is a parameters domain, then compute the gist + * with respect to this parameter domain. + */ +__isl_give isl_union_map *isl_union_map_gist_domain( + __isl_take isl_union_map *umap, __isl_take isl_union_set *uset) +{ + if (isl_union_set_is_params(uset)) + return union_map_gist_params(umap, uset); + return gen_bin_op(umap, uset, &gist_domain_entry); +} + static int intersect_range_entry(void **entry, void *user) { struct isl_union_map_gen_bin_data *data = user; -- 2.11.4.GIT