add isl_constraint_is_{lower,upper}_bound
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 28 Feb 2012 11:42:48 +0000 (12:42 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 6 May 2012 12:33:05 +0000 (14:33 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/constraint.h
isl_constraint.c

index 4358d82..ee73c6a 100644 (file)
@@ -1447,6 +1447,12 @@ represents an equality.  If not, it represents an inequality.
 The coefficients of the constraints can be inspected using
 the following functions.
 
+       int isl_constraint_is_lower_bound(
+               __isl_keep isl_constraint *constraint,
+               enum isl_dim_type type, unsigned pos);
+       int isl_constraint_is_upper_bound(
+               __isl_keep isl_constraint *constraint,
+               enum isl_dim_type type, unsigned pos);
        void isl_constraint_get_constant(
                __isl_keep isl_constraint *constraint, isl_int *v);
        void isl_constraint_get_coefficient(
index 34d53ec..c395d7a 100644 (file)
@@ -99,6 +99,11 @@ struct isl_constraint *isl_constraint_negate(struct isl_constraint *constraint);
 int isl_constraint_is_equality(__isl_keep isl_constraint *constraint);
 int isl_constraint_is_div_constraint(__isl_keep isl_constraint *constraint);
 
+int isl_constraint_is_lower_bound(__isl_keep isl_constraint *constraint,
+       enum isl_dim_type type, unsigned pos);
+int isl_constraint_is_upper_bound(__isl_keep isl_constraint *constraint,
+       enum isl_dim_type type, unsigned pos);
+
 __isl_give isl_basic_map *isl_basic_map_from_constraint(
        __isl_take isl_constraint *constraint);
 struct isl_basic_set *isl_basic_set_from_constraint(
index 68971b3..a5c6e17 100644 (file)
@@ -349,6 +349,40 @@ error:
        return -1;
 }
 
+/* Does the given constraint represent a lower bound on the given
+ * dimension?
+ */
+int isl_constraint_is_lower_bound(__isl_keep isl_constraint *constraint,
+       enum isl_dim_type type, unsigned pos)
+{
+       if (!constraint)
+               return -1;
+
+       if (pos >= isl_local_space_dim(constraint->ls, type))
+               isl_die(isl_constraint_get_ctx(constraint), isl_error_invalid,
+                       "position out of bounds", return -1);
+
+       pos += isl_local_space_offset(constraint->ls, type);
+       return isl_int_is_pos(constraint->v->el[pos]);
+}
+
+/* Does the given constraint represent an upper bound on the given
+ * dimension?
+ */
+int isl_constraint_is_upper_bound(__isl_keep isl_constraint *constraint,
+       enum isl_dim_type type, unsigned pos)
+{
+       if (!constraint)
+               return -1;
+
+       if (pos >= isl_local_space_dim(constraint->ls, type))
+               isl_die(isl_constraint_get_ctx(constraint), isl_error_invalid,
+                       "position out of bounds", return -1);
+
+       pos += isl_local_space_offset(constraint->ls, type);
+       return isl_int_is_neg(constraint->v->el[pos]);
+}
+
 const char *isl_constraint_get_dim_name(__isl_keep isl_constraint *constraint,
        enum isl_dim_type type, unsigned pos)
 {