1/*
2 * Copyright 2019 Cerebras Systems
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
8 */
9
10#include <isl_multi_macro.h>
11
12/* Add "v" to the constant terms of all the base expressions of "multi".
13 */
14__isl_give MULTI(BASE) *FN(MULTI(BASE),add_constant_val)(
15 __isl_take MULTI(BASE) *multi, __isl_take isl_val *v)
16{
17 isl_bool zero;
18
19 zero = isl_val_is_zero(v);
20 if (zero < 0)
21 goto error;
22 if (zero) {
23 isl_val_free(v);
24 return multi;
25 }
26
27 return FN(MULTI(BASE),fn_val)(multi, fn: &FN(EL,add_constant_val), v);
28error:
29 FN(MULTI(BASE),free)(multi);
30 isl_val_free(v);
31 return NULL;
32}
33
34/* Add the elements of "mv" to the constant terms of
35 * the corresponding base expressions of "multi".
36 */
37__isl_give MULTI(BASE) *FN(MULTI(BASE),add_constant_multi_val)(
38 __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv)
39{
40 isl_bool zero;
41
42 zero = isl_multi_val_is_zero(mv);
43 if (zero < 0)
44 goto error;
45 if (zero) {
46 isl_multi_val_free(multi: mv);
47 return multi;
48 }
49
50 return FN(MULTI(BASE),fn_multi_val)(multi, fn: &FN(EL,add_constant_val),
51 mv);
52
53error:
54 FN(MULTI(BASE),free)(multi);
55 isl_multi_val_free(multi: mv);
56 return NULL;
57}
58

source code of polly/lib/External/isl/isl_multi_add_constant_templ.c