From 5255ef2cfd1cf8d6fa3ad2c1f900a5c0b6ff9a10 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 23 Mar 2013 15:53:50 +0100 Subject: [PATCH] add isl_tab_unrestrict This will be useful for another special case of coalescing. Signed-off-by: Sven Verdoolaege --- isl_tab.c | 41 +++++++++++++++++++++++++++++++++++++++++ isl_tab.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/isl_tab.c b/isl_tab.c index b7513df8..e4cc3866 100644 --- a/isl_tab.c +++ b/isl_tab.c @@ -2605,6 +2605,29 @@ error: return NULL; } +/* Remove the sign constraint from constraint "con". + * + * If the constraint variable was originally marked non-negative, + * then we make sure we mark it non-negative again during rollback. + */ +int isl_tab_unrestrict(struct isl_tab *tab, int con) +{ + struct isl_tab_var *var; + + if (!tab) + return -1; + + var = &tab->con[con]; + if (!var->is_nonneg) + return 0; + + var->is_nonneg = 0; + if (isl_tab_push_var(tab, isl_tab_undo_unrestrict, var) < 0) + return -1; + + return 0; +} + int isl_tab_select_facet(struct isl_tab *tab, int con) { if (!tab) @@ -3056,6 +3079,21 @@ static int unrelax(struct isl_tab *tab, struct isl_tab_var *var) return 0; } +/* Undo the operation performed by isl_tab_unrestrict. + * + * In particular, mark the variable as being non-negative and make + * sure the sample value respects this constraint. + */ +static int ununrestrict(struct isl_tab *tab, struct isl_tab_var *var) +{ + var->is_nonneg = 1; + + if (var->is_row && restore_row(tab, var) < -1) + return -1; + + return 0; +} + static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo) WARN_UNUSED; static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo) { @@ -3098,6 +3136,8 @@ static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo) break; case isl_tab_undo_relax: return unrelax(tab, var); + case isl_tab_undo_unrestrict: + return ununrestrict(tab, var); default: isl_die(tab->mat->ctx, isl_error_internal, "perform_undo_var called on invalid undo record", @@ -3198,6 +3238,7 @@ static int perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo) case isl_tab_undo_zero: case isl_tab_undo_allocate: case isl_tab_undo_relax: + case isl_tab_undo_unrestrict: return perform_undo_var(tab, undo); case isl_tab_undo_bmap_eq: return isl_basic_map_free_equality(tab->bmap, 1); diff --git a/isl_tab.h b/isl_tab.h index b48db73c..1ed0d698 100644 --- a/isl_tab.h +++ b/isl_tab.h @@ -35,6 +35,7 @@ enum isl_tab_undo_type { isl_tab_undo_zero, isl_tab_undo_allocate, isl_tab_undo_relax, + isl_tab_undo_unrestrict, isl_tab_undo_bmap_ineq, isl_tab_undo_bmap_eq, isl_tab_undo_bmap_div, @@ -234,6 +235,7 @@ int isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap) WARN_UNUSED struct isl_tab *isl_tab_relax(struct isl_tab *tab, int con) WARN_UNUSED; int isl_tab_select_facet(struct isl_tab *tab, int con) WARN_UNUSED; +int isl_tab_unrestrict(struct isl_tab *tab, int con) WARN_UNUSED; void isl_tab_dump(__isl_keep struct isl_tab *tab); -- 2.11.4.GIT