From 81d594f88d4363a8bdedc7474fd09681529ba2fa Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 23 Nov 2012 15:41:24 +0100 Subject: [PATCH] add isl_union_map_uncurry Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/union_map.h | 1 + isl_union_map.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index abf40311..950f93ca 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2565,6 +2565,8 @@ interchange the range of the domain with the domain of the range. __isl_take isl_map *map); __isl_give isl_union_map *isl_union_map_curry( __isl_take isl_union_map *umap); + __isl_give isl_union_map *isl_union_map_uncurry( + __isl_take isl_union_map *umap); Given a relation with a nested relation for domain, the C functions diff --git a/include/isl/union_map.h b/include/isl/union_map.h index 0992b4cb..8eb7b2fd 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -186,6 +186,7 @@ __isl_give isl_union_map *isl_union_set_unwrap(__isl_take isl_union_set *uset); __isl_give isl_union_map *isl_union_map_zip(__isl_take isl_union_map *umap); __isl_give isl_union_map *isl_union_map_curry(__isl_take isl_union_map *umap); +__isl_give isl_union_map *isl_union_map_uncurry(__isl_take isl_union_map *umap); __isl_give isl_union_map *isl_union_map_align_params( __isl_take isl_union_map *umap, __isl_take isl_space *model); diff --git a/isl_union_map.c b/isl_union_map.c index bb82de70..1528ebd8 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -2394,6 +2394,27 @@ __isl_give isl_union_map *isl_union_map_zip(__isl_take isl_union_map *umap) return cond_un_op(umap, &zip_entry); } +static int uncurry_entry(void **entry, void *user) +{ + isl_map *map = *entry; + isl_union_map **res = user; + + if (!isl_map_can_uncurry(map)) + return 0; + + *res = isl_union_map_add_map(*res, isl_map_uncurry(isl_map_copy(map))); + + return 0; +} + +/* Given a union map, take the maps of the form A -> (B -> C) and + * return the union of the corresponding maps (A -> B) -> C. + */ +__isl_give isl_union_map *isl_union_map_uncurry(__isl_take isl_union_map *umap) +{ + return cond_un_op(umap, &uncurry_entry); +} + static int curry_entry(void **entry, void *user) { isl_map *map = *entry; -- 2.11.4.GIT