* gimple-iterator.h (gsi_prev_nondebug): Fix typo.
[gcc.git] / gcc / gimple-iterator.h
index c35dc816c3fca0d625f149cb0c9d2cadf8dddcd0..9aa7508c9e1df3ae0502e79cc13b0d98585a2a0f 100644 (file)
@@ -1,5 +1,5 @@
 /* Header file for gimple iterators.
-   Copyright (C) 2013-2014 Free Software Foundation, Inc.
+   Copyright (C) 2013-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -34,6 +34,15 @@ struct gimple_stmt_iterator
   gimple_seq *seq;
   basic_block bb;
 };
+
+/* Iterator over GIMPLE_PHI statements.  */
+struct gphi_iterator : public gimple_stmt_iterator
+{
+  gphi *phi () const
+  {
+    return as_a <gphi *> (ptr);
+  }
+};
  
 enum gsi_iterator_update
 {
@@ -58,7 +67,7 @@ extern void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
 extern gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
 extern void gsi_set_stmt (gimple_stmt_iterator *, gimple);
 extern void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *);
-extern void gsi_replace (gimple_stmt_iterator *, gimple, bool);
+extern bool gsi_replace (gimple_stmt_iterator *, gimple, bool);
 extern void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool);
 extern void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
                                              enum gsi_iterator_update);
@@ -70,6 +79,7 @@ extern void gsi_insert_after (gimple_stmt_iterator *, gimple,
                              enum gsi_iterator_update);
 extern bool gsi_remove (gimple_stmt_iterator *, bool);
 extern gimple_stmt_iterator gsi_for_stmt (gimple);
+extern gphi_iterator gsi_for_phi (gphi *);
 extern void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
 extern void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
 extern void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block);
@@ -79,7 +89,7 @@ extern basic_block gsi_insert_on_edge_immediate (edge, gimple);
 extern basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
 extern void gsi_commit_edge_inserts (void);
 extern void gsi_commit_one_edge_insert (edge, basic_block *);
-extern gimple_stmt_iterator gsi_start_phis (basic_block);
+extern gphi_iterator gsi_start_phis (basic_block);
 
 /* Return a new iterator pointing to GIMPLE_SEQ's first statement.  */
 
@@ -123,6 +133,8 @@ gsi_start_bb (basic_block bb)
   return i;
 }
 
+gimple_stmt_iterator gsi_start_edge (edge e);
+
 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement.  */
 
 static inline gimple_stmt_iterator
@@ -199,6 +211,19 @@ gsi_stmt (gimple_stmt_iterator i)
   return i.ptr;
 }
 
+/* Return a new iterator pointing to the first non-debug statement
+   in basic block BB.  */
+
+static inline gimple_stmt_iterator
+gsi_start_bb_nondebug (basic_block bb)
+{
+  gimple_stmt_iterator gsi = gsi_start_bb (bb);
+  while (!gsi_end_p (gsi) && is_gimple_debug (gsi_stmt (gsi)))
+    gsi_next (&gsi);
+
+  return gsi;
+}
+
 /* Return a block statement iterator that points to the first non-label
    statement in block BB.  */
 
@@ -225,7 +250,7 @@ gsi_next_nondebug (gimple_stmt_iterator *i)
   while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
 }
 
-/* Advance the iterator to the next non-debug gimple statement.  */
+/* Advance the iterator to the previous non-debug gimple statement.  */
 
 static inline void
 gsi_prev_nondebug (gimple_stmt_iterator *i)
@@ -279,6 +304,30 @@ gsi_last_nondebug_bb (basic_block bb)
   return i;
 }
 
+/* Iterates I statement iterator to the next non-virtual statement.  */
+
+static inline void
+gsi_next_nonvirtual_phi (gphi_iterator *i)
+{
+  gphi *phi;
+
+  if (gsi_end_p (*i))
+    return;
+
+  phi = i->phi ();
+  gcc_assert (phi != NULL);
+
+  while (virtual_operand_p (gimple_phi_result (phi)))
+    {
+      gsi_next (i);
+
+      if (gsi_end_p (*i))
+       return;
+
+      phi = i->phi ();
+    }
+}
+
 /* Return the basic block associated with this iterator.  */
 
 static inline basic_block