Polly 19.0.0git
isl_multi_identity_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#include <isl/local_space.h>
12
13#include <isl_multi_macro.h>
14
15/* Create a multi expression in the given space that maps each
16 * input dimension to the corresponding output dimension.
17 */
19{
20 int i;
21 isl_size n_in, n_out;
23 MULTI(BASE) *multi;
24
25 if (!space)
26 return NULL;
27
28 if (isl_space_is_set(space))
30 "expecting map space", goto error);
31
32 n_in = isl_space_dim(space, isl_dim_in);
33 n_out = isl_space_dim(space, isl_dim_out);
34 if (n_in < 0 || n_out < 0)
35 goto error;
36 if (n_in != n_out)
38 "number of input and output dimensions needs to be "
39 "the same", goto error);
40
41 multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
42
43 if (!n_out) {
44 isl_space_free(space);
45 return multi;
46 }
47
48 space = isl_space_domain(space);
50
51 for (i = 0; i < n_out; ++i) {
52 EL *el;
53 el = FN(EL,var_on_domain)(isl_local_space_copy(ls),
54 isl_dim_set, i);
55 multi = FN(FN(MULTI(BASE),set),BASE)(multi, i, el);
56 }
57
59
60 return multi;
61error:
62 isl_space_free(space);
63 return NULL;
64}
65
66/* Create a multi expression that maps elements in the given space
67 * to themselves.
68 */
69__isl_give MULTI(BASE) *FN(MULTI(BASE),identity_on_domain_space)(
70 __isl_take isl_space *space)
71{
73}
74
75/* This function performs the same operation as
76 * isl_multi_*_identity_on_domain_space,
77 * but is considered as a function on an isl_space when exported.
78 */
79__isl_give MULTI(BASE) *FN(FN(isl_space_identity_multi,BASE),on_domain)(
80 __isl_take isl_space *space)
81{
82 return FN(MULTI(BASE),identity_on_domain_space)(space);
83}
84
85/* Create a multi expression in the same space as "multi" that maps each
86 * input dimension to the corresponding output dimension.
87 */
88__isl_give MULTI(BASE) *FN(FN(MULTI(BASE),identity_multi),BASE)(
89 __isl_take MULTI(BASE) *multi)
90{
91 isl_space *space;
92
93 space = FN(MULTI(BASE),get_space)(multi);
94 FN(MULTI(BASE),free)(multi);
95 return FN(MULTI(BASE),identity)(space);
96}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
@ isl_error_invalid
Definition: ctx.h:80
int isl_size
Definition: ctx.h:96
#define BASE
Definition: flow_cmp.c:49
#define EL
#define MULTI(BASE)
const char * set
Definition: isl_test.c:1356
static __isl_give isl_space * identity(__isl_take isl_space *space)
__isl_give isl_local_space * isl_local_space_from_space(__isl_take isl_space *space)
__isl_null isl_local_space * isl_local_space_free(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_copy(__isl_keep isl_local_space *ls)
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition: isl_space.c:445
isl_ctx * isl_space_get_ctx(__isl_keep isl_space *space)
Definition: isl_space.c:23
__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_map_from_set(__isl_take isl_space *space)
Definition: isl_space.c:1894
isl_size isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:340
isl_bool isl_space_is_set(__isl_keep isl_space *space)
Definition: isl_space.c:70
__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_set
Definition: space_type.h:18
@ isl_dim_out
Definition: space_type.h:17