clast traversal and node filtering support
[cloog.git] / include / cloog / clast.h
blob0a5e3fde0b3ac6eb97f27e2d1e4a1dd8b0cb252e
1 #ifndef CLOOG_CLAST_H
2 #define CLOOG_CLAST_H
3 #if defined(__cplusplus)
4 extern "C"
6 #endif
8 enum clast_expr_type {
9 clast_expr_name,
10 clast_expr_term,
11 clast_expr_bin,
12 clast_expr_red
14 struct clast_expr {
15 enum clast_expr_type type;
18 struct clast_name {
19 struct clast_expr expr;
20 const char * name;
23 /* Represents the term
24 * val * var (if var != NULL)
25 * or
26 * val (if var == NULL)
28 struct clast_term {
29 struct clast_expr expr;
30 cloog_int_t val;
31 struct clast_expr *var;
34 #define CLAST_PARALLEL_NOT 0
35 #define CLAST_PARALLEL_OMP 1
36 #define CLAST_PARALLEL_MPI 2
38 enum clast_red_type { clast_red_sum, clast_red_min, clast_red_max };
39 struct clast_reduction {
40 struct clast_expr expr;
41 enum clast_red_type type;
42 int n;
43 struct clast_expr* elts[1];
46 enum clast_bin_type { clast_bin_fdiv, clast_bin_cdiv,
47 clast_bin_div, clast_bin_mod };
48 struct clast_binary {
49 struct clast_expr expr;
50 enum clast_bin_type type;
51 struct clast_expr* LHS;
52 cloog_int_t RHS;
55 struct clast_stmt;
56 struct clast_stmt_op {
57 void (*free)(struct clast_stmt *);
60 #define CLAST_STMT_IS_A(stmt, type) ((stmt)->op == &(type))
62 extern const struct clast_stmt_op stmt_root;
63 extern const struct clast_stmt_op stmt_ass;
64 extern const struct clast_stmt_op stmt_user;
65 extern const struct clast_stmt_op stmt_block;
66 extern const struct clast_stmt_op stmt_for;
67 extern const struct clast_stmt_op stmt_guard;
69 struct clast_stmt {
70 const struct clast_stmt_op *op;
71 struct clast_stmt *next;
74 struct clast_root {
75 struct clast_stmt stmt;
76 CloogNames * names; /**< Names of iterators and parameters. */
79 struct clast_assignment {
80 struct clast_stmt stmt;
81 const char * LHS;
82 struct clast_expr * RHS;
85 struct clast_block {
86 struct clast_stmt stmt;
87 struct clast_stmt * body;
90 struct clast_user_stmt {
91 struct clast_stmt stmt;
92 CloogDomain * domain;
93 CloogStatement * statement;
94 struct clast_stmt * substitutions;
97 struct clast_for {
98 struct clast_stmt stmt;
99 CloogDomain * domain;
100 const char * iterator;
101 struct clast_expr * LB;
102 struct clast_expr * UB;
103 cloog_int_t stride;
104 struct clast_stmt * body;
105 int parallel;
106 /* Comma separated list of loop private variables for OpenMP parallelization */
107 char *private_vars;
108 /* Comma separated list of reduction variable/operators for OpenMP parallelization */
109 char *reduction_vars;
112 struct clast_equation {
113 struct clast_expr * LHS;
114 struct clast_expr * RHS;
115 int sign;
118 struct clast_guard {
119 struct clast_stmt stmt;
120 struct clast_stmt * then;
121 int n;
122 struct clast_equation eq[1];
126 struct clast_stmt *cloog_clast_create_from_input(CloogInput *input,
127 CloogOptions *options);
128 struct clast_stmt *cloog_clast_create(CloogProgram *program,
129 CloogOptions *options);
130 void cloog_clast_free(struct clast_stmt *s);
132 struct clast_name *new_clast_name(const char *name);
133 struct clast_term *new_clast_term(cloog_int_t c, struct clast_expr *v);
134 struct clast_binary *new_clast_binary(enum clast_bin_type t,
135 struct clast_expr *lhs, cloog_int_t rhs);
136 struct clast_reduction *new_clast_reduction(enum clast_red_type t, int n);
137 struct clast_root *new_clast_root(CloogNames *names);
138 struct clast_assignment *new_clast_assignment(const char *lhs,
139 struct clast_expr *rhs);
140 struct clast_user_stmt *new_clast_user_stmt(CloogDomain *domain,
141 CloogStatement *stmt, struct clast_stmt *subs);
142 struct clast_block *new_clast_block(void);
143 struct clast_for *new_clast_for(CloogDomain *domain, const char *it,
144 struct clast_expr *LB, struct clast_expr *UB,
145 CloogStride *stride);
146 struct clast_guard *new_clast_guard(int n);
148 void free_clast_name(struct clast_name *t);
149 void free_clast_term(struct clast_term *t);
150 void free_clast_binary(struct clast_binary *b);
151 void free_clast_reduction(struct clast_reduction *r);
152 void free_clast_expr(struct clast_expr *e);
153 void free_clast_stmt(struct clast_stmt *s);
155 int clast_expr_equal(struct clast_expr *e1, struct clast_expr *e2);
157 struct clast_expr *clast_bound_from_constraint(CloogConstraint *constraint,
158 int level, CloogNames *names);
160 typedef enum filterType {exact, subset} ClastFilterType;
162 typedef struct clastFilter{
163 const char *iter;
164 const int *stmts_filter;
165 int nstmts_filter;
166 ClastFilterType filter_type;
167 } ClastFilter;
169 void clast_filter(struct clast_stmt *node, ClastFilter filter,
170 struct clast_for ***loops, int *nloops, int **stmts, int *nstmts);
172 #if defined(__cplusplus)
174 #endif
175 #endif /* define _H */