1#ifndef ISL_AST_PRIVATE_H
2#define ISL_AST_PRIVATE_H
3
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>
10
11/* An expression is either an integer, an identifier or an operation
12 * with zero or more arguments.
13 */
14struct isl_ast_expr {
15	int ref;
16
17	isl_ctx *ctx;
18
19	enum isl_ast_expr_type type;
20
21	union {
22		isl_val *v;
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;
30};
31
32#undef EL
33#define EL isl_ast_expr
34
35#include <isl_list_templ.h>
36
37__isl_give isl_ast_expr *isl_ast_expr_alloc_int_si(isl_ctx *ctx, int i);
38__isl_give isl_ast_expr *isl_ast_expr_alloc_op(isl_ctx *ctx,
39	enum isl_ast_op_type op, int n_arg);
40__isl_give isl_ast_expr *isl_ast_expr_alloc_binary(enum isl_ast_op_type type,
41	__isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2);
42
43#undef EL
44#define EL isl_ast_node
45
46#include <isl_list_templ.h>
47
48/* A node is either a block, an if, a for or a user node.
49 * "else_node" is NULL if the if node does not have an else branch.
50 * "cond" and "inc" are NULL for degenerate for nodes.
51 */
52struct isl_ast_node {
53	int ref;
54
55	isl_ctx *ctx;
56	enum isl_ast_node_type type;
57
58	union {
59		struct {
60			isl_ast_node_list *children;
61		} b;
62		struct {
63			isl_ast_expr *guard;
64			isl_ast_node *then;
65			isl_ast_node *else_node;
66		} i;
67		struct {
68			unsigned degenerate : 1;
69			isl_ast_expr *iterator;
70			isl_ast_expr *init;
71			isl_ast_expr *cond;
72			isl_ast_expr *inc;
73			isl_ast_node *body;
74		} f;
75		struct {
76			isl_ast_expr *expr;
77		} e;
78	} u;
79
80	isl_id *annotation;
81};
82
83__isl_give isl_ast_node *isl_ast_node_alloc_for(__isl_take isl_id *id);
84__isl_give isl_ast_node *isl_ast_node_for_mark_degenerate(
85	__isl_take isl_ast_node *node);
86__isl_give isl_ast_node *isl_ast_node_alloc_if(__isl_take isl_ast_expr *guard);
87__isl_give isl_ast_node *isl_ast_node_alloc_block(
88	__isl_take isl_ast_node_list *list);
89__isl_give isl_ast_node *isl_ast_node_from_ast_node_list(
90	__isl_take isl_ast_node_list *list);
91__isl_give isl_ast_node *isl_ast_node_for_set_body(
92	__isl_take isl_ast_node *node, __isl_take isl_ast_node *body);
93__isl_give isl_ast_node *isl_ast_node_if_set_then(
94	__isl_take isl_ast_node *node, __isl_take isl_ast_node *child);
95
96struct isl_ast_print_options {
97	int ref;
98	isl_ctx *ctx;
99
100	__isl_give isl_printer *(*print_for)(__isl_take isl_printer *p,
101		__isl_take isl_ast_print_options *options,
102		__isl_keep isl_ast_node *node, void *user);
103	void *print_for_user;
104	__isl_give isl_printer *(*print_user)(__isl_take isl_printer *p,
105		__isl_take isl_ast_print_options *options,
106		__isl_keep isl_ast_node *node, void *user);
107	void *print_user_user;
108};
109
110__isl_give isl_printer *isl_ast_node_list_print(
111	__isl_keep isl_ast_node_list *list, __isl_take isl_printer *p,
112	__isl_keep isl_ast_print_options *options);
113
114#endif
115