File: isl_opt_mpa_templ.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (51 lines) | stat: -rw-r--r-- 1,456 bytes parent folder | download | duplicates (29)
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
/*
 * 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
 */

#undef TYPE
#define TYPE CAT(isl_,BASE)
#define xFN(TYPE,NAME) TYPE ## _ ## NAME
#define FN(TYPE,NAME) xFN(TYPE,NAME)

/* Compute the optima of the set or output dimensions as a function of the
 * parameters (and input dimensions), but independently of
 * the other set or output dimensions,
 * given a function "opt" that computes this optimum
 * for a single dimension.
 *
 * If the resulting multi piecewise affine expression has
 * an explicit domain, then assign it the (parameter) domain of the input.
 * In other cases, the (parameter) domain is stored in the individual elements.
 */
static __isl_give isl_multi_pw_aff *FN(BASE,opt_mpa)(__isl_take TYPE *obj,
	__isl_give isl_pw_aff *(*opt)(__isl_take TYPE *obj, int pos))
{
	int i;
	isl_size n;
	isl_multi_pw_aff *mpa;

	mpa = isl_multi_pw_aff_alloc(FN(TYPE,get_space)(obj));
	n = isl_multi_pw_aff_size(mpa);
	if (n < 0)
		mpa = isl_multi_pw_aff_free(mpa);
	for (i = 0; i < n; ++i) {
		isl_pw_aff *pa;

		pa = opt(FN(TYPE,copy)(obj), i);
		mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
	}
	if (isl_multi_pw_aff_has_explicit_domain(mpa)) {
		isl_set *dom;

		dom = FN(TYPE,domain)(FN(TYPE,copy)(obj));
		mpa = isl_multi_pw_aff_intersect_domain(mpa, dom);
	}
	FN(TYPE,free)(obj);

	return mpa;
}