From 15536e208e29fd555b1ace742c8974734daeae87 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 16 Jul 2014 12:39:26 +0200 Subject: [PATCH] add isl_union_map_factor_range Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/union_map.h | 2 ++ isl_union_map.c | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index fa74b7ac..02ee4afe 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -5526,6 +5526,8 @@ from the result using the following functions. __isl_take isl_map *map); #include + __isl_give isl_union_map *isl_union_map_factor_range( + __isl_take isl_union_map *umap); __isl_give isl_union_map * isl_union_map_domain_factor_domain( __isl_take isl_union_map *umap); diff --git a/include/isl/union_map.h b/include/isl/union_map.h index 73236d6f..ef127a33 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -98,6 +98,8 @@ __isl_give isl_union_map *isl_union_map_domain_factor_range( __isl_take isl_union_map *umap); __isl_give isl_union_map *isl_union_map_range_factor_range( __isl_take isl_union_map *umap); +__isl_give isl_union_map *isl_union_map_factor_range( + __isl_take isl_union_map *umap); __isl_export __isl_give isl_union_map *isl_union_map_gist(__isl_take isl_union_map *umap, __isl_take isl_union_map *context); diff --git a/isl_union_map.c b/isl_union_map.c index d4f9568a..28d0661c 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -1982,6 +1982,31 @@ __isl_give isl_union_map *isl_union_map_range_factor_range( return cond_un_op(umap, &range_factor_range_entry); } +/* If "map" is of the form [A -> B] -> [C -> D], then add B -> D to "res". + */ +static int factor_range_entry(void **entry, void *user) +{ + isl_map *map = *entry; + isl_union_map **res = user; + + if (!isl_map_domain_is_wrapping(map) || !isl_map_range_is_wrapping(map)) + return 0; + + *res = isl_union_map_add_map(*res, + isl_map_factor_range(isl_map_copy(map))); + + return *res ? 0 : -1; +} + +/* For each map in "umap" of the form [A -> B] -> [C -> D], + * construct the map B -> D and collect the results. + */ +__isl_give isl_union_map *isl_union_map_factor_range( + __isl_take isl_union_map *umap) +{ + return cond_un_op(umap, &factor_range_entry); +} + static int unwrap_entry(void **entry, void *user) { isl_set *set = *entry; -- 2.11.4.GIT