public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pph] Move code (issue4517108)
@ 2011-05-26 20:03 Lawrence Crowl
  0 siblings, 0 replies; only message in thread
From: Lawrence Crowl @ 2011-05-26 20:03 UTC (permalink / raw)
  To: reply, dnovillo, gcc-patches

Move TEMPLATE_DECL case next to other DECLs in pph_stream_read_tree
and pph_stream_write_tree.  Move pph_output_chain_filtered to just
before its use.


Index: gcc/cp/ChangeLog.pph

2011-05-26  Lawrence Crowl  <crowl@google.com>

	* pph-streamer-in.c (pph_stream_read_tree): Move TEMPLATE_DECL case
	next to other DECLs.
	* pph-streamer-out.c (pph_stream_write_tree): Move TEMPLATE_DECL case
	next to other DECLs.
	(pph_output_chain_filtered):  Move to just before its use.


Index: gcc/cp/pph-streamer-in.c
===================================================================
--- gcc/cp/pph-streamer-in.c	(revision 174301)
+++ gcc/cp/pph-streamer-in.c	(working copy)
@@ -837,6 +837,14 @@ pph_stream_read_tree (struct lto_input_b
       DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
       break;
 
+    case TEMPLATE_DECL:
+      DECL_INITIAL (expr) = pph_input_tree (stream);
+      pph_stream_read_lang_specific (stream, expr);
+      DECL_TEMPLATE_RESULT (expr) = pph_input_tree (stream);
+      DECL_TEMPLATE_PARMS (expr) = pph_input_tree (stream);
+      DECL_CONTEXT (expr) = pph_input_tree (stream);
+      break;
+
     case STATEMENT_LIST:
       {
         HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
@@ -894,14 +902,6 @@ pph_stream_read_tree (struct lto_input_b
       BASELINK_ACCESS_BINFO (expr) = pph_input_tree (stream);
       break;
 
-    case TEMPLATE_DECL:
-      DECL_INITIAL (expr) = pph_input_tree (stream);
-      pph_stream_read_lang_specific (stream, expr);
-      DECL_TEMPLATE_RESULT (expr) = pph_input_tree (stream);
-      DECL_TEMPLATE_PARMS (expr) = pph_input_tree (stream);
-      DECL_CONTEXT (expr) = pph_input_tree (stream);
-      break;
-
     case TEMPLATE_INFO:
       TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr)
           = pph_stream_read_qual_use_vec (stream);
Index: gcc/cp/pph-streamer-out.c
===================================================================
--- gcc/cp/pph-streamer-out.c	(revision 174301)
+++ gcc/cp/pph-streamer-out.c	(working copy)
@@ -378,6 +378,55 @@ pph_stream_write_label_binding (pph_stre
 }
 
 
+/* Output a chain of nodes to STREAM starting with FIRST.  Skip any
+   nodes that do not match FILTER.  REF_P is true if nodes in the chain
+   should be emitted as references.  */
+
+void
+pph_output_chain_filtered (pph_stream *stream, tree first, bool ref_p,
+			   enum chain_filter filter)
+{
+  unsigned count;
+  tree t;
+
+  /* Special case.  If the caller wants no filtering, it is much
+     faster to just call pph_output_chain directly.  */
+  if (filter == NONE)
+    {
+      pph_output_chain (stream, first, ref_p);
+      return;
+    }
+
+  /* Count all the nodes that match the filter.  */
+  for (t = first, count = 0; t; t = TREE_CHAIN (t))
+    {
+      if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t))
+	continue;
+      count++;
+    }
+  pph_output_uint (stream, count);
+
+  /* Output all the nodes that match the filter.  */
+  for (t = first; t; t = TREE_CHAIN (t))
+    {
+      tree saved_chain;
+
+      /* Apply filters to T.  */
+      if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t))
+	continue;
+
+      /* Clear TREE_CHAIN to avoid blindly recursing into the rest
+	 of the list.  */
+      saved_chain = TREE_CHAIN (t);
+      TREE_CHAIN (t) = NULL_TREE;
+
+      pph_output_tree_or_ref_1 (stream, t, ref_p, 2);
+
+      TREE_CHAIN (t) = saved_chain;
+    }
+}
+
+
 /* Write all the fields of cp_binding_level instance BL to STREAM.  If
    REF_P is true, tree fields will be written as references.  */
 
