Patchwork [pph] More C++ Tree Nodes (issue4526083)

login
register
mail settings
Submitter Lawrence Crowl
Date May 27, 2011, 2:24 a.m.
Message ID <20110527022401.F1C91222645@jade.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/97649/
State New
Headers show

Comments

Lawrence Crowl - May 27, 2011, 2:24 a.m.
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
Nathan Froyd - May 27, 2011, 2:30 a.m.
On 05/26/2011 10:24 PM, Lawrence Crowl wrote:
> 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 ();
>      }

This does not look right; TREE_BINFO is a variable-sized structure (and is not
C++-specific in any event).  Maybe you should be using tree_size instead of
tree_code_size someplace?

-Nathan
Lawrence Crowl - May 27, 2011, 5:43 p.m.
On 5/26/11, Nathan Froyd <froydnj@codesourcery.com> wrote:
> On 05/26/2011 10:24 PM, Lawrence Crowl wrote:
>> 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 ();
>>      }
>
> This does not look right; TREE_BINFO is a variable-sized structure
> (and is not C++-specific in any event).

I'd forgotten that.

> Maybe you should be using tree_size instead of tree_code_size
> someplace?

Hm.  Possibly.  The PPH system is still mostly C, and so C++ parts
are being dropped, which could cause a different path further
upstream.

Patch

Index: gcc/cp/ChangeLog.pph

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

	* 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 ();
     }