brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · fc5aed2 Raw
74 lines · c
1/*2 * Copyright 2013      Ecole Normale Superieure3 *4 * Use of this software is governed by the MIT license5 *6 * Written by Sven Verdoolaege,7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France8 */9 10#define xCAT(A,B) A ## B11#define CAT(A,B) xCAT(A,B)12#undef TYPE13#define TYPE CAT(isl_,BASE)14#define xFN(TYPE,NAME) TYPE ## _ ## NAME15#define FN(TYPE,NAME) xFN(TYPE,NAME)16 17#undef SUFFIX18#define SUFFIX	BASE19#undef ARG120#define ARG1	isl_multi_pw_aff21#undef ARG222#define ARG2	TYPE23 24static25#include "isl_align_params_templ.c"26 27/* Compute the pullback of "mpa" by the function represented by "fn".28 * In other words, plug in "fn" in "mpa".29 *30 * If "mpa" has an explicit domain, then it is this domain31 * that needs to undergo a pullback, i.e., a preimage.32 */33__isl_give isl_multi_pw_aff *FN(isl_multi_pw_aff_pullback,BASE)(34	__isl_take isl_multi_pw_aff *mpa, __isl_take TYPE *fn)35{36	int i;37	isl_size n;38	isl_space *space = NULL;39 40	FN(isl_multi_pw_aff_align_params,BASE)(&mpa, &fn);41	mpa = isl_multi_pw_aff_cow(mpa);42	n = isl_multi_pw_aff_size(mpa);43	if (n < 0 || !fn)44		goto error;45 46	space = isl_space_join(FN(TYPE,get_space)(fn),47				isl_multi_pw_aff_get_space(mpa));48 49	for (i = 0; i < n; ++i) {50		isl_pw_aff *pa;51 52		pa = isl_multi_pw_aff_take_at(mpa, i);53		pa = FN(isl_pw_aff_pullback,BASE)(pa, FN(TYPE,copy)(fn));54		mpa = isl_multi_pw_aff_restore_at(mpa, i, pa);55		if (!mpa)56			goto error;57	}58	if (isl_multi_pw_aff_has_explicit_domain(mpa)) {59		mpa->u.dom = FN(isl_set_preimage,BASE)(mpa->u.dom,60							FN(TYPE,copy)(fn));61		if (!mpa->u.dom)62			goto error;63	}64 65	FN(TYPE,free)(fn);66	isl_multi_pw_aff_restore_space(mpa, space);67	return mpa;68error:69	isl_space_free(space);70	isl_multi_pw_aff_free(mpa);71	FN(TYPE,free)(fn);72	return NULL;73}74