provide a simplified and documented API
[cloog/uuh.git] / include / cloog / clast.h
blob78c4ebc28181c3608fd5b4b62f7b659ed5f11e3a
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 enum clast_red_type { clast_red_sum, clast_red_min, clast_red_max };
35 struct clast_reduction {
36 struct clast_expr expr;
37 enum clast_red_type type;
38 int n;
39 struct clast_expr* elts[1];
42 enum clast_bin_type { clast_bin_fdiv, clast_bin_cdiv,
43 clast_bin_div, clast_bin_mod };
44 struct clast_binary {
45 struct clast_expr expr;
46 enum clast_bin_type type;
47 struct clast_expr* LHS;
48 cloog_int_t RHS;
51 struct clast_stmt;
52 struct clast_stmt_op {
53 void (*free)(struct clast_stmt *);
56 #define CLAST_STMT_IS_A(stmt, type) ((stmt)->op == &(type))
58 extern const struct clast_stmt_op stmt_root;
59 extern const struct clast_stmt_op stmt_ass;
60 extern const struct clast_stmt_op stmt_user;
61 extern const struct clast_stmt_op stmt_block;
62 extern const struct clast_stmt_op stmt_for;
63 extern const struct clast_stmt_op stmt_guard;
65 struct clast_stmt {
66 const struct clast_stmt_op *op;
67 struct clast_stmt *next;
70 struct clast_root {
71 struct clast_stmt stmt;
72 CloogNames * names; /**< Names of iterators and parameters. */
75 struct clast_assignment {
76 struct clast_stmt stmt;
77 const char * LHS;
78 struct clast_expr * RHS;
81 struct clast_block {
82 struct clast_stmt stmt;
83 struct clast_stmt * body;
86 struct clast_user_stmt {
87 struct clast_stmt stmt;
88 CloogStatement * statement;
89 struct clast_stmt * substitutions;
92 struct clast_for {
93 struct clast_stmt stmt;
94 const char * iterator;
95 struct clast_expr * LB;
96 struct clast_expr * UB;
97 cloog_int_t stride;
98 struct clast_stmt * body;
101 struct clast_equation {
102 struct clast_expr * LHS;
103 struct clast_expr * RHS;
104 int sign;
107 struct clast_guard {
108 struct clast_stmt stmt;
109 struct clast_stmt * then;
110 int n;
111 struct clast_equation eq[1];
115 struct clast_stmt *cloog_clast_create_from_input(CloogInput *input,
116 CloogOptions *options);
117 struct clast_stmt *cloog_clast_create(CloogProgram *program,
118 CloogOptions *options);
119 void cloog_clast_free(struct clast_stmt *s);
121 struct clast_name *new_clast_name(const char *name);
122 struct clast_term *new_clast_term(cloog_int_t c, struct clast_expr *v);
123 struct clast_binary *new_clast_binary(enum clast_bin_type t,
124 struct clast_expr *lhs, cloog_int_t rhs);
125 struct clast_reduction *new_clast_reduction(enum clast_red_type t, int n);
126 struct clast_root *new_clast_root(CloogNames *names);
127 struct clast_assignment *new_clast_assignment(const char *lhs,
128 struct clast_expr *rhs);
129 struct clast_user_stmt *new_clast_user_stmt(CloogStatement *stmt,
130 struct clast_stmt *subs);
131 struct clast_block *new_clast_block(void);
132 struct clast_for *new_clast_for(const char *it, struct clast_expr *LB,
133 struct clast_expr *UB, cloog_int_t stride);
134 struct clast_guard *new_clast_guard(int n);
136 void free_clast_name(struct clast_name *t);
137 void free_clast_term(struct clast_term *t);
138 void free_clast_binary(struct clast_binary *b);
139 void free_clast_reduction(struct clast_reduction *r);
140 void free_clast_expr(struct clast_expr *e);
141 void free_clast_stmt(struct clast_stmt *s);
143 int clast_expr_equal(struct clast_expr *e1, struct clast_expr *e2);
145 struct clast_expr *clast_bound_from_constraint(CloogConstraint *constraint,
146 int level, CloogNames *names);
148 #if defined(__cplusplus)
150 #endif
151 #endif /* define _H */