From: Sven Verdoolaege Date: Sat, 27 Aug 2011 15:41:45 +0000 (+0200) Subject: proper implementation of isl_union_map_from_range X-Git-Tag: isl-0.08~99 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b278e2b50134060830cecea79e8c6e853f6225e;p=platform%2Fupstream%2Fisl.git proper implementation of isl_union_map_from_range The original implementation would just return the input because isl_sets and isl_maps have the same internal representation. This will change in the near future, however, and so we need to actually compute the range of all the elements in the input. Signed-off-by: Sven Verdoolaege --- diff --git a/isl_union_map.c b/isl_union_map.c index 082025e..f12fd97 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -988,10 +988,41 @@ __isl_give isl_union_map *isl_union_map_flat_range_product( return bin_op(umap1, umap2, &flat_range_product_entry); } +static __isl_give isl_union_set *cond_un_op(__isl_take isl_union_map *umap, + int (*fn)(void **, void *)) +{ + isl_union_set *res; + + if (!umap) + return NULL; + + res = isl_union_map_alloc(isl_space_copy(umap->dim), umap->table.n); + if (isl_hash_table_foreach(umap->dim->ctx, &umap->table, fn, &res) < 0) + goto error; + + isl_union_map_free(umap); + return res; +error: + isl_union_map_free(umap); + isl_union_set_free(res); + return NULL; +} + +static int from_range_entry(void **entry, void *user) +{ + isl_map *set = *entry; + isl_union_set **res = user; + + *res = isl_union_map_add_map(*res, + isl_map_from_range(isl_set_copy(set))); + + return 0; +} + __isl_give isl_union_map *isl_union_map_from_range( __isl_take isl_union_set *uset) { - return uset; + return cond_un_op(uset, &from_range_entry); } __isl_give isl_union_map *isl_union_map_from_domain( @@ -1197,26 +1228,6 @@ __isl_give isl_union_set *isl_union_set_lexmax( return isl_union_map_lexmax(uset); } -static __isl_give isl_union_set *cond_un_op(__isl_take isl_union_map *umap, - int (*fn)(void **, void *)) -{ - isl_union_set *res; - - if (!umap) - return NULL; - - res = isl_union_map_alloc(isl_space_copy(umap->dim), umap->table.n); - if (isl_hash_table_foreach(umap->dim->ctx, &umap->table, fn, &res) < 0) - goto error; - - isl_union_map_free(umap); - return res; -error: - isl_union_map_free(umap); - isl_union_set_free(res); - return NULL; -} - static int universe_entry(void **entry, void *user) { isl_map *map = *entry;