isl_map_coalesce: avoid ignoring constraints redundant wrt implicit equalities
[isl.git] / isl_multi_tuple_id_templ.c
blob87f9fe6b71d88029b79f5554887c1c7a39e4aefa
1 /*
2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
9 */
11 #include <isl/space.h>
13 #include <isl_multi_macro.h>
15 const char *FN(MULTI(BASE),get_tuple_name)(__isl_keep MULTI(BASE) *multi,
16 enum isl_dim_type type)
18 return multi ? isl_space_get_tuple_name(multi->space, type) : NULL;
21 /* Does the specified tuple have an id?
23 isl_bool FN(MULTI(BASE),has_tuple_id)(__isl_keep MULTI(BASE) *multi,
24 enum isl_dim_type type)
26 if (!multi)
27 return isl_bool_error;
28 return isl_space_has_tuple_id(multi->space, type);
31 /* Does the (range) tuple of "multi" have an identifier?
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.
38 isl_bool FN(MULTI(BASE),has_range_tuple_id)(__isl_keep MULTI(BASE) *multi)
40 return FN(MULTI(BASE),has_tuple_id)(multi, isl_dim_out);
43 /* Return the id of the specified tuple.
45 __isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi,
46 enum isl_dim_type type)
48 return multi ? isl_space_get_tuple_id(multi->space, type) : NULL;
51 /* Return the identifier of the (range) tuple of "multi", assuming it has one.
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.
58 __isl_give isl_id *FN(MULTI(BASE),get_range_tuple_id)(
59 __isl_keep MULTI(BASE) *multi)
61 return FN(MULTI(BASE),get_tuple_id)(multi, isl_dim_out);
64 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_name)(
65 __isl_keep MULTI(BASE) *multi, enum isl_dim_type type,
66 const char *s)
68 isl_space *space;
70 multi = FN(MULTI(BASE),cow)(multi);
71 if (!multi)
72 return NULL;
74 space = FN(MULTI(BASE),get_space)(multi);
75 space = isl_space_set_tuple_name(space, type, s);
77 return FN(MULTI(BASE),reset_space)(multi, space);
80 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)(
81 __isl_take MULTI(BASE) *multi, enum isl_dim_type type,
82 __isl_take isl_id *id)
84 isl_space *space;
86 multi = FN(MULTI(BASE),cow)(multi);
87 if (!multi)
88 goto error;
90 space = FN(MULTI(BASE),get_space)(multi);
91 space = isl_space_set_tuple_id(space, type, id);
93 return FN(MULTI(BASE),reset_space)(multi, space);
94 error:
95 isl_id_free(id);
96 return NULL;
99 /* Replace the identifier of the (range) tuple of "multi" by "id".
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.
106 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_range_tuple_id)(
107 __isl_take MULTI(BASE) *multi, __isl_take isl_id *id)
109 return FN(MULTI(BASE),set_tuple_id)(multi, isl_dim_out, id);
112 /* Drop the id on the specified tuple.
114 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)(
115 __isl_take MULTI(BASE) *multi, enum isl_dim_type type)
117 isl_space *space;
119 if (!multi)
120 return NULL;
121 if (!FN(MULTI(BASE),has_tuple_id)(multi, type))
122 return multi;
124 multi = FN(MULTI(BASE),cow)(multi);
125 if (!multi)
126 return NULL;
128 space = FN(MULTI(BASE),get_space)(multi);
129 space = isl_space_reset_tuple_id(space, type);
131 return FN(MULTI(BASE),reset_space)(multi, space);
134 /* Drop the identifier of the (range) tuple of "multi".
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.
141 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_range_tuple_id)(
142 __isl_take MULTI(BASE) *multi)
144 return FN(MULTI(BASE),reset_tuple_id)(multi, isl_dim_out);