isl_tab_pip.c: incrementally build recession cone of gbr context
[platform/upstream/isl.git] / isl_tab.h
index 9af71b7..2e29a0d 100644 (file)
--- a/isl_tab.h
+++ b/isl_tab.h
@@ -14,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 {
@@ -29,11 +30,13 @@ enum isl_tab_undo_type {
        isl_tab_undo_bset_div,
        isl_tab_undo_saved_basis,
        isl_tab_undo_drop_sample,
+       isl_tab_undo_saved_samples,
 };
 
 union isl_tab_undo_val {
        int             var_index;
        int             *col_var;
+       int             n;
 };
 
 struct isl_tab_undo {
@@ -66,7 +69,7 @@ struct isl_tab_undo {
  * 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 will only be used while
+ * considered first.  The big parameter is only used while
  * solving PILP problems.
  *
  * The first n_dead column variables have their values fixed to zero.
@@ -84,19 +87,21 @@ struct isl_tab_undo {
  * 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.
+ * 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
+ * isl_tab_detect_implicit_equalities and isl_tab_detect_redundant can be used
  * 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.
+ * 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,
@@ -133,13 +138,19 @@ struct isl_tab {
 
        unsigned n_sample;
        unsigned n_outside;
+       int *sample_index;
        struct isl_mat *samples;
 
+       int n_zero;
+       int n_unbounded;
+       struct isl_mat *basis;
+
        unsigned need_undo : 1;
        unsigned rational : 1;
        unsigned empty : 1;
        unsigned in_undo : 1;
        unsigned M : 1;
+       unsigned cone : 1;
 };
 
 struct isl_tab *isl_tab_alloc(struct isl_ctx *ctx,
@@ -148,13 +159,13 @@ void isl_tab_free(struct isl_tab *tab);
 
 struct isl_tab *isl_tab_from_basic_map(struct isl_basic_map *bmap);
 struct isl_tab *isl_tab_from_basic_set(struct isl_basic_set *bset);
-struct isl_tab *isl_tab_from_recession_cone(struct isl_basic_map *bmap);
+struct isl_tab *isl_tab_from_recession_cone(struct isl_basic_set *bset);
 int isl_tab_cone_is_bounded(struct isl_tab *tab);
 struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
        struct isl_tab *tab);
 struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset,
        struct isl_tab *tab);
-struct isl_tab *isl_tab_detect_equalities(struct isl_tab *tab);
+struct isl_tab *isl_tab_detect_implicit_equalities(struct isl_tab *tab);
 struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab);
 #define ISL_TAB_SAVE_DUAL      (1 << 0)
 enum isl_lp_result isl_tab_min(struct isl_tab *tab,
@@ -163,6 +174,7 @@ enum isl_lp_result isl_tab_min(struct isl_tab *tab,
 
 struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new);
 struct isl_tab *isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq);
+struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq);
 struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq);
 
 int isl_tab_is_equality(struct isl_tab *tab, int con);
@@ -190,12 +202,17 @@ 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);
 int isl_tab_mark_redundant(struct isl_tab *tab, int row);
 struct isl_tab *isl_tab_mark_empty(struct isl_tab *tab);
 struct isl_tab *isl_tab_dup(struct isl_tab *tab);
+struct isl_tab *isl_tab_product(struct isl_tab *tab1, struct isl_tab *tab2);
 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);
@@ -204,10 +221,20 @@ 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,
        enum isl_tab_undo_type type, struct isl_tab_var *var);
 void isl_tab_push_basis(struct isl_tab *tab);
 
+struct isl_tab *isl_tab_init_samples(struct isl_tab *tab);
+struct isl_tab *isl_tab_add_sample(struct isl_tab *tab,
+       __isl_take isl_vec *sample);
+struct isl_tab *isl_tab_drop_sample(struct isl_tab *tab, int s);
+void isl_tab_save_samples(struct isl_tab *tab);
+
+struct isl_tab *isl_tab_detect_equalities(struct isl_tab *tab,
+       struct isl_tab *tab_cone);
+
 #endif