From: Sven Verdoolaege Date: Sat, 6 Apr 2013 11:45:02 +0000 (+0200) Subject: add isl_constraint_set_coefficient_val X-Git-Tag: isl-0.12~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e99083d6ab70ab8def75e805860c1c866f8e576e;p=platform%2Fupstream%2Fisl.git add isl_constraint_set_coefficient_val Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index a166357..dea020b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1518,6 +1518,10 @@ using the following functions. __isl_give isl_constraint *isl_constraint_set_coefficient_si( __isl_take isl_constraint *constraint, enum isl_dim_type type, int pos, int v); + __isl_give isl_constraint * + isl_constraint_set_coefficient_val( + __isl_take isl_constraint *constraint, + enum isl_dim_type type, int pos, isl_val *v); __isl_give isl_basic_map *isl_basic_map_add_constraint( __isl_take isl_basic_map *bmap, __isl_take isl_constraint *constraint); diff --git a/include/isl/constraint.h b/include/isl/constraint.h index 86ca763..0515e91 100644 --- a/include/isl/constraint.h +++ b/include/isl/constraint.h @@ -98,6 +98,9 @@ __isl_give isl_constraint *isl_constraint_set_coefficient( __isl_give isl_constraint *isl_constraint_set_coefficient_si( __isl_take isl_constraint *constraint, enum isl_dim_type type, int pos, int v); +__isl_give isl_constraint *isl_constraint_set_coefficient_val( + __isl_take isl_constraint *constraint, + enum isl_dim_type type, int pos, isl_val *v); __isl_give isl_aff *isl_constraint_get_div(__isl_keep isl_constraint *constraint, int pos); diff --git a/isl_constraint.c b/isl_constraint.c index 82e8ef7..d72a6fe 100644 --- a/isl_constraint.c +++ b/isl_constraint.c @@ -508,6 +508,34 @@ __isl_give isl_constraint *isl_constraint_set_coefficient( return constraint; } +/* Replace the coefficient of the variable of type "type" at position "pos" + * of "constraint" by "v". + */ +__isl_give isl_constraint *isl_constraint_set_coefficient_val( + __isl_take isl_constraint *constraint, + enum isl_dim_type type, int pos, 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); + + if (pos >= isl_local_space_dim(constraint->ls, type)) + isl_die(isl_constraint_get_ctx(constraint), isl_error_invalid, + "position out of bounds", goto error); + + pos += isl_local_space_offset(constraint->ls, type); + constraint->v = isl_vec_set_element_val(constraint->v, pos, 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_coefficient_si( __isl_take isl_constraint *constraint, enum isl_dim_type type, int pos, int v)