add isl_aff_mod_val
[platform/upstream/isl.git] / isl_tab.h
index 71bc520..8b808f0 100644 (file)
--- a/isl_tab.h
+++ b/isl_tab.h
@@ -1,7 +1,7 @@
 /*
  * Copyright 2008-2009 Katholieke Universiteit Leuven
  *
- * Use of this software is governed by the GNU LGPLv2.1 license
+ * Use of this software is governed by the MIT license
  *
  * Written by Sven Verdoolaege, K.U.Leuven, Departement
  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
 #ifndef ISL_TAB_H
 #define ISL_TAB_H
 
-#include "isl_lp.h"
-#include "isl_map.h"
-#include "isl_mat.h"
-#include "isl_set.h"
+#include <isl/lp.h>
+#include <isl/map.h>
+#include <isl/mat.h>
+#include <isl/set.h>
 
 struct isl_tab_var {
        int index;
@@ -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,
@@ -118,6 +119,9 @@ struct isl_tab_undo {
  * 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.
+ *
+ * If "preserve" is set, then we want to keep all constraints in the
+ * tableau, even if they turn out to be redundant.
  */
 enum isl_tab_row_sign {
        isl_tab_row_unknown = 0,
@@ -161,7 +165,12 @@ struct isl_tab {
        int n_unbounded;
        struct isl_mat *basis;
 
+       int (*conflict)(int con, void *user);
+       void *conflict_user;
+
+       unsigned strict_redundant : 1;
        unsigned need_undo : 1;
+       unsigned preserve : 1;
        unsigned rational : 1;
        unsigned empty : 1;
        unsigned in_undo : 1;
@@ -173,8 +182,12 @@ struct isl_tab *isl_tab_alloc(struct isl_ctx *ctx,
        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);
-struct isl_tab *isl_tab_from_basic_set(struct isl_basic_set *bset);
+isl_ctx *isl_tab_get_ctx(struct isl_tab *tab);
+
+__isl_give struct isl_tab *isl_tab_from_basic_map(
+       __isl_keep isl_basic_map *bmap, int track);
+__isl_give struct isl_tab *isl_tab_from_basic_set(
+       __isl_keep isl_basic_set *bset, int track);
 struct isl_tab *isl_tab_from_recession_cone(struct isl_basic_set *bset,
        int parametric);
 int isl_tab_cone_is_bounded(struct isl_tab *tab);
@@ -182,7 +195,9 @@ 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_implicit_equalities(struct isl_tab *tab) WARN_UNUSED;
+int isl_tab_detect_implicit_equalities(struct isl_tab *tab) WARN_UNUSED;
+__isl_give isl_basic_map *isl_tab_make_equalities_explicit(struct isl_tab *tab,
+       __isl_take isl_basic_map *bmap);
 int isl_tab_detect_redundant(struct isl_tab *tab) WARN_UNUSED;
 #define ISL_TAB_SAVE_DUAL      (1 << 0)
 enum isl_lp_result isl_tab_min(struct isl_tab *tab,
@@ -191,8 +206,8 @@ enum isl_lp_result isl_tab_min(struct isl_tab *tab,
 
 struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
 int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED;
-struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
-struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
+int isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
+int isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
 
 int isl_tab_freeze_constraint(struct isl_tab *tab, int con) WARN_UNUSED;
 
@@ -221,13 +236,32 @@ struct isl_tab_undo *isl_tab_snap(struct isl_tab *tab);
 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;
-struct isl_tab *isl_tab_select_facet(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(struct isl_tab *tab, FILE *out, int indent);
+void isl_tab_dump(__isl_keep struct isl_tab *tab);
 
 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);
+__isl_give isl_pw_multi_aff *isl_basic_map_partial_lexopt_pw_multi_aff(
+       __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
+       __isl_give isl_set **empty, int max);
+
+/* An isl_region represents a sequence of consecutive variables.
+ * pos is the location (starting at 0) of the first variable in the sequence.
+ */
+struct isl_region {
+       int pos;
+       int len;
+};
+
+__isl_give isl_vec *isl_tab_basic_set_non_trivial_lexmin(
+       __isl_take isl_basic_set *bset, int n_op, int n_region,
+       struct isl_region *region,
+       int (*conflict)(int con, void *user), void *user);
+__isl_give isl_vec *isl_tab_basic_set_non_neg_lexmin(
+       __isl_take isl_basic_set *bset);
 
 /* private */
 
@@ -244,6 +278,7 @@ int isl_tab_pivot(struct isl_tab *tab, int row, int col) WARN_UNUSED;
 int isl_tab_add_row(struct isl_tab *tab, isl_int *line) WARN_UNUSED;
 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_sign_of_max(struct isl_tab *tab, int con);
 int isl_tab_kill_col(struct isl_tab *tab, int col) WARN_UNUSED;
 
 int isl_tab_push(struct isl_tab *tab, enum isl_tab_undo_type type) WARN_UNUSED;