public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples] Fixed inconsistent iterator interface
@ 2007-08-07 22:33 Christopher Matthews
  2007-08-07 22:46 ` Diego Novillo
  2007-08-07 22:50 ` Christopher Matthews
  0 siblings, 2 replies; 6+ messages in thread
From: Christopher Matthews @ 2007-08-07 22:33 UTC (permalink / raw)
  To: gcc-patches, Diego, Aldy Hernandez

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

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.

[-- Attachment #2: gsi_ptrv1.diff --]
[-- Type: text/x-patch, Size: 7612 bytes --]

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/tree-flow.h
===================================================================
--- gcc/tree-flow.h	(revision 127279)
+++ gcc/tree-flow.h	(working copy)
@@ -753,7 +753,7 @@ extern void notice_special_calls (tree);
 extern void clear_special_calls (void);
 extern void verify_stmts (void);
 extern void verify_gimple (void);
-extern void verify_gimple_1 (tree);
+extern void verify_gimple_1 (gimple_seq);
 extern tree tree_block_label (basic_block);
 extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
 extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned,
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: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 127279)
+++ gcc/tree-cfg.c	(working copy)
@@ -4029,42 +4029,42 @@ verify_gimple_stmt (tree stmt)
     }
 }
 
-/* Verify the GIMPLE statements inside the statement list STMTS.  */
+/* Verify the GIMPLE statements inside the sequence STMTS.  */
 
 void
-verify_gimple_1 (tree stmts)
+verify_gimple_1 (gimple_seq stmts)
 {
-  tree_stmt_iterator tsi;
-
-  for (tsi = tsi_start (stmts); !tsi_end_p (tsi); tsi_next (&tsi))
-    {
-      tree stmt = tsi_stmt (tsi);
-
-      switch (TREE_CODE (stmt))
-	{
-	case BIND_EXPR:
-	  verify_gimple_1 (BIND_EXPR_BODY (stmt));
-	  break;
-
-	case TRY_CATCH_EXPR:
-	case TRY_FINALLY_EXPR:
-	  verify_gimple_1 (TREE_OPERAND (stmt, 0));
-	  verify_gimple_1 (TREE_OPERAND (stmt, 1));
-	  break;
-
-	case CATCH_EXPR:
-	  verify_gimple_1 (CATCH_BODY (stmt));
-	  break;
-
-	case EH_FILTER_EXPR:
-	  verify_gimple_1 (EH_FILTER_FAILURE (stmt));
-	  break;
-
-	default:
-	  if (verify_gimple_stmt (stmt))
-	    debug_generic_expr (stmt);
-	}
-    }
+  gimple_stmt_iterator* ittr;
+  
+//  for (ittr = gsi_start (stmts); !gsi_end_p (ittr); gsi_next (ittr))
+//    {
+//      gimple stmt = gsi_stmt (ittr);
+//
+//      switch (GIMPLE_CODE (stmt))
+//	{
+//	case BIND_EXPR:
+//	  verify_gimple_1 (BIND_EXPR_BODY (stmt));
+//	  break;
+//
+//	case TRY_CATCH_EXPR:
+//	case TRY_FINALLY_EXPR:
+//	  verify_gimple_1 (TREE_OPERAND (stmt, 0));
+//	  verify_gimple_1 (TREE_OPERAND (stmt, 1));
+//	  break;
+//
+//	case CATCH_EXPR:
+//	  verify_gimple_1 (CATCH_BODY (stmt));
+//	  break;
+//
+//	case EH_FILTER_EXPR:
+//	  verify_gimple_1 (EH_FILTER_FAILURE (stmt));
+//	  break;
+//
+//	default:
+//	  if (verify_gimple_stmt (stmt))
+//	    debug_generic_expr (stmt);
+//	}
+//    }
 }
 
 /* Verify the GIMPLE statements inside the current function.  */
@@ -4079,7 +4079,7 @@ verify_gimple (void)
    TODO: Implement type checking.  */
 
 static bool
