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: [tuples] Fixed inconsistent iterator interface
Date: Tue, 07 Aug 2007 22:33:00 -0000	[thread overview]
Message-ID: <5794c4c80708071533o3b1ae68bncd38d219e702afc0@mail.gmail.com> (raw)

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

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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07 22:33 Christopher Matthews [this message]
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

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=5794c4c80708071533o3b1ae68bncd38d219e702afc0@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).