From a966d16eee23b11a7c7cd4d33dccd2047f256bda Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 7 Apr 2011 14:51:41 +0200 Subject: [PATCH] add isl_union_map_contains Signed-off-by: Sven Verdoolaege --- include/isl/union_map.h | 2 ++ include/isl/union_set.h | 2 ++ isl_union_map.c | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/isl/union_map.h b/include/isl/union_map.h index bd794942..5dcf358d 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -95,6 +95,8 @@ int isl_union_map_is_strict_subset(__isl_keep isl_union_map *umap1, int isl_union_map_n_map(__isl_keep isl_union_map *umap); int isl_union_map_foreach_map(__isl_keep isl_union_map *umap, int (*fn)(__isl_take isl_map *map, void *user), void *user); +__isl_give int isl_union_map_contains(__isl_keep isl_union_map *umap, + __isl_keep isl_dim *dim); __isl_give isl_map *isl_union_map_extract_map(__isl_keep isl_union_map *umap, __isl_take isl_dim *dim); diff --git a/include/isl/union_set.h b/include/isl/union_set.h index 934d34e3..1e647ec4 100644 --- a/include/isl/union_set.h +++ b/include/isl/union_set.h @@ -59,6 +59,8 @@ int isl_union_set_is_strict_subset(__isl_keep isl_union_set *uset1, int isl_union_set_n_set(__isl_keep isl_union_set *uset); int isl_union_set_foreach_set(__isl_keep isl_union_set *uset, int (*fn)(__isl_take isl_set *set, void *user), void *user); +__isl_give int isl_union_set_contains(__isl_keep isl_union_set *uset, + __isl_keep isl_dim *dim); __isl_give isl_set *isl_union_set_extract_set(__isl_keep isl_union_set *uset, __isl_take isl_dim *dim); int isl_union_set_foreach_point(__isl_keep isl_union_set *uset, diff --git a/isl_union_map.c b/isl_union_map.c index 84fb6ce9..428a87ca 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -386,6 +386,29 @@ __isl_give isl_set *isl_union_set_extract_set(__isl_keep isl_union_set *uset, return (isl_set *)isl_union_map_extract_map(uset, dim); } +/* Check if umap contains a map in the given space. + */ +__isl_give int isl_union_map_contains(__isl_keep isl_union_map *umap, + __isl_keep isl_dim *dim) +{ + uint32_t hash; + struct isl_hash_table_entry *entry; + + if (!umap || !dim) + return -1; + + hash = isl_dim_get_hash(dim); + entry = isl_hash_table_find(umap->dim->ctx, &umap->table, hash, + &has_dim, dim, 0); + return !!entry; +} + +__isl_give int isl_union_set_contains(__isl_keep isl_union_set *uset, + __isl_keep isl_dim *dim) +{ + return isl_union_map_contains(uset, dim); +} + int isl_union_set_foreach_set(__isl_keep isl_union_set *uset, int (*fn)(__isl_take isl_set *set, void *user), void *user) { -- 2.11.4.GIT