From 7ec341aa4ebba807211e3a72ba6af10c663998e4 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 5 May 2014 22:15:01 +0200 Subject: [PATCH] add isl_schedule_tree_band_intersect_domain This will be useful for the isl_schedule_node_group function that will be introduced in a subsequent commit. Signed-off-by: Sven Verdoolaege --- isl_schedule_band.c | 21 +++++++++++++++++++++ isl_schedule_band.h | 2 ++ isl_schedule_tree.c | 24 ++++++++++++++++++++++++ isl_schedule_tree.h | 2 ++ 4 files changed, 49 insertions(+) diff --git a/isl_schedule_band.c b/isl_schedule_band.c index 77808be4..647f02fb 100644 --- a/isl_schedule_band.c +++ b/isl_schedule_band.c @@ -309,6 +309,27 @@ __isl_give isl_space *isl_schedule_band_get_space( return isl_multi_union_pw_aff_get_space(band->mupa); } +/* Intersect the domain of the band schedule of "band" with "domain". + */ +__isl_give isl_schedule_band *isl_schedule_band_intersect_domain( + __isl_take isl_schedule_band *band, __isl_take isl_union_set *domain) +{ + band = isl_schedule_band_cow(band); + if (!band || !domain) + goto error; + + band->mupa = isl_multi_union_pw_aff_intersect_domain(band->mupa, + domain); + if (!band->mupa) + return isl_schedule_band_free(band); + + return band; +error: + isl_schedule_band_free(band); + isl_union_set_free(domain); + return NULL; +} + /* Return the schedule of the band in isolation. */ __isl_give isl_multi_union_pw_aff *isl_schedule_band_get_partial_schedule( diff --git a/isl_schedule_band.h b/isl_schedule_band.h index 8ac5e7da..a2975a9d 100644 --- a/isl_schedule_band.h +++ b/isl_schedule_band.h @@ -58,6 +58,8 @@ int isl_schedule_band_is_anchored(__isl_keep isl_schedule_band *band); __isl_give isl_space *isl_schedule_band_get_space( __isl_keep isl_schedule_band *band); +__isl_give isl_schedule_band *isl_schedule_band_intersect_domain( + __isl_take isl_schedule_band *band, __isl_take isl_union_set *domain); __isl_give isl_multi_union_pw_aff *isl_schedule_band_get_partial_schedule( __isl_keep isl_schedule_band *band); enum isl_ast_loop_type isl_schedule_band_member_get_ast_loop_type( diff --git a/isl_schedule_tree.c b/isl_schedule_tree.c index 524da483..0b6f030c 100644 --- a/isl_schedule_tree.c +++ b/isl_schedule_tree.c @@ -929,6 +929,30 @@ __isl_give isl_space *isl_schedule_tree_band_get_space( return isl_schedule_band_get_space(tree->band); } +/* Intersect the domain of the band schedule of the band tree root + * with "domain". + */ +__isl_give isl_schedule_tree *isl_schedule_tree_band_intersect_domain( + __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain) +{ + if (!tree || !domain) + goto error; + + if (tree->type != isl_schedule_node_band) + isl_die(isl_schedule_tree_get_ctx(tree), isl_error_invalid, + "not a band node", goto error); + + tree->band = isl_schedule_band_intersect_domain(tree->band, domain); + if (!tree->band) + return isl_schedule_tree_free(tree); + + return tree; +error: + isl_schedule_tree_free(tree); + isl_union_set_free(domain); + return NULL; +} + /* Return the schedule of the band tree root in isolation. */ __isl_give isl_multi_union_pw_aff *isl_schedule_tree_band_get_partial_schedule( diff --git a/isl_schedule_tree.h b/isl_schedule_tree.h index 6ded6c79..7b40be09 100644 --- a/isl_schedule_tree.h +++ b/isl_schedule_tree.h @@ -99,6 +99,8 @@ int isl_schedule_tree_is_subtree_anchored(__isl_keep isl_schedule_tree *tree); __isl_give isl_space *isl_schedule_tree_band_get_space( __isl_keep isl_schedule_tree *tree); +__isl_give isl_schedule_tree *isl_schedule_tree_band_intersect_domain( + __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain); __isl_give isl_multi_union_pw_aff *isl_schedule_tree_band_get_partial_schedule( __isl_keep isl_schedule_tree *tree); enum isl_ast_loop_type isl_schedule_tree_band_member_get_ast_loop_type( -- 2.11.4.GIT