Home | History | Annotate | Download | only in cloog
      1 #ifndef CLOOG_CLAST_H
      2 #define CLOOG_CLAST_H
      3 #if defined(__cplusplus)
      4 extern "C"
      5   {
      6 #endif
      7 
      8 enum clast_expr_type {
      9     clast_expr_name,
     10     clast_expr_term,
     11     clast_expr_bin,
     12     clast_expr_red
     13 };
     14 struct clast_expr {
     15     enum clast_expr_type type;
     16 };
     17 
     18 struct clast_name {
     19     struct clast_expr	expr;
     20     const char *	name;
     21 };
     22 
     23 /* Represents the term
     24  *	val * var	(if var != NULL)
     25  * or
     26  *	val		(if var == NULL)
     27  */
     28 struct clast_term {
     29     struct clast_expr	expr;
     30     cloog_int_t		val;
     31     struct clast_expr  *var;
     32 };
     33 
     34 #define CLAST_PARALLEL_NOT 0
     35 #define CLAST_PARALLEL_OMP 1
     36 #define CLAST_PARALLEL_MPI 2
     37 #define CLAST_PARALLEL_VEC 4
     38 
     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];
     45 };
     46 
     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;
     54 };
     55 
     56 struct clast_stmt;
     57 struct clast_stmt_op {
     58     void (*free)(struct clast_stmt *);
     59 };
     60 
     61 #define CLAST_STMT_IS_A(stmt, type) ((stmt)->op == &(type))
     62 
     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;
     69 
     70 struct clast_stmt {
     71     const struct clast_stmt_op    *op;
     72     struct clast_stmt	*next;
     73 };
     74 
     75 struct clast_root {
     76     struct clast_stmt	stmt;
     77     CloogNames *	names;       /**< Names of iterators and parameters. */
     78 };
     79 
     80 struct clast_assignment {
     81     struct clast_stmt	stmt;
     82     const char *	LHS;
     83     struct clast_expr *	RHS;
     84 };
     85 
     86 struct clast_block {
     87     struct clast_stmt	stmt;
     88     struct clast_stmt *	body;
     89 };
     90 
     91 struct clast_user_stmt {
     92     struct clast_stmt	stmt;
     93     CloogDomain *	domain;
     94     CloogStatement *	statement;
     95     struct clast_stmt *	substitutions;
     96 };
     97 
     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 };
    112 
    113 struct clast_equation {
    114     struct clast_expr *	LHS;
    115     struct clast_expr *	RHS;
    116     int			sign;
    117 };
    118 
    119 struct clast_guard {
    120     struct clast_stmt	stmt;
    121     struct clast_stmt *	then;
    122     int			n;
    123     struct clast_equation	eq[1];
    124 };
    125 
    126 
    127 struct clast_stmt *cloog_clast_create_from_input(CloogInput *input,
    128 						 CloogOptions *options);
    129 struct clast_stmt *cloog_clast_create(CloogProgram *program,
    130 				      CloogOptions *options);
    131 void cloog_clast_free(struct clast_stmt *s);
    132 
    133 struct clast_name *new_clast_name(const char *name);
    134 struct clast_term *new_clast_term(cloog_int_t c, struct clast_expr *v);
    135 struct clast_binary *new_clast_binary(enum clast_bin_type t,
    136 				      struct clast_expr *lhs, cloog_int_t rhs);
    137 struct clast_reduction *new_clast_reduction(enum clast_red_type t, int n);
    138 struct clast_root *new_clast_root(CloogNames *names);
    139 struct clast_assignment *new_clast_assignment(const char *lhs,
    140 					      struct clast_expr *rhs);
    141 struct clast_user_stmt *new_clast_user_stmt(CloogDomain *domain,
    142     CloogStatement *stmt, struct clast_stmt *subs);
    143 struct clast_block *new_clast_block(void);
    144 struct clast_for *new_clast_for(CloogDomain *domain, const char *it,
    145                                 struct clast_expr *LB, struct clast_expr *UB,
    146                                 CloogStride *stride);
    147 struct clast_guard *new_clast_guard(int n);
    148 
    149 void free_clast_name(struct clast_name *t);
    150 void free_clast_term(struct clast_term *t);
    151 void free_clast_binary(struct clast_binary *b);
    152 void free_clast_reduction(struct clast_reduction *r);
    153 void free_clast_expr(struct clast_expr *e);
    154 void free_clast_stmt(struct clast_stmt *s);
    155 
    156 int clast_expr_equal(struct clast_expr *e1, struct clast_expr *e2);
    157 
    158 struct clast_expr *clast_bound_from_constraint(CloogConstraint *constraint,
    159 					       int level, CloogNames *names);
    160 
    161 typedef enum filterType {exact, subset} ClastFilterType;
    162 
    163 typedef struct clastFilter{
    164     const char *iter;
    165     const int *stmts_filter;
    166     int nstmts_filter;
    167     ClastFilterType filter_type;
    168 } ClastFilter;
    169 
    170 void clast_filter(struct clast_stmt *node, ClastFilter filter,
    171         struct clast_for ***loops, int *nloops, int **stmts, int *nstmts);
    172 
    173 #if defined(__cplusplus)
    174   }
    175 #endif
    176 #endif /* define _H */
    177