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


All suggested changes made.

On 8/7/07, Christopher Matthews <chrismatthews@google.com> wrote:
> I was confused when I saw it - thought itter was more descriptive.  I
> now notice that's how it is done everywhere. I'll change it back to i.
>
> On 8/7/07, Christopher Matthews <chrismatthews@google.com> wrote:
> > 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,17 +58,17 @@ 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.  */
@@ -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/ChangeLog.tuples
===================================================================
--- gcc/ChangeLog.tuples	(revision 127279)
+++ gcc/ChangeLog.tuples	(working copy)
@@ -1,3 +1,15 @@
+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.
+	
 2007-08-07  Diego Novillo  <dnovillo@google.com>
 
 	Merge with mainline @127277.
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,9 +6438,9 @@ void
 c_warn_unused_result (gimple_seq seq)
 {
   tree fdecl, ftype;
-  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 g = gsi_stmt (i);
 
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]