Merge branch 'maint'
[isl.git] / isl_schedule_tree.h
blobfecf9ccf212131bafb401854a44c3c5d3d5a1b4e
1 #ifndef ISL_SCHEDLUE_TREE_H
2 #define ISL_SCHEDLUE_TREE_H
4 #include <isl_schedule_band.h>
5 #include <isl/schedule.h>
6 #include <isl/set.h>
7 #include <isl/union_set.h>
9 struct isl_schedule_tree;
10 typedef struct isl_schedule_tree isl_schedule_tree;
12 ISL_DECLARE_LIST(schedule_tree)
14 /* A schedule (sub)tree.
16 * The leaves of a tree are not explicitly represented inside
17 * the isl_schedule_tree, except when the tree consists of only a leaf.
19 * The "band" field is valid when type is isl_schedule_node_band.
20 * The "context" field is valid when type is isl_schedule_node_context
21 * and represents constraints on the flat product of the outer band nodes,
22 * possibly introducing additional parameters.
23 * The "domain" field is valid when type is isl_schedule_node_domain
24 * and introduces the statement instances scheduled by the tree.
26 * The "contraction" and "expansion" fields are valid when type
27 * is isl_schedule_node_expansion.
28 * "expansion" expands the reaching domain elements to one or more
29 * domain elements for the subtree.
30 * "contraction" maps these elements back to the corresponding
31 * reaching domain element. It does not involve any domain constraints.
33 * The "extension" field is valid when the is isl_schedule_node_extension
34 * maps outer schedule dimenions (the flat product of the outer band nodes)
35 * to additional iteration domains.
37 * The "filter" field is valid when type is isl_schedule_node_filter
38 * and represents the statement instances selected by the node.
40 * The "guard" field is valid when type is isl_schedule_node_guard
41 * and represents constraints on the flat product of the outer band nodes
42 * that need to be enforced by the outer nodes in the generated AST.
44 * The "mark" field is valid when type is isl_schedule_node_mark and
45 * identifies the mark.
47 * The "children" field is valid for all types except
48 * isl_schedule_node_leaf. This field is NULL if there are
49 * no children (except for the implicit leaves).
51 * anchored is set if the node or any of its descendants depends
52 * on its position in the schedule tree.
54 struct isl_schedule_tree {
55 int ref;
56 isl_ctx *ctx;
57 int anchored;
58 enum isl_schedule_node_type type;
59 union {
60 isl_schedule_band *band;
61 isl_set *context;
62 isl_union_set *domain;
63 struct {
64 isl_union_pw_multi_aff *contraction;
65 isl_union_map *expansion;
67 isl_union_map *extension;
68 isl_union_set *filter;
69 isl_set *guard;
70 isl_id *mark;
72 isl_schedule_tree_list *children;
75 isl_ctx *isl_schedule_tree_get_ctx(__isl_keep isl_schedule_tree *tree);
76 enum isl_schedule_node_type isl_schedule_tree_get_type(
77 __isl_keep isl_schedule_tree *tree);
79 __isl_give isl_schedule_tree *isl_schedule_tree_leaf(isl_ctx *ctx);
80 int isl_schedule_tree_is_leaf(__isl_keep isl_schedule_tree *tree);
82 isl_bool isl_schedule_tree_plain_is_equal(__isl_keep isl_schedule_tree *tree1,
83 __isl_keep isl_schedule_tree *tree2);
85 __isl_give isl_schedule_tree *isl_schedule_tree_copy(
86 __isl_keep isl_schedule_tree *tree);
87 __isl_null isl_schedule_tree *isl_schedule_tree_free(
88 __isl_take isl_schedule_tree *tree);
90 __isl_give isl_schedule_tree *isl_schedule_tree_from_band(
91 __isl_take isl_schedule_band *band);
92 __isl_give isl_schedule_tree *isl_schedule_tree_from_context(
93 __isl_take isl_set *context);
94 __isl_give isl_schedule_tree *isl_schedule_tree_from_domain(
95 __isl_take isl_union_set *domain);
96 __isl_give isl_schedule_tree *isl_schedule_tree_from_expansion(
97 __isl_take isl_union_pw_multi_aff *contraction,
98 __isl_take isl_union_map *expansion);
99 __isl_give isl_schedule_tree *isl_schedule_tree_from_extension(
100 __isl_take isl_union_map *extension);
101 __isl_give isl_schedule_tree *isl_schedule_tree_from_filter(
102 __isl_take isl_union_set *filter);
103 __isl_give isl_schedule_tree *isl_schedule_tree_from_guard(
104 __isl_take isl_set *guard);
105 __isl_give isl_schedule_tree *isl_schedule_tree_from_children(
106 enum isl_schedule_node_type type,
107 __isl_take isl_schedule_tree_list *list);
108 __isl_give isl_schedule_tree *isl_schedule_tree_from_pair(
109 enum isl_schedule_node_type type, __isl_take isl_schedule_tree *tree1,
110 __isl_take isl_schedule_tree *tree2);
111 __isl_give isl_schedule_tree *isl_schedule_tree_sequence_pair(
112 __isl_take isl_schedule_tree *tree1,
113 __isl_take isl_schedule_tree *tree2);
115 isl_bool isl_schedule_tree_is_subtree_anchored(
116 __isl_keep isl_schedule_tree *tree);
118 __isl_give isl_space *isl_schedule_tree_band_get_space(
119 __isl_keep isl_schedule_tree *tree);
120 __isl_give isl_schedule_tree *isl_schedule_tree_band_intersect_domain(
121 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain);
122 __isl_give isl_multi_union_pw_aff *isl_schedule_tree_band_get_partial_schedule(
123 __isl_keep isl_schedule_tree *tree);
124 __isl_give isl_schedule_tree *isl_schedule_tree_band_set_partial_schedule(
125 __isl_take isl_schedule_tree *tree,
126 __isl_take isl_multi_union_pw_aff *schedule);
127 enum isl_ast_loop_type isl_schedule_tree_band_member_get_ast_loop_type(
128 __isl_keep isl_schedule_tree *tree, int pos);
129 __isl_give isl_schedule_tree *isl_schedule_tree_band_member_set_ast_loop_type(
130 __isl_take isl_schedule_tree *tree, int pos,
131 enum isl_ast_loop_type type);
132 enum isl_ast_loop_type isl_schedule_tree_band_member_get_isolate_ast_loop_type(
133 __isl_keep isl_schedule_tree *tree, int pos);
134 __isl_give isl_schedule_tree *
135 isl_schedule_tree_band_member_set_isolate_ast_loop_type(
136 __isl_take isl_schedule_tree *tree, int pos,
137 enum isl_ast_loop_type type);
138 __isl_give isl_union_set *isl_schedule_tree_band_get_ast_build_options(
139 __isl_keep isl_schedule_tree *tree);
140 __isl_give isl_schedule_tree *isl_schedule_tree_band_set_ast_build_options(
141 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *options);
142 __isl_give isl_set *isl_schedule_tree_context_get_context(
143 __isl_keep isl_schedule_tree *tree);
144 __isl_give isl_union_set *isl_schedule_tree_domain_get_domain(
145 __isl_keep isl_schedule_tree *tree);
146 __isl_give isl_schedule_tree *isl_schedule_tree_domain_set_domain(
147 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain);
148 __isl_give isl_union_pw_multi_aff *isl_schedule_tree_expansion_get_contraction(
149 __isl_keep isl_schedule_tree *tree);
150 __isl_give isl_union_map *isl_schedule_tree_expansion_get_expansion(
151 __isl_keep isl_schedule_tree *tree);
152 __isl_give isl_schedule_tree *
153 isl_schedule_tree_expansion_set_contraction_and_expansion(
154 __isl_take isl_schedule_tree *tree,
155 __isl_take isl_union_pw_multi_aff *contraction,
156 __isl_take isl_union_map *expansion);
157 __isl_give isl_union_map *isl_schedule_tree_extension_get_extension(
158 __isl_keep isl_schedule_tree *tree);
159 __isl_give isl_schedule_tree *isl_schedule_tree_extension_set_extension(
160 __isl_take isl_schedule_tree *tree,
161 __isl_take isl_union_map *extension);
162 __isl_give isl_union_set *isl_schedule_tree_filter_get_filter(
163 __isl_keep isl_schedule_tree *tree);
164 __isl_give isl_schedule_tree *isl_schedule_tree_filter_set_filter(
165 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter);
166 __isl_give isl_set *isl_schedule_tree_guard_get_guard(
167 __isl_keep isl_schedule_tree *tree);
168 __isl_give isl_id *isl_schedule_tree_mark_get_id(
169 __isl_keep isl_schedule_tree *tree);
171 __isl_give isl_schedule_tree *isl_schedule_tree_first_schedule_descendant(
172 __isl_take isl_schedule_tree *tree, __isl_keep isl_schedule_tree *leaf);
173 __isl_give isl_union_map *isl_schedule_tree_get_subtree_schedule_union_map(
174 __isl_keep isl_schedule_tree *tree);
176 unsigned isl_schedule_tree_band_n_member(__isl_keep isl_schedule_tree *tree);
178 isl_bool isl_schedule_tree_band_member_get_coincident(
179 __isl_keep isl_schedule_tree *tree, int pos);
180 __isl_give isl_schedule_tree *isl_schedule_tree_band_member_set_coincident(
181 __isl_take isl_schedule_tree *tree, int pos, int coincident);
182 isl_bool isl_schedule_tree_band_get_permutable(
183 __isl_keep isl_schedule_tree *tree);
184 __isl_give isl_schedule_tree *isl_schedule_tree_band_set_permutable(
185 __isl_take isl_schedule_tree *tree, int permutable);
187 int isl_schedule_tree_has_children(__isl_keep isl_schedule_tree *tree);
188 int isl_schedule_tree_n_children(__isl_keep isl_schedule_tree *tree);
189 __isl_give isl_schedule_tree *isl_schedule_tree_get_child(
190 __isl_keep isl_schedule_tree *tree, int pos);
192 __isl_give isl_schedule_tree *isl_schedule_tree_insert_band(
193 __isl_take isl_schedule_tree *tree, __isl_take isl_schedule_band *band);
194 __isl_give isl_schedule_tree *isl_schedule_tree_insert_context(
195 __isl_take isl_schedule_tree *tree, __isl_take isl_set *context);
196 __isl_give isl_schedule_tree *isl_schedule_tree_insert_domain(
197 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain);
198 __isl_give isl_schedule_tree *isl_schedule_tree_insert_expansion(
199 __isl_take isl_schedule_tree *tree,
200 __isl_take isl_union_pw_multi_aff *contraction,
201 __isl_take isl_union_map *expansion);
202 __isl_give isl_schedule_tree *isl_schedule_tree_insert_extension(
203 __isl_take isl_schedule_tree *tree,
204 __isl_take isl_union_map *extension);
205 __isl_give isl_schedule_tree *isl_schedule_tree_insert_filter(
206 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter);
207 __isl_give isl_schedule_tree *isl_schedule_tree_children_insert_filter(
208 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter);
209 __isl_give isl_schedule_tree *isl_schedule_tree_insert_guard(
210 __isl_take isl_schedule_tree *tree, __isl_take isl_set *guard);
211 __isl_give isl_schedule_tree *isl_schedule_tree_insert_mark(
212 __isl_take isl_schedule_tree *tree, __isl_take isl_id *mark);
214 __isl_give isl_schedule_tree *isl_schedule_tree_append_to_leaves(
215 __isl_take isl_schedule_tree *tree1,
216 __isl_take isl_schedule_tree *tree2);
218 __isl_give isl_schedule_tree *isl_schedule_tree_band_scale(
219 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
220 __isl_give isl_schedule_tree *isl_schedule_tree_band_scale_down(
221 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
222 __isl_give isl_schedule_tree *isl_schedule_tree_band_mod(
223 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
224 __isl_give isl_schedule_tree *isl_schedule_tree_band_tile(
225 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *sizes);
226 __isl_give isl_schedule_tree *isl_schedule_tree_band_shift(
227 __isl_take isl_schedule_tree *tree,
228 __isl_take isl_multi_union_pw_aff *shift);
229 __isl_give isl_schedule_tree *isl_schedule_tree_band_split(
230 __isl_take isl_schedule_tree *tree, int pos);
231 __isl_give isl_schedule_tree *isl_schedule_tree_band_gist(
232 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *context);
234 __isl_give isl_schedule_tree *isl_schedule_tree_child(
235 __isl_take isl_schedule_tree *tree, int pos);
236 __isl_give isl_schedule_tree *isl_schedule_tree_reset_children(
237 __isl_take isl_schedule_tree *tree);
238 __isl_give isl_schedule_tree *isl_schedule_tree_drop_child(
239 __isl_take isl_schedule_tree *tree, int pos);
240 __isl_give isl_schedule_tree *isl_schedule_tree_replace_child(
241 __isl_take isl_schedule_tree *tree, int pos,
242 __isl_take isl_schedule_tree *new_child);
243 __isl_give isl_schedule_tree *isl_schedule_tree_sequence_splice(
244 __isl_take isl_schedule_tree *tree, int pos,
245 __isl_take isl_schedule_tree *child);
247 __isl_give isl_schedule_tree *isl_schedule_tree_reset_user(
248 __isl_take isl_schedule_tree *tree);
249 __isl_give isl_schedule_tree *isl_schedule_tree_align_params(
250 __isl_take isl_schedule_tree *tree, __isl_take isl_space *space);
251 __isl_give isl_schedule_tree *isl_schedule_tree_pullback_union_pw_multi_aff(
252 __isl_take isl_schedule_tree *tree,
253 __isl_take isl_union_pw_multi_aff *upma);
255 __isl_give isl_printer *isl_printer_print_schedule_tree(
256 __isl_take isl_printer *p, __isl_keep isl_schedule_tree *tree);
257 __isl_give isl_printer *isl_printer_print_schedule_tree_mark(
258 __isl_take isl_printer *p, __isl_keep isl_schedule_tree *tree,
259 int n_ancestor, int *child_pos);
261 #endif