brintos

brintos / llvm-project-archived public Read only

0
0
Text · 955 B · 0b88d1c Raw
40 lines · c
1/*2 * Copyright 2019      Cerebras Systems3 *4 * Use of this software is governed by the MIT license5 *6 * Written by Sven Verdoolaege,7 * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA8 */9 10/* Given a function defined over a parameter domain,11 * convert it to a function defined over a domain corresponding12 * to "domain".13 */14__isl_give TYPE *FN(TYPE,insert_domain)(__isl_take TYPE *obj,15	__isl_take isl_space *domain)16{17	isl_size dim;18	isl_space *obj_space;19 20	obj_space = FN(TYPE,peek_space)(obj);21	if (isl_space_check_is_set(domain) < 0 ||22	    isl_space_check_is_set(obj_space) < 0)23		goto error;24	dim = isl_space_dim(domain, isl_dim_set);25	if (dim < 0)26		goto error;27 28	domain = isl_space_replace_params(domain, obj_space);29 30	obj = FN(TYPE,from_range)(obj);31	obj = FN(TYPE,add_dims)(obj, isl_dim_in, dim);32	obj = FN(TYPE,reset_domain_space)(obj, domain);33 34	return obj;35error:36	isl_space_free(domain);37	FN(TYPE,free)(obj);38	return NULL;39}40