add isl_multi_*_insert_dims
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 15 Jul 2012 19:14:52 +0000 (21:14 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Sep 2012 13:08:19 +0000 (15:08 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_multi_templ.c

index 9823d99..9e154d8 100644 (file)
@@ -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
 
index bfd2f5f..07868e0 100644 (file)
@@ -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);
index 1776b20..aa54c66 100644 (file)
@@ -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)
 {