pet_scop constructors: allow specification of domain space
[pet.git] / tree.h
blobe4e2e3c8b2837cc8761ee74322f561b4e7b1d41b
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.
39 * The "i" field of the union is used for types pet_tree_if
40 * and pet_tree_if_else.
41 * "cond" is the if condition.
42 * "then_body" represents the then branch of the if statement.
43 * "else_body" represents the else branch of the if statement
44 * (in case of pet_tree_if_else).
46 struct pet_tree {
47 int ref;
48 isl_ctx *ctx;
50 pet_loc *loc;
51 isl_id *label;
53 enum pet_tree_type type;
55 union {
56 struct {
57 int block;
58 int n;
59 int max;
60 pet_tree **child;
61 } b;
62 struct {
63 pet_expr *var;
64 pet_expr *init;
65 } d;
66 struct {
67 pet_expr *expr;
68 } e;
69 struct {
70 int declared;
71 pet_expr *iv;
72 pet_expr *init;
73 pet_expr *cond;
74 pet_expr *inc;
75 pet_tree *body;
76 } l;
77 struct {
78 pet_expr *cond;
79 pet_tree *then_body;
80 pet_tree *else_body;
81 } i;
82 } u;
85 const char *pet_tree_type_str(enum pet_tree_type type);
86 enum pet_tree_type pet_tree_str_type(const char *str);
88 int pet_tree_is_equal(__isl_keep pet_tree *tree1, __isl_keep pet_tree *tree2);
90 int pet_tree_is_kill(__isl_keep pet_tree *tree);
91 int pet_tree_is_assign(__isl_keep pet_tree *tree);
92 int pet_tree_is_assume(__isl_keep pet_tree *tree);
93 int pet_tree_is_affine_assume(__isl_keep pet_tree *tree);
94 __isl_give isl_multi_pw_aff *pet_tree_assume_get_index(
95 __isl_keep pet_tree *tree);
97 __isl_give pet_tree *pet_tree_new_decl(__isl_take pet_expr *var);
98 __isl_give pet_tree *pet_tree_new_decl_init(__isl_take pet_expr *var,
99 __isl_take pet_expr *init);
101 __isl_give pet_tree *pet_tree_new_expr(__isl_take pet_expr *expr);
103 __isl_give pet_tree *pet_tree_set_label(__isl_take pet_tree *tree,
104 __isl_take isl_id *label);
106 __isl_give pet_tree *pet_tree_new_block(isl_ctx *ctx, int block, int n);
107 int pet_tree_block_n_child(__isl_keep pet_tree *tree);
108 __isl_give pet_tree *pet_tree_block_add_child(__isl_take pet_tree *block,
109 __isl_take pet_tree *child);
111 __isl_give pet_tree *pet_tree_new_break(isl_ctx *ctx);
112 __isl_give pet_tree *pet_tree_new_continue(isl_ctx *ctx);
114 __isl_give pet_tree *pet_tree_new_infinite_loop(__isl_take pet_tree *body);
115 __isl_give pet_tree *pet_tree_new_while(__isl_take pet_expr *cond,
116 __isl_take pet_tree *body);
117 __isl_give pet_tree *pet_tree_new_for(int declared,
118 __isl_take pet_expr *iv, __isl_take pet_expr *init,
119 __isl_take pet_expr *cond, __isl_take pet_expr *inc,
120 __isl_take pet_tree *body);
121 __isl_give pet_tree *pet_tree_new_if(__isl_take pet_expr *cond,
122 __isl_take pet_tree *then_body);
123 __isl_give pet_tree *pet_tree_new_if_else(__isl_take pet_expr *cond,
124 __isl_take pet_tree *then_body, __isl_take pet_tree *else_body);
126 __isl_give pet_tree *pet_tree_set_loc(__isl_take pet_tree *tree,
127 __isl_take pet_loc *loc);
129 int pet_tree_foreach_sub_tree(__isl_keep pet_tree *tree,
130 int (*fn)(__isl_keep pet_tree *tree, void *user), void *user);
132 __isl_give pet_tree *pet_tree_map_access_expr(__isl_take pet_tree *tree,
133 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
134 void *user);
135 __isl_give pet_tree *pet_tree_map_expr(__isl_take pet_tree *tree,
136 __isl_give pet_expr *(*fn)(__isl_take pet_expr *expr, void *user),
137 void *user);
139 int pet_tree_writes(__isl_keep pet_tree *tree, __isl_keep isl_id *id);
140 int pet_tree_has_continue(__isl_keep pet_tree *tree);
142 void pet_tree_dump_with_indent(__isl_keep pet_tree *tree, int indent);
144 #if defined(__cplusplus)
146 #endif
148 #endif