isl_output.c: print_constraints: avoid invalid access on error
[isl.git] / isl_schedule_tree.h
blobc996b721186e1d52a1067b23d24cca17adca4a05
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);
114 __isl_give isl_schedule_tree *isl_schedule_tree_set_pair(
115 __isl_take isl_schedule_tree *tree1,
116 __isl_take isl_schedule_tree *tree2);
118 isl_bool isl_schedule_tree_is_subtree_anchored(
119 __isl_keep isl_schedule_tree *tree);
121 __isl_give isl_space *isl_schedule_tree_band_get_space(
122 __isl_keep isl_schedule_tree *tree);
123 __isl_give isl_schedule_tree *isl_schedule_tree_band_intersect_domain(
124 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain);
125 __isl_give isl_multi_union_pw_aff *isl_schedule_tree_band_get_partial_schedule(
126 __isl_keep isl_schedule_tree *tree);
127 __isl_give isl_schedule_tree *isl_schedule_tree_band_set_partial_schedule(
128 __isl_take isl_schedule_tree *tree,
129 __isl_take isl_multi_union_pw_aff *schedule);
130 enum isl_ast_loop_type isl_schedule_tree_band_member_get_ast_loop_type(
131 __isl_keep isl_schedule_tree *tree, int pos);
132 __isl_give isl_schedule_tree *isl_schedule_tree_band_member_set_ast_loop_type(
133 __isl_take isl_schedule_tree *tree, int pos,
134 enum isl_ast_loop_type type);
135 enum isl_ast_loop_type isl_schedule_tree_band_member_get_isolate_ast_loop_type(
136 __isl_keep isl_schedule_tree *tree, int pos);
137 __isl_give isl_schedule_tree *
138 isl_schedule_tree_band_member_set_isolate_ast_loop_type(
139 __isl_take isl_schedule_tree *tree, int pos,
140 enum isl_ast_loop_type type);
141 __isl_give isl_union_set *isl_schedule_tree_band_get_ast_build_options(
142 __isl_keep isl_schedule_tree *tree);
143 __isl_give isl_schedule_tree *isl_schedule_tree_band_set_ast_build_options(
144 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *options);
145 __isl_give isl_set *isl_schedule_tree_context_get_context(
146 __isl_keep isl_schedule_tree *tree);
147 __isl_give isl_union_set *isl_schedule_tree_domain_get_domain(
148 __isl_keep isl_schedule_tree *tree);
149 __isl_give isl_schedule_tree *isl_schedule_tree_domain_set_domain(
150 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain);
151 __isl_give isl_union_pw_multi_aff *isl_schedule_tree_expansion_get_contraction(
152 __isl_keep isl_schedule_tree *tree);
153 __isl_give isl_union_map *isl_schedule_tree_expansion_get_expansion(
154 __isl_keep isl_schedule_tree *tree);
155 __isl_give isl_schedule_tree *
156 isl_schedule_tree_expansion_set_contraction_and_expansion(
157 __isl_take isl_schedule_tree *tree,
158 __isl_take isl_union_pw_multi_aff *contraction,
159 __isl_take isl_union_map *expansion);
160 __isl_give isl_union_map *isl_schedule_tree_extension_get_extension(
161 __isl_keep isl_schedule_tree *tree);
162 __isl_give isl_schedule_tree *isl_schedule_tree_extension_set_extension(
163 __isl_take isl_schedule_tree *tree,
164 __isl_take isl_union_map *extension);
165 __isl_give isl_union_set *isl_schedule_tree_filter_get_filter(
166 __isl_keep isl_schedule_tree *tree);
167 __isl_give isl_schedule_tree *isl_schedule_tree_filter_set_filter(
168 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter);
169 __isl_give isl_set *isl_schedule_tree_guard_get_guard(
170 __isl_keep isl_schedule_tree *tree);
171 __isl_give isl_id *isl_schedule_tree_mark_get_id(
172 __isl_keep isl_schedule_tree *tree);
174 __isl_give isl_schedule_tree *isl_schedule_tree_first_schedule_descendant(
175 __isl_take isl_schedule_tree *tree, __isl_keep isl_schedule_tree *leaf);
176 __isl_give isl_union_map *isl_schedule_tree_get_subtree_schedule_union_map(
177 __isl_keep isl_schedule_tree *tree);
179 unsigned isl_schedule_tree_band_n_member(__isl_keep isl_schedule_tree *tree);
181 isl_bool isl_schedule_tree_band_member_get_coincident(
182 __isl_keep isl_schedule_tree *tree, int pos);
183 __isl_give isl_schedule_tree *isl_schedule_tree_band_member_set_coincident(
184 __isl_take isl_schedule_tree *tree, int pos, int coincident);
185 isl_bool isl_schedule_tree_band_get_permutable(
186 __isl_keep isl_schedule_tree *tree);
187 __isl_give isl_schedule_tree *isl_schedule_tree_band_set_permutable(
188 __isl_take isl_schedule_tree *tree, int permutable);
190 int isl_schedule_tree_has_children(__isl_keep isl_schedule_tree *tree);
191 int isl_schedule_tree_n_children(__isl_keep isl_schedule_tree *tree);
192 __isl_give isl_schedule_tree *isl_schedule_tree_get_child(
193 __isl_keep isl_schedule_tree *tree, int pos);
195 __isl_give isl_schedule_tree *isl_schedule_tree_insert_band(
196 __isl_take isl_schedule_tree *tree, __isl_take isl_schedule_band *band);
197 __isl_give isl_schedule_tree *isl_schedule_tree_insert_context(
198 __isl_take isl_schedule_tree *tree, __isl_take isl_set *context);
199 __isl_give isl_schedule_tree *isl_schedule_tree_insert_domain(
200 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *domain);
201 __isl_give isl_schedule_tree *isl_schedule_tree_insert_expansion(
202 __isl_take isl_schedule_tree *tree,
203 __isl_take isl_union_pw_multi_aff *contraction,
204 __isl_take isl_union_map *expansion);
205 __isl_give isl_schedule_tree *isl_schedule_tree_insert_extension(
206 __isl_take isl_schedule_tree *tree,
207 __isl_take isl_union_map *extension);
208 __isl_give isl_schedule_tree *isl_schedule_tree_insert_filter(
209 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter);
210 __isl_give isl_schedule_tree *isl_schedule_tree_children_insert_filter(
211 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *filter);
212 __isl_give isl_schedule_tree *isl_schedule_tree_insert_guard(
213 __isl_take isl_schedule_tree *tree, __isl_take isl_set *guard);
214 __isl_give isl_schedule_tree *isl_schedule_tree_insert_mark(
215 __isl_take isl_schedule_tree *tree, __isl_take isl_id *mark);
217 __isl_give isl_schedule_tree *isl_schedule_tree_append_to_leaves(
218 __isl_take isl_schedule_tree *tree1,
219 __isl_take isl_schedule_tree *tree2);
221 __isl_give isl_schedule_tree *isl_schedule_tree_band_scale(
222 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
223 __isl_give isl_schedule_tree *isl_schedule_tree_band_scale_down(
224 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
225 __isl_give isl_schedule_tree *isl_schedule_tree_band_mod(
226 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
227 __isl_give isl_schedule_tree *isl_schedule_tree_band_tile(
228 __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *sizes);
229 __isl_give isl_schedule_tree *isl_schedule_tree_band_shift(
230 __isl_take isl_schedule_tree *tree,
231 __isl_take isl_multi_union_pw_aff *shift);
232 __isl_give isl_schedule_tree *isl_schedule_tree_band_split(
233 __isl_take isl_schedule_tree *tree, int pos);
234 __isl_give isl_schedule_tree *isl_schedule_tree_band_gist(
235 __isl_take isl_schedule_tree *tree, __isl_take isl_union_set *context);
237 __isl_give isl_schedule_tree *isl_schedule_tree_child(
238 __isl_take isl_schedule_tree *tree, int pos);
239 __isl_give isl_schedule_tree *isl_schedule_tree_reset_children(
240 __isl_take isl_schedule_tree *tree);
241 __isl_give isl_schedule_tree *isl_schedule_tree_drop_child(
242 __isl_take isl_schedule_tree *tree, int pos);
243 __isl_give isl_schedule_tree *isl_schedule_tree_replace_child(
244 __isl_take isl_schedule_tree *tree, int pos,
245 __isl_take isl_schedule_tree *new_child);
246 __isl_give isl_schedule_tree *isl_schedule_tree_sequence_splice(
247 __isl_take isl_schedule_tree *tree, int pos,
248 __isl_take isl_schedule_tree *child);
250 __isl_give isl_schedule_tree *isl_schedule_tree_reset_user(
251 __isl_take isl_schedule_tree *tree);
252 __isl_give isl_schedule_tree *isl_schedule_tree_align_params(
253 __isl_take isl_schedule_tree *tree, __isl_take isl_space *space);
254 __isl_give isl_schedule_tree *isl_schedule_tree_pullback_union_pw_multi_aff(
255 __isl_take isl_schedule_tree *tree,
256 __isl_take isl_union_pw_multi_aff *upma);
258 __isl_give isl_printer *isl_printer_print_schedule_tree(
259 __isl_take isl_printer *p, __isl_keep isl_schedule_tree *tree);
260 __isl_give isl_printer *isl_printer_print_schedule_tree_mark(
261 __isl_take isl_printer *p, __isl_keep isl_schedule_tree *tree,
262 int n_ancestor, int *child_pos);
264 #endif