isl_equalities.c: remove unused variable
[platform/upstream/isl.git] / isl_tab.h
index 8052716..6c4d947 100644 (file)
--- a/isl_tab.h
+++ b/isl_tab.h
@@ -4,6 +4,7 @@
 #include "isl_lp.h"
 #include "isl_map.h"
 #include "isl_mat.h"
+#include "isl_set.h"
 
 struct isl_tab_var {
        int index;
@@ -13,6 +14,7 @@ struct isl_tab_var {
        unsigned is_redundant : 1;
        unsigned marked : 1;
        unsigned frozen : 1;
+       unsigned negated : 1;
 };
 
 enum isl_tab_undo_type {
@@ -23,7 +25,11 @@ enum isl_tab_undo_type {
        isl_tab_undo_zero,
        isl_tab_undo_allocate,
        isl_tab_undo_relax,
+       isl_tab_undo_bset_ineq,
+       isl_tab_undo_bset_eq,
+       isl_tab_undo_bset_div,
        isl_tab_undo_saved_basis,
+       isl_tab_undo_drop_sample,
 };
 
 union isl_tab_undo_val {
@@ -47,7 +53,9 @@ struct isl_tab_undo {
  * Each row expresses the corresponding row variable as an affine expression
  * of the column variables.
  * The first two columns in the matrix contain the common denominator of
- * the row and the numerator of the constant term.  The third column
+ * the row and the numerator of the constant term.
+ * If "M" is set, then the third column represents the "big parameter".
+ * The third (M = 0) or fourth (M = 1) column
  * in the matrix is called column 0 with respect to the col_var array.
  * The sample value of the tableau is the value that assigns zero
  * to all the column variables and the constant term of each affine
@@ -56,6 +64,12 @@ struct isl_tab_undo {
  * value satisfies the non-negativity constraints (usually on the slack
  * variables).
  *
+ * The big parameter represents an arbitrarily big (and divisible)
+ * positive number.  If present, then the sign of a row is determined
+ * lexicographically, with the sign of the big parameter coefficient
+ * considered first.  The big parameter is only used while
+ * solving PILP problems.
+ *
  * The first n_dead column variables have their values fixed to zero.
  * The corresponding tab_vars are flagged "is_zero".
  * Some of the rows that have have zero coefficients in all but
@@ -68,12 +82,31 @@ struct isl_tab_undo {
  * since the constraint has been reduced to 0 = 0 and is therefore always
  * satisfied.
  *
+ * There are "n_var" variables in total.  The first "n_param" of these
+ * are called parameters and the last "n_div" of these are called divs.
+ * The basic tableau operations makes no distinction between different
+ * kinds of variables.  These special variables are only used while
+ * solving PILP problems.
+ *
  * Dead columns and redundant rows are detected on the fly.
  * However, the basic operations do not ensure that all dead columns
  * or all redundant rows are detected.
  * isl_tab_detect_equalities and isl_tab_detect_redundant can be used
- * to peform and exhaustive search for dead columns and redundant rows.
+ * to perform and exhaustive search for dead columns and redundant rows.
+ *
+ * The samples matrix contains "n_sample" integer points that have at some
+ * point been elements satisfying the tableau.  The first "n_outside"
+ * of them no longer satisfy the tableau.  They are kept because they
+ * can be reinstated during rollback when the constraint that cut them
+ * out is removed.  These samples are only maintained for the context
+ * tableau while solving PILP problems.
  */
+enum isl_tab_row_sign {
+       isl_tab_row_unknown = 0,
+       isl_tab_row_pos,
+       isl_tab_row_neg,
+       isl_tab_row_any,
+};
 struct isl_tab {
        struct isl_mat *mat;
 
@@ -83,6 +116,9 @@ struct isl_tab {
        unsigned n_redundant;
 
        unsigned n_var;
+       unsigned n_param;
+       unsigned n_div;
+       unsigned max_var;
        unsigned n_con;
        unsigned n_eq;
        unsigned max_con;
@@ -90,20 +126,27 @@ struct isl_tab {
        struct isl_tab_var *con;
        int *row_var;   /* v >= 0 -> var v;     v < 0 -> con ~v */
        int *col_var;   /* v >= 0 -> var v;     v < 0 -> con ~v */
+       enum isl_tab_row_sign *row_sign;
 
        struct isl_tab_undo bottom;
        struct isl_tab_undo *top;
 
        struct isl_vec *dual;
+       struct isl_basic_set *bset;
+
+       unsigned n_sample;
+       unsigned n_outside;
+       struct isl_mat *samples;
 
        unsigned need_undo : 1;
        unsigned rational : 1;
        unsigned empty : 1;
        unsigned in_undo : 1;
+       unsigned M : 1;
 };
 
 struct isl_tab *isl_tab_alloc(struct isl_ctx *ctx,
-       unsigned n_row, unsigned n_var);
+       unsigned n_row, unsigned n_var, unsigned M);
 void isl_tab_free(struct isl_tab *tab);
 
 struct isl_tab *isl_tab_from_basic_map(struct isl_basic_map *bmap);
@@ -150,6 +193,10 @@ struct isl_tab *isl_tab_select_facet(struct isl_tab *tab, int con);
 
 void isl_tab_dump(struct isl_tab *tab, FILE *out, int indent);
 
+struct isl_map *isl_tab_basic_map_partial_lexopt(
+               struct isl_basic_map *bmap, struct isl_basic_set *dom,
+               struct isl_set **empty, int max);
+
 /* private */
 
 struct isl_tab_var *isl_tab_var_from_row(struct isl_tab *tab, int i);
@@ -158,10 +205,13 @@ struct isl_tab *isl_tab_mark_empty(struct isl_tab *tab);
 struct isl_tab *isl_tab_dup(struct isl_tab *tab);
 int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new);
 int isl_tab_allocate_con(struct isl_tab *tab);
+int isl_tab_extend_vars(struct isl_tab *tab, unsigned n_new);
+int isl_tab_allocate_var(struct isl_tab *tab);
 void isl_tab_pivot(struct isl_tab *tab, int row, int col);
 int isl_tab_add_row(struct isl_tab *tab, isl_int *line);
 int isl_tab_row_is_redundant(struct isl_tab *tab, int row);
 int isl_tab_min_at_most_neg_one(struct isl_tab *tab, struct isl_tab_var *var);
+int isl_tab_kill_col(struct isl_tab *tab, int col);
 
 void isl_tab_push(struct isl_tab *tab, enum isl_tab_undo_type type);
 void isl_tab_push_var(struct isl_tab *tab,