Polly 19.0.0git
isl_multi_add_constant_templ.c
Go to the documentation of this file.
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)(
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(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)(
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(mv);
47 return multi;
48 }
49
50 return FN(MULTI(BASE),fn_multi_val)(multi, &FN(EL,add_constant_val),
51 mv);
52
53error:
54 FN(MULTI(BASE),free)(multi);
55 isl_multi_val_free(mv);
56 return NULL;
57}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
isl_bool
Definition: ctx.h:89
#define BASE
Definition: flow_cmp.c:49
#define EL
#define MULTI(BASE)
isl_bool isl_multi_val_is_zero(__isl_keep isl_multi_val *mv)
Definition: isl_val.c:1594
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
Definition: isl_val.c:263
__isl_export isl_bool isl_val_is_zero(__isl_keep isl_val *v)
Definition: isl_val.c:1191
struct isl_multi_val isl_multi_val
Definition: val_type.h:16