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 */ 14 struct 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_expr_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_expr_op_type op, int n_arg); 40 __isl_give isl_ast_expr *isl_ast_expr_alloc_binary( 41 enum isl_ast_expr_op_type type, 42 __isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2); 43 44 #undef EL 45 #define EL isl_ast_node 46 47 #include <isl_list_templ.h> 48 49 /* A node is either a block, an if, a for, a user node or a mark 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. 52 * In case of a mark node, "mark" is the mark and "node" is the marked node. 53 */ 54 struct isl_ast_node { 55 int ref; 56 57 isl_ctx *ctx; 58 enum isl_ast_node_type type; 59 60 union { 61 struct { 62 isl_ast_node_list *children; 63 } b; 64 struct { 65 isl_ast_expr *guard; 66 isl_ast_node *then; 67 isl_ast_node *else_node; 68 } i; 69 struct { 70 unsigned degenerate : 1; 71 isl_ast_expr *iterator; 72 isl_ast_expr *init; 73 isl_ast_expr *cond; 74 isl_ast_expr *inc; 75 isl_ast_node *body; 76 } f; 77 struct { 78 isl_ast_expr *expr; 79 } e; 80 struct { 81 isl_id *mark; 82 isl_ast_node *node; 83 } m; 84 } u; 85 86 isl_id *annotation; 87 }; 88 89 __isl_give isl_ast_node *isl_ast_node_alloc_for(__isl_take isl_id *id); 90 __isl_give isl_ast_node *isl_ast_node_for_mark_degenerate( 91 __isl_take isl_ast_node *node); 92 __isl_give isl_ast_node *isl_ast_node_alloc_if(__isl_take isl_ast_expr *guard); 93 __isl_give isl_ast_node *isl_ast_node_alloc_block( 94 __isl_take isl_ast_node_list *list); 95 __isl_give isl_ast_node *isl_ast_node_alloc_mark(__isl_take isl_id *id, 96 __isl_take isl_ast_node *node); 97 __isl_give isl_ast_node *isl_ast_node_from_ast_node_list( 98 __isl_take isl_ast_node_list *list); 99 __isl_give isl_ast_node *isl_ast_node_for_set_body( 100 __isl_take isl_ast_node *node, __isl_take isl_ast_node *body); 101 __isl_give isl_ast_node *isl_ast_node_if_set_then( 102 __isl_take isl_ast_node *node, __isl_take isl_ast_node *child); 103 104 struct isl_ast_print_options { 105 int ref; 106 isl_ctx *ctx; 107 108 __isl_give isl_printer *(*print_for)(__isl_take isl_printer *p, 109 __isl_take isl_ast_print_options *options, 110 __isl_keep isl_ast_node *node, void *user); 111 void *print_for_user; 112 __isl_give isl_printer *(*print_user)(__isl_take isl_printer *p, 113 __isl_take isl_ast_print_options *options, 114 __isl_keep isl_ast_node *node, void *user); 115 void *print_user_user; 116 }; 117 118 __isl_give isl_printer *isl_ast_node_list_print( 119 __isl_keep isl_ast_node_list *list, __isl_take isl_printer *p, 120 __isl_keep isl_ast_print_options *options); 121 122 #endif 123