Patchwork [pph] Minor cleanups (issue4908048)

login
register
mail settings
Submitter Diego Novillo
Date Aug. 17, 2011, 4:25 p.m.
Message ID <20110817162525.8F37F1DA1CF@topo.tor.corp.google.com>
Download mbox | patch
Permalink /patch/110337/
State New
Headers show

Comments

Diego Novillo - Aug. 17, 2011, 4:25 p.m.
These two patches clean up:

- The streaming of token values.  During PTH, we did not have a generic
  tree streamer, so we were implementing our own.  Easier to just call
  pph_out_tree/pph_in_tree now.

- pph_out_tree_or_ref and pph_out_tree_or_ref_1 were misnamed.  Renamed
  all references to them with pph_out_tree.


Tested on x86_64.  Committed to branch


Diego.
  
        * pph-streamer.h (pph_out_tree_1): Rename from pph_out_tree_or_ref_1.
 	Update all users.
 	(pph_out_tree): Rename from pph_out_tree_or_ref.  Update all users.

        * pph-streamer-in.c (pph_get_type_from_index): Remove.
 	(pph_in_number): Remove.
 	(pph_in_token_value): Handle all cases that read a tree
 	with pph_in_tree.
 	* pph-streamer-out.c (pph_out_number): Remove.
 	(pph_get_index_from_type): Remove.
 	(pph_out_token_value): Handle all cases that write a tree
 	with pph_out_tree.


---
 gcc/cp/ChangeLog.pph      |    6 ++
 gcc/cp/name-lookup.c      |    4 +-
 gcc/cp/pph-streamer-out.c |  146 ++++++++++++++++++++++----------------------
 gcc/cp/pph-streamer.h     |   15 +----
 gcc/cp/pt.c               |    6 +-
 5 files changed, 87 insertions(+), 90 deletions(-)

Patch

diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index edb3986..666033b 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,3 +1,9 @@ 
+2011-08-17   Diego Novillo  <dnovillo@google.com>
+
+	* pph-streamer.h (pph_out_tree_1): Rename from pph_out_tree_or_ref_1.
+	Update all users.
+	(pph_out_tree): Rename from pph_out_tree_or_ref.  Update all users.
+
 2011-08-16  Gabriel Charette  <gchare@google.com>
 
 	* pph-streamer-in.c (pph_read_file_1): Set location of replayed
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 96d41f3..ac10d44 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -6012,8 +6012,8 @@  pph_out_binding_table (pph_stream *stream, binding_table bt)
       if (bt->chain[i])
 	{
 	  pph_out_record_marker (stream, PPH_RECORD_START);
-	  pph_out_tree_or_ref (stream, bt->chain[i]->name);
-	  pph_out_tree_or_ref (stream, bt->chain[i]->type);
+	  pph_out_tree (stream, bt->chain[i]->name);
+	  pph_out_tree (stream, bt->chain[i]->type);
 	}
       else
 	pph_out_record_marker (stream, PPH_RECORD_END);
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 1c5c5d4..b631825 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -458,9 +458,9 @@  pph_out_ld_base (pph_stream *stream, struct lang_decl_base *ldb)
 static void
 pph_out_ld_min (pph_stream *stream, struct lang_decl_min *ldm)
 {
-  pph_out_tree_or_ref_1 (stream, ldm->template_info, 1);
+  pph_out_tree_1 (stream, ldm->template_info, 1);
   if (ldm->base.u2sel == 0)
-    pph_out_tree_or_ref_1 (stream, ldm->u2.access, 1);
+    pph_out_tree_1 (stream, ldm->u2.access, 1);
   else if (ldm->base.u2sel == 1)
     pph_out_uint (stream, ldm->u2.discriminator);
   else
@@ -496,7 +496,7 @@  pph_out_tree_vec (pph_stream *stream, VEC(tree,gc) *v)
 
   pph_out_uint (stream, VEC_length (tree, v));
   FOR_EACH_VEC_ELT (tree, v, i, t)
-    pph_out_tree_or_ref (stream, t);
+    pph_out_tree (stream, t);
 }
 
 
@@ -539,8 +539,8 @@  pph_out_qual_use_vec (pph_stream *stream, VEC(qualified_typedef_usage_t,gc) *v)
   pph_out_uint (stream, VEC_length (qualified_typedef_usage_t, v));
   FOR_EACH_VEC_ELT (qualified_typedef_usage_t, v, i, q)
     {
-      pph_out_tree_or_ref (stream, q->typedef_decl);
-      pph_out_tree_or_ref (stream, q->context);
+      pph_out_tree (stream, q->typedef_decl);
+      pph_out_tree (stream, q->context);
       /* FIXME pph: also write location.  */
     }
 }
