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.  
static CloogUnionDomain* build_cloog_union_domain ( )
static
   Build cloog union domain for SCoP.  
         Dead code elimination: when the domain of a PBB is empty,
         don't generate code for the PBB.  
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 bb_pbb_def::bb, hash_table< Descriptor, Allocator >::find_slot(), and new_bb_pbb_def().

Referenced by find_pbb_via_hash().

static bool clast_expr_const_value_p ( )
static
   Returns true if the clast expression E is a constant with VALUE.  
static tree clast_name_to_gcc ( )
static
   Returns the tree variable from the name NAME that was given in
   Cloog representation.  

References type().

Referenced by clast_to_gcc_expression_red().

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, and clast_name_index::name.

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.  
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.  
static tree clast_to_gcc_expression ( tree  ,
struct clast_expr *  ,
ivs_params_p   
)
static
static tree clast_to_gcc_expression ( )
static
   Converts a Cloog AST expression E back to a GCC expression tree of
   type TYPE.  
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_name_to_gcc(), and 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. 
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.  
DEBUG_FUNCTION void debug_clast_stmt ( )
   Prints STMT to STDERR.  

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

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

References loop::can_be_parallel, and dump_file.

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

Referenced by init_cloog_input_file().

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

References build_iv_mapping(), cfun, and number_of_loops().

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.  
static int get_max_scattering_dimensions ( scop_p  scop)
static
   Get the maximal number of scattering dimensions in the scop SCOP.  
bool gloog ( )
@verbatim 

GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for the given SCOP. Return true if code generation succeeded. BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.

static tree gmp_cst_to_tree ( )
static
   Converts a GMP constant VAL to a tree and returns it.  
static tree graphite_create_guard_cond_expr ( struct clast_guard *  stmt,
ivs_params_p  ip 
)
static
   Creates the test for the condition in STMT.  
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.  

Referenced by translate_clast_for().

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 clast_to_gcc_expression(), gbb_loop_at_index(), loop::num, ivs_params::region, and type_for_clast_expr().

Referenced by graphite_create_new_loop_guard().

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).  
     When ub is simply a constant or a parameter, use lb <= ub.  
         Adding +1 and using LT_EXPR helps with loop latches that have a
         loop iteration count of "PARAMETER - 1".  For PARAMETER == 0 this becomes
         2^k-1 due to integer overflow, and the condition lb <= ub is true,
         even if we do not want this.  However lb < ub + 1 is false, as
         expected.  

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().

static tree graphite_translate_clast_equation ( struct clast_equation *  cleq,
ivs_params_p  ip 
)
static
   Translates a clast equation CLEQ to a tree.  
     Special cases to reduce range of arguments to hopefully
     don't need types with larger precision than the input.  
         X >= A+1 --> X > A and
         X <= A-1 --> X < A  
static void graphite_verify ( )
inlinestatic
   Verifies properties that GRAPHITE should maintain during translation.  

Referenced by translate_clast_assignment().

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

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

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.  
static tree max_precision_type ( )
static
   Returns the maximal precision type for expressions TYPE1 and TYPE2.  

Referenced by type_for_clast_term().

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

References get_loop_body_in_dom_order(), and loop::num_nodes.

Referenced by build_iv_mapping().

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.  
void print_clast_stmt ( )
   Prints STMT to STDERR.  
void print_generated_program ( )
   Prints to FILE the code generated by CLooG for SCOP.  
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
   Records in INDEX_TABLE the INDEX and LEVEL for NAME.  

References ivs_params::newivs, ivs_params::newivs_index, ivs_params::params, ivs_params::params_index, and ivs_params::region.

Referenced by translate_clast_for_loop().

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.  
     Dump a .cloog input file, if requested.  This feature is only
     enabled in the Graphite branch.  
static CloogOptions* set_cloog_options ( )
static
   Return the options that will be used in GLOOG.  
     Change cloog output language to C.  If we do use FORTRAN instead, cloog
     will stop e.g. with "ERROR: unbounded loops not allowed in FORTRAN.", if
     we pass an incomplete program to cloog.  
     Enable complex equality spreading: removes dummy statements
     (assignments) in the generated code which repeats the
     substitution equations for statements.  This is useless for
     GLooG.  
     Silence CLooG to avoid failing tests due to debug output to stderr.  
     Allow cloog to build strides with a stride width different to one.
     This example has stride = 4:

     for (i = 0; i < 20; i += 4)
       A  
     We want the clast to provide the iteration domains of the executed loops.
     This allows us to derive minimal/maximal values for the induction
     variables.  
     Disable optimizations and make cloog generate source code closer to the
     input.  This is useful for debugging,  but later we want the optimized
     code.

     XXX: We can not disable optimizations, as loop blocking is not working
     without them.  

References poly_bb::transformed.

Referenced by debug_clast_stmt().

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.  

Referenced by graphite_create_new_loop_guard(), translate_clast_assignment(), and translate_clast_for().

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 graphite_verify(), loop::next, recompute_all_dominators(), translate_clast(), translate_clast_for(), translate_clast_guard(), and translate_clast_user().

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_guard(), and translate_clast().

Referenced by translate_clast_assignment().

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.  
     Create a basic block for loop close phi nodes.  
     Translate the body of the loop.  

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().

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 get_name(), and scop_max_loop_depth().

Referenced by translate_clast_assignment().

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.  

Referenced by translate_clast_assignment().

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.  
     Return a type that can represent the result of the reduction.  
static tree type_for_clast_expr ( struct clast_expr *  e,
ivs_params_p  ip,
mpz_t  bound_one,
mpz_t  bound_two 
)
static
   Returns the type for the CLAST expression E when used in statement
   STMT.  

Referenced by graphite_create_new_loop(), translate_clast_for_loop(), and type_for_clast_term().

static tree type_for_clast_for ( )
static
   Returns the type for the induction variable for the loop translated
   from STMT_FOR.  
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.  
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.  
     Return a type that can represent the result of the reduction.  
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(), and value_min().

static tree type_for_interval ( )
static
   Return a type that could represent the values between BOUND_ONE and
   BOUND_TWO.  
     As we want to generate signed types as much as possible, try to
     fit the interval [bound_one, bound_two] in a signed type.  For example,
     supposing that we have the interval [0, 100], instead of
     generating unsigned char, we want to generate a signed char.  
static tree type_for_value ( )
static
   Return a type that could represent the integer value VAL, or
   otherwise return NULL_TREE.  
static void value_max ( )
static
   Sets RES to the max of V1 and V2.  
static void value_min ( )
static
   Sets RES to the min of V1 and V2.  

Referenced by type_for_clast_term().


Variable Documentation

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