GCC Middle and Back End API Reference
graphite-scop-detection.c File Reference

Data Structures

struct  sd_region_p
struct  scopdet_info

Typedefs

typedef enum gbb_type gbb_type
typedef struct sd_region_p sd_region

Enumerations

enum  gbb_type {
  GBB_UNKNOWN, GBB_LOOP_SING_EXIT_HEADER, GBB_LOOP_MULT_EXIT_HEADER, GBB_LOOP_EXIT,
  GBB_COND_HEADER, GBB_SIMPLE, GBB_LAST
}

Functions

static void make_close_phi_nodes_unique (basic_block)
static gbb_type get_bb_type ()
static void move_sd_regions ()
static bool graphite_can_represent_init ()
static bool graphite_can_represent_scev ()
static bool graphite_can_represent_expr (basic_block scop_entry, loop_p loop, tree expr)
static bool stmt_has_simple_data_refs_p (loop_p outermost_loop, gimple stmt)
static bool stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop, gimple stmt, basic_block bb)
static gimple harmful_stmt_in_bb ()
static bool graphite_can_represent_loop ()
static struct scopdet_info build_scops_1 (basic_block, loop_p, vec< sd_region > *, loop_p)
static struct scopdet_info scopdet_basic_block_info (basic_block bb, loop_p outermost_loop, vec< sd_region > *scops, gbb_type type)
static bool bb_in_sd_region ()
static edge find_single_entry_edge ()
static edge find_single_exit_edge ()
static void create_single_entry_edge ()
static bool sd_region_without_exit ()
static void create_single_exit_edge ()
static void unmark_exit_edges ()
static void mark_exit_edges ()
static void create_sese_edges ()
static void build_graphite_scops (vec< sd_region > regions, vec< scop_p > *scops)
static bool contains_only_close_phi_nodes ()
static void print_graphite_scop_statistics ()
static void print_graphite_statistics ()
static void limit_scops ()
static bool same_close_phi_node ()
static void remove_duplicate_close_phi ()
static void make_close_phi_nodes_unique ()
static void canonicalize_loop_closed_ssa ()
static void canonicalize_loop_closed_ssa_form ()
void build_scops ()
static void dot_all_scops_1 ()
DEBUG_FUNCTION void dot_all_scops ()
DEBUG_FUNCTION void dot_scop ()

Typedef Documentation

typedef enum gbb_type gbb_type
The type of the analyzed basic block.   
typedef struct sd_region_p sd_region
A SCoP detection region, defined using bbs as borders.

   All control flow touching this region, comes in passing basic_block
   ENTRY and leaves passing basic_block EXIT.  By using bbs instead of
   edges for the borders we are able to represent also regions that do
   not have a single entry or exit edge.

   But as they have a single entry basic_block and a single exit
   basic_block, we are able to generate for every sd_region a single
   entry and exit edge.

   1   2
    \ /
     3  <- entry
     |
     4
    / \                 This region contains: {3, 4, 5, 6, 7, 8}
   5   6
   |   |
   7   8
    \ /
     9  <- exit   

Enumeration Type Documentation

enum gbb_type
The type of the analyzed basic block.   
Enumerator:
GBB_UNKNOWN 
GBB_LOOP_SING_EXIT_HEADER 
GBB_LOOP_MULT_EXIT_HEADER 
GBB_LOOP_EXIT 
GBB_COND_HEADER 
GBB_SIMPLE 
GBB_LAST 

Function Documentation

static bool bb_in_sd_region ( )
static
static void build_graphite_scops ( vec< sd_region regions,
vec< scop_p > *  scops 
)
static
Create graphite SCoPs from an array of scop detection REGIONS.   

References bb_in_sd_region(), sd_region_p::entry, scopdet_info::exit, find_single_entry_edge(), find_single_exit_edge(), new_scop(), and new_sese().

Referenced by build_scops(), and limit_scops().

void build_scops ( )
static struct scopdet_info build_scops_1 ( basic_block  current,
loop_p  outermost_loop,
vec< sd_region > *  scops,
loop_p  loop 
)
staticread
Starting from CURRENT we walk the dominance tree and add new sd_regions to
   SCOPS. The analyse if a sd_region can be handled is based on the value
   of OUTERMOST_LOOP. Only loops inside OUTERMOST loops may change.  LOOP
   is the loop in which CURRENT is handled.

   TODO: These functions got a little bit big. They definitely should be cleaned
         up.   

References scopdet_info::difficult, sd_region_p::entry, sd_region_p::exit, scopdet_info::exit, scopdet_info::exits, get_bb_type(), scopdet_info::next, and scopdet_basic_block_info().

Referenced by build_scops(), and scopdet_basic_block_info().