@@ -561,8 +561,8 @@  pph_out_cxx_binding_1 (pph_stream *stream, cxx_binding *cb)
   if (!pph_out_start_record (stream, cb))
     return;
 
-  pph_out_tree_or_ref (stream, cb->value);
-  pph_out_tree_or_ref (stream, cb->type);
+  pph_out_tree (stream, cb->value);
+  pph_out_tree (stream, cb->type);
   pph_out_binding_level (stream, cb->scope, PPHF_NONE);
   bp = bitpack_create (stream->encoder.w.ob->main_stream);
   bp_pack_value (&bp, cb->value_is_inherited, 1);
@@ -600,7 +600,7 @@  pph_out_class_binding (pph_stream *stream, cp_class_binding *cb)
     return;
 
   pph_out_cxx_binding (stream, cb->base);
-  pph_out_tree_or_ref (stream, cb->identifier);
+  pph_out_tree (stream, cb->identifier);
 }
 
 
@@ -612,8 +612,8 @@  pph_out_label_binding (pph_stream *stream, cp_label_binding *lb)
   if (!pph_out_start_record (stream, lb))
     return;
 
-  pph_out_tree_or_ref (stream, lb->label);
-  pph_out_tree_or_ref (stream, lb->prev_value);
+  pph_out_tree (stream, lb->label);
+  pph_out_tree (stream, lb->prev_value);
 }
 
 
@@ -628,7 +628,7 @@  pph_out_chained_tree (pph_stream *stream, tree t)
   saved_chain = TREE_CHAIN (t);
   TREE_CHAIN (t) = NULL_TREE;
 
-  pph_out_tree_or_ref_1 (stream, t, 2);
+  pph_out_tree_1 (stream, t, 2);
 
   TREE_CHAIN (t) = saved_chain;
 }
@@ -688,14 +688,14 @@  pph_out_binding_level_1 (pph_stream *stream, cp_binding_level *bl,
   FOR_EACH_VEC_ELT (cp_class_binding, bl->class_shadowed, i, cs)
     pph_out_class_binding (stream, cs);
 
-  pph_out_tree_or_ref (stream, bl->type_shadowed);
+  pph_out_tree (stream, bl->type_shadowed);
 
   pph_out_uint (stream, VEC_length (cp_label_binding, bl->shadowed_labels));
   FOR_EACH_VEC_ELT (cp_label_binding, bl->shadowed_labels, i, sl)
     pph_out_label_binding (stream, sl);
 
   pph_out_chain (stream, bl->blocks);
-  pph_out_tree_or_ref (stream, bl->this_entity);
+  pph_out_tree (stream, bl->this_entity);
   pph_out_binding_level (stream, bl->level_chain, filter);
   pph_out_tree_vec (stream, bl->dead_vars_from_for);
   pph_out_chain (stream, bl->statement_list);
@@ -730,7 +730,7 @@  static void
 pph_out_tree_common (pph_stream *stream, tree t)
 {
   /* The 'struct tree_typed typed' base class is handled in LTO.  */
-  pph_out_tree_or_ref (stream, TREE_CHAIN (t));
+  pph_out_tree (stream, TREE_CHAIN (t));
 }
 
 
@@ -759,13 +759,13 @@  pph_out_language_function (pph_stream *stream, struct language_function *lf)
     return;
 
   pph_out_c_language_function (stream, &lf->base);
-  pph_out_tree_or_ref (stream, lf->x_cdtor_label);
-  pph_out_tree_or_ref (stream, lf->x_current_class_ptr);
-  pph_out_tree_or_ref (stream, lf->x_current_class_ref);
-  pph_out_tree_or_ref (stream, lf->x_eh_spec_block);
-  pph_out_tree_or_ref (stream, lf->x_in_charge_parm);
-  pph_out_tree_or_ref (stream, lf->x_vtt_parm);
-  pph_out_tree_or_ref (stream, lf->x_return_value);
+  pph_out_tree (stream, lf->x_cdtor_label);
+  pph_out_tree (stream, lf->x_current_class_ptr);
+  pph_out_tree (stream, lf->x_current_class_ref);
+  pph_out_tree (stream, lf->x_eh_spec_block);
+  pph_out_tree (stream, lf->x_in_charge_parm);
+  pph_out_tree (stream, lf->x_vtt_parm);
+  pph_out_tree (stream, lf->x_return_value);
   bp = bitpack_create (stream->encoder.w.ob->main_stream);
   bp_pack_value (&bp, lf->x_returns_value, 1);
   bp_pack_value (&bp, lf->x_returns_null, 1);
@@ -813,11 +813,11 @@  pph_out_ld_fn (pph_stream *stream, struct lang_decl_fn *ldf)
   bp_pack_value (&bp, ldf->hidden_friend_p, 1);
   pph_out_bitpack (stream, &bp);
 
-  pph_out_tree_or_ref (stream, ldf->befriending_classes);
-  pph_out_tree_or_ref (stream, ldf->context);
+  pph_out_tree (stream, ldf->befriending_classes);
+  pph_out_tree (stream, ldf->context);
 
   if (ldf->thunk_p == 0)
-    pph_out_tree_or_ref (stream, ldf->u5.cloned_function);
+    pph_out_tree (stream, ldf->u5.cloned_function);
   else if (ldf->thunk_p == 1)
     pph_out_uint (stream, ldf->u5.fixed_offset);
   else
@@ -841,7 +841,7 @@  static int
 pph_out_used_types_slot (void **slot, void *aux)
 {
   struct pph_tree_info *pti = (struct pph_tree_info *) aux;
-  pph_out_tree_or_ref (pti->stream, (tree) *slot);
+  pph_out_tree (pti->stream, (tree) *slot);
   return 1;
 }
 
@@ -1001,8 +1001,8 @@  pph_out_tree_pair_vec (pph_stream *stream, VEC(tree_pair_s,gc) *v)
   pph_out_uint (stream, VEC_length (tree_pair_s, v));
   FOR_EACH_VEC_ELT (tree_pair_s, v, i, p)
     {
-      pph_out_tree_or_ref (stream, p->purpose);
-      pph_out_tree_or_ref (stream, p->value);
+      pph_out_tree (stream, p->purpose);
+      pph_out_tree (stream, p->value);
     }
 }
 
