temporarily make isl_val_int_from_isl_int available
[platform/upstream/isl.git] / isl_val.c
index 4af87de..c61b4ad 100644 (file)
--- a/isl_val.c
+++ b/isl_val.c
@@ -749,6 +749,17 @@ error:
 }
 
 /* Return the product of "v1" and "v2".
+ *
+ * This is a private copy of isl_val_mul for use in the generic
+ * isl_multi_*_scale_val instantiated for isl_val.
+ */
+__isl_give isl_val *isl_val_scale_val(__isl_take isl_val *v1,
+       __isl_take isl_val *v2)
+{
+       return isl_val_mul(v1, v2);
+}
+
+/* Return the product of "v1" and "v2".
  */
 __isl_give isl_val *isl_val_mul_ui(__isl_take isl_val *v1, unsigned long v2)
 {
@@ -1369,3 +1380,53 @@ int isl_val_check_match_domain_space(__isl_keep isl_val *v,
 #define NO_IDENTITY
 #define NO_FROM_BASE
 #include <isl_multi_templ.c>
+
+/* Apply "fn" to each of the elements of "mv" with as second argument "v".
+ */
+static __isl_give isl_multi_val *isl_multi_val_fn_val(
+       __isl_take isl_multi_val *mv,
+       __isl_give isl_val *(*fn)(__isl_take isl_val *v1,
+                                       __isl_take isl_val *v2),
+       __isl_take isl_val *v)
+{
+       int i;
+
+       mv = isl_multi_val_cow(mv);
+       if (!mv || !v)
+               goto error;
+
+       for (i = 0; i < mv->n; ++i) {
+               mv->p[i] = fn(mv->p[i], isl_val_copy(v));
+               if (!mv->p[i])
+                       goto error;
+       }
+
+       isl_val_free(v);
+       return mv;
+error:
+       isl_val_free(v);
+       isl_multi_val_free(mv);
+       return NULL;
+}
+
+/* Add "v" to each of the elements of "mv".
+ */
+__isl_give isl_multi_val *isl_multi_val_add_val(__isl_take isl_multi_val *mv,
+       __isl_take isl_val *v)
+{
+       if (!v)
+               return isl_multi_val_free(mv);
+       if (isl_val_is_zero(v)) {
+               isl_val_free(v);
+               return mv;
+       }
+       return isl_multi_val_fn_val(mv, &isl_val_add, v);
+}
+
+/* Reduce the elements of "mv" modulo "v".
+ */
+__isl_give isl_multi_val *isl_multi_val_mod_val(__isl_take isl_multi_val *mv,
+       __isl_take isl_val *v)
+{
+       return isl_multi_val_fn_val(mv, &isl_val_mod, v);
+}