From: Sven Verdoolaege Date: Sat, 6 Apr 2013 11:45:02 +0000 (+0200) Subject: add isl_constraint_set_constant_val X-Git-Tag: isl-0.12~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84ecd9debe30c72dd7fd565c3d1ed0cbb362a16a;p=platform%2Fupstream%2Fisl.git add isl_constraint_set_constant_val Signed-off-by: Sven Verdoolaege --- 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) {