@@ -1019,7 +1019,7 @@  pph_out_sorted_fields_type (pph_stream *stream, struct sorted_fields_type *sft)
 
   pph_out_uint (stream, sft->len);
   for (i = 0; i < sft->len; i++)
-    pph_out_tree_or_ref (stream, sft->elts[i]);
+    pph_out_tree (stream, sft->elts[i]);
 }
 
 
@@ -1078,24 +1078,24 @@  pph_out_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
   bp_pack_value (&bp, ltc->has_constexpr_ctor, 1);
   pph_out_bitpack (stream, &bp);
 
-  pph_out_tree_or_ref (stream, ltc->primary_base);
+  pph_out_tree (stream, ltc->primary_base);
   pph_out_tree_pair_vec (stream, ltc->vcall_indices);
-  pph_out_tree_or_ref (stream, ltc->vtables);
-  pph_out_tree_or_ref (stream, ltc->typeinfo_var);
+  pph_out_tree (stream, ltc->vtables);
+  pph_out_tree (stream, ltc->typeinfo_var);
   pph_out_tree_vec (stream, ltc->vbases);
   if (pph_out_start_record (stream, ltc->nested_udts))
     pph_out_binding_table (stream, ltc->nested_udts);
-  pph_out_tree_or_ref (stream, ltc->as_base);
+  pph_out_tree (stream, ltc->as_base);
   pph_out_tree_vec (stream, ltc->pure_virtuals);
-  pph_out_tree_or_ref (stream, ltc->friend_classes);
+  pph_out_tree (stream, ltc->friend_classes);
   pph_out_tree_vec (stream, ltc->methods);
-  pph_out_tree_or_ref (stream, ltc->key_method);
-  pph_out_tree_or_ref (stream, ltc->decl_list);
-  pph_out_tree_or_ref (stream, ltc->template_info);
-  pph_out_tree_or_ref (stream, ltc->befriending_classes);
-  pph_out_tree_or_ref (stream, ltc->objc_info);
+  pph_out_tree (stream, ltc->key_method);
+  pph_out_tree (stream, ltc->decl_list);
+  pph_out_tree (stream, ltc->template_info);
+  pph_out_tree (stream, ltc->befriending_classes);
+  pph_out_tree (stream, ltc->objc_info);
   pph_out_sorted_fields_type (stream, ltc->sorted_fields);
-  pph_out_tree_or_ref (stream, ltc->lambda_expr);
+  pph_out_tree (stream, ltc->lambda_expr);
 }
 
 
@@ -1104,7 +1104,7 @@  pph_out_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
 static void
 pph_out_lang_type_ptrmem (pph_stream *stream, struct lang_type_ptrmem *ltp)
 {
-  pph_out_tree_or_ref (stream, ltp->record);
+  pph_out_tree (stream, ltp->record);
 }
 
 
