add isl_local_space_swap_div
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 19 Jul 2012 16:20:57 +0000 (18:20 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 10 Sep 2012 09:43:33 +0000 (11:43 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_local_space.c
isl_local_space_private.h

index dce7e5f..0759b13 100644 (file)
@@ -542,6 +542,27 @@ __isl_give isl_mat *isl_merge_divs(__isl_keep isl_mat *div1,
        return div;
 }
 
+/* Swap divs "a" and "b" in "ls".
+ */
+__isl_give isl_local_space *isl_local_space_swap_div(
+       __isl_take isl_local_space *ls, int a, int b)
+{
+       int offset;
+
+       ls = isl_local_space_cow(ls);
+       if (!ls)
+               return NULL;
+       if (a < 0 || a >= ls->div->n_row || b < 0 || b >= ls->div->n_row)
+               isl_die(isl_local_space_get_ctx(ls), isl_error_invalid,
+                       "index out of bounds", return isl_local_space_free(ls));
+       offset = ls->div->n_col - ls->div->n_row;
+       ls->div = isl_mat_swap_cols(ls->div, offset + a, offset + b);
+       ls->div = isl_mat_swap_rows(ls->div, a, b);
+       if (!ls->div)
+               return isl_local_space_free(ls);
+       return ls;
+}
+
 /* Construct a local space that contains all the divs in either
  * "ls1" or "ls2".
  */
index 75526ec..990aff8 100644 (file)
@@ -17,6 +17,8 @@ __isl_give isl_local_space *isl_local_space_alloc(__isl_take isl_space *dim,
 __isl_give isl_local_space *isl_local_space_alloc_div(__isl_take isl_space *dim,
        __isl_take isl_mat *div);
 
+__isl_give isl_local_space *isl_local_space_swap_div(
+       __isl_take isl_local_space *ls, int a, int b);
 __isl_give isl_local_space *isl_local_space_add_div(
        __isl_take isl_local_space *ls, __isl_take isl_vec *div);