-verify_stmt (tree stmt, bool last_in_block)
+verify_stmt (gimple stmt, bool last_in_block)
 {
   tree addr;
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tuples] Fixed inconsistent iterator interface
  2007-08-07 22:33 [tuples] Fixed inconsistent iterator interface Christopher Matthews
@ 2007-08-07 22:46 ` Diego Novillo
  2007-08-07 22:50 ` Christopher Matthews
  1 sibling, 0 replies; 6+ messages in thread
From: Diego Novillo @ 2007-08-07 22:46 UTC (permalink / raw)
  To: Christopher Matthews; +Cc: gcc-patches, Aldy Hernandez

On 8/7/07 6:33 PM, Christopher Matthews wrote:

> -static inline gimple_stmt_iterator
> +static inline gimple_stmt_iterator*

space before '*'.

> gsi_start (gimple_seq seq)
> {
> - gimple_stmt_iterator i;
> + gimple_stmt_iterator* i = ggc_alloc_cleared (sizeof (gimple_stmt_iterator));
    ^^^^^^^^^^^^^^^^^^^^^^^
    gimple_stmt_iterator *i


> - gimple_stmt_iterator i;
> + gimple_stmt_iterator* ittr; 

Why the new name?  Was 'i' clashing with some other local?

> -extern void verify_gimple_1 (tree);
> +extern void verify_gimple_1 (gimple_seq); 

This is for your next patch, me thinks.

> -/* Verify the GIMPLE statements inside the statement list STMTS. */
> +/* Verify the GIMPLE statements inside the sequence STMTS. */
> void
> -verify_gimple_1 (tree stmts)
> +verify_gimple_1 (gimple_seq stmts)

Likewise.

OK with those changes.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tuples] Fixed inconsistent iterator interface
  2007-08-07 22:33 [tuples] Fixed inconsistent iterator interface Christopher Matthews
  2007-08-07 22:46 ` Diego Novillo
@ 2007-08-07 22:50 ` Christopher Matthews
  2007-08-07 22:56   ` Christopher Matthews
  1 sibling, 1 reply; 6+ messages in thread
From: Christopher Matthews @ 2007-08-07 22:50 UTC (permalink / raw)
  To: gcc-patches, Diego, Aldy Hernandez

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gsi_ptrv1.diff --]
[-- Type: text/x-patch; name="gsi_ptrv1.diff", Size: 4897 bytes --]

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);
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tuples] Fixed inconsistent iterator interface
  2007-08-07 22:50 ` Christopher Matthews
@ 2007-08-07 22:56   ` Christopher Matthews
  2007-08-07 23:07     ` Christopher Matthews
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Matthews @ 2007-08-07 22:56 UTC (permalink / raw)
  To: gcc-patches, Diego, Aldy Hernandez

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tuples] Fixed inconsistent iterator interface
  2007-08-07 22:56   ` Christopher Matthews
@ 2007-08-07 23:07     ` Christopher Matthews
  2007-08-07 23:11       ` Diego Novillo
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Matthews @ 2007-08-07 23:07 UTC (permalink / raw)
  To: gcc-patches, Diego, Aldy Hernandez

[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]

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

[-- Attachment #2: gsi_ptrv1.diff --]
[-- Type: text/x-patch, Size: 4952 bytes --]

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);
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tuples] Fixed inconsistent iterator interface
  2007-08-07 23:07     ` Christopher Matthews
@ 2007-08-07 23:11       ` Diego Novillo
  0 siblings, 0 replies; 6+ messages in thread
From: Diego Novillo @ 2007-08-07 23:11 UTC (permalink / raw)
  To: Christopher Matthews; +Cc: gcc-patches, Aldy Hernandez

On 8/7/07 7:07 PM, Christopher Matthews wrote:
> All suggested changes made.

Thanks.  Patch is OK.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-08-07 23:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-07 22:33 [tuples] Fixed inconsistent iterator interface Christopher Matthews
2007-08-07 22:46 ` Diego Novillo
2007-08-07 22:50 ` Christopher Matthews
2007-08-07 22:56   ` Christopher Matthews
2007-08-07 23:07     ` Christopher Matthews
2007-08-07 23:11       ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).