@@ -1410,10 +1410,10 @@  pph_out_function_decl (pph_stream *stream, tree fndecl)
      order when reading the image (the allocation of
      DECL_STRUCT_FUNCTION has the side effect of generating function
      sequence numbers (function.funcdef_no).  */
-  pph_out_tree_or_ref_1 (stream, DECL_INITIAL (fndecl), 3);
+  pph_out_tree_1 (stream, DECL_INITIAL (fndecl), 3);
   pph_out_lang_specific (stream, fndecl);
-  pph_out_tree_or_ref_1 (stream, DECL_SAVED_TREE (fndecl), 3);
-  pph_out_tree_or_ref_1 (stream, DECL_CHAIN (fndecl), 3);
+  pph_out_tree_1 (stream, DECL_SAVED_TREE (fndecl), 3);
+  pph_out_tree_1 (stream, DECL_CHAIN (fndecl), 3);
 }
 
 
@@ -1444,7 +1444,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
     case IMPORTED_DECL:
     case LABEL_DECL:
     case RESULT_DECL:
-      pph_out_tree_or_ref_1 (stream, DECL_INITIAL (expr), 3);
+      pph_out_tree_1 (stream, DECL_INITIAL (expr), 3);
       break;
 
     case CONST_DECL:
@@ -1454,11 +1454,11 @@  pph_write_tree_body (pph_stream *stream, tree expr)
     case USING_DECL:
     case VAR_DECL:
       /* FIXME pph: Should we merge DECL_INITIAL into lang_specific? */
-      pph_out_tree_or_ref_1 (stream, DECL_INITIAL (expr), 3);
+      pph_out_tree_1 (stream, DECL_INITIAL (expr), 3);
       pph_out_lang_specific (stream, expr);
       /* DECL_CHAIN is handled by generic code, except for VAR_DECLs.  */
       if (TREE_CODE (expr) == VAR_DECL)
-	pph_out_tree_or_ref_1 (stream, DECL_CHAIN (expr), 3);
+	pph_out_tree_1 (stream, DECL_CHAIN (expr), 3);
       break;
 
     case FUNCTION_DECL:
@@ -1466,17 +1466,17 @@  pph_write_tree_body (pph_stream *stream, tree expr)
       break;
 
     case TYPE_DECL:
-      pph_out_tree_or_ref_1 (stream, DECL_INITIAL (expr), 3);
+      pph_out_tree_1 (stream, DECL_INITIAL (expr), 3);
       pph_out_lang_specific (stream, expr);
-      pph_out_tree_or_ref_1 (stream, DECL_ORIGINAL_TYPE (expr), 3);
+      pph_out_tree_1 (stream, DECL_ORIGINAL_TYPE (expr), 3);
       break;
 
     case TEMPLATE_DECL:
-      pph_out_tree_or_ref_1 (stream, DECL_INITIAL (expr), 3);
+      pph_out_tree_1 (stream, DECL_INITIAL (expr), 3);
       pph_out_lang_specific (stream, expr);
-      pph_out_tree_or_ref_1 (stream, DECL_TEMPLATE_RESULT (expr), 3);
-      pph_out_tree_or_ref_1 (stream, DECL_TEMPLATE_PARMS (expr), 3);
-      pph_out_tree_or_ref_1 (stream, DECL_CONTEXT (expr), 3);
+      pph_out_tree_1 (stream, DECL_TEMPLATE_RESULT (expr), 3);
+      pph_out_tree_1 (stream, DECL_TEMPLATE_PARMS (expr), 3);
+      pph_out_tree_1 (stream, DECL_CONTEXT (expr), 3);
       break;
 
     /* tcc_type */
@@ -1504,7 +1504,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
     case RECORD_TYPE:
     case UNION_TYPE:
       pph_out_lang_type (stream, expr);
-      pph_out_tree_or_ref_1 (stream, TYPE_BINFO (expr), 3);
+      pph_out_tree_1 (stream, TYPE_BINFO (expr), 3);
       break;
 
     case BOUND_TEMPLATE_TEMPLATE_PARM:
@@ -1514,7 +1514,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
     case TYPENAME_TYPE:
     case TYPEOF_TYPE:
       pph_out_lang_type (stream, expr);
-      pph_out_tree_or_ref_1 (stream, TYPE_CACHED_VALUES (expr), 3);
+      pph_out_tree_1 (stream, TYPE_CACHED_VALUES (expr), 3);
       /* Note that we are using TYPED_CACHED_VALUES for it access to
          the generic .values field of types. */
       break;
@@ -1534,7 +1534,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
 
         /* Write the statements.  */
         for (i = tsi_start (expr); !tsi_end_p (i); tsi_next (&i))
-	  pph_out_tree_or_ref_1 (stream, tsi_stmt (i), 3);
+	  pph_out_tree_1 (stream, tsi_stmt (i), 3);
       }
       break;
 
@@ -1552,7 +1552,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
 
     case OVERLOAD:
       pph_out_tree_common (stream, expr);
