drop "nparam" argument from isl_{set,map}_read_from_{file,str}
[platform/upstream/isl.git] / isl_local_space.c
index e051465..ebf222c 100644 (file)
@@ -13,6 +13,7 @@
 #include <isl_local_space_private.h>
 #include <isl_space_private.h>
 #include <isl_mat_private.h>
+#include <isl_aff_private.h>
 #include <isl/seq.h>
 
 isl_ctx *isl_local_space_get_ctx(__isl_keep isl_local_space *ls)
@@ -113,6 +114,13 @@ void *isl_local_space_free(__isl_take isl_local_space *ls)
        return NULL;
 }
 
+/* Is the local space that of a set?
+ */
+int isl_local_space_is_set(__isl_keep isl_local_space *ls)
+{
+       return ls ? isl_space_is_set(ls->dim) : -1;
+}
+
 /* Return true if the two local spaces are identical, with identical
  * expressions for the integer divisions.
  */
@@ -173,10 +181,10 @@ const char *isl_local_space_get_dim_name(__isl_keep isl_local_space *ls,
        return ls ? isl_space_get_dim_name(ls->dim, type, pos) : NULL;
 }
 
-__isl_give isl_div *isl_local_space_get_div(__isl_keep isl_local_space *ls,
+__isl_give isl_aff *isl_local_space_get_div(__isl_keep isl_local_space *ls,
        int pos)
 {
-       isl_basic_map *bmap;
+       isl_aff *aff;
 
        if (!ls)
                return NULL;
@@ -189,8 +197,11 @@ __isl_give isl_div *isl_local_space_get_div(__isl_keep isl_local_space *ls,
                isl_die(isl_local_space_get_ctx(ls), isl_error_invalid,
                        "expression of div unknown", return NULL);
 
-       bmap = isl_basic_map_from_local_space(isl_local_space_copy(ls));
-       return isl_basic_map_div(bmap, pos);
+       aff = isl_aff_alloc(isl_local_space_copy(ls));
+       if (!aff)
+               return NULL;
+       isl_seq_cpy(aff->v->el, ls->div->row[pos], aff->v->size);
+       return aff;
 }
 
 __isl_give isl_space *isl_local_space_get_space(__isl_keep isl_local_space *ls)
@@ -440,6 +451,20 @@ int isl_local_space_divs_known(__isl_keep isl_local_space *ls)
        return 1;
 }
 
+__isl_give isl_local_space *isl_local_space_domain(
+       __isl_take isl_local_space *ls)
+{
+       ls = isl_local_space_drop_dims(ls, isl_dim_out,
+                                       0, isl_local_space_dim(ls, isl_dim_out));
+       ls = isl_local_space_cow(ls);
+       if (!ls)
+               return NULL;
+       ls->dim = isl_space_domain(ls->dim);
+       if (!ls->dim)
+               return isl_local_space_free(ls);
+       return ls;
+}
+
 /* Construct a local space for a map that has the given local
  * space as domain and that has a zero-dimensional range.
  */
@@ -658,3 +683,35 @@ int isl_local_space_is_div_constraint(__isl_keep isl_local_space *ls,
 
        return 1;
 }
+
+/*
+ * Set active[i] to 1 if the dimension at position i is involved
+ * in the linear expression l.
+ */
+int *isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l)
+{
+       int i, j;
+       isl_ctx *ctx;
+       int *active = NULL;
+       unsigned total;
+       unsigned offset;
+
+       ctx = isl_local_space_get_ctx(ls);
+       total = isl_local_space_dim(ls, isl_dim_all);
+       active = isl_calloc_array(ctx, int, total);
+       if (!active)
+               return NULL;
+
+       for (i = 0; i < total; ++i)
+               active[i] = !isl_int_is_zero(l[i]);
+
+       offset = isl_local_space_offset(ls, isl_dim_div) - 1;
+       for (i = ls->div->n_row - 1; i >= 0; --i) {
+               if (!active[offset + i])
+                       continue;
+               for (j = 0; j < total; ++j)
+                       active[j] |= !isl_int_is_zero(ls->div->row[i][2 + j]);
+       }
+
+       return active;
+}