GCC Middle and Back End API Reference
graphite-clast-to-gimple.c File Reference

Data Structures

struct  clast_name_index
struct  clast_index_hasher
struct  ivs_params

Typedefs

typedef struct clast_expr * clast_name_p
typedef struct clast_name_indexclast_name_index_p
typedef hash_table
< clast_index_hasher
clast_index_htab_type
typedef struct ivs_paramsivs_params_p

Functions

static tree gmp_cst_to_tree ()
static void value_min ()
static void value_max ()
static void graphite_verify ()
static clast_name_index_p new_clast_name_index (const char *name, int index, int level, mpz_t bound_one, mpz_t bound_two)
static int clast_name_to_level ()
static int clast_name_to_index ()
static bool clast_name_to_lb_ub (struct clast_name *name, clast_index_htab_type index_table, mpz_t bound_one, mpz_t bound_two)
static void save_clast_name_index (clast_index_htab_type index_table, const char *name, int index, int level, mpz_t bound_one, mpz_t bound_two)
static tree clast_name_to_gcc ()
static tree max_precision_type ()
static tree clast_to_gcc_expression (tree, struct clast_expr *, ivs_params_p)
static tree clast_to_gcc_expression_red (tree type, enum tree_code op, struct clast_reduction *r, ivs_params_p ip)
static tree clast_to_gcc_expression ()
static tree type_for_interval ()
static tree type_for_value ()
static tree type_for_clast_expr (struct clast_expr *, ivs_params_p, mpz_t, mpz_t)
static tree type_for_clast_term (struct clast_term *t, ivs_params_p ip, mpz_t bound_one, mpz_t bound_two)
static tree type_for_clast_red (struct clast_reduction *r, ivs_params_p ip, mpz_t bound_one, mpz_t bound_two)
static tree type_for_clast_bin (struct clast_binary *b, ivs_params_p ip, mpz_t bound_one, mpz_t bound_two)
static tree type_for_clast_name (struct clast_name *name, ivs_params_p ip, mpz_t bound_one, mpz_t bound_two)
static bool clast_expr_const_value_p ()
static tree graphite_translate_clast_equation (struct clast_equation *cleq, ivs_params_p ip)
static tree graphite_create_guard_cond_expr (struct clast_guard *stmt, ivs_params_p ip)
static edge graphite_create_new_guard (edge entry_edge, struct clast_guard *stmt, ivs_params_p ip)
static void compute_bounds_for_param ()
static void compute_bounds_for_loop ()
static tree type_for_clast_for ()
static struct loopgraphite_create_new_loop (edge entry_edge, struct clast_for *stmt, loop_p outer, tree type, tree lb, tree ub, int level, ivs_params_p ip)
static void build_iv_mapping (vec< tree > iv_map, struct clast_user_stmt *user_stmt, ivs_params_p ip)
static bb_pbb_defnew_bb_pbb_def ()
static void mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, bb_pbb_htab_type bb_pbb_mapping)
poly_bb_p find_pbb_via_hash ()
scop_p get_loop_body_pbbs (loop_p loop, bb_pbb_htab_type bb_pbb_mapping, vec< poly_bb_p > *pbbs)
static edge translate_clast_user (struct clast_user_stmt *stmt, edge next_e, bb_pbb_htab_type bb_pbb_mapping, ivs_params_p ip)
static edge graphite_create_new_loop_guard (edge entry_edge, struct clast_for *stmt, tree *type, tree *lb, tree *ub, ivs_params_p ip)
static edge translate_clast (loop_p, struct clast_stmt *, edge, bb_pbb_htab_type, int, ivs_params_p)
static edge translate_clast_for_loop (loop_p context_loop, struct clast_for *stmt, edge next_e, bb_pbb_htab_type bb_pbb_mapping, int level, tree type, tree lb, tree ub, ivs_params_p ip)
static edge translate_clast_for (loop_p context_loop, struct clast_for *stmt, edge next_e, bb_pbb_htab_type bb_pbb_mapping, int level, ivs_params_p ip)
static edge translate_clast_assignment (struct clast_assignment *stmt, edge next_e, int level, ivs_params_p ip)
static edge translate_clast_guard (loop_p context_loop, struct clast_guard *stmt, edge next_e, bb_pbb_htab_type bb_pbb_mapping, int level, ivs_params_p ip)
static CloogUnionDomain * add_names_to_union_domain (scop_p scop, CloogUnionDomain *union_domain, int nb_scattering_dims, clast_index_htab_type params_index)
static FILE * init_cloog_input_file ()
static isl_map * extend_scattering (isl_map *scattering, int new_dims)
static CloogUnionDomain * build_cloog_union_domain ()
static CloogOptions * set_cloog_options ()
void print_clast_stmt ()
DEBUG_FUNCTION void debug_clast_stmt ()
static int get_max_scattering_dimensions (scop_p scop)
static CloogInput * generate_cloog_input ()
static struct clast_stmt * scop_to_clast ()
void print_generated_program ()
DEBUG_FUNCTION void debug_generated_program ()
bool gloog ()