static void canonicalize_loop_closed_ssa_form ( )
static
Converts the current loop closed SSA form to a canonical form
   expected by the Graphite code generation.

   The loop closed SSA form has the following invariant: a variable
   defined in a loop that is used outside the loop appears only in the
   phi nodes in the destination of the loop exit.  These phi nodes are
   called close phi nodes.

   The canonical loop closed SSA form contains the extra invariants:

   - when the loop contains only one exit, the close phi nodes contain
   only one argument.  That implies that the basic block that contains
   the close phi nodes has only one predecessor, that is a basic block
   in the loop.

   - the basic block containing the close phi nodes does not contain
   other statements.

   - there exist only one phi node per definition in the loop.

References canonicalize_loop_closed_ssa(), rewrite_into_loop_closed_ssa(), update_ssa(), and verify_loop_closed_ssa().

Referenced by build_scops().

static bool contains_only_close_phi_nodes ( )
static
Returns true when BB contains only close phi nodes.   

References gsi_end_p(), gsi_next(), gsi_start_bb(), and gsi_stmt().

Referenced by limit_scops().

static void create_sese_edges ( )
static
static void create_single_exit_edge ( )
static
DEBUG_FUNCTION void dot_all_scops ( )
Display all SCoPs using dotty.   

References dot_all_scops_1().

static void dot_all_scops_1 ( )
static
Pretty print to FILE all the SCoPs in DOT format and mark them with
   different colors.  If there are not enough colors, paint the
   remaining SCoPs in gray.

   Special nodes:
   - "*" after the node number denotes the entry of a SCoP,
   - "#" after the node number denotes the exit of a SCoP,
   - "()" around the node number denotes the entry or the
     exit nodes of the SCOP.  These are not part of SCoP.   

References bb_in_sese_p(), color(), edge_def::dest, dump_flags, basic_block_def::index, and basic_block_def::succs.

Referenced by dot_all_scops(), and dot_scop().

DEBUG_FUNCTION void dot_scop ( )
Display all SCoPs using dotty.   

References dot_all_scops_1(), and vNULL.

static edge find_single_entry_edge ( )
static
Returns the single entry edge of REGION, if it does not exits NULL.   

References bb_in_sd_region(), sd_region_p::entry, basic_block_def::preds, and edge_def::src.

Referenced by build_graphite_scops(), and create_single_entry_edge().

static edge find_single_exit_edge ( )
static
Returns the single exit edge of REGION, if it does not exits NULL.   

References bb_in_sd_region(), sd_region_p::exit, scopdet_info::exit, basic_block_def::preds, and edge_def::src.

Referenced by build_graphite_scops(), create_sese_edges(), and create_single_exit_edge().

static gbb_type get_bb_type ( )
static
Detect the type of BB.  Loop headers are only marked, if they are
   new.  This means their loop_father is different to LAST_LOOP.
   Otherwise they are treated like any other bb and their type can be
   any other type.   

References CDI_DOMINATORS, dom, GBB_COND_HEADER, GBB_LAST, GBB_LOOP_MULT_EXIT_HEADER, GBB_LOOP_SING_EXIT_HEADER, GBB_SIMPLE, get_dominated_by(), basic_block_def::loop_father, loop::num, single_exit(), and single_succ_p().

Referenced by build_scops_1().

static bool graphite_can_represent_expr ( basic_block  scop_entry,
loop_p  loop,
tree  expr 
)
static
Return true when EXPR can be represented in the polyhedral model.

   This means an expression can be represented, if it is linear with
   respect to the loops and the strides are non parametric.
   LOOP is the place where the expr will be evaluated.  SCOP_ENTRY defines the
   entry of the region we analyse.   

References analyze_scalar_evolution(), graphite_can_represent_scev(), and instantiate_scev().

Referenced by graphite_can_represent_loop(), and stmt_simple_for_scop_p().

static bool graphite_can_represent_init ( )
static
Something like "n * m" is not allowed.   

References chrec_contains_symbols(), and host_integerp().

Referenced by graphite_can_represent_scev().

static bool graphite_can_represent_loop ( )
static
Return true if LOOP can be represented in the polyhedral
   representation.  This is evaluated taking SCOP_ENTRY and
   OUTERMOST_LOOP in mind.   

References chrec_contains_undetermined(), tree_niter_desc::control, graphite_can_represent_expr(), affine_iv::no_overflow, number_of_iterations_exit(), number_of_latch_executions(), and single_exit().

Referenced by scopdet_basic_block_info().

static bool graphite_can_represent_scev ( )
static
Return true when SCEV can be represented in the polyhedral model.

   An expression can be represented, if it can be expressed as an
   affine expression.  For loops (i, j) and parameters (m, n) all
   affine expressions are of the form:

   x1 * i + x2 * j + x3 * m + x4 * n + x5 * 1 where x1..x5 element of Z

   1 i + 20 j + (-2) m + 25

   Something like "i * n" or "n * m" is not allowed.   

