Polly 19.0.0git
isl_domain_factor_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2012 Ecole Normale Superieure
3 * Copyright 2017 Sven Verdoolaege
4 *
5 * Use of this software is governed by the MIT license
6 *
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
9 */
10
11#define xFN(TYPE,NAME) TYPE ## _ ## NAME
12#define FN(TYPE,NAME) xFN(TYPE,NAME)
13
14/* Drop the "n" domain dimensions starting at "first" from "obj",
15 * after checking that they do not appear in the affine expression.
16 */
17static __isl_give TYPE *FN(TYPE,drop_domain)(__isl_take TYPE *obj,
18 unsigned first, unsigned n)
19{
20 isl_bool involves;
21
22 involves = FN(TYPE,involves_dims)(obj, isl_dim_in, first, n);
23 if (involves < 0)
24 return FN(TYPE,free)(obj);
25 if (involves)
27 "affine expression involves some of the domain dimensions",
28 return FN(TYPE,free)(obj));
29 return FN(TYPE,drop_dims)(obj, isl_dim_in, first, n);
30}
31
32/* Check that the domain of "obj" is a product.
33 */
34static isl_stat FN(TYPE,check_domain_product)(__isl_keep TYPE *obj)
35{
36 isl_bool is_product;
37
38 is_product = FN(TYPE,domain_is_product)(obj);
39 if (is_product < 0)
40 return isl_stat_error;
41 if (!is_product)
43 "domain is not a product", return isl_stat_error);
44 return isl_stat_ok;
45}
46
47/* Given an affine function with a domain of the form [A -> B] that
48 * does not depend on B, return the same function on domain A.
49 */
51{
52 isl_space *space;
53 isl_size n, n_in;
54
55 if (FN(TYPE,check_domain_product)(obj) < 0)
56 return FN(TYPE,free)(obj);
57 space = FN(TYPE,get_domain_space)(obj);
58 n = isl_space_dim(space, isl_dim_set);
59 space = isl_space_factor_domain(space);
60 n_in = isl_space_dim(space, isl_dim_set);
61 if (n < 0 || n_in < 0)
62 obj = FN(TYPE,free)(obj);
63 else
64 obj = FN(TYPE,drop_domain)(obj, n_in, n - n_in);
65 obj = FN(TYPE,reset_domain_space)(obj, space);
66 return obj;
67}
#define TYPE
#define __isl_take
Definition: ctx.h:22
isl_stat
Definition: ctx.h:84
@ isl_stat_error
Definition: ctx.h:85
@ isl_stat_ok
Definition: ctx.h:86
#define __isl_give
Definition: ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
@ isl_error_invalid
Definition: ctx.h:80
#define __isl_keep
Definition: ctx.h:25
int isl_size
Definition: ctx.h:96
isl_bool
Definition: ctx.h:89
#define FN(TYPE, NAME)
static __isl_give isl_qpolynomial * reset_domain_space(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:232
static __isl_give isl_qpolynomial * drop_dims(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:373
const char * obj
Definition: isl_test.c:3316
__isl_give isl_space * isl_space_factor_domain(__isl_take isl_space *space)
Definition: isl_space.c:1776
isl_size isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:340
@ isl_dim_in
Definition: space_type.h:16
@ isl_dim_set
Definition: space_type.h:18
static Signature domain_factor_domain
n
Definition: youcefn.c:8