Variables

static bool gloog_error

Typedef Documentation

Stores the INDEX in a vector and the loop nesting LEVEL for a given
   clast NAME.  BOUND_ONE and BOUND_TWO represent the exact lower and
   upper bounds that can be inferred from the polyhedral representation.   
typedef struct clast_expr* clast_name_p
@verbatim Translation of CLAST (CLooG AST) to Gimple.

Copyright (C) 2009-2013 Free Software Foundation, Inc. Contributed by Sebastian Pop sebas.nosp@m.tian.nosp@m..pop@.nosp@m.amd..nosp@m.com.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

typedef struct ivs_params * ivs_params_p
NEWIVS_INDEX binds CLooG's scattering name to the index of the tree
   induction variable in NEWIVS.

   PARAMS_INDEX binds CLooG's parameter name to the index of the tree
   parameter in PARAMS.   

Function Documentation

static CloogUnionDomain* add_names_to_union_domain ( scop_p  scop,
CloogUnionDomain *  union_domain,
int  nb_scattering_dims,
clast_index_htab_type  params_index 
)
static
Add parameter and iterator names to the CloogUnionDomain.   

References compute_bounds_for_param(), free(), get_name(), len, save_clast_name_index(), scop_max_loop_depth(), snprintf(), and strlen().

Referenced by generate_cloog_input().

static CloogUnionDomain* build_cloog_union_domain ( )
static
Build cloog union domain for SCoP.   

References poly_bb::domain, extend_scattering(), scop_nb_params(), and poly_bb::transformed.

Referenced by generate_cloog_input().

static void build_iv_mapping ( vec< tree iv_map,
struct clast_user_stmt *  user_stmt,
ivs_params_p  ip 
)
static
Inserts in iv_map a tuple (OLD_LOOP->num, NEW_NAME) for the
   induction variables of the loops around GBB in SESE.   

References clast_to_gcc_expression(), gbb_loop_at_index(), loop::num, ivs_params::region, and type_for_clast_expr().

Referenced by translate_clast_user().

static bool clast_expr_const_value_p ( )
static
Returns true if the clast expression E is a constant with VALUE.   

Referenced by graphite_translate_clast_equation().

static tree clast_name_to_gcc ( )
static
Returns the tree variable from the name NAME that was given in
   Cloog representation.   

References clast_name_to_index(), hash_table< Descriptor, Allocator >::is_created(), ivs_params::newivs, ivs_params::newivs_index, ivs_params::params, and ivs_params::params_index.

Referenced by clast_to_gcc_expression(), and type_for_clast_name().

static int clast_name_to_index ( )
inlinestatic
For a given clast NAME, returns -1 if it does not correspond to any
   parameter, or otherwise, returns the index in the PARAMS or
   SCATTERING_DIMENSIONS vector.   

References hash_table< Descriptor, Allocator >::find_slot(), clast_name_index::free_name, clast_name_index::index, and clast_name_index::name.