-      pph_out_tree_or_ref_1 (stream, OVL_CURRENT (expr), 3);
+      pph_out_tree_1 (stream, OVL_CURRENT (expr), 3);
       break;
 
     case IDENTIFIER_NODE:
@@ -1560,17 +1560,17 @@  pph_write_tree_body (pph_stream *stream, tree expr)
         struct lang_identifier *id = LANG_IDENTIFIER_CAST (expr);
         pph_out_cxx_binding (stream, id->namespace_bindings);
         pph_out_cxx_binding (stream, id->bindings);
-        pph_out_tree_or_ref_1 (stream, id->class_template_info, 3);
-        pph_out_tree_or_ref_1 (stream, id->label_value, 3);
-	pph_out_tree_or_ref_1 (stream, TREE_TYPE (expr), 3);
+        pph_out_tree_1 (stream, id->class_template_info, 3);
+        pph_out_tree_1 (stream, id->label_value, 3);
+	pph_out_tree_1 (stream, TREE_TYPE (expr), 3);
       }
       break;
 
     case BASELINK:
       pph_out_tree_common (stream, expr);
-      pph_out_tree_or_ref_1 (stream, BASELINK_BINFO (expr), 3);
-      pph_out_tree_or_ref_1 (stream, BASELINK_FUNCTIONS (expr), 3);
-      pph_out_tree_or_ref_1 (stream, BASELINK_ACCESS_BINFO (expr), 3);
+      pph_out_tree_1 (stream, BASELINK_BINFO (expr), 3);
+      pph_out_tree_1 (stream, BASELINK_FUNCTIONS (expr), 3);
+      pph_out_tree_1 (stream, BASELINK_ACCESS_BINFO (expr), 3);
       break;
 
     case TEMPLATE_INFO:
@@ -1587,7 +1587,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
         pph_out_uint (stream, p->level);
         pph_out_uint (stream, p->orig_level);
         pph_out_uint (stream, p->num_siblings);
-        pph_out_tree_or_ref_1 (stream, p->decl, 3);
+        pph_out_tree_1 (stream, p->decl, 3);
       }
       break;
 
@@ -1595,7 +1595,7 @@  pph_write_tree_body (pph_stream *stream, tree expr)
 
     case PTRMEM_CST:
       pph_out_tree_common (stream, expr);
-      pph_out_tree_or_ref_1 (stream, PTRMEM_CST_MEMBER (expr), 3);
+      pph_out_tree_1 (stream, PTRMEM_CST_MEMBER (expr), 3);
       break;
 
     /* tcc_exceptional */
@@ -1608,21 +1608,21 @@  pph_write_tree_body (pph_stream *stream, tree expr)
 
     case STATIC_ASSERT:
       pph_out_tree_common (stream, expr);
-      pph_out_tree_or_ref_1 (stream, STATIC_ASSERT_CONDITION (expr), 3);
-      pph_out_tree_or_ref_1 (stream, STATIC_ASSERT_MESSAGE (expr), 3);
+      pph_out_tree_1 (stream, STATIC_ASSERT_CONDITION (expr), 3);
+      pph_out_tree_1 (stream, STATIC_ASSERT_MESSAGE (expr), 3);
       pph_out_location (stream, STATIC_ASSERT_SOURCE_LOCATION (expr));
       break;
 
     case ARGUMENT_PACK_SELECT:
       pph_out_tree_common (stream, expr);
-      pph_out_tree_or_ref_1 (stream, ARGUMENT_PACK_SELECT_FROM_PACK (expr), 3);
+      pph_out_tree_1 (stream, ARGUMENT_PACK_SELECT_FROM_PACK (expr), 3);
       pph_out_uint (stream, ARGUMENT_PACK_SELECT_INDEX (expr));
       break;
 
     case TRAIT_EXPR:
       pph_out_tree_common (stream, expr);
-      pph_out_tree_or_ref_1 (stream, TRAIT_EXPR_TYPE1 (expr), 3);
-      pph_out_tree_or_ref_1 (stream, TRAIT_EXPR_TYPE2 (expr), 3);
+      pph_out_tree_1 (stream, TRAIT_EXPR_TYPE1 (expr), 3);
+      pph_out_tree_1 (stream, TRAIT_EXPR_TYPE2 (expr), 3);
       pph_out_uint (stream, TRAIT_EXPR_KIND (expr));
       break;
 
