GCC Middle and Back End API Reference
gimple-iterator.c File Reference

Functions

static void update_modified_stmt ()
static void update_modified_stmts ()
static void update_bb_for_stmts (gimple_seq_node first, gimple_seq_node last, basic_block bb)
static void update_call_edge_frequencies ()
static void gsi_insert_seq_nodes_before (gimple_stmt_iterator *i, gimple_seq_node first, gimple_seq_node last, enum gsi_iterator_update mode)
void gsi_insert_seq_before_without_update (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)
void gsi_insert_seq_before (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)
static void gsi_insert_seq_nodes_after (gimple_stmt_iterator *i, gimple_seq_node first, gimple_seq_node last, enum gsi_iterator_update m)
void gsi_insert_seq_after_without_update (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)
void gsi_insert_seq_after (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode)
gimple_seq gsi_split_seq_after ()
void gsi_set_stmt ()
void gsi_split_seq_before ()
void gsi_replace ()
void gsi_replace_with_seq (gimple_stmt_iterator *gsi, gimple_seq seq, bool update_eh_info)
void gsi_insert_before_without_update (gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update m)
void gsi_insert_before (gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update m)
void gsi_insert_after_without_update (gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update m)
void gsi_insert_after (gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update m)
bool gsi_remove ()
gimple_stmt_iterator gsi_for_stmt ()
void gsi_move_after ()
void gsi_move_before ()
void gsi_move_to_bb_end ()
void gsi_insert_on_edge ()
void gsi_insert_seq_on_edge ()
static bool gimple_find_edge_insert_loc (edge e, gimple_stmt_iterator *gsi, basic_block *new_bb)
basic_block gsi_insert_on_edge_immediate ()
basic_block gsi_insert_seq_on_edge_immediate ()
void gsi_commit_edge_inserts ()
void gsi_commit_one_edge_insert ()
gimple_stmt_iterator gsi_start_phis ()

Function Documentation

static bool gimple_find_edge_insert_loc ( edge  e,
gimple_stmt_iterator gsi,
basic_block new_bb 
)
static
   Insert the statement pointed-to by GSI into edge E.  Every attempt
   is made to place the statement in an existing basic block, but
   sometimes that isn't possible.  When it isn't possible, the edge is
   split and the statement is added to the new block.

   In all cases, the returned *GSI points to the correct location.  The
   return value is true if insertion should be done after the location,
   or false if it should be done before the location.  If a new basic block
   has to be created, it is stored in *NEW_BB.  
     If the destination has one predecessor which has no PHI nodes,
     insert there.  Except for the exit block.

     The requirement for no PHI nodes could be relaxed.  Basically we
     would have to examine the PHIs to prove that none of them used
     the value set by the statement we want to insert on E.  That
     hardly seems worth the effort.  
         Make sure we insert after any leading labels.  
     If the source has one successor, the edge is not abnormal and
     the last statement does not end a basic block, insert there.
     Except for the entry block.  
     Otherwise, create a new basic block, and split this edge.  

Referenced by gsi_insert_on_edge_immediate().

void gsi_commit_edge_inserts ( void  )
   This routine will commit all pending edge insertions, creating any new
   basic blocks which are necessary.  

Referenced by close_phi_written_to_memory(), find_switch_asserts(), and translate_clast_for_loop().

void gsi_commit_one_edge_insert ( )
   Commit insertions pending at edge E. If a new block is created, set NEW_BB
   to this block, otherwise set it to NULL.  
void gsi_insert_after ( gimple_stmt_iterator i,
gimple  stmt,
enum gsi_iterator_update  m 
)
void gsi_insert_after_without_update ( gimple_stmt_iterator i,
gimple  stmt,
enum gsi_iterator_update  m 
)
   Insert statement STMT after the statement pointed-to by iterator I.
   M specifies how to update iterator I after insertion (see enum
   gsi_iterator_update).

   This function does not scan for new operands.  It is provided for
   the use of the gimplifier, which manipulates statements for which
   def/use information has not yet been constructed.  Most callers
   should use gsi_insert_after.  