Referenced by clast_name_to_gcc().

static bool clast_name_to_lb_ub ( struct clast_name *  name,
clast_index_htab_type  index_table,
mpz_t  bound_one,
mpz_t  bound_two 
)
inlinestatic
For a given clast NAME, initializes the lower and upper bounds BOUND_ONE
   and BOUND_TWO stored in the INDEX_TABLE.  Returns true when NAME has been
   found in the INDEX_TABLE, false otherwise.   

References hash_table< Descriptor, Allocator >::find_slot(), clast_name_index::free_name, and clast_name_index::name.

Referenced by type_for_clast_name().

static int clast_name_to_level ( )
inlinestatic
For a given clast NAME, returns -1 if NAME is not in the
   INDEX_TABLE, otherwise returns the loop level for the induction
   variable NAME, or if it is a parameter, the parameter number in the
   vector of parameters.   

References hash_table< Descriptor, Allocator >::find_slot(), clast_name_index::free_name, clast_name_index::level, and clast_name_index::name.

static tree clast_to_gcc_expression ( )
static
Converts a Cloog AST expression E back to a GCC expression tree of
   type TYPE.   

References clast_name_to_gcc(), clast_to_gcc_expression(), clast_to_gcc_expression_red(), gloog_error, gmp_cst_to_tree(), and tr().

static tree clast_to_gcc_expression_red ( tree  type,
enum tree_code  op,
struct clast_reduction *  r,
ivs_params_p  ip 
)
static
Converts a Cloog reduction expression R with reduction operation OP
   to a GCC expression tree of type TYPE.   

References clast_to_gcc_expression().

Referenced by clast_to_gcc_expression().

static void compute_bounds_for_loop ( )
static
Compute the lower bound LOW and upper bound UP for the induction
   variable of loop LOOP.

   FIXME: This one is not entirely correct, as min/max expressions in the
          calculation can yield to incorrect results. To be completely
          correct, we need to evaluate each subexpression generated by
          CLooG. CLooG does not yet support this, so this is as good as
          it can be.  

Referenced by graphite_create_new_loop().

static void compute_bounds_for_param ( )
static
Compute the lower bound LOW and upper bound UP for the parameter
   PARAM in scop SCOP based on the constraints in the context.   

References scop::context.

Referenced by add_names_to_union_domain().

DEBUG_FUNCTION void debug_clast_stmt ( )
Prints STMT to STDERR.   

References print_clast_stmt().

DEBUG_FUNCTION void debug_generated_program ( )
Prints to STDERR the code generated by CLooG for SCOP.   

References print_generated_program().

static isl_map* extend_scattering ( isl_map *  scattering,
int  new_dims 
)
static
Extend the scattering to NEW_DIMS scattering dimensions.   

Referenced by build_cloog_union_domain().

poly_bb_p find_pbb_via_hash ( )
Find BB's related poly_bb_p in hash table BB_PBB_MAPPING.   

References bb_pbb_def::bb, and hash_table< Descriptor, Allocator >::find_slot().

Referenced by get_loop_body_pbbs().

static CloogInput* generate_cloog_input ( )
static
scop_p get_loop_body_pbbs ( loop_p  loop,
bb_pbb_htab_type  bb_pbb_mapping,
vec< poly_bb_p > *  pbbs 
)
Return the scop of the loop and initialize PBBS the set of
   poly_bb_p that belong to the LOOP.  BB_PBB_MAPPING is a map created
   by the CLAST code generator between a generated basic_block and its
   related poly_bb_p.   

References find_pbb_via_hash(), free(), get_loop_body_in_dom_order(), and loop::num_nodes.

Referenced by loop_is_parallel_p().

static int get_max_scattering_dimensions ( scop_p  scop)
static
Get the maximal number of scattering dimensions in the scop SCOP.   

References poly_bb::transformed.

Referenced by generate_cloog_input().

static tree gmp_cst_to_tree ( )
static
Converts a GMP constant VAL to a tree and returns it.   

