From 5e18d4dde5a378590d9aa0de6f13e5a0d736b30e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 14 May 2012 11:35:38 +0200 Subject: [PATCH] add pet_scop_reset_context This will be useful for handling while loops, where we want to drop the context of the body because we don't know if the body is going to be executed. Signed-off-by: Sven Verdoolaege --- scop.c | 19 +++++++++++++++++++ scop.h | 1 + 2 files changed, 20 insertions(+) diff --git a/scop.c b/scop.c index 4f04407..6ca510d 100644 --- a/scop.c +++ b/scop.c @@ -2303,3 +2303,22 @@ error: isl_set_free(context); return pet_scop_free(scop); } + +/* Drop the current context of "scop". That is, replace the context + * by a universal set. + */ +struct pet_scop *pet_scop_reset_context(struct pet_scop *scop) +{ + isl_space *space; + + if (!scop) + return NULL; + + space = isl_set_get_space(scop->context); + isl_set_free(scop->context); + scop->context = isl_set_universe(space); + if (!scop->context) + return pet_scop_free(scop); + + return scop; +} diff --git a/scop.h b/scop.h index a8e0488..ffaef1b 100644 --- a/scop.h +++ b/scop.h @@ -56,6 +56,7 @@ struct pet_scop *pet_scop_restrict(struct pet_scop *scop, __isl_take isl_set *cond); struct pet_scop *pet_scop_restrict_context(struct pet_scop *scop, __isl_take isl_set *context); +struct pet_scop *pet_scop_reset_context(struct pet_scop *scop); struct pet_scop *pet_scop_filter(struct pet_scop *scop, __isl_take isl_map *test, int satisfied); -- 2.11.4.GIT