merge isl_pw_*_from_* implementations
[isl.git] / isl_multi_tuple_id_templ.c
blob03f74d479176bfe56432153aa1a6570e97914488
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 /* Return the id of the specified tuple.
33 __isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi,
34 enum isl_dim_type type)
36 return multi ? isl_space_get_tuple_id(multi->space, type) : NULL;
39 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_name)(
40 __isl_keep MULTI(BASE) *multi, enum isl_dim_type type,
41 const char *s)
43 isl_space *space;
45 multi = FN(MULTI(BASE),cow)(multi);
46 if (!multi)
47 return NULL;
49 space = FN(MULTI(BASE),get_space)(multi);
50 space = isl_space_set_tuple_name(space, type, s);
52 return FN(MULTI(BASE),reset_space)(multi, space);
55 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)(
56 __isl_take MULTI(BASE) *multi, enum isl_dim_type type,
57 __isl_take isl_id *id)
59 isl_space *space;
61 multi = FN(MULTI(BASE),cow)(multi);
62 if (!multi)
63 goto error;
65 space = FN(MULTI(BASE),get_space)(multi);
66 space = isl_space_set_tuple_id(space, type, id);
68 return FN(MULTI(BASE),reset_space)(multi, space);
69 error:
70 isl_id_free(id);
71 return NULL;
74 /* Drop the id on the specified tuple.
76 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)(
77 __isl_take MULTI(BASE) *multi, enum isl_dim_type type)
79 isl_space *space;
81 if (!multi)
82 return NULL;
83 if (!FN(MULTI(BASE),has_tuple_id)(multi, type))
84 return multi;
86 multi = FN(MULTI(BASE),cow)(multi);
87 if (!multi)
88 return NULL;
90 space = FN(MULTI(BASE),get_space)(multi);
91 space = isl_space_reset_tuple_id(space, type);
93 return FN(MULTI(BASE),reset_space)(multi, space);