@@ -1632,10 +1632,10 @@  pph_write_tree_body (pph_stream *stream, tree expr)
             = (struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (expr);
         pph_out_tree_common (stream, expr);
 	pph_out_location (stream, e->locus);
-        pph_out_tree_or_ref_1 (stream, e->capture_list, 3);
-        pph_out_tree_or_ref_1 (stream, e->this_capture, 3);
-        pph_out_tree_or_ref_1 (stream, e->return_type, 3);
-        pph_out_tree_or_ref_1 (stream, e->extra_scope, 3);
+        pph_out_tree_1 (stream, e->capture_list, 3);
+        pph_out_tree_1 (stream, e->this_capture, 3);
+        pph_out_tree_1 (stream, e->return_type, 3);
+        pph_out_tree_1 (stream, e->extra_scope, 3);
         pph_out_uint (stream, e->discriminator);
       }
       break;
diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h
index 415995b..8c3298a 100644
--- a/gcc/cp/pph-streamer.h
+++ b/gcc/cp/pph-streamer.h
@@ -239,15 +239,6 @@  extern void pph_in_spec_entry_tables (pph_stream *stream);
 
 /* Inline functions.  */
 
-/* Output AST T to STREAM.  This function is the primary interface.  */
-static inline void
-pph_out_tree (pph_stream *stream, tree t)
-{
-  if (flag_pph_tracer >= 1)
-    pph_trace_tree (stream, t);
-  pph_write_tree (stream->encoder.w.ob, t, false);
-}
-
 /* Output array A of cardinality C of ASTs to STREAM.  */
 /* FIXME pph: hold for alternate routine. */
 #if 0
@@ -267,7 +258,7 @@  pph_out_tree_array (pph_stream *stream, tree *a, size_t c)
 /* Output AST T to STREAM.  If -fpph-tracer is set to TLEVEL or
    higher, T is sent to pph_trace_tree.  */
 static inline void
