File: isl_map_bound_templ.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (57 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download | duplicates (24)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright 2018      Cerebras Systems
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege,
 * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
 */

#include "isl_multi_macro.h"
#undef TYPE
#define TYPE CAT(isl_,BASE)

/* Check that "map" and "multi" live in the same space, ignoring parameters.
 */
static isl_stat FN(check_map_equal_tuples_multi,BASE)(__isl_keep isl_map *map,
	__isl_keep MULTI(BASE) *multi)
{
	isl_space *map_space, *multi_space;

	map_space = isl_map_peek_space(map);
	multi_space = FN(MULTI(BASE),peek_space)(multi);
	return isl_space_check_equal_tuples(map_space, multi_space);
}

/* Apply "map_bound" to "map" with the corresponding value in "bound"
 * for each output dimension.
 * If "bound" has an explicit domain (which implies that "bound"
 * is zero-dimensional), then intersect the domain of "map"
 * with this explicit domain instead.
 */
static __isl_give isl_map *FN(map_bound_multi,BASE)(__isl_take isl_map *map,
	__isl_take MULTI(BASE) *bound,
	__isl_give isl_map *map_bound(__isl_take isl_map *map,
		unsigned pos, __isl_take TYPE *value))
{
	int i;
	isl_size dim;

	dim = isl_map_dim(map, isl_dim_out);
	if (dim < 0 || FN(check_map_equal_tuples_multi,BASE)(map, bound) < 0)
		goto error;

	for (i = 0; i < dim; ++i) {
		TYPE *el;

		el = FN(MULTI(BASE),get_at)(bound, i);
		map = map_bound(map, i, el);
	}
	map = FN(FN(isl_map_intersect_multi,BASE),explicit_domain)(map, bound);
	FN(MULTI(BASE),free)(bound);
	return map;
error:
	isl_map_free(map);
	FN(MULTI(BASE),free)(bound);
	return NULL;
}