Polly 19.0.0git
isl_multi_bin_val_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ecole Normale Superieure
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
9
10/* Apply "fn" to each of the elements of "multi" with as second argument "v".
11 */
12static __isl_give MULTI(BASE) *FN(MULTI(BASE),fn_val)(
13 __isl_take MULTI(BASE) *multi,
16{
17 isl_size n;
18 int i;
19
20 n = FN(MULTI(BASE),size)(multi);
21 if (n < 0 || !v)
22 goto error;
23
24 for (i = 0; i < n; ++i) {
25 EL *el;
26
27 el = FN(MULTI(BASE),take_at)(multi, i);
28 el = fn(el, isl_val_copy(v));
29 multi = FN(MULTI(BASE),restore_at)(multi, i, el);
30 }
31
32 isl_val_free(v);
33 return multi;
34error:
35 isl_val_free(v);
36 FN(MULTI(BASE),free)(multi);
37 return NULL;
38}
39
40#undef TYPE
41#define TYPE MULTI(BASE)
43
44/* Elementwise apply "fn" to "multi" and "mv".
45 */
46static __isl_give MULTI(BASE) *FN(MULTI(BASE),fn_multi_val)(
47 __isl_take MULTI(BASE) *multi,
50{
51 isl_size n;
52 int i;
53
54 n = FN(MULTI(BASE),size)(multi);
55 if (n < 0 || FN(MULTI(BASE),check_match_range_multi_val)(multi, mv) < 0)
56 goto error;
57
58 for (i = 0; i < n; ++i) {
59 isl_val *v;
60 EL *el;
61
62 v = isl_multi_val_get_val(mv, i);
63 el = FN(MULTI(BASE),take_at)(multi, i);
64 el = fn(el, v);
65 multi = FN(MULTI(BASE),restore_at)(multi, i, el);
66 }
67
68 isl_multi_val_free(mv);
69 return multi;
70error:
71 isl_multi_val_free(mv);
72 return FN(MULTI(BASE),free)(multi);
73}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
int isl_size
Definition: ctx.h:96
#define BASE
Definition: flow_cmp.c:49
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
Definition: hmap.h:37
#define EL
#define MULTI(BASE)
const char * size
Definition: isl_test.c:1570
__isl_give isl_val * isl_val_copy(__isl_keep isl_val *v)
Definition: isl_val.c:219
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
Definition: isl_val.c:263
struct isl_multi_val isl_multi_val
Definition: val_type.h:16
n
Definition: youcefn.c:8