1 #ifndef ISL_AST_GRAFT_PRIVATE_H
2 #define ISL_AST_GRAFT_PRIVATE_H
3 
4 #include <isl/ast.h>
5 #include <isl/ast_build.h>
6 #include <isl/set.h>
7 #include <isl/list.h>
8 #include <isl/printer.h>
9 
10 struct isl_ast_graft;
11 typedef struct isl_ast_graft isl_ast_graft;
12 
13 /* Representation of part of an AST ("node") with some additional polyhedral
14  * information about the tree.
15  *
16  * "guard" contains conditions that should still be enforced by
17  * some ancestor of the current tree.  In particular, the already
18  * generated tree assumes that these conditions hold, but may not
19  * have enforced them itself.
20  * The guard should not contain any unknown divs as it will be used
21  * to generate an if condition.
22  *
23  * "enforced" expresses constraints that are already enforced by the for
24  * nodes in the current tree and that therefore do not need to be enforced
25  * by any ancestor.
26  * The constraints only involve outer loop iterators.
27  */
28 struct isl_ast_graft {
29 	int ref;
30 
31 	isl_ast_node *node;
32 
33 	isl_set *guard;
34 	isl_basic_set *enforced;
35 };
36 
37 ISL_DECLARE_LIST(ast_graft)
38 
39 #undef EL
40 #define EL isl_ast_graft
41 
42 #include <isl_list_templ.h>
43 
44 isl_ctx *isl_ast_graft_get_ctx(__isl_keep isl_ast_graft *graft);
45 
46 __isl_give isl_ast_graft *isl_ast_graft_alloc(
47 	__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build);
48 __isl_give isl_ast_graft *isl_ast_graft_alloc_from_children(
49 	__isl_take isl_ast_graft_list *list, __isl_take isl_set *guard,
50 	__isl_take isl_basic_set *enforced, __isl_keep isl_ast_build *build,
51 	__isl_keep isl_ast_build *sub_build);
52 __isl_give isl_ast_graft_list *isl_ast_graft_list_fuse(
53 	__isl_take isl_ast_graft_list *children,
54 	__isl_keep isl_ast_build *build);
55 __isl_give isl_ast_graft *isl_ast_graft_alloc_domain(
56 	__isl_take isl_map *schedule, __isl_keep isl_ast_build *build);
57 __isl_null isl_ast_graft *isl_ast_graft_free(__isl_take isl_ast_graft *graft);
58 __isl_give isl_ast_graft_list *isl_ast_graft_list_sort_guard(
59 	__isl_take isl_ast_graft_list *list);
60 
61 __isl_give isl_ast_graft_list *isl_ast_graft_list_merge(
62 	__isl_take isl_ast_graft_list *list1,
63 	__isl_take isl_ast_graft_list *list2,
64 	__isl_keep isl_ast_build *build);
65 __isl_give isl_ast_graft_list *isl_ast_graft_list_group_on_guard(
66 	__isl_take isl_ast_graft_list *list, __isl_keep isl_ast_build *build);
67 
68 __isl_give isl_ast_node *isl_ast_graft_get_node(
69 	__isl_keep isl_ast_graft *graft);
70 __isl_give isl_basic_set *isl_ast_graft_get_enforced(
71 	__isl_keep isl_ast_graft *graft);
72 __isl_give isl_set *isl_ast_graft_get_guard(__isl_keep isl_ast_graft *graft);
73 
74 __isl_give isl_ast_graft *isl_ast_graft_insert_for(
75 	__isl_take isl_ast_graft *graft, __isl_take isl_ast_node *node);
76 __isl_give isl_ast_graft *isl_ast_graft_add_guard(
77 	__isl_take isl_ast_graft *graft,
78 	__isl_take isl_set *guard, __isl_keep isl_ast_build *build);
79 __isl_give isl_ast_graft *isl_ast_graft_enforce(
80 	__isl_take isl_ast_graft *graft, __isl_take isl_basic_set *enforced);
81 
82 __isl_give isl_ast_graft *isl_ast_graft_insert_mark(
83 	__isl_take isl_ast_graft *graft, __isl_take isl_id *mark);
84 
85 __isl_give isl_ast_graft_list *isl_ast_graft_list_unembed(
86 	__isl_take isl_ast_graft_list *list, int product);
87 __isl_give isl_ast_graft_list *isl_ast_graft_list_preimage_multi_aff(
88 	__isl_take isl_ast_graft_list *list, __isl_take isl_multi_aff *ma);
89 __isl_give isl_ast_graft_list *isl_ast_graft_list_insert_pending_guard_nodes(
90 	__isl_take isl_ast_graft_list *list, __isl_keep isl_ast_build *build);
91 
92 __isl_give isl_ast_node *isl_ast_node_from_graft_list(
93 	__isl_take isl_ast_graft_list *list, __isl_keep isl_ast_build *build);
94 
95 __isl_give isl_basic_set *isl_ast_graft_list_extract_shared_enforced(
96 	__isl_keep isl_ast_graft_list *list, __isl_keep isl_ast_build *build);
97 __isl_give isl_set *isl_ast_graft_list_extract_hoistable_guard(
98 	__isl_keep isl_ast_graft_list *list, __isl_keep isl_ast_build *build);
99 __isl_give isl_ast_graft_list *isl_ast_graft_list_gist_guards(
100 	__isl_take isl_ast_graft_list *list, __isl_take isl_set *context);
101 
102 __isl_give isl_printer *isl_printer_print_ast_graft(__isl_take isl_printer *p,
103 	__isl_keep isl_ast_graft *graft);
104 
105 #endif
106