1/*
2 * Copyright 2018 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/* Bind the expressions of "multi" to parameters with identifiers
11 * specified by "tuple", living in the same space as
12 * (the target space of) "multi",
13 * returning the elements in the domain where the expressions
14 * are equal to the parameters.
15 */
16__isl_give DOM *FN(MULTI(BASE),bind)(__isl_take MULTI(BASE) *multi,
17 __isl_take isl_multi_id *tuple)
18{
19 int i;
20 isl_id *id;
21 isl_stat r;
22 isl_size n;
23 isl_space *multi_space, *tuple_space;
24 EL *el;
25 DOM *bnd;
26
27 multi_space = isl_space_range(FN(MULTI(BASE),get_space)(multi));
28 tuple_space = isl_multi_id_peek_space(multi: tuple);
29 r = isl_space_check_equal_tuples(space1: multi_space, space2: tuple_space);
30 isl_space_free(space: multi_space);
31 if (r < 0)
32 goto error;
33 n = FN(MULTI(BASE),dim)(multi, type: isl_dim_set);
34 if (n < 0)
35 goto error;
36
37 if (n == 0) {
38 isl_multi_id_free(multi: tuple);
39 return FN(MULTI(BASE),domain)(ma: multi);
40 }
41
42 el = FN(MULTI(BASE),get_at)(multi, pos: 0);
43 id = isl_multi_id_get_at(multi: tuple, pos: 0);
44 bnd = FN(EL,bind_id)(aff: el, id);
45
46 for (i = 1; i < n; ++i) {
47 DOM *bnd_i;
48
49 el = FN(MULTI(BASE),get_at)(multi, pos: i);
50 id = isl_multi_id_get_at(multi: tuple, pos: i);
51 bnd_i = FN(EL,bind_id)(aff: el, id);
52
53 bnd_i = FN(DOM,align_params)(bmap: bnd_i, FN(DOM,get_space)(bmap: bnd));
54 bnd = FN(DOM,align_params)(bmap: bnd, FN(DOM,get_space)(bmap: bnd_i));
55 bnd = FN(DOM,intersect)(bmap1: bnd, bmap2: bnd_i);
56 }
57
58 FN(MULTI(BASE),free)(multi);
59 isl_multi_id_free(multi: tuple);
60 return bnd;
61error:
62 FN(MULTI(BASE),free)(multi);
63 isl_multi_id_free(multi: tuple);
64 return NULL;
65}
66

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