From 9db976c8e19bcea64d201f88119a5342c58f404f Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 15 Jul 2012 21:14:52 +0200 Subject: [PATCH] add isl_multi_*_insert_dims Signed-off-by: Sven Verdoolaege --- doc/user.pod | 7 +++++++ include/isl/aff.h | 7 +++++++ isl_multi_templ.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 9823d99a..9e154d83 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3754,6 +3754,9 @@ It can be modified using __isl_take isl_multi_pw_aff *mpa, enum isl_dim_type type, unsigned pos, const char *s); + __isl_give isl_multi_aff *isl_multi_aff_insert_dims( + __isl_take isl_multi_aff *ma, + enum isl_dim_type type, unsigned first, unsigned n); __isl_give isl_multi_aff *isl_multi_aff_drop_dims( __isl_take isl_multi_aff *maff, enum isl_dim_type type, unsigned first, unsigned n); @@ -3761,6 +3764,10 @@ It can be modified using __isl_take isl_pw_multi_aff *pma, enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims( + __isl_take isl_multi_pw_aff *mpa, + enum isl_dim_type type, unsigned first, unsigned n); + To check whether two multiple affine expressions are obviously equal to each other, use diff --git a/include/isl/aff.h b/include/isl/aff.h index bfd2f5f5..07868e07 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -281,6 +281,9 @@ unsigned isl_multi_aff_dim(__isl_keep isl_multi_aff *maff, __isl_give isl_aff *isl_multi_aff_get_aff(__isl_keep isl_multi_aff *multi, int pos); +__isl_give isl_multi_aff *isl_multi_aff_insert_dims( + __isl_take isl_multi_aff *ma, + enum isl_dim_type type, unsigned first, unsigned n); __isl_give isl_multi_aff *isl_multi_aff_drop_dims( __isl_take isl_multi_aff *maff, enum isl_dim_type type, unsigned first, unsigned n); @@ -495,6 +498,10 @@ unsigned isl_multi_pw_aff_dim(__isl_keep isl_multi_pw_aff *mpa, __isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff( __isl_keep isl_multi_pw_aff *mpa, int pos); +__isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims( + __isl_take isl_multi_pw_aff *mpa, + enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_multi_pw_aff *isl_multi_pw_aff_set_dim_name( __isl_take isl_multi_pw_aff *mpa, enum isl_dim_type type, unsigned pos, const char *s); diff --git a/isl_multi_templ.c b/isl_multi_templ.c index 1776b208..aa54c66e 100644 --- a/isl_multi_templ.c +++ b/isl_multi_templ.c @@ -119,6 +119,38 @@ void *FN(MULTI(BASE),free)(__isl_take MULTI(BASE) *multi) return NULL; } +__isl_give MULTI(BASE) *FN(MULTI(BASE),insert_dims)( + __isl_take MULTI(BASE) *multi, + enum isl_dim_type type, unsigned first, unsigned n) +{ + int i; + + if (!multi) + return NULL; + if (type == isl_dim_out) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid, + "cannot insert output/set dimensions", + return FN(MULTI(BASE),free)(multi)); + if (n == 0 && !isl_space_is_named_or_nested(multi->space, type)) + return multi; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + multi->space = isl_space_insert_dims(multi->space, type, first, n); + if (!multi->space) + return FN(MULTI(BASE),free)(multi); + + for (i = 0; i < multi->n; ++i) { + multi->p[i] = FN(EL,insert_dims)(multi->p[i], type, first, n); + if (!multi->p[i]) + return FN(MULTI(BASE),free)(multi); + } + + return multi; +} + unsigned FN(MULTI(BASE),dim)(__isl_keep MULTI(BASE) *multi, enum isl_dim_type type) { -- 2.11.4.GIT