Polly 20.0.0git
isl_map_bound_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2018 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#include "isl_multi_macro.h"
11#undef TYPE
12#define TYPE CAT(isl_,BASE)
13
14/* Check that "map" and "multi" live in the same space, ignoring parameters.
15 */
16static isl_stat FN(check_map_equal_tuples_multi,BASE)(__isl_keep isl_map *map,
17 __isl_keep MULTI(BASE) *multi)
18{
19 isl_space *map_space, *multi_space;
20
21 map_space = isl_map_peek_space(map);
22 multi_space = FN(MULTI(BASE),peek_space)(multi);
23 return isl_space_check_equal_tuples(map_space, multi_space);
24}
25
26/* Apply "map_bound" to "map" with the corresponding value in "bound"
27 * for each output dimension.
28 * If "bound" has an explicit domain (which implies that "bound"
29 * is zero-dimensional), then intersect the domain of "map"
30 * with this explicit domain instead.
31 */
32static __isl_give isl_map *FN(map_bound_multi,BASE)(__isl_take isl_map *map,
35 unsigned pos, __isl_take TYPE *value))
36{
37 int i;
38 isl_size dim;
39
41 if (dim < 0 || FN(check_map_equal_tuples_multi,BASE)(map, bound) < 0)
42 goto error;
43
44 for (i = 0; i < dim; ++i) {
45 TYPE *el;
46
47 el = FN(MULTI(BASE),get_at)(bound, i);
48 map = map_bound(map, i, el);
49 }
50 map = FN(FN(isl_map_intersect_multi,BASE),explicit_domain)(map, bound);
51 FN(MULTI(BASE),free)(bound);
52 return map;
53error:
55 FN(MULTI(BASE),free)(bound);
56 return NULL;
57}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
isl_stat
Definition: ctx.h:84
#define __isl_give
Definition: ctx.h:19
#define __isl_keep
Definition: ctx.h:25
int isl_size
Definition: ctx.h:96
#define BASE
Definition: flow_cmp.c:49
static __isl_give isl_map * map_bound(__isl_take isl_map *map, enum isl_dim_type type, unsigned pos, isl_int value, int upper)
Definition: isl_map.c:6855
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_map.c:70
__isl_keep isl_space * isl_map_peek_space(__isl_keep const isl_map *map)
Definition: isl_map.c:98
#define TYPE
#define MULTI(BASE)
static struct isl_arg_choice bound[]
Definition: isl_options.c:39
isl_stat isl_space_check_equal_tuples(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
Definition: isl_space.c:1026
const char * map
Definition: isl_test.c:1783
isl_size isl_map_dim(__isl_keep isl_map *map, enum isl_dim_type type)
Definition: isl_map.c:110
__isl_null isl_map * isl_map_free(__isl_take isl_map *map)
Definition: isl_map.c:6421
@ isl_dim_out
Definition: space_type.h:17