From 34f4fdba988485e086db2c47e3529ded64c15d39 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 19 Jul 2012 18:20:57 +0200 Subject: [PATCH] add isl_local_space_swap_div Signed-off-by: Sven Verdoolaege --- isl_local_space.c | 21 +++++++++++++++++++++ isl_local_space_private.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/isl_local_space.c b/isl_local_space.c index dce7e5f4..0759b132 100644 --- a/isl_local_space.c +++ b/isl_local_space.c @@ -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". */ diff --git a/isl_local_space_private.h b/isl_local_space_private.h index 75526ec3..990aff83 100644 --- a/isl_local_space_private.h +++ b/isl_local_space_private.h @@ -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); -- 2.11.4.GIT