README: update latest release of clang
[pet.git] / tree.h
blobcb4c36bac63a3e84f775c747e4fa0961e7f11c86
1 #ifndef PET_TREE_H
2 #define PET_TREE_H
4 #include <pet.h>
6 #if defined(__cplusplus)
7 extern "C" {
8 #endif
10 /* A pet_tree represents an AST.
12 * "loc" is the location of the code corresponding to the tree
13 * in the input file.
14 * "label" is the label (if any) that precedes the AST and may be NULL.
16 * The "b" field of the union is used for type pet_tree_block.
17 * "block" is set if the block has its own scope.
18 * "n" is the number of children in "child".
19 * "max" is the capacity of the child array "child".
21 * The "d" field of the union is used for types pet_tree_decl
22 * and pet_tree_decl_init.
23 * "var" is the variable that is being declared.
24 * "init" is the initial value (in case of pet_tree_decl_init).
26 * The "e" field of the union is used for type pet_tree_expr and
27 * for type pet_tree_return.
28 * "expr" is the expression represented or returned by the tree.
30 * The "l" field of the union is used for types pet_tree_for,
31 * pet_tree_infinite_loop and pet_tree_while.
32 * "body" represents the body of the loop.
33 * "cond" is the loop condition (for pet_tree_for and pet_tree_while).
34 * The remaining fields are only used for pet_tree_for.
35 * "iv" is the induction variable of the for loop.
36 " "declared" is set if this induction variable is declared by the loop.
37 * "init" is the initial value of the induction variable.
38 * "inc" is the increment to the induction variable.
39 * "independent" is set if the for loop is marked independent.
41 * The "i" field of the union is used for types pet_tree_if
42 * and pet_tree_if_else.
43 * "cond" is the if condition.
44 * "then_body" represents the then branch of the if statement.
45 * "else_body" represents the else branch of the if statement
46 * (in case of pet_tree_if_else).
48 struct pet_tree {
49 int ref;
50 isl_ctx *ctx;
52 pet_loc *loc;
53 isl_id *label;
55 enum pet_tree_type type;
57 union {
58 struct {
59 int block;
60 int n;
61 int max;
62 pet_tree **child;
63 } b;
64 struct {
65 pet_expr *var;
66 pet_expr *init;
67 } d;
68 struct {
69 pet_expr *expr;
70 } e;
71 struct {
72 int independent;
73 int declared;
74 pet_expr *iv;
75 pet_expr *init;
76 pet_expr *cond;
77 pet_expr *inc;
78 pet_tree *body;
79 } l;
80 struct {
81 pet_expr *cond;
82 pet_tree *then_body;
83 pet_tree *else_body;
84 } i;
85 } u;
88 const char *pet_tree_type_str(enum pet_tree_type type);
89 enum pet_tree_type pet_tree_str_type(const char *str);
91 int pet_tree_is_equal(__isl_keep pet_tree *tree1, __isl_keep pet_tree *tree2);
93 int pet_tree_is_kill(__isl_keep pet_tree *tree);
94 int pet_tree_is_assign(__isl_keep pet_tree *tree);
95 int pet_tree_is_assume(__isl_keep pet_tree *tree);
96 isl_bool pet_tree_is_affine_assume(__isl_keep pet_tree *tree);
97 __isl_give isl_multi_pw_aff *pet_tree_assume_get_index(
98 __isl_keep pet_tree *tree);
100 __isl_give pet_tree *pet_tree_new_decl(__isl_take pet_expr *var);
101 __isl_give pet_tree *pet_tree_new_decl_init(__isl_take pet_expr *var,
102 __isl_take pet_expr *init);
104 __isl_give pet_tree *pet_tree_new_expr(__isl_take pet_expr *expr);
105 __isl_give pet_tree *pet_tree_new_return(__isl_take pet_expr *expr);
107 __isl_give pet_tree *pet_tree_set_label(__isl_take pet_tree *tree,
108 __isl_take isl_id *label);
110 __isl_give pet_tree *pet_tree_new_block(isl_ctx *ctx, int block, int n);
111 __isl_give pet_tree *pet_tree_block_add_child(__isl_take pet_tree *block,
112 __isl_take pet_tree *child);
113 int pet_tree_block_get_block(__isl_keep pet_tree *block);
114 __isl_give pet_tree *pet_tree_block_set_block(__isl_take pet_tree *block,
115 int is_block);
117 __isl_give pet_tree *pet_tree_new_break(isl_ctx *ctx);
118 __isl_give pet_tree *pet_tree_new_continue(isl_ctx *ctx);
120 __isl_give pet_tree *pet_tree_new_infinite_loop(__isl_take pet_tree *body);
121 __isl_give pet_tree *pet_tree_new_while(__isl_take pet_expr *cond,
122 __isl_take pet_tree *body);
123 __isl_give pet_tree *pet_tree_new_for(int independent, int declared,
124 __isl_take pet_expr *iv, __isl_take pet_expr *init,
125 __isl_take pet_expr *cond, __isl_take pet_expr *inc,
126 __isl_take pet_tree *body);
127 __isl_give pet_tree *pet_tree_new_if(__isl_take pet_expr *cond,
128 __isl_take pet_tree *then_body);
129 __isl_give pet_tree *pet_tree_new_if_else(__isl_take pet_expr *cond,
130 __isl_take pet_tree *then_body, __isl_take pet_tree *else_body);
132 __isl_give pet_tree *pet_tree_set_loc(__isl_take pet_tree *tree,
133 __isl_take pet_loc *loc);
135 int pet_tree_foreach_sub_tree(__isl_keep pet_tree *tree,
136 int (*fn)(__isl_keep pet_tree *tree, void *user), void *user);
138 __isl_give pet_tree *pet_tree_map_top_down(__isl_take pet_tree *tree,
139 __isl_give pet_tree *(*fn)(__isl_take pet_tree *tree, void *user),
140 void *user);
141 __isl_give pet_tree *pet_tree_map_access_expr(__isl_take pet_tree *tree,
142 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
143 void *user);
144 __isl_give pet_tree *pet_tree_map_expr(__isl_take pet_tree *tree,
145 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
146 void *user);
148 int pet_tree_writes(__isl_keep pet_tree *tree, __isl_keep isl_id *id);
149 int pet_tree_has_continue_or_break(__isl_keep pet_tree *tree);
151 __isl_give pet_tree *pet_tree_align_params(__isl_take pet_tree *tree,
152 __isl_take isl_space *space);
153 __isl_give pet_tree *pet_tree_add_ref_ids(__isl_take pet_tree *tree,
154 int *n_ref);
155 __isl_give pet_tree *pet_tree_anonymize(__isl_take pet_tree *tree);
156 __isl_give pet_tree *pet_tree_gist(__isl_take pet_tree *tree,
157 __isl_keep isl_set *context, __isl_keep isl_union_map *value_bounds);
158 __isl_give pet_tree *pet_tree_update_domain(__isl_take pet_tree *tree,
159 __isl_take isl_multi_pw_aff *update);
161 void pet_tree_dump_with_indent(__isl_keep pet_tree *tree, int indent);
163 #if defined(__cplusplus)
165 #endif
167 #endif