Polly 20.0.0git
isl_multi_product_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2012 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#include <isl/space.h>
11
12#include <isl_multi_macro.h>
13
14/* Given two MULTI(BASE)s A -> B and C -> D,
15 * construct a MULTI(BASE) [A -> C] -> [B -> D].
16 *
17 * If "multi1" and/or "multi2" has an explicit domain, then
18 * intersect the domain of the result with these explicit domains.
19 */
21 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
22{
23 int i;
24 EL *el;
25 isl_space *space;
26 MULTI(BASE) *res;
27 isl_size in1, in2, out1, out2;
28
29 FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
30 in1 = FN(MULTI(BASE),dim)(multi1, isl_dim_in);
31 in2 = FN(MULTI(BASE),dim)(multi2, isl_dim_in);
32 out1 = FN(MULTI(BASE),dim)(multi1, isl_dim_out);
33 out2 = FN(MULTI(BASE),dim)(multi2, isl_dim_out);
34 if (in1 < 0 || in2 < 0 || out1 < 0 || out2 < 0)
35 goto error;
36 space = isl_space_product(FN(MULTI(BASE),get_space)(multi1),
37 FN(MULTI(BASE),get_space)(multi2));
38 res = FN(MULTI(BASE),alloc)(isl_space_copy(space));
39 space = isl_space_domain(space);
40
41 for (i = 0; i < out1; ++i) {
42 el = FN(FN(MULTI(BASE),get),BASE)(multi1, i);
43 el = FN(EL,insert_dims)(el, isl_dim_in, in1, in2);
44 el = FN(EL,reset_domain_space)(el, isl_space_copy(space));
45 res = FN(FN(MULTI(BASE),set),BASE)(res, i, el);
46 }
47
48 for (i = 0; i < out2; ++i) {
49 el = FN(FN(MULTI(BASE),get),BASE)(multi2, i);
50 el = FN(EL,insert_dims)(el, isl_dim_in, 0, in1);
51 el = FN(EL,reset_domain_space)(el, isl_space_copy(space));
52 res = FN(FN(MULTI(BASE),set),BASE)(res, out1 + i, el);
53 }
54
55 if (FN(MULTI(BASE),has_explicit_domain)(multi1) ||
56 FN(MULTI(BASE),has_explicit_domain)(multi2))
57 res = FN(MULTI(BASE),intersect_explicit_domain_product)(res,
58 multi1, multi2);
59
60 isl_space_free(space);
61 FN(MULTI(BASE),free)(multi1);
62 FN(MULTI(BASE),free)(multi2);
63 return res;
64error:
65 FN(MULTI(BASE),free)(multi1);
66 FN(MULTI(BASE),free)(multi2);
67 return NULL;
68}
#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
#define EL
static __isl_give isl_qpolynomial * reset_domain_space(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:232
static __isl_give isl_qpolynomial * insert_dims(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:412
#define MULTI(BASE)
const char * set
Definition: isl_test.c:1356
const char * res
Definition: isl_test.c:775
__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_product(__isl_take isl_space *left, __isl_take isl_space *right)
Definition: isl_space.c:1552
__isl_give isl_space * isl_space_copy(__isl_keep isl_space *space)
Definition: isl_space.c:436
__isl_export __isl_give isl_space * isl_space_domain(__isl_take isl_space *space)
Definition: isl_space.c:2138
@ isl_dim_in
Definition: space_type.h:16
@ isl_dim_out
Definition: space_type.h:17