From 9da631b7d4e3e71e597515ed18dad8c7a4fac962 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 12 Oct 2013 20:31:17 +0200 Subject: [PATCH] add isl_aff_set_tuple_id Tested-by: Michael Kruse Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/aff.h | 2 ++ isl_aff.c | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index beaaaff3..162dac4b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3758,6 +3758,9 @@ The expression can be inspected using It can be modified using #include + __isl_give isl_aff *isl_aff_set_tuple_id( + __isl_take isl_aff *aff, + enum isl_dim_type type, __isl_take isl_id *id); __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id( __isl_take isl_pw_aff *pwaff, enum isl_dim_type type, __isl_take isl_id *id); diff --git a/include/isl/aff.h b/include/isl/aff.h index 6f65847b..f4ee1fe7 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -59,6 +59,8 @@ __isl_give isl_aff *isl_aff_add_coefficient_val(__isl_take isl_aff *aff, int isl_aff_is_cst(__isl_keep isl_aff *aff); +__isl_give isl_aff *isl_aff_set_tuple_id(__isl_take isl_aff *aff, + enum isl_dim_type type, __isl_take isl_id *id); __isl_give isl_aff *isl_aff_set_dim_name(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, const char *s); __isl_give isl_aff *isl_aff_set_dim_id(__isl_take isl_aff *aff, diff --git a/isl_aff.c b/isl_aff.c index 94f8f3ab..97008b0e 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -1752,6 +1752,29 @@ error: return NULL; } +/* Replace the identifier of the input tuple of "aff" by "id". + * type is currently required to be equal to isl_dim_in + */ +__isl_give isl_aff *isl_aff_set_tuple_id(__isl_take isl_aff *aff, + enum isl_dim_type type, __isl_take isl_id *id) +{ + aff = isl_aff_cow(aff); + if (!aff) + return isl_id_free(id); + if (type != isl_dim_out) + isl_die(aff->v->ctx, isl_error_invalid, + "cannot only set id of input tuple", goto error); + aff->ls = isl_local_space_set_tuple_id(aff->ls, isl_dim_set, id); + if (!aff->ls) + return isl_aff_free(aff); + + return aff; +error: + isl_id_free(id); + isl_aff_free(aff); + return NULL; +} + /* Exploit the equalities in "eq" to simplify the affine expression * and the expressions of the integer divisions in the local space. * The integer divisions in this local space are assumed to appear -- 2.11.4.GIT