From c32039813ebafd5df59c87e626c99c9d1e88e605 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 28 Jul 2014 16:52:48 +0200 Subject: [PATCH] add isl_ast_build_replace_pending_by_guard We will be changing the way we handle pending constraints in the next commit from removing pending constraints that may not end up getting generated to replacing pending constraints by constraints that will be generated. This function will be useful for this replacement of pending constraints by actual guards. Signed-off-by: Sven Verdoolaege --- isl_ast_build.c | 24 ++++++++++++++++++++++++ isl_ast_build_private.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/isl_ast_build.c b/isl_ast_build.c index 6cedb693..6cd80046 100644 --- a/isl_ast_build.c +++ b/isl_ast_build.c @@ -866,6 +866,30 @@ error: return NULL; } +/* Replace the set of pending constraints by "guard", which is then + * no longer considered as pending. + * That is, add "guard" to the generated constraints and clear all pending + * constraints, making the domain equal to the generated constraints. + */ +__isl_give isl_ast_build *isl_ast_build_replace_pending_by_guard( + __isl_take isl_ast_build *build, __isl_take isl_set *guard) +{ + build = isl_ast_build_restrict_generated(build, guard); + build = isl_ast_build_cow(build); + if (!build) + return NULL; + + isl_set_free(build->domain); + build->domain = isl_set_copy(build->generated); + isl_set_free(build->pending); + build->pending = isl_set_universe(isl_set_get_space(build->domain)); + + if (!build->pending) + return isl_ast_build_free(build); + + return build; +} + /* Intersect build->pending and build->domain with "set", * where "set" is specified in terms of the internal schedule domain. */ diff --git a/isl_ast_build_private.h b/isl_ast_build_private.h index d858cc24..28688b39 100644 --- a/isl_ast_build_private.h +++ b/isl_ast_build_private.h @@ -199,6 +199,8 @@ __isl_give isl_set *isl_ast_build_get_generated( __isl_keep isl_ast_build *build); __isl_give isl_ast_build *isl_ast_build_restrict_generated( __isl_take isl_ast_build *build, __isl_take isl_set *set); +__isl_give isl_ast_build *isl_ast_build_replace_pending_by_guard( + __isl_take isl_ast_build *build, __isl_take isl_set *guard); __isl_give isl_ast_build *isl_ast_build_restrict_pending( __isl_take isl_ast_build *build, __isl_take isl_set *set); __isl_give isl_ast_build *isl_ast_build_set_enforced( -- 2.11.4.GIT