From cd800d88649f078ab4d8112086ee07c68b11c566 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 5 Feb 2014 13:45:02 +0100 Subject: [PATCH] extract out pet_not During the incemental move of some functionality from operating on the clang AST to operating on pet_expr objects, this function will be used by both. Since this function only depends on isl functionality, we move it to aff.c. Signed-off-by: Sven Verdoolaege --- aff.c | 13 +++++++++++++ aff.h | 1 + scan.cc | 12 ++---------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/aff.c b/aff.c index 3af3a82..e9c657f 100644 --- a/aff.c +++ b/aff.c @@ -60,6 +60,19 @@ __isl_give isl_pw_aff *pet_and(__isl_take isl_pw_aff *lhs, return indicator_function(cond, dom); } +/* Return "!pa", defined on the domain of "pa". + */ +__isl_give isl_pw_aff *pet_not(__isl_take isl_pw_aff *pa) +{ + isl_set *cond, *dom; + + dom = isl_pw_aff_domain(isl_pw_aff_copy(pa)); + cond = isl_pw_aff_zero_set(pa); + pa = indicator_function(cond, dom); + + return pa; +} + /* Return the result of applying the comparison operator "type" * to "pa1" and "pa2". * diff --git a/aff.h b/aff.h index 71ab203..8589b68 100644 --- a/aff.h +++ b/aff.h @@ -11,6 +11,7 @@ extern "C" { __isl_give isl_pw_aff *pet_and(__isl_take isl_pw_aff *lhs, __isl_take isl_pw_aff *rhs); +__isl_give isl_pw_aff *pet_not(__isl_take isl_pw_aff *pa); __isl_give isl_pw_aff *pet_comparison(enum pet_op_type type, __isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2); diff --git a/scan.cc b/scan.cc index e9cdbaa..51cc613 100644 --- a/scan.cc +++ b/scan.cc @@ -1455,18 +1455,10 @@ __isl_give isl_pw_aff *PetScan::extract_comparison(BinaryOperator *comp) */ __isl_give isl_pw_aff *PetScan::extract_boolean(UnaryOperator *op) { - isl_set *set_cond, *dom; - isl_pw_aff *cond, *res; + isl_pw_aff *cond; cond = extract_condition(op->getSubExpr()); - - dom = isl_pw_aff_domain(isl_pw_aff_copy(cond)); - - set_cond = isl_pw_aff_zero_set(cond); - - res = indicator_function(set_cond, dom); - - return res; + return pet_not(cond); } /* Extract an affine expression representing the disjunction (logical or) -- 2.11.4.GIT