handle pencil independent pragmas
[pet.git] / tree.h
blob131f23910fec7289608c4c6bffbdbfea30c79e5d
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.
27 * "expr" is the expression represented by the tree.
29 * The "l" field of the union is used for types pet_tree_for,
30 * pet_tree_infinite_loop and pet_tree_while.
31 * "body" represents the body of the loop.
32 * "cond" is the loop condition (for pet_tree_for and pet_tree_while).
33 * The remaining fields are only used for pet_tree_for.
34 * "iv" is the induction variable of the for loop.
35 " "declared" is set if this induction variable is declared by the loop.
36 * "init" is the initial value of the induction variable.
37 * "inc" is the increment to the induction variable.
38 * "independent" is set if the for loop is marked independent.
40 * The "i" field of the union is used for types pet_tree_if
41 * and pet_tree_if_else.
42 * "cond" is the if condition.
43 * "then_body" represents the then branch of the if statement.
44 * "else_body" represents the else branch of the if statement
45 * (in case of pet_tree_if_else).
47 struct pet_tree {
48 int ref;
49 isl_ctx *ctx;
51 pet_loc *loc;
52 isl_id *label;
54 enum pet_tree_type type;
56 union {
57 struct {
58 int block;
59 int n;
60 int max;
61 pet_tree **child;
62 } b;
63 struct {
64 pet_expr *var;
65 pet_expr *init;
66 } d;
67 struct {
68 pet_expr *expr;
69 } e;
70 struct {
71 int independent;
72 int declared;
73 pet_expr *iv;
74 pet_expr *init;
75 pet_expr *cond;
76 pet_expr *inc;
77 pet_tree *body;
78 } l;
79 struct {
80 pet_expr *cond;
81 pet_tree *then_body;
82 pet_tree *else_body;
83 } i;
84 } u;
87 const char *pet_tree_type_str(enum pet_tree_type type);
88 enum pet_tree_type pet_tree_str_type(const char *str);
90 int pet_tree_is_equal(__isl_keep pet_tree *tree1, __isl_keep pet_tree *tree2);
92 int pet_tree_is_kill(__isl_keep pet_tree *tree);
93 int pet_tree_is_assign(__isl_keep pet_tree *tree);
94 int pet_tree_is_assume(__isl_keep pet_tree *tree);
95 int pet_tree_is_affine_assume(__isl_keep pet_tree *tree);
96 __isl_give isl_multi_pw_aff *pet_tree_assume_get_index(
97 __isl_keep pet_tree *tree);
99 __isl_give pet_tree *pet_tree_new_decl(__isl_take pet_expr *var);
100 __isl_give pet_tree *pet_tree_new_decl_init(__isl_take pet_expr *var,
101 __isl_take pet_expr *init);
103 __isl_give pet_tree *pet_tree_new_expr(__isl_take pet_expr *expr);
105 __isl_give pet_tree *pet_tree_set_label(__isl_take pet_tree *tree,
106 __isl_take isl_id *label);
108 __isl_give pet_tree *pet_tree_new_block(isl_ctx *ctx, int block, int n);
109 int pet_tree_block_n_child(__isl_keep pet_tree *tree);
110 __isl_give pet_tree *pet_tree_block_add_child(__isl_take pet_tree *block,
111 __isl_take pet_tree *child);
113 __isl_give pet_tree *pet_tree_new_break(isl_ctx *ctx);
114 __isl_give pet_tree *pet_tree_new_continue(isl_ctx *ctx);
116 __isl_give pet_tree *pet_tree_new_infinite_loop(__isl_take pet_tree *body);
117 __isl_give pet_tree *pet_tree_new_while(__isl_take pet_expr *cond,
118 __isl_take pet_tree *body);
119 __isl_give pet_tree *pet_tree_new_for(int independent, int declared,
120 __isl_take pet_expr *iv, __isl_take pet_expr *init,
121 __isl_take pet_expr *cond, __isl_take pet_expr *inc,
122 __isl_take pet_tree *body);
123 __isl_give pet_tree *pet_tree_new_if(__isl_take pet_expr *cond,
124 __isl_take pet_tree *then_body);
125 __isl_give pet_tree *pet_tree_new_if_else(__isl_take pet_expr *cond,
126 __isl_take pet_tree *then_body, __isl_take pet_tree *else_body);
128 __isl_give pet_tree *pet_tree_set_loc(__isl_take pet_tree *tree,
129 __isl_take pet_loc *loc);
131 int pet_tree_foreach_sub_tree(__isl_keep pet_tree *tree,
132 int (*fn)(__isl_keep pet_tree *tree, void *user), void *user);
134 __isl_give pet_tree *pet_tree_map_access_expr(__isl_take pet_tree *tree,
135 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
136 void *user);
137 __isl_give pet_tree *pet_tree_map_expr(__isl_take pet_tree *tree,
138 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
139 void *user);
141 int pet_tree_writes(__isl_keep pet_tree *tree, __isl_keep isl_id *id);
142 int pet_tree_has_continue(__isl_keep pet_tree *tree);
144 __isl_give pet_tree *pet_tree_align_params(__isl_take pet_tree *tree,
145 __isl_take isl_space *space);
146 __isl_give pet_tree *pet_tree_add_ref_ids(__isl_take pet_tree *tree,
147 int *n_ref);
148 __isl_give pet_tree *pet_tree_anonymize(__isl_take pet_tree *tree);
149 __isl_give pet_tree *pet_tree_gist(__isl_take pet_tree *tree,
150 __isl_keep isl_set *context, __isl_keep isl_union_map *value_bounds);
151 __isl_give pet_tree *pet_tree_update_domain(__isl_take pet_tree *tree,
152 __isl_take isl_multi_pw_aff *update);
154 void pet_tree_dump_with_indent(__isl_keep pet_tree *tree, int indent);
156 #if defined(__cplusplus)
158 #endif
160 #endif