brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 87f9fe6 Raw
146 lines · c
1/*2 * Copyright 2011      Sven Verdoolaege3 * Copyright 2012-2013 Ecole Normale Superieure4 *5 * Use of this software is governed by the MIT license6 *7 * Written by Sven Verdoolaege,8 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France9 */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 equal36 * 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 */45__isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi,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 equal56 * 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)(65	__isl_keep MULTI(BASE) *multi, enum isl_dim_type type,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)(81	__isl_take MULTI(BASE) *multi, enum isl_dim_type type,82	__isl_take isl_id *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 equal104 * to isl_dim_out.105 */106__isl_give MULTI(BASE) *FN(MULTI(BASE),set_range_tuple_id)(107	__isl_take MULTI(BASE) *multi, __isl_take isl_id *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 equal139 * 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}146