Referenced by gsi_insert_before_without_update().

void gsi_insert_before_without_update ( gimple_stmt_iterator i,
gimple  stmt,
enum gsi_iterator_update  m 
)
   Insert statement STMT before the statement pointed-to by iterator I.
   M specifies how to update iterator I after insertion (see enum
   gsi_iterator_update).

   This function does not scan for new operands.  It is provided for
   the use of the gimplifier, which manipulates statements for which
   def/use information has not yet been constructed.  Most callers
   should use gsi_insert_before.  

References gsi_insert_after_without_update(), and update_modified_stmt().

Referenced by gsi_replace_with_seq().

void gsi_insert_on_edge ( )
   Add STMT to the pending list of edge E.  No actual insertion is
   made until a call to gsi_commit_edge_inserts () is made.  

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

basic_block gsi_insert_on_edge_immediate ( )
   Similar to gsi_insert_on_edge+gsi_commit_edge_inserts.  If a new
   block has to be created, it is returned.  

References gimple_stmt_iterator_d::bb, gimple_find_edge_insert_loc(), gimple_seq_first(), gsi_insert_seq_after(), gsi_insert_seq_before(), GSI_NEW_STMT, and update_call_edge_frequencies().

Referenced by dump_var_infos(), and vect_permute_store_chain().

void gsi_insert_seq_after ( gimple_stmt_iterator i,
gimple_seq  seq,
enum gsi_iterator_update  mode 
)
   Links sequence SEQ after the statement pointed-to by iterator I.
   MODE is as in gsi_insert_after.  Scan the statements in SEQ
   for new operands.  

Referenced by expand_complex_conjugate(), extract_component(), find_goto_replacement(), and gsi_insert_on_edge_immediate().

void gsi_insert_seq_after_without_update ( gimple_stmt_iterator i,
gimple_seq  seq,
enum gsi_iterator_update  mode 
)
   Links sequence SEQ after the statement pointed-to by iterator I.
   MODE is as in gsi_insert_after.

   This function does not scan for new operands.  It is provided for
   the use of the gimplifier, which manipulates statements for which
   def/use information has not yet been constructed.  Most callers
   should use gsi_insert_seq_after.  
     Don't allow inserting a sequence into itself.  
     Empty sequences need no work.  
void gsi_insert_seq_before ( gimple_stmt_iterator i,
gimple_seq  seq,
enum gsi_iterator_update  mode 
)
   Inserts the sequence of statements SEQ before the statement pointed
   by iterator I.  MODE indicates what to do with the iterator after
   insertion (see enum gsi_iterator_update). Scan the statements in SEQ
   for new operands.  

References gsi_bb(), gimple_statement_base::prev, gimple_stmt_iterator_d::ptr, and update_bb_for_stmts().

Referenced by gsi_insert_on_edge_immediate(), gsi_replace(), and replace_goto_queue_cond_clause().

void gsi_insert_seq_before_without_update ( gimple_stmt_iterator i,
gimple_seq  seq,
enum gsi_iterator_update  mode 
)
   Inserts the sequence of statements SEQ before the statement pointed
   by iterator I.  MODE indicates what to do with the iterator after
   insertion (see enum gsi_iterator_update).

   This function does not scan for new operands.  It is provided for
   the use of the gimplifier, which manipulates statements for which
   def/use information has not yet been constructed.  Most callers
   should use gsi_insert_seq_before.  
     Don't allow inserting a sequence into itself.  
     Empty sequences need no work.  
static void gsi_insert_seq_nodes_after ( gimple_stmt_iterator i,
gimple_seq_node  first,
gimple_seq_node  last,
enum gsi_iterator_update  m 
)
static
   Insert the sequence delimited by nodes FIRST and LAST after
   iterator I.  M specifies how to update iterator I after insertion
   (see enum gsi_iterator_update).

   This routine assumes that there is a forward and backward path
   between FIRST and LAST (i.e., they are linked in a doubly-linked
   list).  Additionally, if FIRST == LAST, this routine will properly
   insert a single node.  
     If the iterator is inside a basic block, we need to update the
     basic block information for all the nodes between FIRST and LAST.  
     Link SEQ after CUR.  
     Update the iterator, if requested.  

