1 | /* |
2 | * Copyright 2019 Cerebras Systems |
3 | * |
4 | * Use of this software is governed by the MIT license |
5 | * |
6 | * Written by Sven Verdoolaege, |
7 | * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA |
8 | */ |
9 | |
10 | #define xFN(TYPE,NAME) TYPE ## _ ## NAME |
11 | #define FN(TYPE,NAME) xFN(TYPE,NAME) |
12 | |
13 | /* If "obj" involves a parameter with identifier "id", |
14 | * then turn it into an existentially quantified variable. |
15 | */ |
16 | __isl_give TYPE *FN(TYPE,project_out_param_id)(__isl_take TYPE *obj, |
17 | __isl_take isl_id *id) |
18 | { |
19 | int pos; |
20 | |
21 | if (!obj || !id) |
22 | goto error; |
23 | pos = FN(TYPE,find_dim_by_id)(map: obj, type: isl_dim_param, id); |
24 | isl_id_free(id); |
25 | if (pos < 0) |
26 | return obj; |
27 | return FN(TYPE,project_out)(map: obj, type: isl_dim_param, first: pos, n: 1); |
28 | error: |
29 | FN(TYPE,free)(map: obj); |
30 | isl_id_free(id); |
31 | return NULL; |
32 | } |
33 | |
34 | /* If "obj" involves any of the parameters with identifiers in "list", |
35 | * then turn them into existentially quantified variables. |
36 | */ |
37 | __isl_give TYPE *FN(TYPE,project_out_param_id_list)(__isl_take TYPE *obj, |
38 | __isl_take isl_id_list *list) |
39 | { |
40 | int i; |
41 | isl_size n; |
42 | |
43 | n = isl_id_list_size(list); |
44 | if (n < 0) |
45 | goto error; |
46 | for (i = 0; i < n; ++i) { |
47 | isl_id *id; |
48 | |
49 | id = isl_id_list_get_at(list, index: i); |
50 | obj = FN(TYPE,project_out_param_id)(obj, id); |
51 | } |
52 | |
53 | isl_id_list_free(list); |
54 | return obj; |
55 | error: |
56 | isl_id_list_free(list); |
57 | FN(TYPE,free)(map: obj); |
58 | return NULL; |
59 | } |
60 | |