From patchwork Thu May 26 18:32:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 97610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D789CB6F92 for ; Fri, 27 May 2011 04:33:08 +1000 (EST) Received: (qmail 17288 invoked by alias); 26 May 2011 18:33:07 -0000 Received: (qmail 17275 invoked by uid 22791); 26 May 2011 18:33:06 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 May 2011 18:32:49 +0000 Received: from kpbe13.cbf.corp.google.com (kpbe13.cbf.corp.google.com [172.25.105.77]) by smtp-out.google.com with ESMTP id p4QIWmtW027588; Thu, 26 May 2011 11:32:48 -0700 Received: from jade.mtv.corp.google.com (jade.mtv.corp.google.com [172.18.110.116]) by kpbe13.cbf.corp.google.com with ESMTP id p4QIWl2A005109; Thu, 26 May 2011 11:32:47 -0700 Received: by jade.mtv.corp.google.com (Postfix, from userid 21482) id 309992225F8; Thu, 26 May 2011 11:32:47 -0700 (PDT) To: reply@codereview.appspotmail.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Move code (issue4517108) Message-Id: <20110526183247.309992225F8@jade.mtv.corp.google.com> Date: Thu, 26 May 2011 11:32:46 -0700 (PDT) From: crowl@google.com (Lawrence Crowl) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. --- This patch is available for review at http://codereview.appspot.com/4517108 Index: gcc/cp/ChangeLog.pph 2011-05-26 Lawrence Crowl * 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; - } -}