References first, gimple_seq_set_last(), last, gimple_statement_base::next, gimple_statement_base::prev, and gimple_stmt_iterator_d::seq.

static void gsi_insert_seq_nodes_before ( gimple_stmt_iterator i,
gimple_seq_node  first,
gimple_seq_node  last,
enum gsi_iterator_update  mode 
)
static
   Insert the sequence delimited by nodes FIRST and LAST before
   iterator I.  M specifies how to update iterator I after insertion
   (see enum gsi_iterator_update).

   This routine assumes that there is a forward and backward path
   between FIRST and LAST (i.e., they are linked in a doubly-linked
   list).  Additionally, if FIRST == LAST, this routine will properly
   insert a single node.  
     Link SEQ before CUR in the sequence.  
         If CUR is NULL, we link at the end of the sequence (this case happens
         when gsi_after_labels is called for a basic block that contains only
         labels, so it returns an iterator after the end of the block, and
         we need to insert before it; it might be cleaner to add a flag to the
         iterator saying whether we are at the start or end of the list).  
     Update the iterator, if requested.  
void gsi_insert_seq_on_edge ( )
   Add the sequence of statements SEQ to the pending list of edge E.
   No actual insertion is made until a call to gsi_commit_edge_inserts
   is made.  

Referenced by copy_edges_for_bb(), inhibit_phi_insertion(), lower_emutls_function_body(), and translate_clast_for_loop().

basic_block gsi_insert_seq_on_edge_immediate ( )
   Insert STMTS on edge E.  If a new block has to be created, it
   is returned.  

Referenced by create_iv(), and vect_do_peeling_for_loop_bound().

void gsi_move_after ( )
   Move the statement at FROM so it comes right after the statement at TO.  
     We must have GSI_NEW_STMT here, as gsi_move_after is sometimes used to
     move statements to an empty block.  

References gimple_seq_add_stmt().

Referenced by gsi_for_stmt().

void gsi_move_before ( )
   Move the statement at FROM so it comes right before the statement
   at TO.  
     For consistency with gsi_move_after, it might be better to have
     GSI_NEW_STMT here; however, that breaks several places that expect
     that TO does not change.  

References edge_def::dest.

Referenced by gsi_for_stmt().

void gsi_move_to_bb_end ( )
   Move the statement at FROM to the end of basic block BB.  
     Have to check gsi_end_p because it could be an empty block.  

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

bool gsi_remove ( )
   Remove the current stmt from the sequence.  The iterator is updated
   to point to the next statement.

   REMOVE_PERMANENTLY is true when the statement is going to be removed
   from the IL and not reinserted elsewhere.  In that case we remove the
   statement pointed to by iterator I from the EH tables, and free its
   operand caches.  Otherwise we do not modify this information.  Returns
   true whether EH edge cleanup is required.  
     Free all the data flow information for STMT.  
     Update the iterator and re-wire the links in I->SEQ.  
     See gsi_set_stmt for why we don't reset prev/next of STMT.  
       Cur is not last.  
       Cur is last but not first.  
       Cur is not first.  
       Cur is first.  

Referenced by dse_optimize_stmt(), execute_lower_resx(), expand_omp_for(), expand_omp_sections(), expand_omp_target(), gsi_replace(), handle_pointer_plus(), lower_stmt(), process_assert_insertions_for(), replace_goto_queue_cond_clause(), and stmt_is_power_of_op().

void gsi_replace ( )
   Replace the statement pointed-to by GSI to STMT.  If UPDATE_EH_INFO
   is true, the exception handling information of the original
   statement is moved to the new statement.  Assignments must only be
   replaced with assignments to the same LHS.  
     Preserve EH region information from the original statement, if
     requested by the caller.  
     Free all the data flow information for ORIG_STMT.  

