public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Christopher Matthews" <chrismatthews@google.com>
To: gcc-patches@gcc.gnu.org, Diego <dnovillo@google.com>,
	        "Aldy Hernandez" <aldyh@redhat.com>
Subject: Re: [tuples] Fixed inconsistent iterator interface
Date: Tue, 07 Aug 2007 22:50:00 -0000	[thread overview]
Message-ID: <5794c4c80708071550y4747df3ew9966b560405db4b2@mail.gmail.com> (raw)
In-Reply-To: <5794c4c80708071533o3b1ae68bncd38d219e702afc0@mail.gmail.com>

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

  parent reply	other threads:[~2007-08-07 22:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07 22:33 Christopher Matthews
2007-08-07 22:46 ` Diego Novillo
2007-08-07 22:50 ` Christopher Matthews [this message]
2007-08-07 22:56   ` Christopher Matthews
2007-08-07 23:07     ` Christopher Matthews
2007-08-07 23:11       ` Diego Novillo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5794c4c80708071550y4747df3ew9966b560405db4b2@mail.gmail.com \
    --to=chrismatthews@google.com \
    --cc=aldyh@redhat.com \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).