add isl_tab_unrestrict
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 23 Mar 2013 14:53:50 +0000 (15:53 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 28 Mar 2013 16:11:05 +0000 (17:11 +0100)
This will be useful for another special case of coalescing.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_tab.c
isl_tab.h

index b7513df..e4cc386 100644 (file)
--- 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);
index b48db73..1ed0d69 100644 (file)
--- 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);