From 84ecd9debe30c72dd7fd565c3d1ed0cbb362a16a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 6 Apr 2013 13:45:02 +0200 Subject: [PATCH] add isl_constraint_set_constant_val Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/constraint.h | 3 +++ isl_constraint.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 5f8e980..a166357 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1509,6 +1509,9 @@ using the following functions. __isl_take isl_constraint *constraint, isl_int v); __isl_give isl_constraint *isl_constraint_set_constant_si( __isl_take isl_constraint *constraint, int v); + __isl_give isl_constraint *isl_constraint_set_constant_val( + __isl_take isl_constraint *constraint, + __isl_take isl_val *v); __isl_give isl_constraint *isl_constraint_set_coefficient( __isl_take isl_constraint *constraint, enum isl_dim_type type, int pos, isl_int v); diff --git a/include/isl/constraint.h b/include/isl/constraint.h index 131db2f..86ca763 100644 --- a/include/isl/constraint.h +++ b/include/isl/constraint.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #if defined(__cplusplus) @@ -89,6 +90,8 @@ __isl_give isl_constraint *isl_constraint_set_constant( __isl_take isl_constraint *constraint, isl_int v); __isl_give isl_constraint *isl_constraint_set_constant_si( __isl_take isl_constraint *constraint, int v); +__isl_give isl_constraint *isl_constraint_set_constant_val( + __isl_take isl_constraint *constraint, __isl_take isl_val *v); __isl_give isl_constraint *isl_constraint_set_coefficient( __isl_take isl_constraint *constraint, enum isl_dim_type type, int pos, isl_int v); diff --git a/isl_constraint.c b/isl_constraint.c index 483e26c..82e8ef7 100644 --- a/isl_constraint.c +++ b/isl_constraint.c @@ -446,6 +446,26 @@ __isl_give isl_constraint *isl_constraint_set_constant( return constraint; } +/* Replace the constant term of "constraint" by "v". + */ +__isl_give isl_constraint *isl_constraint_set_constant_val( + __isl_take isl_constraint *constraint, __isl_take isl_val *v) +{ + constraint = isl_constraint_cow(constraint); + if (!constraint || !v) + goto error; + if (!isl_val_is_int(v)) + isl_die(isl_constraint_get_ctx(constraint), isl_error_invalid, + "expecting integer value", goto error); + constraint->v = isl_vec_set_element_val(constraint->v, 0, v); + if (!constraint->v) + constraint = isl_constraint_free(constraint); + return constraint; +error: + isl_val_free(v); + return isl_constraint_free(constraint); +} + __isl_give isl_constraint *isl_constraint_set_constant_si( __isl_take isl_constraint *constraint, int v) { -- 2.7.4