From ca7e11ff16b4ec3e7c646db0aae11f7c63c2fe57 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 27 Jun 2013 21:51:55 +0200 Subject: [PATCH] add isl_pw_multi_aff_fix_si Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/aff.h | 4 ++++ isl_pw_templ.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index b39d6846..935decfc 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -4302,6 +4302,9 @@ C subtracts the second argument from the first. C scales the elements of C by the corresponding elements of C. + __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si( + __isl_take isl_pw_multi_aff *pma, + enum isl_dim_type type, unsigned pos, int value); __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params( __isl_take isl_pw_multi_aff *pma, __isl_take isl_set *set); diff --git a/include/isl/aff.h b/include/isl/aff.h index 2a959ac2..8fefb79e 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -393,6 +393,10 @@ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_dim_id( int isl_pw_multi_aff_plain_is_equal(__isl_keep isl_pw_multi_aff *pma1, __isl_keep isl_pw_multi_aff *pma2); +__isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si( + __isl_take isl_pw_multi_aff *pma, enum isl_dim_type type, + unsigned pos, int value); + __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2); diff --git a/isl_pw_templ.c b/isl_pw_templ.c index eed2520f..94315c1f 100644 --- a/isl_pw_templ.c +++ b/isl_pw_templ.c @@ -766,6 +766,40 @@ __isl_give PW *FN(PW,from_range)(__isl_take PW *pw) return pw; } +/* Fix the value of the given parameter or domain dimension of "pw" + * to be equal to "value". + */ +__isl_give PW *FN(PW,fix_si)(__isl_take PW *pw, enum isl_dim_type type, + unsigned pos, int value) +{ + int i; + + if (!pw) + return NULL; + + if (type == isl_dim_out) + isl_die(FN(PW,get_ctx)(pw), isl_error_invalid, + "cannot fix output dimension", return FN(PW,free)(pw)); + + if (pw->n == 0) + return pw; + + if (type == isl_dim_in) + type = isl_dim_set; + + pw = FN(PW,cow)(pw); + if (!pw) + return FN(PW,free)(pw); + + for (i = pw->n - 1; i >= 0; --i) { + pw->p[i].set = isl_set_fix_si(pw->p[i].set, type, pos, value); + if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0) + return FN(PW,free)(pw); + } + + return pw; +} + /* Restrict the domain of "pw" by combining each cell * with "set" through a call to "fn", where "fn" may be * isl_set_intersect or isl_set_intersect_params. -- 2.11.4.GIT