manpagez: man pages & more
info cloog
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 CLooG Output

Given a description of the input, an AST corresponding to the CloogInput can be constructed using cloog_clast_create_from_input and destroyed using free_clast_stmt.

struct clast_stmt *cloog_clast_create_from_input(CloogInput *input,
                                      CloogOptions *options);
void free_clast_stmt(struct clast_stmt *s);

clast_stmt represents a linked list of “statements”.

struct clast_stmt {
    const struct clast_stmt_op    *op;
    struct clast_stmt	*next;
};

The entries in the list are not of type clast_stmt itself, but of some larger type. The following statement types are defined by CLooG.

struct clast_root {
    struct clast_stmt   stmt;
    CloogNames *        names;
};
struct clast_root *new_clast_root(CloogNames *names);

struct clast_assignment {
    struct clast_stmt   stmt;
    const char *        LHS;
    struct clast_expr * RHS;
};
struct clast_assignment *new_clast_assignment(const char *lhs,
                                              struct clast_expr *rhs);

struct clast_block {
    struct clast_stmt   stmt;
    struct clast_stmt * body;
};
struct clast_block *new_clast_block(void);

struct clast_user_stmt {
    struct clast_stmt   stmt;
    CloogDomain *	domain;
    CloogStatement *    statement;
    struct clast_stmt * substitutions;
};
struct clast_user_stmt *new_clast_user_stmt(CloogDomain *domain,
    CloogStatement *stmt, struct clast_stmt *subs);

struct clast_for {
    struct clast_stmt   stmt;
    CloogDomain *       domain;
    const char *        iterator;
    struct clast_expr * LB;
    struct clast_expr * UB;
    cloog_int_t         stride;
    struct clast_stmt * body;
};
struct clast_for *new_clast_for(CloogDomain *domain, const char *it,
                                struct clast_expr *LB, struct clast_expr *UB,
                                cloog_int_t stride);

struct clast_guard {
    struct clast_stmt   stmt;
    struct clast_stmt * then;
    int                 n;
    struct clast_equation       eq[1];
};
struct clast_guard *new_clast_guard(int n);

The clast_stmt returned by cloog_clast_create is a clast_root. It contains a placeholder for all the variable names that appear in the AST and a (list of) nested statement(s).

A clast_assignment assigns the value given by the clast_expr RHS to a variable named LHS.

A clast_block groups a list of statements into one statement. These statements are only generated if the block option is set, see section Statement Block -block <boolean> and CloogOptions.

A clast_user_stmt represents a call to a statement specified by the user, see section CloogStatement. substitutions is a list of clast_assignment statements assigning an expression in terms of the scattering dimensions to each of the original iterators in the original order. The LHSs of these assignments are left blank (NULL). The domain is set to NULL if the save_domains option is not set. Otherwise, it is set to the set of values for the scattering dimensions for which this instance of the user statement is executed. Note that unless the noscalars option has been set, the constant scattering dimensions may have been removed from this set.

A clast_for represents a for loop, iterating body for each value of iterator between LB and UB in steps of size stride. The domain is set to NULL if the save_domains option is not set. Otherwise, it is set to the set of values for the scattering dimensions for which a user statement is executed inside this clast_for. Note that unless the noscalars option has been set, the constant scattering dimensions may have been removed from this set.

A clast_guard represents the guarded execution of the then (list of) statement(s) by a conjunction of n (in)equalities. Each (in)equality is represented by a clast_equation.

struct clast_equation {
    struct clast_expr *	LHS;
    struct clast_expr *	RHS;
    int			sign;
};

The condition expressed by a clast_equation is LHS <= RHS, LHS == RHS or LHS >= RHS depending on whether sign is less than zero, equal to zero, or greater than zero.

The dynamic type of a clast_stmt can be determined using the macro CLAST_STMT_IS_A(stmt,type), where stmt is a pointer to a clast_stmt and type is one of stmt_root, stmt_ass, stmt_user, stmt_block, stmt_for or stmt_guard. Users are allowed to define their own statement types by assigning the op field of the statements a pointer to a clast_stmt_op structure.

struct clast_stmt_op {
    void (*free)(struct clast_stmt *);
};

The free field of this structure should point to a function that frees the user defined statement.

A clast_expr can be an identifier, a term, a binary expression or a reduction.

enum clast_expr_type {
    clast_expr_name,
    clast_expr_term,
    clast_expr_bin,
    clast_expr_red
};
struct clast_expr {
    enum clast_expr_type type;
};
void free_clast_expr(struct clast_expr *e);

Identifiers are of subtype clast_name.

struct clast_name {
    struct clast_expr	expr;
    const char *	name;
};
struct clast_name *new_clast_name(const char *name);
void free_clast_name(struct clast_name *t);

The character string pointed to by name is assumed to be part of the CloogNames structure in the root of the clast as is therefore not copied.

Terms are of type clast_term.

struct clast_term {
    struct clast_expr   expr;
    cloog_int_t         val;
    struct clast_expr  *var;
};
struct clast_term *new_clast_term(cloog_int_t c, struct clast_expr *v);
void free_clast_term(struct clast_term *t);

If var is set to NULL, then the term represents the integer value val. Otherwise, it represents the term val * var. new_clast_term simply copies the v pointer without copying the underlying clast_expr. free_clast_term, on the other hand, recursively frees var.

Binary expressions are of type clast_bin_type and represent either the floor of a division (fdiv), the ceil of a division (cdiv), an exact division or the remainder of an fdiv.

enum clast_bin_type { clast_bin_fdiv, clast_bin_cdiv, 
                      clast_bin_div, clast_bin_mod };
struct clast_binary {
    struct clast_expr   expr;
    enum clast_bin_type type;
    struct clast_expr*  LHS;
    cloog_int_t         RHS;
};
struct clast_binary *new_clast_binary(enum clast_bin_type t, 
                          struct clast_expr *lhs, cloog_int_t rhs);
void free_clast_binary(struct clast_binary *b);

Reductions are of type clast_reduction and can represent either the sum, the minimum or the maximum of its elements.

enum clast_red_type { clast_red_sum, clast_red_min, clast_red_max };
struct clast_reduction {
    struct clast_expr   expr;
    enum clast_red_type type;
    int                 n;
    struct clast_expr*  elts[1];
};
struct clast_reduction *new_clast_reduction(enum clast_red_type t,
                                            int n);
void free_clast_reduction(struct clast_reduction *r);

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on August 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.