References double_int_to_tree(), and mpz_get_double_int().

Referenced by clast_to_gcc_expression(), and graphite_create_new_loop().

static tree graphite_create_guard_cond_expr ( struct clast_guard *  stmt,
ivs_params_p  ip 
)
static
Creates the test for the condition in STMT.   

References graphite_translate_clast_equation().

Referenced by graphite_create_new_guard().

static edge graphite_create_new_guard ( edge  entry_edge,
struct clast_guard *  stmt,
ivs_params_p  ip 
)
static
Creates a new if region corresponding to Cloog's guard.   

References create_empty_if_region_on_edge(), and graphite_create_guard_cond_expr().

Referenced by translate_clast_guard().

static struct loop* graphite_create_new_loop ( edge  entry_edge,
struct clast_for *  stmt,
loop_p  outer,
tree  type,
tree  lb,
tree  ub,
int  level,
ivs_params_p  ip 
)
staticread
Creates a new LOOP corresponding to Cloog's STMT.  Inserts an
   induction variable for the new LOOP.  New LOOP is attached to CFG
   starting at ENTRY_EDGE.  LOOP is inserted into the loop tree and
   becomes the child loop of the OUTER_LOOP.  NEWIVS_INDEX binds
   CLooG's scattering name to the induction variable created for the
   loop of STMT.  The new induction variable is inserted in the NEWIVS
   vector and is of type TYPE.   

References compute_bounds_for_loop(), create_empty_loop_on_edge(), create_tmp_var(), gmp_cst_to_tree(), basic_block_def::loop_father, ivs_params::newivs, ivs_params::newivs_index, save_clast_name_index(), and edge_def::src.

Referenced by translate_clast_for_loop().

static edge graphite_create_new_loop_guard ( edge  entry_edge,
struct clast_for *  stmt,
tree type,
tree lb,
tree ub,
ivs_params_p  ip 
)
static
Creates a new if region protecting the loop to be executed, if the execution
   count is zero (lb > ub).   

References clast_to_gcc_expression(), create_empty_if_region_on_edge(), and type_for_clast_for().

Referenced by translate_clast_for().

static tree graphite_translate_clast_equation ( struct clast_equation *  cleq,
ivs_params_p  ip 
)
static
static void graphite_verify ( )
inlinestatic
Verifies properties that GRAPHITE should maintain during translation.   

References verify_loop_closed_ssa(), and verify_loop_structure().

Referenced by gloog(), and translate_clast().

static FILE* init_cloog_input_file ( )
static
Initialize a CLooG input file.   

References fatal_error(), free(), len, memcpy(), strip_off_ending(), and strlen().

Referenced by scop_to_clast().

static void mark_bb_with_pbb ( poly_bb_p  pbb,
basic_block  bb,
bb_pbb_htab_type  bb_pbb_mapping 
)
static
Mark BB with it's relevant PBB via hashing table BB_PBB_MAPPING.   

References bb_pbb_def::bb, hash_table< Descriptor, Allocator >::find_slot(), and new_bb_pbb_def().

Referenced by translate_clast_user().

static tree max_precision_type ( )
static
static bb_pbb_def* new_bb_pbb_def ( )
static
Construct bb_pbb_def with BB and PBB.   

References bb_pbb_def::bb, and bb_pbb_def::pbb.

Referenced by mark_bb_with_pbb().

static clast_name_index_p new_clast_name_index ( const char *  name,
int  index,
int  level,
mpz_t  bound_one,
mpz_t  bound_two 
)
inlinestatic
Returns a pointer to a new element of type clast_name_index_p built
   from NAME, INDEX, LEVEL, BOUND_ONE, and BOUND_TWO.   

References clast_name_index::bound_one, clast_name_index::bound_two, clast_name_index::free_name, clast_name_index::index, clast_name_index::level, clast_name_index::name, and strlen().

Referenced by save_clast_name_index().

void print_clast_stmt ( )
Prints STMT to STDERR.   

References set_cloog_options().

Referenced by debug_clast_stmt(), and gloog().

