File: isl_multi_pw_aff_explicit_domain.c

package info (click to toggle)
isl 0.20-2
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 12,708 kB
  • sloc: ansic: 125,702; python: 5,770; sh: 4,291; cpp: 1,057; makefile: 497; lisp: 54; perl: 9
file content (134 lines) | stat: -rw-r--r-- 4,163 bytes parent folder | download | duplicates (12)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * Copyright 2017      Sven Verdoolaege
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege.
 */

/* Initialize the explicit domain of "mpa".
 *
 * The explicit domain is initialized to a universe set
 * in the domain space.
 */
static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_init_explicit_domain(
	__isl_take isl_multi_pw_aff *mpa)
{
	if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0)
		return isl_multi_pw_aff_free(mpa);
	mpa->u.dom = isl_set_universe(isl_multi_pw_aff_get_domain_space(mpa));
	if (!mpa->u.dom)
		return isl_multi_pw_aff_free(mpa);
	return mpa;
}

/* Intersect the domain of "dst" with the domain product
 * of the explicit domains of "src1" and "src2".
 * This function is only called if at least one of "src1" or "src2"
 * has an explicit domain.
 */
static __isl_give isl_multi_pw_aff *
isl_multi_pw_aff_intersect_explicit_domain_product(
	__isl_take isl_multi_pw_aff *dst, __isl_keep isl_multi_pw_aff *src1,
	__isl_keep isl_multi_pw_aff *src2)
{
	isl_space *space;
	isl_set *dom;
	isl_map *map;

	if (!src1 || !src2)
		return FN(isl_multi_pw_aff,free)(dst);
	space = isl_multi_pw_aff_get_domain_space(dst);
	dom = isl_set_universe(space);
	map = isl_set_unwrap(dom);
	if (isl_multi_pw_aff_has_explicit_domain(src1)) {
		dom = isl_set_copy(src1->u.dom);
		map = isl_map_intersect_domain(map, dom);
	}
	if (isl_multi_pw_aff_has_explicit_domain(src2)) {
		dom = isl_set_copy(src2->u.dom);
		map = isl_map_intersect_range(map, dom);
	}
	dom = isl_map_wrap(map);
	dst = isl_multi_pw_aff_intersect_domain(dst, dom);
	return dst;
}

/* Check whether the explicit domain of "mpa" has non-zero coefficients
 * for any dimension in the given range or if any of these dimensions appear
 * with non-zero coefficients in any of the integer divisions involved.
 */
isl_bool isl_multi_pw_aff_involves_explicit_domain_dims(
	__isl_keep isl_multi_pw_aff *mpa,
	enum isl_dim_type type, unsigned pos, unsigned n)
{
	if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0)
		return isl_bool_error;
	if (type == isl_dim_in)
		type = isl_dim_set;
	return isl_set_involves_dims(mpa->u.dom, type, pos, n);
}

/* Insert "n" dimensions of type "type" at position "pos"
 * of the explicit domain of "mpa".
 */
static __isl_give isl_multi_pw_aff *
isl_multi_pw_aff_insert_explicit_domain_dims(__isl_take isl_multi_pw_aff *mpa,
	enum isl_dim_type type, unsigned pos, unsigned n)
{
	if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0)
		return isl_multi_pw_aff_free(mpa);
	mpa = isl_multi_pw_aff_cow(mpa);
	if (!mpa)
		return NULL;
	if (type == isl_dim_in)
		type = isl_dim_set;
	mpa->u.dom = isl_set_insert_dims(mpa->u.dom, type, pos, n);
	if (!mpa->u.dom)
		return isl_multi_pw_aff_free(mpa);
	return mpa;
}

/* Drop the "n" dimensions of type "type" starting at position "pos"
 * of the explicit domain of "mpa".
 */
static __isl_give isl_multi_pw_aff *
isl_multi_pw_aff_drop_explicit_domain_dims(__isl_take isl_multi_pw_aff *mpa,
	enum isl_dim_type type, unsigned pos, unsigned n)
{
	if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0)
		return isl_multi_pw_aff_free(mpa);
	mpa = isl_multi_pw_aff_cow(mpa);
	if (!mpa)
		return NULL;
	if (type == isl_dim_in)
		type = isl_dim_set;
	mpa->u.dom = isl_set_drop(mpa->u.dom, type, pos, n);
	if (!mpa->u.dom)
		return isl_multi_pw_aff_free(mpa);
	return mpa;
}

/* Move the "n" dimensions of "src_type" starting at "src_pos" of
 * of the explicit domain of "mpa" to dimensions of "dst_type" at "dst_pos".
 */
static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_explicit_domain_dims(
	__isl_take isl_multi_pw_aff *mpa,
	enum isl_dim_type dst_type, unsigned dst_pos,
	enum isl_dim_type src_type, unsigned src_pos, unsigned n)
{
	if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0)
		return isl_multi_pw_aff_free(mpa);
	mpa = isl_multi_pw_aff_cow(mpa);
	if (!mpa)
		return NULL;
	if (dst_type == isl_dim_in)
		dst_type = isl_dim_set;
	if (src_type == isl_dim_in)
		src_type = isl_dim_set;
	mpa->u.dom = isl_set_move_dims(mpa->u.dom, dst_type, dst_pos,
				src_type, src_pos, n);
	if (!mpa->u.dom)
		return isl_multi_pw_aff_free(mpa);
	return mpa;
}