@@ -838,6 +887,14 @@ pph_stream_write_tree (struct output_blo
       pph_output_tree_or_ref_1 (stream, DECL_ORIGINAL_TYPE (expr), ref_p, 3);
       break;
 
+    case TEMPLATE_DECL:
+      pph_output_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3);
+      pph_stream_write_lang_specific (stream, expr, ref_p);
+      pph_output_tree_or_ref_1 (stream, DECL_TEMPLATE_RESULT (expr), ref_p, 3);
+      pph_output_tree_or_ref_1 (stream, DECL_TEMPLATE_PARMS (expr), ref_p, 3);
+      pph_output_tree_or_ref_1 (stream, DECL_CONTEXT (expr), ref_p, 3);
+      break;
+
     case STATEMENT_LIST:
       {
         tree_stmt_iterator i;
@@ -901,14 +958,6 @@ pph_stream_write_tree (struct output_blo
       pph_output_tree_or_ref_1 (stream, BASELINK_ACCESS_BINFO (expr), ref_p, 3);
       break;
 
-    case TEMPLATE_DECL:
-      pph_output_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3);
-      pph_stream_write_lang_specific (stream, expr, ref_p);
-      pph_output_tree_or_ref_1 (stream, DECL_TEMPLATE_RESULT (expr), ref_p, 3);
-      pph_output_tree_or_ref_1 (stream, DECL_TEMPLATE_PARMS (expr), ref_p, 3);
-      pph_output_tree_or_ref_1 (stream, DECL_CONTEXT (expr), ref_p, 3);
-      break;
-
     case TEMPLATE_INFO:
       pph_stream_write_qual_use_vec (stream,
           TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr), ref_p);
@@ -925,52 +974,3 @@ pph_stream_write_tree (struct output_blo
                  tree_code_name[TREE_CODE (expr)]);
     }
 }
-
-
-/* Output a chain of nodes to STREAM starting with FIRST.  Skip any
-   nodes that do not match FILTER.  REF_P is true if nodes in the chain
-   should be emitted as references.  */
-
-void
-pph_output_chain_filtered (pph_stream *stream, tree first, bool ref_p,
-			   enum chain_filter filter)
-{
-  unsigned count;
-  tree t;
-
-  /* Special case.  If the caller wants no filtering, it is much
-     faster to just call pph_output_chain directly.  */
-  if (filter == NONE)
-    {
-      pph_output_chain (stream, first, ref_p);
-      return;
-    }
-
-  /* Count all the nodes that match the filter.  */
-  for (t = first, count = 0; t; t = TREE_CHAIN (t))
-    {
-      if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t))
-	continue;
-      count++;
-    }
-  pph_output_uint (stream, count);
-
-  /* Output all the nodes that match the filter.  */
-  for (t = first; t; t = TREE_CHAIN (t))
-    {
-      tree saved_chain;
-
-      /* Apply filters to T.  */
-      if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t))
-	continue;
-
-      /* Clear TREE_CHAIN to avoid blindly recursing into the rest
-	 of the list.  */
-      saved_chain = TREE_CHAIN (t);
-      TREE_CHAIN (t) = NULL_TREE;
-
-      pph_output_tree_or_ref_1 (stream, t, ref_p, 2);
-
-      TREE_CHAIN (t) = saved_chain;
-    }
-}

--
This patch is available for review at http://codereview.appspot.com/4517108

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-26 18:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 20:03 [pph] Move code (issue4517108) Lawrence Crowl

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