void print_generated_program ( )
Prints to FILE the code generated by CLooG for SCOP.   

References hash_table< Descriptor, Allocator >::create(), scop_to_clast(), and set_cloog_options().

Referenced by debug_generated_program().

static void save_clast_name_index ( clast_index_htab_type  index_table,
const char *  name,
int  index,
int  level,
mpz_t  bound_one,
mpz_t  bound_two 
)
inlinestatic
static struct clast_stmt* scop_to_clast ( )
staticread
Translate SCOP to a CLooG program and clast.  These two
   representations should be freed together: a clast cannot be used
   without a program.   

References generate_cloog_input(), init_cloog_input_file(), and set_cloog_options().

Referenced by gloog(), and print_generated_program().

static CloogOptions* set_cloog_options ( )
static
Return the options that will be used in GLOOG.   

References cloog_state, and options.

Referenced by print_clast_stmt(), print_generated_program(), and scop_to_clast().

static edge translate_clast ( loop_p  context_loop,
struct clast_stmt *  stmt,
edge  next_e,
bb_pbb_htab_type  bb_pbb_mapping,
int  level,
ivs_params_p  ip 
)
static
Translates a CLAST statement STMT to GCC representation in the
   context of a SESE.

   - NEXT_E is the edge where new generated code should be attached.
   - CONTEXT_LOOP is the loop in which the generated code will be placed
   - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.   

References graphite_verify(), loop::next, recompute_all_dominators(), translate_clast_assignment(), translate_clast_for(), translate_clast_guard(), and translate_clast_user().

Referenced by gloog(), translate_clast_for_loop(), and translate_clast_guard().

static edge translate_clast_assignment ( struct clast_assignment *  stmt,
edge  next_e,
int  level,
ivs_params_p  ip 
)
static
Translates a clast assignment STMT to gimple.

   - NEXT_E is the edge where new generated code should be attached.
   - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.   

References clast_to_gcc_expression(), create_tmp_var(), force_gimple_operand(), gsi_commit_edge_inserts(), gsi_insert_seq_on_edge(), ivs_params::newivs, ivs_params::newivs_index, save_clast_name_index(), single_succ_edge(), split_edge(), type(), and type_for_clast_expr().

Referenced by translate_clast().

static edge translate_clast_for ( loop_p  context_loop,
struct clast_for *  stmt,
edge  next_e,
bb_pbb_htab_type  bb_pbb_mapping,
int  level,
ivs_params_p  ip 
)
static
Translates a clast for statement STMT to gimple.  First a guard is created
   protecting the loop, if it is executed zero times.  In this guard we create
   the real loop structure.

   - NEXT_E is the edge where new generated code should be attached.
   - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.   

References edge_def::dest, get_true_edge_from_guard_bb(), graphite_create_new_loop_guard(), translate_clast_for_loop(), and type().

Referenced by translate_clast().

static edge translate_clast_for_loop ( loop_p  context_loop,
struct clast_for *  stmt,
edge  next_e,
bb_pbb_htab_type  bb_pbb_mapping,
int  level,
tree  type,
tree  lb,
tree  ub,
ivs_params_p  ip 
)
static
Create the loop for a clast for statement.

   - NEXT_E is the edge where new generated code should be attached.
   - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.   

References loop::can_be_parallel, CDI_DOMINATORS, edge_def::dest, graphite_create_new_loop(), loop::header, loop_is_parallel_p(), redirect_edge_succ_nodup(), set_immediate_dominator(), single_exit(), single_succ_edge(), split_edge(), edge_def::src, and translate_clast().

Referenced by translate_clast_for().

static edge translate_clast_guard ( loop_p  context_loop,
struct clast_guard *  stmt,
edge  next_e,
bb_pbb_htab_type  bb_pbb_mapping,
int  level,
ivs_params_p  ip 
)
static
Translates a clast guard statement STMT to gimple.

   - NEXT_E is the edge where new generated code should be attached.
   - CONTEXT_LOOP is the loop in which the generated code will be placed
   - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.   

