CLooG 0.18.4
[cloog.git] / include / cloog / clast.h
blob3348aa8eeebf620628bd3900c88532544a2d8242
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
37 #define CLAST_PARALLEL_VEC 4
39 enum clast_red_type { clast_red_sum, clast_red_min, clast_red_max };
40 struct clast_reduction {
41 struct clast_expr expr;
42 enum clast_red_type type;
43 int n;
44 struct clast_expr* elts[1];
47 enum clast_bin_type { clast_bin_fdiv, clast_bin_cdiv,
48 clast_bin_div, clast_bin_mod };
49 struct clast_binary {
50 struct clast_expr expr;
51 enum clast_bin_type type;
52 struct clast_expr* LHS;
53 cloog_int_t RHS;
56 struct clast_stmt;
57 struct clast_stmt_op {
58 void (*free)(struct clast_stmt *);
61 #define CLAST_STMT_IS_A(stmt, type) ((stmt)->op == &(type))
63 extern const struct clast_stmt_op stmt_root;
64 extern const struct clast_stmt_op stmt_ass;
65 extern const struct clast_stmt_op stmt_user;
66 extern const struct clast_stmt_op stmt_block;
67 extern const struct clast_stmt_op stmt_for;
68 extern const struct clast_stmt_op stmt_guard;
70 struct clast_stmt {
71 const struct clast_stmt_op *op;
72 struct clast_stmt *next;
75 struct clast_root {
76 struct clast_stmt stmt;
77 CloogNames * names; /**< Names of iterators and parameters. */
80 struct clast_assignment {
81 struct clast_stmt stmt;
82 const char * LHS;
83 struct clast_expr * RHS;
86 struct clast_block {
87 struct clast_stmt stmt;
88 struct clast_stmt * body;
91 struct clast_user_stmt {
92 struct clast_stmt stmt;
93 CloogDomain * domain;
94 CloogStatement * statement;
95 struct clast_stmt * substitutions;
98 struct clast_for {
99 struct clast_stmt stmt;
100 CloogDomain * domain;
101 const char * iterator;
102 struct clast_expr * LB;
103 struct clast_expr * UB;
104 cloog_int_t stride;
105 struct clast_stmt * body;
106 int parallel;
107 /* Comma separated list of loop private variables for OpenMP parallelization */
108 char *private_vars;
109 /* Comma separated list of reduction variable/operators for OpenMP parallelization */
110 char *reduction_vars;
111 /* Enable execution time reporting for this loop */
112 /* Variable name to accumulate execution time this loop */
113 char *time_var_name;
116 struct clast_equation {
117 struct clast_expr * LHS;
118 struct clast_expr * RHS;
119 int sign;
122 struct clast_guard {
123 struct clast_stmt stmt;
124 struct clast_stmt * then;
125 int n;
126 struct clast_equation eq[1];
130 struct clast_stmt *cloog_clast_create_from_input(CloogInput *input,
131 CloogOptions *options);
132 struct clast_stmt *cloog_clast_create(CloogProgram *program,
133 CloogOptions *options);
134 void cloog_clast_free(struct clast_stmt *s);
136 struct clast_name *new_clast_name(const char *name);
137 struct clast_term *new_clast_term(cloog_int_t c, struct clast_expr *v);
138 struct clast_binary *new_clast_binary(enum clast_bin_type t,
139 struct clast_expr *lhs, cloog_int_t rhs);
140 struct clast_reduction *new_clast_reduction(enum clast_red_type t, int n);
141 struct clast_root *new_clast_root(CloogNames *names);
142 struct clast_assignment *new_clast_assignment(const char *lhs,
143 struct clast_expr *rhs);
144 struct clast_user_stmt *new_clast_user_stmt(CloogDomain *domain,
145 CloogStatement *stmt, struct clast_stmt *subs);
146 struct clast_block *new_clast_block(void);
147 struct clast_for *new_clast_for(CloogDomain *domain, const char *it,
148 struct clast_expr *LB, struct clast_expr *UB,
149 CloogStride *stride);
150 struct clast_guard *new_clast_guard(int n);
152 void free_clast_name(struct clast_name *t);
153 void free_clast_term(struct clast_term *t);
154 void free_clast_binary(struct clast_binary *b);
155 void free_clast_reduction(struct clast_reduction *r);
156 void free_clast_expr(struct clast_expr *e);
157 void free_clast_stmt(struct clast_stmt *s);
159 int clast_expr_equal(struct clast_expr *e1, struct clast_expr *e2);
161 struct clast_expr *clast_bound_from_constraint(CloogConstraint *constraint,
162 int level, CloogNames *names);
164 typedef enum filterType {exact, subset} ClastFilterType;
166 typedef struct clastFilter{
167 const char *iter;
168 const int *stmts_filter;
169 int nstmts_filter;
170 ClastFilterType filter_type;
171 } ClastFilter;
173 void clast_filter(struct clast_stmt *node, ClastFilter filter,
174 struct clast_for ***loops, int *nloops, int **stmts, int *nstmts);
176 #if defined(__cplusplus)
178 #endif
179 #endif /* define _H */