GCC Middle and Back End API Reference
hw-doloop.c File Reference

Functions

static void dump_hwloops ()
static bool bb_in_loop_p ()
static void scan_loop ()
static bool process_incoming_edges ()
static bool add_forwarder_blocks ()
static void discover_loop ()
static hwloop_info discover_loops ()
static void free_loops ()
static void set_bb_indices ()
static void reorder_loops ()
static void optimize_loop ()
void reorg_loops ()

Function Documentation

static bool add_forwarder_blocks ( )
static
Try to identify a forwarder block that jump into LOOP, and add it to
   the set of blocks in the loop, updating the vector of incoming blocks as
   well.  This transformation gives a second chance to loops we couldn't
   otherwise handle by increasing the chance that we'll end up with one
   incoming_src block.
   Return true if we made a change, false otherwise.   

References bitmap_set_bit(), hwloop_info_d::block_bitmap, hwloop_info_d::blocks, dump_file, forwarder_block_p(), hwloop_info_d::incoming, basic_block_def::index, edge_iterator::index, hwloop_info_d::loop_no, basic_block_def::preds, edge_def::src, and vec_safe_push().

Referenced by discover_loop().

static bool bb_in_loop_p ( )
static
Return true if BB is part of LOOP.   

References bitmap_bit_p(), hwloop_info_d::block_bitmap, and basic_block_def::index.

Referenced by discover_loop(), and scan_loop().

static void discover_loop ( )
static
Called from reorg_loops when a potential loop end is found.  LOOP is
   a newly set up structure describing the loop, it is this function's
   responsibility to fill most of it.  TAIL_BB and TAIL_INSN point to the
   loop_end insn and its enclosing basic block.  REG is the loop counter
   register.
   For our purposes, a loop is defined by the set of blocks reachable from
   the loop head in which the loop counter register is live.  This matches
   the expected use; targets that call into this code usually replace the
   loop counter with a different special register.   

References add_forwarder_blocks(), hwloop_info_d::bad, bb_in_loop_p(), bitmap_bit_p(), bitmap_set_bit(), hwloop_info_d::block_bitmap, hwloop_info_d::blocks, edge_def::dest, df_get_live_in(), dump_file, hwloop_info_d::head, hwloop_info_d::incoming, basic_block_def::index, edge_iterator::index, hwloop_info_d::iter_reg, hwloop_info_d::loop_end, hwloop_info_d::loop_no, basic_block_def::preds, process_incoming_edges(), edge_def::src, hwloop_info_d::start_label, hwloop_info_d::successor, basic_block_def::succs, hwloop_info_d::tail, vec_alloc(), and vec_safe_push().

Referenced by discover_loops().

static hwloop_info discover_loops ( )
static
Analyze the structure of the loops in the current function.  Use
   LOOP_STACK for bitmap allocations.  Returns all the valid candidates for
   hardware loops found in this function.  HOOKS is the argument
   passed to reorg_loops, used here to find the iteration registers
   from a loop_end pattern.   

References hwloop_info_d::bad, bitmap_intersect_compl_p(), bitmap_intersect_p(), hwloop_info_d::block_bitmap, hwloop_info_d::blocks, delete_insn_and_edges(), df_get_live_in(), discover_loop(), dump_file, dump_hwloops(), hw_doloop_hooks::end_pattern_reg, hwloop_info_d::loop_no, hwloop_info_d::loops, hwloop_info_d::next, and print_rtl_single().

Referenced by reorg_loops().

static void dump_hwloops ( )
static
@verbatim Code to analyze doloop loops in order for targets to perform late

optimizations converting doloops to other forms of hardware loops. Copyright (C) 2011-2013 Free Software Foundation, Inc.

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

Dump information collected in LOOPS.   

References hwloop_info_d::bad, hwloop_info_d::blocks, hwloop_info_d::depth, dump_file, hwloop_info_d::head, basic_block_def::index, hwloop_info_d::iter_reg, hwloop_info_d::loop_no, hwloop_info_d::loops, and hwloop_info_d::next.

Referenced by discover_loops(), and reorg_loops().

static void free_loops ( )
static
Free up the loop structures in LOOPS.   

References hwloop_info_d::block_bitmap, hwloop_info_d::blocks, hwloop_info_d::loops, and hwloop_info_d::next.

Referenced by reorg_loops().

static void optimize_loop ( )
static
Call the OPT function for LOOP and all of its sub-loops.  This is
   done in a depth-first search; innermost loops are visited first.
   OPTIMIZE and FAIL are the functions passed to reorg_loops by the
   target's reorg pass.   

References hwloop_info_d::bad, hwloop_info_d::depth, dump_file, hw_doloop_hooks::fail, hwloop_info_d::loop_no, hwloop_info_d::loops, hw_doloop_hooks::opt, hwloop_info_d::regs_set_in_loop, and hwloop_info_d::visited.

Referenced by reorg_loops().

static bool process_incoming_edges ( )
static
Compute the incoming_dest and incoming_src members of LOOP by
   identifying the edges that jump into the loop.  If there is more
   than one block that jumps into the loop, incoming_src will be set
   to NULL; likewise, if there is more than one block in the loop that
   is the destination of an incoming edge, incoming_dest will be NULL.

   Return true if either of these two fields is nonnull, false
   otherwise.   

References edge_def::dest, first, hwloop_info_d::incoming, hwloop_info_d::incoming_dest, hwloop_info_d::incoming_src, and edge_def::src.

Referenced by discover_loop().

static void reorder_loops ( )
static
The taken-branch edge from the loop end can actually go forward.
   If the target's hardware loop support requires that the loop end be
   after the loop start, try to reorder a loop's basic blocks when we
   find such a case.
   This is not very aggressive; it only moves at most one block.  It
   does not introduce new branches into loops; it may remove them, or
   it may switch fallthru/jump edges.   

References basic_block_def::aux, hwloop_info_d::bad, bitmap_bit_p(), hwloop_info_d::block_bitmap, cfg_layout_finalize(), cfg_layout_initialize(), clear_aux_for_blocks(), edge_def::dest, df_analyze(), dump_file, hwloop_info_d::head, basic_block_def::index, hwloop_info_d::next, basic_block_def::next_bb, basic_block_def::prev_bb, set_bb_indices(), basic_block_def::succs, and hwloop_info_d::tail.

Referenced by reorg_loops().

void reorg_loops ( )
This function can be used from a port's machine_dependent_reorg to
   find and analyze loops that end in loop_end instructions.  It uses
   a set of function pointers in HOOKS to call back into the
   target-specific functions to perform the actual machine-specific
   transformations.

   Such transformations typically involve additional set-up
   instructions before the loop, to define loop bounds or set up a
   special loop counter register.

   DO_REORDER should be set to true if we should try to use the
   reorder_loops function to ensure the loop end occurs after the loop
   start.  This is for use by targets where the loop hardware requires
   this condition.

   HOOKS is used to pass in target specific hooks; see
   hw-doloop.h.   

References bitmap_obstack_initialize(), df_analyze(), df_live_add_problem(), df_live_set_all_dirty(), discover_loops(), dump_file, dump_hwloops(), free_loops(), get_insns(), hwloop_info_d::next, optimize_loop(), print_rtl(), reorder_loops(), and scan_loop().

static void set_bb_indices ( )
static
Initialize the aux fields to give ascending indices to basic blocks.   

References basic_block_def::aux.

Referenced by reorder_loops().