References edge_def::dest, get_true_edge_from_guard_bb(), graphite_create_new_guard(), and translate_clast().

Referenced by translate_clast().

static edge translate_clast_user ( struct clast_user_stmt *  stmt,
edge  next_e,
bb_pbb_htab_type  bb_pbb_mapping,
ivs_params_p  ip 
)
static
Translates a clast user statement STMT to gimple.

   - NEXT_E is the edge where new generated code should be attached.
   - CONTEXT_LOOP is the loop in which the generated code will be placed
   - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.   

References build_iv_mapping(), cfun, copy_bb_and_scalar_dependences(), gloog_error, mark_bb_with_pbb(), mark_virtual_operands_for_renaming(), number_of_loops(), ivs_params::region, edge_def::src, and update_ssa().

Referenced by translate_clast().

static tree type_for_clast_bin ( struct clast_binary *  b,
ivs_params_p  ip,
mpz_t  bound_one,
mpz_t  bound_two 
)
static
Return the type for the clast_binary B used in STMT.   

References max_precision_type(), type_for_clast_expr(), type_for_interval(), and type_for_value().

Referenced by type_for_clast_expr().

static tree type_for_clast_expr ( struct clast_expr *  e,
ivs_params_p  ip,
mpz_t  bound_one,
mpz_t  bound_two 
)
static
static tree type_for_clast_for ( )
static
Returns the type for the induction variable for the loop translated
   from STMT_FOR.   

References max_precision_type(), and type_for_clast_expr().

Referenced by graphite_create_new_loop_guard().

static tree type_for_clast_name ( struct clast_name *  name,
ivs_params_p  ip,
mpz_t  bound_one,
mpz_t  bound_two 
)
static
Return the type for the clast_name NAME.  Initializes BOUND_ONE and
   BOUND_TWO to the bounds of the term.   

References clast_name_to_gcc(), clast_name_to_lb_ub(), hash_table< Descriptor, Allocator >::is_created(), ivs_params::newivs, ivs_params::newivs_index, ivs_params::params, and ivs_params::params_index.

Referenced by type_for_clast_expr().

static tree type_for_clast_red ( struct clast_reduction *  r,
ivs_params_p  ip,
mpz_t  bound_one,
mpz_t  bound_two 
)
static
Return the type for the clast_reduction R.  Initializes BOUND_ONE
   and BOUND_TWO to the bounds of the reduction expression.   

References max_precision_type(), type(), type_for_clast_expr(), type_for_interval(), value_max(), and value_min().

Referenced by type_for_clast_expr().

static tree type_for_clast_term ( struct clast_term *  t,
ivs_params_p  ip,
mpz_t  bound_one,
mpz_t  bound_two 
)
static
Return the type for the clast_term T.  Initializes BOUND_ONE and
   BOUND_TWO to the bounds of the term.   

References max_precision_type(), type(), type_for_clast_expr(), type_for_interval(), and type_for_value().

Referenced by type_for_clast_expr().

static tree type_for_interval ( )
static
Return a type that could represent the values between BOUND_ONE and
   BOUND_TWO.   

References build_nonstandard_integer_type(), gloog_error, smallest_mode_for_size(), and type().

Referenced by type_for_clast_bin(), type_for_clast_red(), type_for_clast_term(), and type_for_value().

static tree type_for_value ( )
static
Return a type that could represent the integer value VAL, or
   otherwise return NULL_TREE.   

References type_for_interval().

Referenced by type_for_clast_bin(), and type_for_clast_term().

static void value_max ( )
static
Sets RES to the max of V1 and V2.   

Referenced by type_for_clast_red().

static void value_min ( )
static
Sets RES to the min of V1 and V2.   

Referenced by type_for_clast_red().


Variable Documentation

bool gloog_error
static
This flag is set when an error occurred during the translation of
   CLAST to Gimple.   

Referenced by clast_to_gcc_expression(), gloog(), max_precision_type(), translate_clast_user(), and type_for_interval().