-pph_out_tree_or_ref_1 (pph_stream *stream, tree t, int tlevel)
+pph_out_tree_1 (pph_stream *stream, tree t, int tlevel)
 {
   if (flag_pph_tracer >= tlevel)
     pph_trace_tree (stream, t);
@@ -276,9 +267,9 @@  pph_out_tree_or_ref_1 (pph_stream *stream, tree t, int tlevel)
 
 /* Output AST T to STREAM.  Trigger tracing at -fpph-tracer=2.  */
 static inline void
-pph_out_tree_or_ref (pph_stream *stream, tree t)
+pph_out_tree (pph_stream *stream, tree t)
 {
-  pph_out_tree_or_ref_1 (stream, t, 2);
+  pph_out_tree_1 (stream, t, 2);
 }
 
 /* Write an unsigned int VALUE to STREAM.  */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f4b3e8e..3af33a6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20213,9 +20213,9 @@  pph_out_spec_entry_slot (void **slot, void *aux)
 {
   pph_stream *stream = (pph_stream *)aux;
   struct spec_entry *entry = (struct spec_entry *) *slot;
-  pph_out_tree_or_ref (stream, entry->tmpl);
-  pph_out_tree_or_ref (stream, entry->args);
-  pph_out_tree_or_ref (stream, entry->spec);
+  pph_out_tree (stream, entry->tmpl);
+  pph_out_tree (stream, entry->args);
+  pph_out_tree (stream, entry->spec);
   return 1;
 }
 
---
 gcc/cp/ChangeLog.pph      |   11 ++++
 gcc/cp/pph-streamer-in.c  |   86 ++---------------------------
 gcc/cp/pph-streamer-out.c |  132 ++------------------------------------------
 3 files changed, 23 insertions(+), 206 deletions(-)

diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index 666033b..7f4b200 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,5 +1,16 @@ 
 2011-08-17   Diego Novillo  <dnovillo@google.com>
 
+	* pph-streamer-in.c (pph_get_type_from_index): Remove.
+	(pph_in_number): Remove.
+	(pph_in_token_value): Handle all cases that read a tree
+	with pph_in_tree.
+	* pph-streamer-out.c (pph_out_number): Remove.
+	(pph_get_index_from_type): Remove.
+	(pph_out_token_value): Handle all cases that write a tree
+	with pph_out_tree.
+
+2011-08-17   Diego Novillo  <dnovillo@google.com>
+
 	* pph-streamer.h (pph_out_tree_1): Rename from pph_out_tree_or_ref_1.
 	Update all users.
 	(pph_out_tree): Rename from pph_out_tree_or_ref.  Update all users.
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 8d25de8..013f526 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -225,107 +225,33 @@  pph_read_location (struct lto_input_block *ib,
 }
 
 
-/* Given a type index TYPE_IDX and TYPE_KIND specifying the kind of type,
-   return a type from integer_types or global_trees.  */
-
-static tree
-pph_get_type_from_index (unsigned type_idx, unsigned type_kind)
-{
-  if (type_kind == CPP_N_INTEGER)
-    return integer_types[type_idx];
-  else if (type_kind == CPP_N_FLOATING || type_kind == CPP_N_FRACT)
-    return global_trees[type_idx];
-  else if (type_kind == CPP_N_IMAGINARY)
-    {
-      /* We don't need a type for the complex number.  The type is
-	 associated with the real and imaginary parts.  */
-      return NULL_TREE;
-    }
-  else
-    gcc_unreachable ();
-}
-
-
-/* Load a numeric value from file F.  Return the corresponding tree.  */
-
-static tree
-pph_in_number (pph_stream *f)
-{
-  unsigned type_idx, type_kind;
-  tree type, val;
-
-  type_idx = pph_in_uint (f);
-  type_kind = pph_in_uint (f);
-
-  type = pph_get_type_from_index (type_idx, type_kind);
-
-  if (type_kind == CPP_N_INTEGER)
-    {
-      HOST_WIDE_INT v[2];
-      pph_in_bytes (f, v, 2 * sizeof (HOST_WIDE_INT));
-      val = build_int_cst_wide (type, v[0], v[1]);
-    }
-  else if (type_kind == CPP_N_FLOATING)
-    {
-      REAL_VALUE_TYPE r;
-      pph_in_bytes (f, &r, sizeof (REAL_VALUE_TYPE));
-      val = build_real (type, r);
-    }
-  else if (type_kind == CPP_N_FRACT)
-    {
-      FIXED_VALUE_TYPE fv;
-      pph_in_bytes (f, &fv, sizeof (FIXED_VALUE_TYPE));
-      val = build_fixed (type, fv);
-    }
-  else if (type_kind == CPP_N_IMAGINARY)
-    {
-      tree r = pph_in_number (f);
-      tree i = pph_in_number (f);
-      val = build_complex (NULL_TREE, r, i);
-    }
-  else
-    gcc_unreachable ();
-
-  return val;
-}
-
-
-/* Load the tree value associated with TOKEN to file F.  */
+/* Load the tree value associated with TOKEN from STREAM.  */
 
 static void
-pph_in_token_value (pph_stream *f, cp_token *token)
+pph_in_token_value (pph_stream *stream, cp_token *token)
 {
-  const char *str;
-
   switch (token->type)
     {
       case CPP_TEMPLATE_ID:
       case CPP_NESTED_NAME_SPECIFIER:
-	break;
-
-      case CPP_NAME:
-	str = pph_in_string (f);
-	token->u.value = get_identifier (str);
+	/* FIXME pph - Need to handle struct tree_check.  */
 	break;
 
       case CPP_KEYWORD:
 	token->u.value = ridpointers[token->keyword];
 	break;
 
+      case CPP_NAME:
       case CPP_CHAR:
       case CPP_WCHAR:
       case CPP_CHAR16:
       case CPP_CHAR32:
       case CPP_NUMBER:
-	token->u.value = pph_in_number (f);
-	break;
-
       case CPP_STRING:
       case CPP_WSTRING:
       case CPP_STRING16:
       case CPP_STRING32:
-	str = pph_in_string (f);
-	token->u.value = build_string (strlen (str), str);
+	token->u.value = pph_in_tree (stream);
 	break;
 
       case CPP_PRAGMA:
@@ -333,7 +259,7 @@  pph_in_token_value (pph_stream *f, cp_token *token)
 	break;
 
       default:
-	pph_in_bytes (f, &token->u.value, sizeof (token->u.value));
+	pph_in_bytes (stream, &token->u.value, sizeof (token->u.value));
 	gcc_assert (token->u.value == NULL);
     }
 }
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index b631825..2099d4e 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -228,120 +228,11 @@  pph_out_start_record (pph_stream *stream, void *data)
 }
 
 
-/* Compute an index value for TYPE suitable for restoring it later
-   from global_trees[] or integer_types.  The index is saved
-   in TYPE_IX_P and the number category (one of CPP_N_INTEGER,
-   CPP_N_FLOATING, etc) is saved in CATEGORY_P.  */
+/* Save the tree associated with TOKEN to STREAM.  */
 
 static void
