• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010      INRIA Saclay
3  *
4  * Use of this software is governed by the MIT license
5  *
6  * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7  * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8  * 91893 Orsay, France
9  */
10 
FN(PW,morph_domain)11 __isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
12 	__isl_take isl_morph *morph)
13 {
14 	int i;
15 	isl_ctx *ctx;
16 
17 	if (!pw || !morph)
18 		goto error;
19 
20 	ctx = isl_space_get_ctx(pw->dim);
21 	isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
22 		goto error);
23 
24 	pw = FN(PW,cow)(pw);
25 	if (!pw)
26 		goto error;
27 	pw->dim = isl_space_extend_domain_with_range(
28 			isl_space_copy(morph->ran->dim), pw->dim);
29 	if (!pw->dim)
30 		goto error;
31 
32 	for (i = 0; i < pw->n; ++i) {
33 		pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
34 		if (!pw->p[i].set)
35 			goto error;
36 		pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
37 						isl_morph_copy(morph));
38 		if (!pw->p[i].FIELD)
39 			goto error;
40 	}
41 
42 	isl_morph_free(morph);
43 
44 	return pw;
45 error:
46 	FN(PW,free)(pw);
47 	isl_morph_free(morph);
48 	return NULL;
49 }
50