This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tuples] Fixed inconsistent iterator interface


ops. Included some stuff from another patch I was working on. Here is an update

On 8/7/07, Christopher Matthews <chrismatthews@google.com> wrote:
> Some of the functions in the gimple statement iterator had struct
> arguments, others had pointer arguments. Changed them to all use
> pointers, and update all the (now much nicer looking) uses.
>
> Tested on gimple.exp, compile.exp, and libgcc.
>
> 2007-08-07  Chris Matthews  <chrismatthews@google.com>
>
>         * gimple_iterator.h (gsi_start): Changed to produce a pointer instead of
>         struct.  Updated clients.
>         (gsi_last): Same.
>         (gsi_end_p): Changed to operate on a pointer instead of struct.  Updated
>         clients.
>         (gsi_one_before_end_p): Same.
>         (gsi_next): Same.
>         (gsi_prev): Same.
>         (gsi_stmt): Same.
>
>
Index: gcc/gimple-iterator.h
===================================================================
--- gcc/gimple-iterator.h	(revision 127279)
+++ gcc/gimple-iterator.h	(working copy)
@@ -21,7 +21,7 @@ Boston, MA 02110-1301, USA.  */
 
 #ifndef GCC_SEQ_ITERATOR_H
 #define GCC_SEQ_ITERATOR_H
-
+#include "ggc.h"
 /* Iterator object for GIMPLE statement sequences.  */
 
 typedef struct {
@@ -31,26 +31,26 @@ typedef struct {
 
 /* Return a new iterator initially pointing to GIMPLE_SEQ's first statement.  */
 
-static inline gimple_stmt_iterator
+static inline gimple_stmt_iterator*
 gsi_start (gimple_seq seq)
 {
-  gimple_stmt_iterator i;
+  gimple_stmt_iterator* i = ggc_alloc_cleared (sizeof (gimple_stmt_iterator));
 
-  i.stmt = gimple_seq_first (seq);
-  i.seq = seq;
+  i->stmt = gimple_seq_first (seq);
+  i->seq = seq;
 
   return i;
 }
 
 /* Return a new iterator initially pointing to GIMPLE_SEQ's last statement.  */
 
-static inline gimple_stmt_iterator
+static inline gimple_stmt_iterator*
 gsi_last (gimple_seq seq)
 {
-  gimple_stmt_iterator i;
+  gimple_stmt_iterator* i = ggc_alloc_cleared (sizeof (gimple_stmt_iterator));
 
-  i.stmt = gimple_seq_last (seq);
-  i.seq = seq;
+  i->stmt = gimple_seq_last (seq);
+  i->seq = seq;
 
   return i;
 }
@@ -58,23 +58,23 @@ gsi_last (gimple_seq seq)
 /* Return TRUE if at the end of I.  */
 
 static inline bool
-gsi_end_p (gimple_stmt_iterator i)
+gsi_end_p (gimple_stmt_iterator* i)
 {
-  return i.stmt == NULL;
+  return i->stmt == NULL;
 }
 
 /* Return TRUE if we're one statement before the end of I.  */
 
 static inline bool
-gsi_one_before_end_p (gimple_stmt_iterator i)
+gsi_one_before_end_p (gimple_stmt_iterator* i)
 {
-  return i.stmt == gimple_seq_last (i.seq);
+  return i->stmt == gimple_seq_last (i->seq);
 }
 
 /* Return the next gimple statement in I.  */
 
 static inline void
-gsi_next (gimple_stmt_iterator *i)
+gsi_next (gimple_stmt_iterator* i)
 {
 #if defined ENABLE_GIMPLE_CHECKING
   /* The last statement of the sequence should not have anything
@@ -89,7 +89,7 @@ gsi_next (gimple_stmt_iterator *i)
 /* Return the previous gimple statement in I.  */
 
 static inline void
-gsi_prev (gimple_stmt_iterator *i)
+gsi_prev (gimple_stmt_iterator* i)
 {
 #if defined ENABLE_GIMPLE_CHECKING
   /* The first statement of the sequence should not have anything
@@ -104,9 +104,9 @@ gsi_prev (gimple_stmt_iterator *i)
 /* Return the current stmt.  */
 
 static inline gimple
-gsi_stmt (gimple_stmt_iterator i)
+gsi_stmt (gimple_stmt_iterator* i)
 {
-  return i.stmt;
+  return i->stmt;
 }
 
 #endif /* GCC_SEQ_ITERATOR_H */
Index: gcc/gimple-pretty-print.c
===================================================================
--- gcc/gimple-pretty-print.c	(revision 127279)
+++ gcc/gimple-pretty-print.c	(working copy)
@@ -107,9 +107,9 @@ print_gimple_stmt (FILE *file, gimple g,
 static void
 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
 {
-  gimple_stmt_iterator i;
+  gimple_stmt_iterator* i;
 
-  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (i))
     {
       gimple gs = gsi_stmt (i);
       if (flags & TDF_DETAILS)
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 127279)
+++ gcc/gimplify.c	(working copy)
@@ -776,12 +776,12 @@ annotate_one_with_locus (gimple gs, loca
 void
 annotate_all_with_locus (gimple_seq stmt_p, location_t locus)
 {
-  gimple_stmt_iterator i;
+  gimple_stmt_iterator* i;
 
   if (gimple_seq_empty_p (stmt_p))
     return;
 
-  for (i = gsi_start (stmt_p); !gsi_end_p (i); gsi_next (&i))
+  for (i = gsi_start (stmt_p); !gsi_end_p (i); gsi_next (i))
     {
       gimple gs = gsi_stmt (i);
       annotate_one_with_locus (gs, locus);
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(revision 127279)
+++ gcc/c-common.c	(working copy)
@@ -6438,11 +6438,11 @@ void
 c_warn_unused_result (gimple_seq seq)
 {
   tree fdecl, ftype;
-  gimple_stmt_iterator i;
+  gimple_stmt_iterator* ittr;
 
-  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+  for (ittr = gsi_start (seq); !gsi_end_p (ittr); gsi_next (ittr))
     {
-      gimple g = gsi_stmt (i);
+      gimple g = gsi_stmt (ittr);
 
       switch (gimple_code (g))
 	{
Index: gcc/gimple.c
===================================================================
--- gcc/gimple.c	(revision 127279)
+++ gcc/gimple.c	(working copy)
@@ -909,9 +909,9 @@ void
 walk_seq_ops (gimple_seq seq, walk_tree_fn func, void *data,
 	      struct pointer_set_t *pset)
 {
-  gimple_stmt_iterator gsi;
+  gimple_stmt_iterator* gsi;
 
-  for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (gsi))
     walk_tuple_ops (gsi_stmt (gsi), func, data, pset);
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]