From 1267c5db29d31c9119c3ae25327b68d734870fa5 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Mon, 30 Jan 2012 13:19:38 +0100 Subject: [PATCH] Add isl_union_map_gist_range Signed-off-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/union_map.h | 3 +++ isl_union_map.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 4adedc1..e620391 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2486,6 +2486,9 @@ instead. __isl_give isl_union_map *isl_union_map_gist_domain( __isl_take isl_union_map *umap, __isl_take isl_union_set *uset); + __isl_give isl_union_map *isl_union_map_gist_range( + __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 21ffa78..8054d9d 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -86,6 +86,9 @@ __isl_give isl_union_map *isl_union_map_gist_params( __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_gist_range( + __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 445d4fe..461c504 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -936,6 +936,46 @@ __isl_give isl_union_map *isl_union_map_gist_domain( return gen_bin_op(umap, uset, &gist_domain_entry); } +static int gist_range_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 *space; + isl_map *map = *entry; + int empty; + + space = isl_map_get_space(map); + space = isl_space_range(space); + hash = isl_space_get_hash(space); + entry2 = isl_hash_table_find(data->umap2->dim->ctx, &data->umap2->table, + hash, &has_dim, space, 0); + isl_space_free(space); + if (!entry2) + return 0; + + map = isl_map_copy(map); + map = isl_map_gist_range(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 range "uset". + */ +__isl_give isl_union_map *isl_union_map_gist_range( + __isl_take isl_union_map *umap, __isl_take isl_union_set *uset) +{ + return gen_bin_op(umap, uset, &gist_range_entry); +} + static int intersect_range_entry(void **entry, void *user) { struct isl_union_map_gen_bin_data *data = user; -- 2.7.4