References chrec_contains_symbols(), chrec_contains_undetermined(), evolution_function_right_is_integer_cst(), graphite_can_represent_init(), and scev_is_linear_expression().

Referenced by graphite_can_represent_expr(), and stmt_has_simple_data_refs_p().

static gimple harmful_stmt_in_bb ( )
static
Returns the statement of BB that contains a harmful operation: that
   can be a function call with side effects, the induction variables
   are not linear with respect to SCOP_ENTRY, etc.  The current open
   scop should end before this statement.  The evaluation is limited using
   OUTERMOST_LOOP as outermost loop that may change.   

References gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), and stmt_simple_for_scop_p().

Referenced by scopdet_basic_block_info().

static void limit_scops ( )
static
We limit all SCoPs to SCoPs, that are completely surrounded by a loop.

   Example:

   for (i      |
     {         |
       for (j  |  SCoP 1
       for (k  |
     }         |

   * SCoP frontier, as this line is not surrounded by any loop. *

   for (l      |  SCoP 2

   This is necessary as scalar evolution and parameter detection need a
   outermost loop to initialize parameters correctly.

   TODO: FIX scalar evolution and parameter detection to allow more flexible
         SCoP frontiers.   

References build_graphite_scops(), build_sese_loop_nests(), contains_only_close_phi_nodes(), create_sese_edges(), edge_def::dest, sd_region_p::entry, sd_region_p::exit, free_scops(), loop::header, loop_in_sese_p(), loop_outer(), single_exit(), single_succ_edge(), and single_succ_p().

Referenced by build_scops().

static void make_close_phi_nodes_unique ( basic_block  )
static
@verbatim Detection of Static Control Parts (SCoP) for Graphite.

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 and Tobias Grosser gross.nosp@m.er@f.nosp@m.im.un.nosp@m.i-pa.nosp@m.ssau..nosp@m.de.

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/.

Forward declarations.   

Referenced by canonicalize_loop_closed_ssa(), and remove_duplicate_close_phi().

static void make_close_phi_nodes_unique ( )
static
static void mark_exit_edges ( )
static
Mark the exit edges of all REGIONS.
   See comment in "create_single_exit_edge".  

References edge_def::aux, bb_in_sd_region(), sd_region_p::exit, basic_block_def::preds, and edge_def::src.

Referenced by create_sese_edges().

static void move_sd_regions ( )
static
Moves the scops from SOURCE to TARGET and clean up SOURCE.   

Referenced by scopdet_basic_block_info().

static void print_graphite_scop_statistics ( )
static
static void print_graphite_statistics ( )
static
Print statistics for SCOPS to FILE.   

References print_graphite_scop_statistics().

Referenced by build_scops().

static void remove_duplicate_close_phi ( )
static
Remove the close phi node at GSI and replace its rhs with the rhs
   of PHI.   

References gimple_phi_num_args(), gimple_phi_result(), gsi_stmt(), make_close_phi_nodes_unique(), remove_phi_node(), same_close_phi_node(), and update_stmt().

Referenced by make_close_phi_nodes_unique().

static bool same_close_phi_node ( )
inlinestatic
Returns true when P1 and P2 are close phis with the same
   argument.   

References gimple_phi_arg_def(), and operand_equal_p().

Referenced by make_close_phi_nodes_unique(), and remove_duplicate_close_phi().

static bool sd_region_without_exit ( )
static
Check if the sd_region, mentioned in EDGE, has no exit bb.   

References edge_def::aux, and sd_region_p::exit.

Referenced by create_single_exit_edge().

static bool stmt_has_simple_data_refs_p ( loop_p  outermost_loop,
gimple  stmt 
)
static
Return true if the data references of STMT can be represented by
   Graphite.   

References DR_ACCESS_FN, DR_NUM_DIMENSIONS, free_data_refs(), graphite_can_represent_scev(), graphite_find_data_references_in_stmt(), loop_containing_stmt(), loop_outer(), and vNULL.

Referenced by stmt_simple_for_scop_p().

static bool stmt_simple_for_scop_p ( basic_block  scop_entry,
loop_p  outermost_loop,
gimple  stmt,
basic_block  bb 
)
static
Return true only when STMT is simple enough for being handled by
   Graphite.  This depends on SCOP_ENTRY, as the parameters are
   initialized relatively to this basic block, the linear functions
   are initialized to OUTERMOST_LOOP and BB is the place where we try
   to evaluate the STMT.   

References gimple_call_flags(), gimple_cond_code(), gimple_has_volatile_ops(), graphite_can_represent_expr(), is_gimple_debug(), basic_block_def::loop_father, and stmt_has_simple_data_refs_p().

Referenced by harmful_stmt_in_bb().

static void unmark_exit_edges ( )
static
Unmark the exit edges of all REGIONS.
   See comment in "create_single_exit_edge".  

References edge_def::aux, sd_region_p::exit, and basic_block_def::preds.

Referenced by create_sese_edges().