References gimple_seq_empty_p(), gsi_insert_seq_before(), gsi_remove(), GSI_SAME_STMT, gsi_stmt(), and last.

Referenced by fold_gimple_cond(), lower_omp_sections(), maybe_add_implicit_barrier_cancel(), and valid_gimple_call_p().

void gsi_replace_with_seq ( gimple_stmt_iterator gsi,
gimple_seq  seq,
bool  update_eh_info 
)
   Replace the statement pointed-to by GSI with the sequence SEQ.
   If UPDATE_EH_INFO is true, the exception handling information of
   the original statement is moved to the last statement of the new
   sequence.  If the old statement is an assignment, then so must
   be the last statement of the new sequence, and they must have the
   same LHS.  

References gsi_insert_before_without_update(), and update_modified_stmt().

void gsi_set_stmt ( )
   Set the statement to which GSI points to STMT.  This only updates
   the iterator and the gimple sequence, it doesn't do the bookkeeping
   of gsi_replace.  
     Note how we don't clear next/prev of orig_stmt.  This is so that
     copies of *GSI our callers might still hold (to orig_stmt)
     can be advanced as if they too were replaced.  

References gimple_seq_last(), gimple_seq_set_first(), gimple_seq_set_last(), gimple_statement_base::next, gimple_statement_base::prev, gimple_stmt_iterator_d::ptr, and gimple_stmt_iterator_d::seq.

Referenced by gsi_split_seq_before().

gimple_seq gsi_split_seq_after ( )
   Move all statements in the sequence after I to a new sequence.
   Return this new sequence.  
     How can we possibly split after the end, or before the beginning?  

References gimple_seq_set_first(), gimple_seq_set_last(), gsi_stmt(), gimple_statement_base::next, gimple_statement_base::prev, gimple_stmt_iterator_d::ptr, and gimple_stmt_iterator_d::seq.

void gsi_split_seq_before ( )
   Move all statements in the sequence before I to a new sequence.
   Return this new sequence.  I is set to the head of the new list.  
     How can we possibly split after the end?  
     Set the limits on NEW_SEQ.  
     Cut OLD_SEQ before I.  

References cfun, delink_stmt_imm_use(), gimple_duplicate_stmt_histograms(), gimple_get_lhs(), gimple_has_lhs(), gimple_location(), gimple_remove_stmt_histograms(), gimple_set_bb(), gimple_set_location(), gimple_set_modified(), gsi_bb(), gsi_set_stmt(), gsi_stmt(), maybe_clean_or_replace_eh_stmt(), and update_modified_stmt().

Referenced by gimple_make_forwarder_block().

static void update_bb_for_stmts ( gimple_seq_node  first,
gimple_seq_node  last,
basic_block  bb 
)
static
   Set BB to be the basic block for all the statements in the list
   starting at FIRST and LAST.  

References gimple_set_bb().

Referenced by gsi_insert_seq_before().

static void update_call_edge_frequencies ( )
static
   Set the frequencies for the cgraph_edges for each of the calls
   starting at FIRST for their new position within BB.  
           These function calls are expensive enough that we want
           to avoid calling them if we never see any calls.  

References cgraph_edge(), cgraph_get_node(), compute_call_stmt_bb_frequency(), current_function_decl, and cgraph_edge::frequency.

Referenced by gsi_insert_on_edge_immediate().

static void update_modified_stmt ( )
inlinestatic
@verbatim 

Iterator routines for GIMPLE statements. Copyright (C) 2007-2013 Free Software Foundation, Inc. Contributed by Aldy Hernandez aldy@.nosp@m.ques.nosp@m.ejoda.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/.

   Mark the statement STMT as modified, and update it.  

Referenced by gsi_insert_before_without_update(), gsi_replace_with_seq(), and gsi_split_seq_before().

static void update_modified_stmts ( )
static
   Mark the statements in SEQ as modified, and update them.