add support for generating ASTs from schedule relations
[isl.git] / isl_ast_private.h
blob8aef29a88b0fa73b23db7703dd6cdb59d1c6700b
1 #ifndef ISL_AST_PRIVATE_H
2 #define ISL_AST_PRIVATE_H
4 #include <isl/aff.h>
5 #include <isl/ast.h>
6 #include <isl/set.h>
7 #include <isl/map.h>
8 #include <isl/vec.h>
9 #include <isl/list.h>
11 /* An expression is either an integer, an identifier or an operation
12 * with zero or more arguments.
14 struct isl_ast_expr {
15 int ref;
17 isl_ctx *ctx;
19 enum isl_ast_expr_type type;
21 union {
22 isl_int i;
23 isl_id *id;
24 struct {
25 enum isl_ast_op_type op;
26 unsigned n_arg;
27 isl_ast_expr **args;
28 } op;
29 } u;
32 #undef EL
33 #define EL isl_ast_expr
35 #include <isl_list_templ.h>
37 __isl_give isl_ast_expr *isl_ast_expr_alloc_int(isl_ctx *ctx, isl_int i);
38 __isl_give isl_ast_expr *isl_ast_expr_alloc_int_si(isl_ctx *ctx, int i);
39 __isl_give isl_ast_expr *isl_ast_expr_alloc_op(isl_ctx *ctx,
40 enum isl_ast_op_type op, int n_arg);
41 __isl_give isl_ast_expr *isl_ast_expr_alloc_binary(enum isl_ast_op_type type,
42 __isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2);
44 #undef EL
45 #define EL isl_ast_node
47 #include <isl_list_templ.h>
49 /* A node is either a block, an if, a for or a user node.
50 * "else_node" is NULL if the if node does not have an else branch.
51 * "cond" and "inc" are NULL for degenerate for nodes.
53 struct isl_ast_node {
54 int ref;
56 isl_ctx *ctx;
57 enum isl_ast_node_type type;
59 union {
60 struct {
61 isl_ast_node_list *children;
62 } b;
63 struct {
64 isl_ast_expr *guard;
65 isl_ast_node *then;
66 isl_ast_node *else_node;
67 } i;
68 struct {
69 unsigned degenerate : 1;
70 isl_ast_expr *iterator;
71 isl_ast_expr *init;
72 isl_ast_expr *cond;
73 isl_ast_expr *inc;
74 isl_ast_node *body;
75 } f;
76 struct {
77 isl_ast_expr *expr;
78 } e;
79 } u;
81 isl_id *annotation;
84 __isl_give isl_ast_node *isl_ast_node_alloc_for(__isl_take isl_id *id);
85 __isl_give isl_ast_node *isl_ast_node_for_mark_degenerate(
86 __isl_take isl_ast_node *node);
87 __isl_give isl_ast_node *isl_ast_node_alloc_if(__isl_take isl_ast_expr *guard);
88 __isl_give isl_ast_node *isl_ast_node_alloc_block(
89 __isl_take isl_ast_node_list *list);
90 __isl_give isl_ast_node *isl_ast_node_from_ast_node_list(
91 __isl_take isl_ast_node_list *list);
92 __isl_give isl_ast_node *isl_ast_node_for_set_body(
93 __isl_take isl_ast_node *node, __isl_take isl_ast_node *body);
94 __isl_give isl_ast_node *isl_ast_node_if_set_then(
95 __isl_take isl_ast_node *node, __isl_take isl_ast_node *child);
97 struct isl_ast_print_options {
98 __isl_give isl_printer *(*print_for)(__isl_take isl_printer *p,
99 __isl_keep isl_ast_node *node, void *user);
100 void *print_for_user;
101 __isl_give isl_printer *(*print_user)(__isl_take isl_printer *p,
102 __isl_keep isl_ast_node *node, void *user);
103 void *print_user_user;
106 __isl_give isl_printer *isl_ast_node_list_print(
107 __isl_keep isl_ast_node_list *list, __isl_take isl_printer *p,
108 __isl_keep isl_ast_print_options *options);
110 #endif