-pph_get_index_from_type (tree type, unsigned *type_ix_p, unsigned *category_p)
+pph_out_token_value (pph_stream *stream, cp_token *token)
 {
-  void **val_p;
-  static struct pointer_map_t *type_cache = NULL;
-
-  /* For complex types we will just use the type of the components.  */
-  if (TREE_CODE (type) == COMPLEX_TYPE)
-    {
-      *type_ix_p = 0;
-      *category_p = CPP_N_IMAGINARY;
-      return;
-    }
-
-  if (type_cache == NULL)
-    type_cache = pointer_map_create ();
-
-  val_p = pointer_map_contains (type_cache, type);
-  if (val_p)
-    *type_ix_p = *((unsigned *) val_p);
-  else
-    {
-      if (CP_INTEGRAL_TYPE_P (type))
-	{
-	  unsigned i;
-	  for (i = itk_char; i < itk_none; i++)
-	    if (type == integer_types[i])
-	      {
-		*type_ix_p = (unsigned) i;
-		break;
-	      }
-
-	  gcc_assert (i != itk_none);
-	}
-      else if (FLOAT_TYPE_P (type) || FIXED_POINT_TYPE_P (type))
-	{
-	  unsigned i;
-
-	  for (i = TI_ERROR_MARK; i < TI_MAX; i++)
-	    if (global_trees[i] == type)
-	      {
-		*type_ix_p = (unsigned) i;
-		break;
-	      }
-
-	  gcc_assert (i != TI_MAX);
-	}
-      else
-	gcc_unreachable ();
-    }
-
-  if (CP_INTEGRAL_TYPE_P (type))
-    *category_p = CPP_N_INTEGER;
-  else if (FLOAT_TYPE_P (type))
-    *category_p = CPP_N_FLOATING;
-  else if (FIXED_POINT_TYPE_P (type))
-    *category_p = CPP_N_FRACT;
-  else
-    gcc_unreachable ();
-}
-
-
-/* Save the number VAL to file F.  */
-
-static void
-pph_out_number (pph_stream *f, tree val)
-{
-  unsigned type_idx, type_kind;
-
-  pph_get_index_from_type (TREE_TYPE (val), &type_idx, &type_kind);
-
-  pph_out_uint (f, type_idx);
-  pph_out_uint (f, type_kind);
-
-  if (type_kind == CPP_N_INTEGER)
-    {
-      HOST_WIDE_INT v[2];
-
-      v[0] = TREE_INT_CST_LOW (val);
-      v[1] = TREE_INT_CST_HIGH (val);
-      pph_out_bytes (f, v, 2 * sizeof (HOST_WIDE_INT));
-    }
-  else if (type_kind == CPP_N_FLOATING)
-    {
-      REAL_VALUE_TYPE r = TREE_REAL_CST (val);
-      pph_out_bytes (f, &r, sizeof (REAL_VALUE_TYPE));
-    }
-  else if (type_kind == CPP_N_FRACT)
-    {
-      FIXED_VALUE_TYPE fv = TREE_FIXED_CST (val);
-      pph_out_bytes (f, &fv, sizeof (FIXED_VALUE_TYPE));
-    }
-  else if (type_kind == CPP_N_IMAGINARY)
-    {
-      pph_out_number (f, TREE_REALPART (val));
-      pph_out_number (f, TREE_IMAGPART (val));
-    }
-  else
-    gcc_unreachable ();
-}
-
-
-/* Save the tree associated with TOKEN to file F.  */
-
-static void
-pph_out_token_value (pph_stream *f, cp_token *token)
-{
-  const char *str;
-  unsigned len;
   tree val;
 
   val = token->u.value;
@@ -349,13 +240,7 @@  pph_out_token_value (pph_stream *f, cp_token *token)
     {
       case CPP_TEMPLATE_ID:
       case CPP_NESTED_NAME_SPECIFIER:
-	break;
-
-      case CPP_NAME:
-	/* FIXME pph.  Hash the strings and emit a string table.  */
-	str = IDENTIFIER_POINTER (val);
-	len = IDENTIFIER_LENGTH (val);
-	pph_out_string_with_length (f, str, len);
+	/* FIXME pph - Need to handle struct tree_check.  */
 	break;
 
       case CPP_KEYWORD:
@@ -363,22 +248,17 @@  pph_out_token_value (pph_stream *f, cp_token *token)
 	   ridpointers[token->keyword] at load time.  */
 	break;
 
+      case CPP_NAME:
       case CPP_CHAR:
       case CPP_WCHAR:
       case CPP_CHAR16:
       case CPP_CHAR32:
       case CPP_NUMBER:
-	pph_out_number (f, val);
-	break;
-
       case CPP_STRING:
       case CPP_WSTRING:
       case CPP_STRING16:
       case CPP_STRING32:
-	/* FIXME pph.  Need to represent the type.  */
-	str = TREE_STRING_POINTER (val);
-	len = TREE_STRING_LENGTH (val);
-	pph_out_string_with_length (f, str, len);
+	pph_out_tree (stream, val);
 	break;
 
       case CPP_PRAGMA:
@@ -387,7 +267,7 @@  pph_out_token_value (pph_stream *f, cp_token *token)
 
       default:
 	gcc_assert (token->u.value == NULL);
-	pph_out_bytes (f, &token->u.value, sizeof (token->u.value));
+	pph_out_bytes (stream, &token->u.value, sizeof (token->u.value));
     }
 }