From 79e41cd2c459bbf91cae0871450896fccbd53972 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 17 Sep 2012 15:57:26 +0200 Subject: [PATCH] add isl_union_map_subtract_range Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/union_map.h | 3 +++ isl_union_map.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 6099c079..cd1c510e 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2701,6 +2701,9 @@ a parametric set as well. __isl_give isl_union_map *isl_union_map_subtract_domain( __isl_take isl_union_map *umap, __isl_take isl_union_set *dom); + __isl_give isl_union_map *isl_union_map_subtract_range( + __isl_take isl_union_map *umap, + __isl_take isl_union_set *dom); =item * Application diff --git a/include/isl/union_map.h b/include/isl/union_map.h index a30effa2..0992b4cb 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -99,6 +99,9 @@ __isl_give isl_union_map *isl_union_map_intersect_range( __isl_export __isl_give isl_union_map *isl_union_map_subtract_domain( __isl_take isl_union_map *umap, __isl_take isl_union_set *dom); +__isl_export +__isl_give isl_union_map *isl_union_map_subtract_range( + __isl_take isl_union_map *umap, __isl_take isl_union_set *dom); __isl_export __isl_give isl_union_map *isl_union_map_apply_domain( diff --git a/isl_union_map.c b/isl_union_map.c index c2f1faea..bb82de70 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -961,6 +961,57 @@ __isl_give isl_union_map *isl_union_map_subtract_domain( return gen_bin_op(umap, dom, &subtract_domain_entry); } +/* Remove the elements of data->umap2 from the range of *entry + * and add the result to data->res. + */ +static int subtract_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); + + map = isl_map_copy(map); + + if (!entry2) { + data->res = isl_union_map_add_map(data->res, map); + return 0; + } + + map = isl_map_subtract_range(map, isl_set_copy(entry2->data)); + + empty = isl_map_is_empty(map); + if (empty < 0) { + isl_map_free(map); + return -1; + } + if (empty) { + isl_map_free(map); + return 0; + } + + data->res = isl_union_map_add_map(data->res, map); + + return 0; +} + +/* Remove the elements of "uset" from the range of "umap". + */ +__isl_give isl_union_map *isl_union_map_subtract_range( + __isl_take isl_union_map *umap, __isl_take isl_union_set *dom) +{ + return gen_bin_op(umap, dom, &subtract_range_entry); +} + static int gist_domain_entry(void **entry, void *user) { struct isl_union_map_gen_bin_data *data = user; -- 2.11.4.GIT