Polly 20.0.0git
isl_multi_tuple_id_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
4 *
5 * Use of this software is governed by the MIT license
6 *
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
9 */
10
11#include <isl/space.h>
12
13#include <isl_multi_macro.h>
14
15const char *FN(MULTI(BASE),get_tuple_name)(__isl_keep MULTI(BASE) *multi,
16 enum isl_dim_type type)
17{
18 return multi ? isl_space_get_tuple_name(multi->space, type) : NULL;
19}
20
21/* Does the specified tuple have an id?
22 */
23isl_bool FN(MULTI(BASE),has_tuple_id)(__isl_keep MULTI(BASE) *multi,
24 enum isl_dim_type type)
25{
26 if (!multi)
27 return isl_bool_error;
28 return isl_space_has_tuple_id(multi->space, type);
29}
30
31/* Does the (range) tuple of "multi" have an identifier?
32 *
33 * Technically, the implementation should use isl_dim_set if "multi"
34 * lives in a set space and isl_dim_out if it lives in a map space.
35 * Internally, however, it can be assumed that isl_dim_set is equal
36 * to isl_dim_out.
37 */
38isl_bool FN(MULTI(BASE),has_range_tuple_id)(__isl_keep MULTI(BASE) *multi)
39{
40 return FN(MULTI(BASE),has_tuple_id)(multi, isl_dim_out);
41}
42
43/* Return the id of the specified tuple.
44 */
46 enum isl_dim_type type)
47{
48 return multi ? isl_space_get_tuple_id(multi->space, type) : NULL;
49}
50
51/* Return the identifier of the (range) tuple of "multi", assuming it has one.
52 *
53 * Technically, the implementation should use isl_dim_set if "multi"
54 * lives in a set space and isl_dim_out if it lives in a map space.
55 * Internally, however, it can be assumed that isl_dim_set is equal
56 * to isl_dim_out.
57 */
58__isl_give isl_id *FN(MULTI(BASE),get_range_tuple_id)(
59 __isl_keep MULTI(BASE) *multi)
60{
61 return FN(MULTI(BASE),get_tuple_id)(multi, isl_dim_out);
62}
63
64__isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_name)(
66 const char *s)
67{
68 isl_space *space;
69
70 multi = FN(MULTI(BASE),cow)(multi);
71 if (!multi)
72 return NULL;
73
74 space = FN(MULTI(BASE),get_space)(multi);
75 space = isl_space_set_tuple_name(space, type, s);
76
77 return FN(MULTI(BASE),reset_space)(multi, space);
78}
79
80__isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)(
83{
84 isl_space *space;
85
86 multi = FN(MULTI(BASE),cow)(multi);
87 if (!multi)
88 goto error;
89
90 space = FN(MULTI(BASE),get_space)(multi);
91 space = isl_space_set_tuple_id(space, type, id);
92
93 return FN(MULTI(BASE),reset_space)(multi, space);
94error:
95 isl_id_free(id);
96 return NULL;
97}
98
99/* Replace the identifier of the (range) tuple of "multi" by "id".
100 *
101 * Technically, the implementation should use isl_dim_set if "multi"
102 * lives in a set space and isl_dim_out if it lives in a map space.
103 * Internally, however, it can be assumed that isl_dim_set is equal
104 * to isl_dim_out.
105 */
106__isl_give MULTI(BASE) *FN(MULTI(BASE),set_range_tuple_id)(
108{
109 return FN(MULTI(BASE),set_tuple_id)(multi, isl_dim_out, id);
110}
111
112/* Drop the id on the specified tuple.
113 */
114__isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)(
115 __isl_take MULTI(BASE) *multi, enum isl_dim_type type)
116{
117 isl_space *space;
118
119 if (!multi)
120 return NULL;
121 if (!FN(MULTI(BASE),has_tuple_id)(multi, type))
122 return multi;
123
124 multi = FN(MULTI(BASE),cow)(multi);
125 if (!multi)
126 return NULL;
127
128 space = FN(MULTI(BASE),get_space)(multi);
129 space = isl_space_reset_tuple_id(space, type);
130
131 return FN(MULTI(BASE),reset_space)(multi, space);
132}
133
134/* Drop the identifier of the (range) tuple of "multi".
135 *
136 * Technically, the implementation should use isl_dim_set if "multi"
137 * lives in a set space and isl_dim_out if it lives in a map space.
138 * Internally, however, it can be assumed that isl_dim_set is equal
139 * to isl_dim_out.
140 */
141__isl_give MULTI(BASE) *FN(MULTI(BASE),reset_range_tuple_id)(
142 __isl_take MULTI(BASE) *multi)
143{
144 return FN(MULTI(BASE),reset_tuple_id)(multi, isl_dim_out);
145}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define __isl_keep
Definition: ctx.h:25
isl_bool
Definition: ctx.h:89
@ isl_bool_error
Definition: ctx.h:90
#define BASE
Definition: flow_cmp.c:49
__isl_null isl_id * isl_id_free(__isl_take isl_id *id)
Definition: isl_id.c:207
#define MULTI(BASE)
enum isl_fold type
Definition: isl_test.c:4017
const char * id
Definition: isl_test.c:7279
__isl_give isl_space * isl_space_set_tuple_id(__isl_take isl_space *space, enum isl_dim_type type, __isl_take isl_id *id)
Definition: isl_space.c:636
isl_bool isl_space_has_tuple_id(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:572
__isl_give isl_id * isl_space_get_tuple_id(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:598
__isl_give isl_space * isl_space_set_tuple_name(__isl_take isl_space *space, enum isl_dim_type type, const char *s)
Definition: isl_space.c:785
__isl_keep const char * isl_space_get_tuple_name(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:819
__isl_give isl_space * isl_space_reset_tuple_id(__isl_take isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:679
isl_dim_type
Definition: space_type.h:13
@ isl_dim_out
Definition: space_type.h:17