From patchwork Fri May 27 02:24:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 97649 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 ABA97B6F90 for ; Fri, 27 May 2011 12:24:36 +1000 (EST) Received: (qmail 1287 invoked by alias); 27 May 2011 02:24:33 -0000 Received: (qmail 1269 invoked by uid 22791); 27 May 2011 02:24:31 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_BJ, TW_JC, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 May 2011 02:24:11 +0000 Received: from hpaq3.eem.corp.google.com (hpaq3.eem.corp.google.com [172.25.149.3]) by smtp-out.google.com with ESMTP id p4R2OAtk032068; Thu, 26 May 2011 19:24:10 -0700 Received: from jade.mtv.corp.google.com (jade.mtv.corp.google.com [172.18.110.116]) by hpaq3.eem.corp.google.com with ESMTP id p4R2O2QE025741; Thu, 26 May 2011 19:24:03 -0700 Received: by jade.mtv.corp.google.com (Postfix, from userid 21482) id F1C91222645; Thu, 26 May 2011 19:24:01 -0700 (PDT) To: reply@codereview.appspotmail.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] More C++ Tree Nodes (issue4526083) Message-Id: <20110527022401.F1C91222645@jade.mtv.corp.google.com> Date: Thu, 26 May 2011 19:24:01 -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 Oranize the PPH tree switch into tcc_* chunks, in each of four sections: needs more work, already handled, unimplemented, and unrecognized. Implement several C++ tree nodes. These nodes do not get any more tests to pass, but they do move the failures deeper into the compilation. --- This patch is available for review at http://codereview.appspot.com/4526083 Index: gcc/cp/ChangeLog.pph 2011-05-26 Lawrence Crowl * cp-objcp-common.c (cp_tree_size): Add case TREE_BINFO. * pph.c (pph_read_file): Also log closing of PPH files. * pph-streamer-in.c (pph_stream_read_tree): Organize the switch into tcc_* chunks. Move tcc_statement case STATEMENT_LIST down. Implement tcc_type cases for BOUND_TEMPLATE_TEMPLATE_PARM, DECLTYPE_TYPE, TEMPLATE_TEMPLATE_PARM, TEMPLATE_TYPE_PARM, TYPENAME_TYPE, and TYPEOF_TYPE. Implement tcc_exceptional case TEMPLATE_PARM_INDEX. Add tcc_declaration case TRANSLATION_UNIT_DECL to already handled list. Create a section for unimplemented cases as opposed to unrecognized cases. * pph-streamer-out.c (pph_stream_write_tree): Organize the switch into tcc_* chunks. Move tcc_statement case STATEMENT_LIST down. Implement tcc_type cases for BOUND_TEMPLATE_TEMPLATE_PARM, DECLTYPE_TYPE, TEMPLATE_TEMPLATE_PARM, TEMPLATE_TYPE_PARM, TYPENAME_TYPE, and TYPEOF_TYPE. Move tcc_statement case STATEMENT_LIST down. Implement tcc_exceptional case TEMPLATE_PARM_INDEX. Add tcc_declaration case TRANSLATION_UNIT_DECL to already handled list. Create a section for unimplemented cases as opposed to unrecognized cases. Index: gcc/cp/pph.c =================================================================== --- gcc/cp/pph.c (revision 174301) +++ gcc/cp/pph.c (working copy) @@ -2072,6 +2072,9 @@ pph_read_file (const char *filename) { pph_read_file_contents (stream); pph_stream_close (stream); + + if (flag_pph_debug >= 1) + fprintf (pph_logfile, "PPH: Closing %s\n", filename); } else error ("Cannot open PPH file for reading: %s: %m", filename); Index: gcc/cp/pph-streamer-in.c =================================================================== --- gcc/cp/pph-streamer-in.c (revision 174304) +++ gcc/cp/pph-streamer-in.c (working copy) @@ -807,6 +807,10 @@ pph_stream_read_tree (struct lto_input_b switch (TREE_CODE (expr)) { + /* TREES NEEDING EXTRA WORK */ + + /* tcc_declaration */ + case DEBUG_EXPR_DECL: case IMPORTED_DECL: case LABEL_DECL: @@ -845,16 +849,7 @@ pph_stream_read_tree (struct lto_input_b DECL_CONTEXT (expr) = pph_input_tree (stream); break; - case STATEMENT_LIST: - { - HOST_WIDE_INT i, num_trees = pph_input_uint (stream); - for (i = 0; i < num_trees; i++) - { - tree stmt = pph_input_tree (stream); - append_to_statement_list (stmt, &expr); - } - } - break; + /* tcc_type */ case ARRAY_TYPE: case BOOLEAN_TYPE: @@ -882,6 +877,43 @@ pph_stream_read_tree (struct lto_input_b TYPE_BINFO (expr) = pph_input_tree (stream); break; + case BOUND_TEMPLATE_TEMPLATE_PARM: + case DECLTYPE_TYPE: + case TEMPLATE_TEMPLATE_PARM: + case TEMPLATE_TYPE_PARM: + case TYPENAME_TYPE: + case TYPEOF_TYPE: + pph_stream_read_lang_type (stream, expr); + TYPE_CACHED_VALUES (expr) = pph_input_tree (stream); + /* Note that we are using TYPED_CACHED_VALUES for it access to + the generic .values field of types. */ + break; + + /* tcc_statement */ + + case STATEMENT_LIST: + { + HOST_WIDE_INT i, num_trees = pph_input_uint (stream); + for (i = 0; i < num_trees; i++) + { + tree stmt = pph_input_tree (stream); + append_to_statement_list (stmt, &expr); + } + } + break; + + /* tcc_expression */ + + /* tcc_unary */ + + /* tcc_vl_exp */ + + /* tcc_reference */ + + /* tcc_constant */ + + /* tcc_exceptional */ + case OVERLOAD: OVL_FUNCTION (expr) = pph_input_tree (stream); break; @@ -907,11 +939,127 @@ pph_stream_read_tree (struct lto_input_b = pph_stream_read_qual_use_vec (stream); break; - case TREE_LIST: + case TEMPLATE_PARM_INDEX: + { + template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr); + p->index = pph_input_uint (stream); + p->level = pph_input_uint (stream); + p->orig_level = pph_input_uint (stream); + p->num_siblings = pph_input_uint (stream); + p->decl = pph_input_tree (stream); + /* FIXME pph: Is TEMPLATE_PARM_PARAMETER_PACK using TREE_LANG_FLAG_0 + already handled? */ + } + break; + + /* TREES ALREADY HANDLED */ + + /* tcc_declaration */ + + case TRANSLATION_UNIT_DECL: + + /* tcc_exceptional */ + case TREE_BINFO: - /* These trees are already fully handled. */ + case TREE_LIST: + case TREE_VEC: + + break; + + /* TREES UNIMPLEMENTED */ + + /* tcc_declaration */ + + /* tcc_type */ + + case TYPE_ARGUMENT_PACK: + case TYPE_PACK_EXPANSION: + case UNBOUND_CLASS_TEMPLATE: + + /* tcc_statement */ + + case USING_STMT: + case TRY_BLOCK: + case EH_SPEC_BLOCK: + case HANDLER: + case CLEANUP_STMT: + case IF_STMT: + case FOR_STMT: + case RANGE_FOR_STMT: + case WHILE_STMT: + case DO_STMT: + case BREAK_STMT: + case CONTINUE_STMT: + case SWITCH_STMT: + + /* tcc_expression */ + + case NEW_EXPR: + case VEC_NEW_EXPR: + case DELETE_EXPR: + case VEC_DELETE_EXPR: + case TYPE_EXPR: + case VEC_INIT_EXPR: + case THROW_EXPR: + case EMPTY_CLASS_EXPR: + case TEMPLATE_ID_EXPR: + case PSEUDO_DTOR_EXPR: + case MODOP_EXPR: + case DOTSTAR_EXPR: + case TYPEID_EXPR: + case NON_DEPENDENT_EXPR: + case CTOR_INITIALIZER: + case MUST_NOT_THROW_EXPR: + case EXPR_STMT: + case TAG_DEFN: + case OFFSETOF_EXPR: + case SIZEOF_EXPR: + case ARROW_EXPR: + case ALIGNOF_EXPR: + case AT_ENCODE_EXPR: + case STMT_EXPR: + case NONTYPE_ARGUMENT_PACK: + case EXPR_PACK_EXPANSION: + + /* tcc_unary */ + + case CAST_EXPR: + case REINTERPRET_CAST_EXPR: + case CONST_CAST_EXPR: + case STATIC_CAST_EXPR: + case DYNAMIC_CAST_EXPR: + case NOEXCEPT_EXPR: + case UNARY_PLUS_EXPR: + + /* tcc_reference */ + + case MEMBER_REF: + case OFFSET_REF: + case SCOPE_REF: + + /* tcc_constant */ + + case PTRMEM_CST: + + /* tcc_vl_exp */ + + case AGGR_INIT_EXPR: + + /* tcc_exceptional */ + + case DEFAULT_ARG: + case STATIC_ASSERT: + case ARGUMENT_PACK_SELECT: + case TRAIT_EXPR: + case LAMBDA_EXPR: + + if (flag_pph_untree) + fprintf (pph_logfile, "PPH: unimplemented tree node %s\n", + tree_code_name[TREE_CODE (expr)]); break; + /* TREES UNRECOGNIZED */ + default: if (flag_pph_untree) fprintf (pph_logfile, "PPH: unrecognized tree node %s\n", Index: gcc/cp/pph-streamer-out.c =================================================================== --- gcc/cp/pph-streamer-out.c (revision 174304) +++ gcc/cp/pph-streamer-out.c (working copy) @@ -857,6 +857,10 @@ pph_stream_write_tree (struct output_blo switch (TREE_CODE (expr)) { + /* TREES NEEDING EXTRA WORK */ + + /* tcc_declaration */ + case DEBUG_EXPR_DECL: case IMPORTED_DECL: case LABEL_DECL: @@ -895,22 +899,7 @@ pph_stream_write_tree (struct output_blo pph_output_tree_or_ref_1 (stream, DECL_CONTEXT (expr), ref_p, 3); break; - case STATEMENT_LIST: - { - tree_stmt_iterator i; - unsigned num_stmts; - - /* Compute and write the number of statements in the list. */ - for (num_stmts = 0, i = tsi_start (expr); !tsi_end_p (i); tsi_next (&i)) - num_stmts++; - - pph_output_uint (stream, num_stmts); - - /* Write the statements. */ - for (i = tsi_start (expr); !tsi_end_p (i); tsi_next (&i)) - pph_output_tree_or_ref_1 (stream, tsi_stmt (i), ref_p, 3); - } - break; + /* tcc_type */ case ARRAY_TYPE: case BOOLEAN_TYPE: @@ -938,6 +927,49 @@ pph_stream_write_tree (struct output_blo pph_output_tree_or_ref_1 (stream, TYPE_BINFO (expr), ref_p, 3); break; + case BOUND_TEMPLATE_TEMPLATE_PARM: + case DECLTYPE_TYPE: + case TEMPLATE_TEMPLATE_PARM: + case TEMPLATE_TYPE_PARM: + case TYPENAME_TYPE: + case TYPEOF_TYPE: + pph_stream_write_lang_type (stream, expr, ref_p); + pph_output_tree_or_ref_1 (stream, TYPE_CACHED_VALUES (expr), ref_p, 3); + /* Note that we are using TYPED_CACHED_VALUES for it access to + the generic .values field of types. */ + break; + + /* tcc_statement */ + + case STATEMENT_LIST: + { + tree_stmt_iterator i; + unsigned num_stmts; + + /* Compute and write the number of statements in the list. */ + for (num_stmts = 0, i = tsi_start (expr); !tsi_end_p (i); tsi_next (&i)) + num_stmts++; + + pph_output_uint (stream, num_stmts); + + /* Write the statements. */ + for (i = tsi_start (expr); !tsi_end_p (i); tsi_next (&i)) + pph_output_tree_or_ref_1 (stream, tsi_stmt (i), ref_p, 3); + } + break; + + /* tcc_expression */ + + /* tcc_unary */ + + /* tcc_vl_exp */ + + /* tcc_reference */ + + /* tcc_constant */ + + /* tcc_exceptional */ + case OVERLOAD: pph_output_tree_or_ref_1 (stream, OVL_CURRENT (expr), ref_p, 3); break; @@ -963,11 +995,127 @@ pph_stream_write_tree (struct output_blo TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr), ref_p); break; - case TREE_LIST: + case TEMPLATE_PARM_INDEX: + { + template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr); + pph_output_uint (stream, p->index); + pph_output_uint (stream, p->level); + pph_output_uint (stream, p->orig_level); + pph_output_uint (stream, p->num_siblings); + pph_output_tree_or_ref_1 (stream, p->decl, ref_p, 3); + /* FIXME pph: Is TEMPLATE_PARM_PARAMETER_PACK using TREE_LANG_FLAG_0 + already handled? */ + } + break; + + /* TREES ALREADY HANDLED */ + + /* tcc_declaration */ + + case TRANSLATION_UNIT_DECL: + + /* tcc_exceptional */ + case TREE_BINFO: - /* These trees are already fully handled. */ + case TREE_LIST: + case TREE_VEC: + + break; + + /* TREES UNIMPLEMENTED */ + + /* tcc_declaration */ + + /* tcc_type */ + + case TYPE_ARGUMENT_PACK: + case TYPE_PACK_EXPANSION: + case UNBOUND_CLASS_TEMPLATE: + + /* tcc_statement */ + + case USING_STMT: + case TRY_BLOCK: + case EH_SPEC_BLOCK: + case HANDLER: + case CLEANUP_STMT: + case IF_STMT: + case FOR_STMT: + case RANGE_FOR_STMT: + case WHILE_STMT: + case DO_STMT: + case BREAK_STMT: + case CONTINUE_STMT: + case SWITCH_STMT: + + /* tcc_expression */ + + case NEW_EXPR: + case VEC_NEW_EXPR: + case DELETE_EXPR: + case VEC_DELETE_EXPR: + case TYPE_EXPR: + case VEC_INIT_EXPR: + case THROW_EXPR: + case EMPTY_CLASS_EXPR: + case TEMPLATE_ID_EXPR: + case PSEUDO_DTOR_EXPR: + case MODOP_EXPR: + case DOTSTAR_EXPR: + case TYPEID_EXPR: + case NON_DEPENDENT_EXPR: + case CTOR_INITIALIZER: + case MUST_NOT_THROW_EXPR: + case EXPR_STMT: + case TAG_DEFN: + case OFFSETOF_EXPR: + case SIZEOF_EXPR: + case ARROW_EXPR: + case ALIGNOF_EXPR: + case AT_ENCODE_EXPR: + case STMT_EXPR: + case NONTYPE_ARGUMENT_PACK: + case EXPR_PACK_EXPANSION: + + /* tcc_unary */ + + case CAST_EXPR: + case REINTERPRET_CAST_EXPR: + case CONST_CAST_EXPR: + case STATIC_CAST_EXPR: + case DYNAMIC_CAST_EXPR: + case NOEXCEPT_EXPR: + case UNARY_PLUS_EXPR: + + /* tcc_reference */ + + case MEMBER_REF: + case OFFSET_REF: + case SCOPE_REF: + + /* tcc_constant */ + + case PTRMEM_CST: + + /* tcc_vl_exp */ + + case AGGR_INIT_EXPR: + + /* tcc_exceptional */ + + case DEFAULT_ARG: + case STATIC_ASSERT: + case ARGUMENT_PACK_SELECT: + case TRAIT_EXPR: + case LAMBDA_EXPR: + + if (flag_pph_untree) + fprintf (pph_logfile, "PPH: unimplemented tree node %s\n", + tree_code_name[TREE_CODE (expr)]); break; + /* TREES UNRECOGNIZED */ + default: if (flag_pph_untree) fprintf (pph_logfile, "PPH: unrecognized tree node %s\n", Index: gcc/cp/cp-objcp-common.c =================================================================== --- gcc/cp/cp-objcp-common.c (revision 174301) +++ gcc/cp/cp-objcp-common.c (working copy) @@ -99,6 +99,8 @@ cp_tree_size (enum tree_code code) case TEMPLATE_INFO: return sizeof (struct tree_template_info); + case TREE_BINFO: return sizeof (struct tree_binfo); + default: gcc_unreachable (); }