Polly 20.0.0git
isl_multi_bind_templ.c
Go to the documentation of this file.
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 */
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(tuple);
29 r = isl_space_check_equal_tuples(multi_space, tuple_space);
30 isl_space_free(multi_space);
31 if (r < 0)
32 goto error;
33 n = FN(MULTI(BASE),dim)(multi, isl_dim_set);
34 if (n < 0)
35 goto error;
36
37 if (n == 0) {
38 isl_multi_id_free(tuple);
39 return FN(MULTI(BASE),domain)(multi);
40 }
41
42 el = FN(MULTI(BASE),get_at)(multi, 0);
43 id = isl_multi_id_get_at(tuple, 0);
44 bnd = FN(EL,bind_id)(el, id);
45
46 for (i = 1; i < n; ++i) {
47 DOM *bnd_i;
48
49 el = FN(MULTI(BASE),get_at)(multi, i);
50 id = isl_multi_id_get_at(tuple, i);
51 bnd_i = FN(EL,bind_id)(el, id);
52
53 bnd_i = FN(DOM,align_params)(bnd_i, FN(DOM,get_space)(bnd));
54 bnd = FN(DOM,align_params)(bnd, FN(DOM,get_space)(bnd_i));
55 bnd = FN(DOM,intersect)(bnd, bnd_i);
56 }
57
58 FN(MULTI(BASE),free)(multi);
59 isl_multi_id_free(tuple);
60 return bnd;
61error:
62 FN(MULTI(BASE),free)(multi);
63 isl_multi_id_free(tuple);
64 return NULL;
65}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
isl_stat
Definition: ctx.h:84
#define __isl_give
Definition: ctx.h:19
int isl_size
Definition: ctx.h:96
#define BASE
Definition: flow_cmp.c:49
struct isl_multi_id isl_multi_id
Definition: id_type.h:16
static isl_stat bind_id(__isl_take isl_pw_aff *pa, void *user)
Definition: isl_aff.c:8480
#define EL
#define MULTI(BASE)
#define DOM
static __isl_give isl_schedule_node * align_params(__isl_take isl_schedule_node *node, void *user)
Definition: isl_schedule.c:311
isl_stat isl_space_check_equal_tuples(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
Definition: isl_space.c:1026
const char * tuple
Definition: isl_test.c:7008
const char * id
Definition: isl_test.c:7279
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition: isl_space.c:445
__isl_export __isl_give isl_space * isl_space_range(__isl_take isl_space *space)
Definition: isl_space.c:2163
@ isl_dim_set
Definition: space_type.h:18
static Signature domain
static std::vector< std::string > intersect(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
n
Definition: youcefn.c:8