diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index e42bbb2..c2ad11f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2352,7 +2352,8 @@ lto-section-out.o : lto-section-out.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(DIAGNOSTIC_CORE_H) $(TREE_H) $(EXPR_H) $(PARAMS_H) input.h \
    $(HASHTAB_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) $(TREE_PASS_H) \
    $(CGRAPH_H) $(FUNCTION_H) $(GGC_H) $(EXCEPT_H) pointer-set.h \
-   $(BITMAP_H) langhooks.h $(LTO_STREAMER_H) lto-compress.h
+   $(BITMAP_H) langhooks.h $(LTO_STREAMER_H) lto-compress.h \
+   $(DATA_STREAMER_H)
 lto-symtab.o: lto-symtab.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TREE_H) $(GIMPLE_H) $(GGC_H) $(HASHTAB_H) \
    $(LTO_STREAMER_H) $(LINKER_PLUGIN_API_H) gt-lto-symtab.h
@@ -3090,7 +3091,8 @@ ipa-reference.o : ipa-reference.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
    pointer-set.h $(GGC_H) $(IPA_REFERENCE_H) $(IPA_UTILS_H) $(SPLAY_TREE_H) \
    $(GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) $(TREE_PASS_H) \
-   $(TIMEVAR_H) $(DIAGNOSTIC_H) $(FUNCTION_H) $(LTO_STREAMER_H) $(DIAGNOSTIC_CORE_H)
+   $(TIMEVAR_H) $(DIAGNOSTIC_H) $(FUNCTION_H) $(LTO_STREAMER_H) \
+   $(DIAGNOSTIC_CORE_H) $(DATA_STREAMER_H)
 ipa-pure-const.o : ipa-pure-const.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
    pointer-set.h $(GGC_H) $(IPA_UTILS_H) $(TARGET_H) \
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 65307f0..97d021b 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -195,10 +195,10 @@ pph_read_location (struct lto_input_block *ib,
   unsigned HOST_WIDE_INT n;
   location_t old_loc;
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   is_builtin = bp_unpack_value (&bp, 1);
 
-  n = lto_input_uleb128 (ib);
+  n = streamer_read_wide_uint (ib);
   old_loc = (location_t) n;
   gcc_assert (old_loc == n);
 
@@ -1564,7 +1564,7 @@ pph_read_tree_body (pph_stream *stream, tree expr)
   struct data_in *data_in = stream->encoder.r.data_in;
 
   /* Read the language-independent parts of EXPR's body.  */
-  lto_input_tree_pointers (ib, data_in, expr);
+  streamer_read_tree_body (ib, data_in, expr);
 
   /* Read all the language-dependent fields.  */
   switch (TREE_CODE (expr))
@@ -1931,21 +1931,21 @@ pph_read_tree_header (pph_stream *stream, tree *expr_p, unsigned ix)
   struct lto_input_block *ib = stream->encoder.r.ib;
   struct data_in *data_in = stream->encoder.r.data_in;
 
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   gcc_assert ((unsigned) tag < (unsigned) LTO_NUM_TAGS);
 
   if (tag == LTO_builtin_decl)
     {
       /* If we are going to read a built-in function, all we need is
 	 the code and class.  */
-      *expr_p = lto_get_builtin_tree (ib, data_in);
+      *expr_p = streamer_get_builtin_tree (ib, data_in);
       fully_read_p = true;
     }
   else if (tag == lto_tree_code_to_tag (INTEGER_CST))
     {
       /* For integer constants we only need the type and its hi/low
 	 words.  */
-      *expr_p = lto_input_integer_cst (ib, data_in);
+      *expr_p = streamer_read_integer_cst (ib, data_in);
       fully_read_p = true;
     }
   else
@@ -1954,10 +1954,10 @@ pph_read_tree_header (pph_stream *stream, tree *expr_p, unsigned ix)
 
       /* Otherwise, materialize a new node from IB.  This will also read
 	 all the language-independent bitfields for the new tree.  */
-      *expr_p = lto_materialize_tree (ib, data_in, tag);
+      *expr_p = streamer_alloc_tree (ib, data_in, tag);
 
       /* Read the language-independent bitfields for *EXPR_P.  */
-      bp = tree_read_bitfields (ib, *expr_p);
+      bp = streamer_read_tree_bitfields (ib, *expr_p);
 
       /* Unpack all language-dependent bitfields.  */
       pph_unpack_value_fields (&bp, *expr_p);
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 1b7ab55..eec9197 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -107,8 +107,8 @@ pph_write_location (struct output_block *ob, location_t loc)
       bp_pack_value (&bp, false, 1);
     }
 
-  lto_output_bitpack (&bp);
-  lto_output_sleb128_stream (ob->main_stream, loc);
+  streamer_write_bitpack (&bp);
+  streamer_write_wide_int (ob, loc);
 }
 
 
@@ -1365,7 +1365,7 @@ static void
 pph_write_tree_body (pph_stream *stream, tree expr)
 {
   /* Write the language-independent parts of EXPR's body.  */
-  lto_output_tree_pointers (stream->encoder.w.ob, expr, false);
+  streamer_write_tree_body (stream->encoder.w.ob, expr, false);
 
   /* The following trees have language-dependent information that is
      not written by the generic tree streaming routines.  Handle them
@@ -1694,7 +1694,7 @@ static void
 pph_pack_value_fields (struct bitpack_d *bp, tree expr)
 {
   /* First pack all the language-independent bitfields.  */
-  pack_value_fields (bp, expr);
+  streamer_pack_tree_bitfields (bp, expr);
 
   /* Now pack all the bitfields not handled by the generic packer.  */
   if (TYPE_P (expr))
@@ -1742,7 +1742,7 @@ pph_write_tree_header (pph_stream *stream, tree expr)
 
   /* Write the header, containing everything needed to materialize EXPR
      on the reading side.  */
-  lto_output_tree_header (ob, expr);
+  streamer_write_tree_header (ob, expr);
 
   /* Pack all the non-pointer fields in EXPR into a bitpack and write
      the resulting bitpack.  */
@@ -1765,21 +1765,21 @@ pph_write_tree (struct output_block *ob, tree expr, bool ref_p ATTRIBUTE_UNUSED)
   if (!pph_out_start_record (stream, expr))
     return;
 
-  if (lto_stream_as_builtin_p (expr))
+  if (streamer_handle_as_builtin_p (expr))
     {
       /* MD and NORMAL builtins do not need to be written out
 	 completely as they are always instantiated by the
 	 compiler on startup.  The only builtins that need to
 	 be written out are BUILT_IN_FRONTEND.  For all other
 	 builtins, we simply write the class and code.  */
-      lto_output_builtin_tree (ob, expr);
+      streamer_write_builtin (ob, expr);
     }
   else if (TREE_CODE (expr) == INTEGER_CST)
     {
       /* INTEGER_CST nodes are special because they need their
 	 original type to be materialized by the reader (to implement
 	 TYPE_CACHED_VALUES).  */
-      lto_output_integer_cst (ob, expr, ref_p);
+      streamer_write_integer_cst (ob, expr, ref_p);
     }
   else
     {
diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h
index 5c90be0..dcee717 100644
--- a/gcc/cp/pph-streamer.h
+++ b/gcc/cp/pph-streamer.h
@@ -273,7 +273,7 @@ pph_out_uint (pph_stream *stream, unsigned int value)
 {
   if (flag_pph_tracer >= 4)
     pph_trace_uint (stream, value);
-  lto_output_sleb128_stream (stream->encoder.w.ob->main_stream, value);
+  streamer_write_wide_int (stream->encoder.w.ob, value);
 }
 
 /* Write an unsigned char VALUE to STREAM.  */
@@ -282,7 +282,7 @@ pph_out_uchar (pph_stream *stream, unsigned char value)
 {
   if (flag_pph_tracer >= 4)
     pph_trace_uint (stream, value);
-  lto_output_1_stream (stream->encoder.w.ob->main_stream, value);
+  streamer_write_char_stream (stream->encoder.w.ob->main_stream, value);
 }
 
 /* Write N bytes from P to STREAM.  */
@@ -300,8 +300,8 @@ pph_out_string (pph_stream *stream, const char *str)
 {
   if (flag_pph_tracer >= 4)
     pph_trace_string (stream, str);
-  lto_output_string (stream->encoder.w.ob, stream->encoder.w.ob->main_stream,
-		     str, false);
+  streamer_write_string (stream->encoder.w.ob,
+			 stream->encoder.w.ob->main_stream, str, false);
 }
 
 /* Write string STR of length LEN to STREAM.  */
@@ -311,9 +311,9 @@ pph_out_string_with_length (pph_stream *stream, const char *str,
 {
   if (flag_pph_tracer >= 4)
     pph_trace_string_with_length (stream, str, len);
-  lto_output_string_with_length (stream->encoder.w.ob,
-				 stream->encoder.w.ob->main_stream,
-				 str, len + 1, false);
+  streamer_write_string_with_length (stream->encoder.w.ob,
+				     stream->encoder.w.ob->main_stream,
+				     str, len + 1, false);
 }
 
 /* Output VEC V of ASTs to STREAM.  */
@@ -350,7 +350,7 @@ pph_out_chain (pph_stream *stream, tree first)
 {
   if (flag_pph_tracer >= 2)
     pph_trace_chain (stream, first);
-  lto_output_chain (stream->encoder.w.ob, first, false);
+  streamer_write_chain (stream->encoder.w.ob, first, false);
 }
 
 /* Write a bitpack BP to STREAM.  */
@@ -360,14 +360,14 @@ pph_out_bitpack (pph_stream *stream, struct bitpack_d *bp)
   gcc_assert (stream->encoder.w.ob->main_stream == bp->stream);
   if (flag_pph_tracer >= 4)
     pph_trace_bitpack (stream, bp);
-  lto_output_bitpack (bp);
+  streamer_write_bitpack (bp);
 }
 
 /* Read an unsigned HOST_WIDE_INT integer from STREAM.  */
 static inline unsigned int
 pph_in_uint (pph_stream *stream)
 {
-  HOST_WIDE_INT unsigned n = lto_input_uleb128 (stream->encoder.r.ib);
+  HOST_WIDE_INT unsigned n = streamer_read_wide_uint (stream->encoder.r.ib);
   gcc_assert (n == (unsigned) n);
   if (flag_pph_tracer >= 4)
     pph_trace_uint (stream, n);
@@ -378,7 +378,7 @@ pph_in_uint (pph_stream *stream)
 static inline unsigned char
 pph_in_uchar (pph_stream *stream)
 {
-  unsigned char n = lto_input_1_unsigned (stream->encoder.r.ib);
+  unsigned char n = streamer_read_uchar (stream->encoder.r.ib);
   if (flag_pph_tracer >= 4)
     pph_trace_uint (stream, n);
   return n;
@@ -399,8 +399,8 @@ pph_in_bytes (pph_stream *stream, void *p, size_t n)
 static inline const char *
 pph_in_string (pph_stream *stream)
 {
-  const char *s = lto_input_string (stream->encoder.r.data_in,
-				    stream->encoder.r.ib);
+  const char *s = streamer_read_string (stream->encoder.r.data_in,
+				        stream->encoder.r.ib);
   if (flag_pph_tracer >= 4)
     pph_trace_string (stream, s);
   return s;
@@ -470,7 +470,8 @@ pph_in_tree_VEC (pph_stream *stream, VEC(tree,gc) *v)
 static inline tree
 pph_in_chain (pph_stream *stream)
 {
-  tree t = lto_input_chain (stream->encoder.r.ib, stream->encoder.r.data_in);
+  tree t = streamer_read_chain (stream->encoder.r.ib,
+                                stream->encoder.r.data_in);
   if (flag_pph_tracer >= 2)
     pph_trace_chain (stream, t);
   return t;
@@ -480,7 +481,7 @@ pph_in_chain (pph_stream *stream)
 static inline struct bitpack_d
 pph_in_bitpack (pph_stream *stream)
 {
-  struct bitpack_d bp = lto_input_bitpack (stream->encoder.r.ib);
+  struct bitpack_d bp = streamer_read_bitpack (stream->encoder.r.ib);
   if (flag_pph_tracer >= 4)
     pph_trace_bitpack (stream, &bp);
   return bp;
diff --git a/gcc/data-streamer-in.c b/gcc/data-streamer-in.c
index 5e366b1..446bdd2 100644
--- a/gcc/data-streamer-in.c
+++ b/gcc/data-streamer-in.c
@@ -45,7 +45,7 @@ string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen)
   /* Get the string stored at location LOC in DATA_IN->STRINGS.  */
   LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc - 1,
 			data_in->strings_len);
-  len = lto_input_uleb128 (&str_tab);
+  len = streamer_read_wide_uint (&str_tab);
   *rlen = len;
 
   if (str_tab.p + len > data_in->strings_len)
@@ -61,22 +61,22 @@ string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen)
    IB.  Write the length to RLEN.  */
 
 const char *
-input_string_internal (struct data_in *data_in, struct lto_input_block *ib,
-		       unsigned int *rlen)
+streamer_read_indexed_string (struct data_in *data_in,
+			      struct lto_input_block *ib, unsigned int *rlen)
 {
-  return string_for_index (data_in, lto_input_uleb128 (ib), rlen);
+  return string_for_index (data_in, streamer_read_wide_uint (ib), rlen);
 }
 
 
 /* Read a NULL terminated string from the string table in DATA_IN.  */
 
 const char *
-lto_input_string (struct data_in *data_in, struct lto_input_block *ib)
+streamer_read_string (struct data_in *data_in, struct lto_input_block *ib)
 {
   unsigned int len;
   const char *ptr;
 
-  ptr = input_string_internal (data_in, ib, &len);
+  ptr = streamer_read_indexed_string (data_in, ib, &len);
   if (!ptr)
     return NULL;
   if (ptr[len - 1] != '\0')
@@ -86,10 +86,10 @@ lto_input_string (struct data_in *data_in, struct lto_input_block *ib)
 }
 
 
-/* Read an ULEB128 Number of IB.  */
+/* Read an unsigned HOST_WIDE_INT number from IB.  */
 
 unsigned HOST_WIDE_INT
-lto_input_uleb128 (struct lto_input_block *ib)
+streamer_read_wide_uint (struct lto_input_block *ib)
 {
   unsigned HOST_WIDE_INT result = 0;
   int shift = 0;
@@ -97,7 +97,7 @@ lto_input_uleb128 (struct lto_input_block *ib)
 
   while (true)
     {
-      byte = lto_input_1_unsigned (ib);
+      byte = streamer_read_uchar (ib);
       result |= (byte & 0x7f) << shift;
       shift += 7;
       if ((byte & 0x80) == 0)
@@ -106,31 +106,10 @@ lto_input_uleb128 (struct lto_input_block *ib)
 }
 
 
-/* HOST_WIDEST_INT version of lto_input_uleb128.  IB is as in
-   lto_input_uleb128.  */
-
-unsigned HOST_WIDEST_INT
-lto_input_widest_uint_uleb128 (struct lto_input_block *ib)
-{
-  unsigned HOST_WIDEST_INT result = 0;
-  int shift = 0;
-  unsigned HOST_WIDEST_INT byte;
-
-  while (true)
-    {
-      byte = lto_input_1_unsigned (ib);
-      result |= (byte & 0x7f) << shift;
-      shift += 7;
-      if ((byte & 0x80) == 0)
-	return result;
-    }
-}
-
-
-/* Read an SLEB128 Number of IB.  */
+/* Read a HOST_WIDE_INT number from IB.  */
 
 HOST_WIDE_INT
-lto_input_sleb128 (struct lto_input_block *ib)
+streamer_read_wide_int (struct lto_input_block *ib)
 {
   HOST_WIDE_INT result = 0;
   int shift = 0;
@@ -138,7 +117,7 @@ lto_input_sleb128 (struct lto_input_block *ib)
 
   while (true)
     {
-      byte = lto_input_1_unsigned (ib);
+      byte = streamer_read_uchar (ib);
       result |= (byte & 0x7f) << shift;
       shift += 7;
       if ((byte & 0x80) == 0)
diff --git a/gcc/data-streamer-out.c b/gcc/data-streamer-out.c
index 07d5b35..e231da5 100644
--- a/gcc/data-streamer-out.c
+++ b/gcc/data-streamer-out.c
@@ -32,8 +32,8 @@ along with GCC; see the file COPYING3.  If not see
    duration of the OB and thus OB can keep pointer into it.  */
 
 unsigned
-lto_string_index (struct output_block *ob, const char *s, unsigned int len,
-		  bool persistent)
+streamer_string_index (struct output_block *ob, const char *s, unsigned int len,
+		       bool persistent)
 {
   struct string_slot **slot;
   struct string_slot s_slot;
@@ -64,7 +64,7 @@ lto_string_index (struct output_block *ob, const char *s, unsigned int len,
       new_slot->len = len;
       new_slot->slot_num = start;
       *slot = new_slot;
-      lto_output_uleb128_stream (string_stream, len);
+      streamer_write_wide_uint_stream (string_stream, len);
       lto_output_data_stream (string_stream, string, len);
       return start + 1;
     }
@@ -83,15 +83,17 @@ lto_string_index (struct output_block *ob, const char *s, unsigned int len,
    duration of the OB and thus OB can keep pointer into it.  */
 
 void
-lto_output_string_with_length (struct output_block *ob,
-			       struct lto_output_stream *index_stream,
-			       const char *s, unsigned int len, bool persistent)
+streamer_write_string_with_length (struct output_block *ob,
+				   struct lto_output_stream *index_stream,
+				   const char *s, unsigned int len,
+				   bool persistent)
 {
   if (s)
-    lto_output_uleb128_stream (index_stream,
-			       lto_string_index (ob, s, len, persistent));
+    streamer_write_wide_uint_stream (index_stream,
+				     streamer_string_index (ob, s, len,
+				                            persistent));
   else
-    lto_output_1_stream (index_stream, 0);
+    streamer_write_char_stream (index_stream, 0);
 }
 
 
@@ -101,51 +103,51 @@ lto_output_string_with_length (struct output_block *ob,
    duration of the OB and thus OB can keep pointer into it.  */
 
 void
-lto_output_string (struct output_block *ob,
-	           struct lto_output_stream *index_stream,
-	           const char *string, bool persistent)
+streamer_write_string (struct output_block *ob,
+		       struct lto_output_stream *index_stream,
+		       const char *string, bool persistent)
 {
   if (string)
-    lto_output_string_with_length (ob, index_stream, string,
-				   strlen (string) + 1,
-				   persistent);
+    streamer_write_string_with_length (ob, index_stream, string,
+				       strlen (string) + 1,
+				       persistent);
   else
-    lto_output_1_stream (index_stream, 0);
+    streamer_write_char_stream (index_stream, 0);
 }
 
 
 /* Write a zero to the output stream.  */
 
 void
-output_zero (struct output_block *ob)
+streamer_write_zero (struct output_block *ob)
 {
-  lto_output_1_stream (ob->main_stream, 0);
+  streamer_write_char_stream (ob->main_stream, 0);
 }
 
 
-/* Output an unsigned LEB128 quantity to OB->main_stream.  */
+/* Write an unsigned HOST_WIDE_INT value WORK to OB->main_stream.  */
 
 void
-output_uleb128 (struct output_block *ob, unsigned HOST_WIDE_INT work)
+streamer_write_wide_uint (struct output_block *ob, unsigned HOST_WIDE_INT work)
 {
-  lto_output_uleb128_stream (ob->main_stream, work);
+  streamer_write_wide_uint_stream (ob->main_stream, work);
 }
 
 
-/* Output a signed LEB128 quantity to OB->main_stream.  */
+/* Write a HOST_WIDE_INT value WORK to OB->main_stream.  */
 
 void
-output_sleb128 (struct output_block *ob, HOST_WIDE_INT work)
+streamer_write_wide_int (struct output_block *ob, HOST_WIDE_INT work)
 {
-  lto_output_sleb128_stream (ob->main_stream, work);
+  streamer_write_wide_int_stream (ob->main_stream, work);
 }
 
 
-/* Output an unsigned LEB128 quantity to OBS.  */
+/* Write an unsigned HOST_WIDE_INT value WORK to OBS.  */
 
 void
-lto_output_uleb128_stream (struct lto_output_stream *obs,
-			   unsigned HOST_WIDE_INT work)
+streamer_write_wide_uint_stream (struct lto_output_stream *obs,
+				 unsigned HOST_WIDE_INT work)
 {
   do
     {
@@ -155,39 +157,17 @@ lto_output_uleb128_stream (struct lto_output_stream *obs,
 	/* More bytes to follow.  */
 	byte |= 0x80;
 
-      lto_output_1_stream (obs, byte);
+      streamer_write_char_stream (obs, byte);
     }
   while (work != 0);
 }
 
 
-/* Identical to output_uleb128_stream above except using unsigned
-   HOST_WIDEST_INT type.  For efficiency on host where unsigned HOST_WIDEST_INT
-   is not native, we only use this if we know that HOST_WIDE_INT is not wide
-   enough.  */
+/* Write a HOST_WIDE_INT value WORK to OBS.  */
 
 void
-lto_output_widest_uint_uleb128_stream (struct lto_output_stream *obs,
-				       unsigned HOST_WIDEST_INT work)
-{
-  do
-    {
-      unsigned int byte = (work & 0x7f);
-      work >>= 7;
-      if (work != 0)
-	/* More bytes to follow.  */
-	byte |= 0x80;
-
-      lto_output_1_stream (obs, byte);
-    }
-  while (work != 0);
-}
-
-
-/* Output a signed LEB128 quantity.  */
-
-void
-lto_output_sleb128_stream (struct lto_output_stream *obs, HOST_WIDE_INT work)
+streamer_write_wide_int_stream (struct lto_output_stream *obs,
+				HOST_WIDE_INT work)
 {
   int more, byte;
 
@@ -201,7 +181,7 @@ lto_output_sleb128_stream (struct lto_output_stream *obs, HOST_WIDE_INT work)
       if (more)
 	byte |= 0x80;
 
-      lto_output_1_stream (obs, byte);
+      streamer_write_char_stream (obs, byte);
     }
   while (more);
 }
diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h
index c2f6fa8..f4e8531 100644
--- a/gcc/data-streamer.h
+++ b/gcc/data-streamer.h
@@ -55,6 +55,35 @@ struct string_slot
   unsigned int slot_num;
 };
 
+/* In data-streamer.c  */
+void bp_pack_var_len_unsigned (struct bitpack_d *, unsigned HOST_WIDE_INT);
+void bp_pack_var_len_int (struct bitpack_d *, HOST_WIDE_INT);
+unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
+HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
+
+/* In data-streamer-out.c  */
+void streamer_write_zero (struct output_block *);
+void streamer_write_wide_uint (struct output_block *, unsigned HOST_WIDE_INT);
+void streamer_write_wide_int (struct output_block *, HOST_WIDE_INT);
+void streamer_write_string (struct output_block *, struct lto_output_stream *,
+			    const char *, bool);
+unsigned streamer_string_index (struct output_block *, const char *,
+				unsigned int, bool);
+void streamer_write_string_with_length (struct output_block *,
+					struct lto_output_stream *,
+					const char *, unsigned int, bool);
+void streamer_write_wide_uint_stream (struct lto_output_stream *,
+       				       unsigned HOST_WIDE_INT);
+void streamer_write_wide_int_stream (struct lto_output_stream *, HOST_WIDE_INT);
+
+/* In data-streamer-in.c  */
+const char *string_for_index (struct data_in *, unsigned int, unsigned int *);
+const char *streamer_read_string (struct data_in *, struct lto_input_block *);
+const char *streamer_read_indexed_string (struct data_in *,
+					  struct lto_input_block *,
+					  unsigned int *);
+unsigned HOST_WIDE_INT streamer_read_wide_uint (struct lto_input_block *);
+HOST_WIDE_INT streamer_read_wide_int (struct lto_input_block *);
 
 /* Returns a hash code for P.  Adapted from libiberty's htab_hash_string
    to support strings that may not end in '\0'.  */
@@ -111,7 +140,8 @@ bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits)
      next one.  */
   if (pos + nbits > BITS_PER_BITPACK_WORD)
     {
-      lto_output_uleb128_stream ((struct lto_output_stream *) bp->stream, word);
+      streamer_write_wide_uint_stream ((struct lto_output_stream *) bp->stream,
+				       word);
       word = val;
       pos = nbits;
     }
@@ -126,20 +156,20 @@ bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits)
 
 /* Finishes bit-packing of BP.  */
 static inline void
-lto_output_bitpack (struct bitpack_d *bp)
+streamer_write_bitpack (struct bitpack_d *bp)
 {
-  lto_output_uleb128_stream ((struct lto_output_stream *) bp->stream,
-			     bp->word);
+  streamer_write_wide_uint_stream ((struct lto_output_stream *) bp->stream,
+				   bp->word);
   bp->word = 0;
   bp->pos = 0;
 }
 
 /* Returns a new bit-packing context for bit-unpacking from IB.  */
 static inline struct bitpack_d
-lto_input_bitpack (struct lto_input_block *ib)
+streamer_read_bitpack (struct lto_input_block *ib)
 {
   struct bitpack_d bp;
-  bp.word = lto_input_uleb128 (ib);
+  bp.word = streamer_read_wide_uint (ib);
   bp.pos = 0;
   bp.stream = (void *)ib;
   return bp;
@@ -160,7 +190,8 @@ bp_unpack_value (struct bitpack_d *bp, unsigned nbits)
      switch to the next one.  */
   if (pos + nbits > BITS_PER_BITPACK_WORD)
     {
-      bp->word = val = lto_input_uleb128 ((struct lto_input_block *)bp->stream);
+      bp->word = val 
+	= streamer_read_wide_uint ((struct lto_input_block *)bp->stream);
       bp->pos = nbits;
       return val & mask;
     }
@@ -175,7 +206,7 @@ bp_unpack_value (struct bitpack_d *bp, unsigned nbits)
 /* Write a character to the output block.  */
 
 static inline void
-lto_output_1_stream (struct lto_output_stream *obs, char c)
+streamer_write_char_stream (struct lto_output_stream *obs, char c)
 {
   /* No space left.  */
   if (obs->left_in_block == 0)
@@ -192,7 +223,7 @@ lto_output_1_stream (struct lto_output_stream *obs, char c)
 /* Read byte from the input block.  */
 
 static inline unsigned char
-lto_input_1_unsigned (struct lto_input_block *ib)
+streamer_read_uchar (struct lto_input_block *ib)
 {
   if (ib->p >= ib->len)
     lto_section_overrun (ib);
@@ -204,10 +235,10 @@ lto_input_1_unsigned (struct lto_input_block *ib)
    Be host independent, limit range to 31bits.  */
 
 static inline void
-lto_output_int_in_range (struct lto_output_stream *obs,
-			 HOST_WIDE_INT min,
-			 HOST_WIDE_INT max,
-			 HOST_WIDE_INT val)
+streamer_write_wide_int_in_range (struct lto_output_stream *obs,
+				  HOST_WIDE_INT min,
+				  HOST_WIDE_INT max,
+				  HOST_WIDE_INT val)
 {
   HOST_WIDE_INT range = max - min;
 
@@ -215,35 +246,35 @@ lto_output_int_in_range (struct lto_output_stream *obs,
 		       && range < 0x7fffffff);
 
   val -= min;
-  lto_output_1_stream (obs, val & 255);
+  streamer_write_char_stream (obs, val & 255);
   if (range >= 0xff)
-    lto_output_1_stream (obs, (val >> 8) & 255);
+    streamer_write_char_stream (obs, (val >> 8) & 255);
   if (range >= 0xffff)
-    lto_output_1_stream (obs, (val >> 16) & 255);
+    streamer_write_char_stream (obs, (val >> 16) & 255);
   if (range >= 0xffffff)
-    lto_output_1_stream (obs, (val >> 24) & 255);
+    streamer_write_char_stream (obs, (val >> 24) & 255);
 }
 
 /* Input VAL into OBS and verify it is in range MIN...MAX that is supposed
    to be compile time constant.  PURPOSE is used for error reporting.  */
 
 static inline HOST_WIDE_INT
-lto_input_int_in_range (struct lto_input_block *ib,
-			const char *purpose,
-			HOST_WIDE_INT min,
-			HOST_WIDE_INT max)
+streamer_read_wide_int_in_range (struct lto_input_block *ib,
+				 const char *purpose,
+				 HOST_WIDE_INT min,
+				 HOST_WIDE_INT max)
 {
   HOST_WIDE_INT range = max - min;
-  HOST_WIDE_INT val = lto_input_1_unsigned (ib);
+  HOST_WIDE_INT val = streamer_read_uchar (ib);
 
   gcc_checking_assert (range > 0 && range < 0x7fffffff);
 
   if (range >= 0xff)
-    val |= ((HOST_WIDE_INT)lto_input_1_unsigned (ib)) << 8;
+    val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 8;
   if (range >= 0xffff)
-    val |= ((HOST_WIDE_INT)lto_input_1_unsigned (ib)) << 16;
+    val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 16;
   if (range >= 0xffffff)
-    val |= ((HOST_WIDE_INT)lto_input_1_unsigned (ib)) << 24;
+    val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 24;
   val += min;
   if (val < min || val > max)
     lto_value_range_error (purpose, val, min, max);
@@ -292,14 +323,14 @@ bp_unpack_int_in_range (struct bitpack_d *bp,
 
 /* Output VAL of type "enum enum_name" into OBS.
    Assume range 0...ENUM_LAST - 1.  */
-#define lto_output_enum(obs,enum_name,enum_last,val) \
-  lto_output_int_in_range ((obs), 0, (int)(enum_last) - 1, (int)(val))
+#define streamer_write_enum(obs,enum_name,enum_last,val) \
+  streamer_write_wide_int_in_range ((obs), 0, (int)(enum_last) - 1, (int)(val))
 
 /* Input enum of type "enum enum_name" from IB.
    Assume range 0...ENUM_LAST - 1.  */
 #define lto_input_enum(ib,enum_name,enum_last) \
-  (enum enum_name)lto_input_int_in_range ((ib), #enum_name, 0, \
-					  (int)(enum_last) - 1)
+  (enum enum_name)streamer_read_wide_int_in_range ((ib), #enum_name, 0, \
+						   (int)(enum_last) - 1)
 
 /* Output VAL of type "enum enum_name" into BP.
    Assume range 0...ENUM_LAST - 1.  */
@@ -315,41 +346,17 @@ bp_unpack_int_in_range (struct bitpack_d *bp,
 /* Output the start of a record with TAG to output block OB.  */
 
 static inline void
-output_record_start (struct output_block *ob, enum LTO_tags tag)
+streamer_write_record_start (struct output_block *ob, enum LTO_tags tag)
 {
-  lto_output_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS, tag);
+  streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS, tag);
 }
 
 /* Return the next tag in the input block IB.  */
 
 static inline enum LTO_tags
-input_record_start (struct lto_input_block *ib)
+streamer_read_record_start (struct lto_input_block *ib)
 {
   return lto_input_enum (ib, LTO_tags, LTO_NUM_TAGS);
 }
 
-/* In data-streamer.c  */
-void bp_pack_var_len_unsigned (struct bitpack_d *, unsigned HOST_WIDE_INT);
-void bp_pack_var_len_int (struct bitpack_d *, HOST_WIDE_INT);
-unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
-HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
-
-/* In data-streamer-out.c  */
-void output_zero (struct output_block *);
-void output_uleb128 (struct output_block *, unsigned HOST_WIDE_INT);
-void output_sleb128 (struct output_block *, HOST_WIDE_INT);
-void lto_output_string (struct output_block *, struct lto_output_stream *,
-			const char *, bool);
-unsigned lto_string_index (struct output_block *, const char *, unsigned int,
-			   bool);
-void lto_output_string_with_length (struct output_block *,
-				    struct lto_output_stream *,
-				    const char *, unsigned int, bool);
-const char *input_string_internal (struct data_in *, struct lto_input_block *,
-				   unsigned int *);
-
-/* In data-streamer-in.c  */
-const char *string_for_index (struct data_in *, unsigned int, unsigned int *);
-const char *lto_input_string (struct data_in *, struct lto_input_block *);
-
 #endif  /* GCC_DATA_STREAMER_H  */
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 78ab729..b2afd43 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -41,7 +41,7 @@ input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
   int i, len;
   gimple result;
 
-  ix = lto_input_uleb128 (ib);
+  ix = streamer_read_wide_uint (ib);
   phi_result = VEC_index (tree, SSANAMES (fn), ix);
   len = EDGE_COUNT (bb->preds);
   result = create_phi_node (phi_result, bb);
@@ -53,7 +53,7 @@ input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
   for (i = 0; i < len; i++)
     {
       tree def = stream_read_tree (ib, data_in);
-      int src_index = lto_input_uleb128 (ib);
+      int src_index = streamer_read_wide_uint (ib);
       location_t arg_loc = lto_input_location (ib, data_in);
       basic_block sbb = BASIC_BLOCK_FOR_FUNCTION (fn, src_index);
 
@@ -90,7 +90,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
   code = lto_tag_to_gimple_code (tag);
 
   /* Read the tuple header.  */
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   num_ops = bp_unpack_var_len_unsigned (&bp);
   stmt = gimple_alloc (code, num_ops);
   stmt->gsbase.no_warning = bp_unpack_value (&bp, 1);
@@ -109,7 +109,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
   switch (code)
     {
     case GIMPLE_RESX:
-      gimple_resx_set_region (stmt, lto_input_sleb128 (ib));
+      gimple_resx_set_region (stmt, streamer_read_wide_int (ib));
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
@@ -117,18 +117,18 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
       break;
 
     case GIMPLE_EH_DISPATCH:
-      gimple_eh_dispatch_set_region (stmt, lto_input_sleb128 (ib));
+      gimple_eh_dispatch_set_region (stmt, streamer_read_wide_int (ib));
       break;
 
     case GIMPLE_ASM:
       {
 	/* FIXME lto.  Move most of this into a new gimple_asm_set_string().  */
 	tree str;
-	stmt->gimple_asm.ni = lto_input_uleb128 (ib);
-	stmt->gimple_asm.no = lto_input_uleb128 (ib);
-	stmt->gimple_asm.nc = lto_input_uleb128 (ib);
-	stmt->gimple_asm.nl = lto_input_uleb128 (ib);
-	str = input_string_cst (data_in, ib);
+	stmt->gimple_asm.ni = streamer_read_wide_uint (ib);
+	stmt->gimple_asm.no = streamer_read_wide_uint (ib);
+	stmt->gimple_asm.nc = streamer_read_wide_uint (ib);
+	stmt->gimple_asm.nl = streamer_read_wide_uint (ib);
+	str = streamer_read_string_cst (data_in, ib);
 	stmt->gimple_asm.string = TREE_STRING_POINTER (str);
       }
       /* Fallthru  */
@@ -286,21 +286,21 @@ input_bb (struct lto_input_block *ib, enum LTO_tags tag,
      basic GIMPLE routines that use CFUN.  */
   gcc_assert (cfun == fn);
 
-  index = lto_input_uleb128 (ib);
+  index = streamer_read_wide_uint (ib);
   bb = BASIC_BLOCK_FOR_FUNCTION (fn, index);
 
-  bb->count = (lto_input_sleb128 (ib) * count_materialization_scale
+  bb->count = (streamer_read_wide_int (ib) * count_materialization_scale
 	       + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
-  bb->loop_depth = lto_input_sleb128 (ib);
-  bb->frequency = lto_input_sleb128 (ib);
-  bb->flags = lto_input_sleb128 (ib);
+  bb->loop_depth = streamer_read_wide_int (ib);
+  bb->frequency = streamer_read_wide_int (ib);
+  bb->flags = streamer_read_wide_int (ib);
 
   /* LTO_bb1 has statements.  LTO_bb0 does not.  */
   if (tag == LTO_bb0)
     return;
 
   bsi = gsi_start_bb (bb);
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   while (tag)
     {
       gimple stmt = input_gimple_stmt (ib, data_in, fn, tag);
@@ -310,24 +310,24 @@ input_bb (struct lto_input_block *ib, enum LTO_tags tag,
 
       /* After the statement, expect a 0 delimiter or the EH region
 	 that the previous statement belongs to.  */
-      tag = input_record_start (ib);
+      tag = streamer_read_record_start (ib);
       lto_tag_check_set (tag, 2, LTO_eh_region, LTO_null);
 
       if (tag == LTO_eh_region)
 	{
-	  HOST_WIDE_INT region = lto_input_sleb128 (ib);
+	  HOST_WIDE_INT region = streamer_read_wide_int (ib);
 	  gcc_assert (region == (int) region);
 	  add_stmt_to_eh_lp (stmt, region);
 	}
 
-      tag = input_record_start (ib);
+      tag = streamer_read_record_start (ib);
     }
 
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   while (tag)
     {
       gimple phi = input_phi (ib, bb, data_in, fn);
       find_referenced_vars_in (phi);
-      tag = input_record_start (ib);
+      tag = streamer_read_record_start (ib);
     }
 }
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 233862c..40165ed 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -36,13 +36,13 @@ output_phi (struct output_block *ob, gimple phi)
 {
   unsigned i, len = gimple_phi_num_args (phi);
 
-  output_record_start (ob, lto_gimple_code_to_tag (GIMPLE_PHI));
-  output_uleb128 (ob, SSA_NAME_VERSION (PHI_RESULT (phi)));
+  streamer_write_record_start (ob, lto_gimple_code_to_tag (GIMPLE_PHI));
+  streamer_write_wide_uint (ob, SSA_NAME_VERSION (PHI_RESULT (phi)));
 
   for (i = 0; i < len; i++)
     {
       stream_write_tree (ob, gimple_phi_arg_def (phi, i), true);
-      output_uleb128 (ob, gimple_phi_arg_edge (phi, i)->src->index);
+      streamer_write_wide_uint (ob, gimple_phi_arg_edge (phi, i)->src->index);
       lto_output_location (ob, gimple_phi_arg_location (phi, i));
     }
 }
@@ -61,7 +61,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
   /* Emit identifying tag.  */
   code = gimple_code (stmt);
   tag = lto_gimple_code_to_tag (code);
-  output_record_start (ob, tag);
+  streamer_write_record_start (ob, tag);
 
   /* Emit the tuple header.  */
   bp = bitpack_create (ob->main_stream);
@@ -71,7 +71,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
     bp_pack_value (&bp, gimple_assign_nontemporal_move_p (stmt), 1);
   bp_pack_value (&bp, gimple_has_volatile_ops (stmt), 1);
   bp_pack_var_len_unsigned (&bp, stmt->gsbase.subcode);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
 
   /* Emit location information for the statement.  */
   lto_output_location (ob, gimple_location (stmt));
@@ -83,7 +83,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
   switch (gimple_code (stmt))
     {
     case GIMPLE_RESX:
-      output_sleb128 (ob, gimple_resx_region (stmt));
+      streamer_write_wide_int (ob, gimple_resx_region (stmt));
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
@@ -91,15 +91,16 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       break;
 
     case GIMPLE_EH_DISPATCH:
-      output_sleb128 (ob, gimple_eh_dispatch_region (stmt));
+      streamer_write_wide_int (ob, gimple_eh_dispatch_region (stmt));
       break;
 
     case GIMPLE_ASM:
-      lto_output_uleb128_stream (ob->main_stream, gimple_asm_ninputs (stmt));
-      lto_output_uleb128_stream (ob->main_stream, gimple_asm_noutputs (stmt));
-      lto_output_uleb128_stream (ob->main_stream, gimple_asm_nclobbers (stmt));
-      lto_output_uleb128_stream (ob->main_stream, gimple_asm_nlabels (stmt));
-      lto_output_string (ob, ob->main_stream, gimple_asm_string (stmt), true);
+      streamer_write_wide_uint (ob, gimple_asm_ninputs (stmt));
+      streamer_write_wide_uint (ob, gimple_asm_noutputs (stmt));
+      streamer_write_wide_uint (ob, gimple_asm_nclobbers (stmt));
+      streamer_write_wide_uint (ob, gimple_asm_nlabels (stmt));
+      streamer_write_string (ob, ob->main_stream, gimple_asm_string (stmt),
+			     true);
       /* Fallthru  */
 
     case GIMPLE_ASSIGN:
@@ -139,8 +140,8 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       if (is_gimple_call (stmt))
 	{
 	  if (gimple_call_internal_p (stmt))
-	    lto_output_enum (ob->main_stream, internal_fn,
-			     IFN_LAST, gimple_call_internal_fn (stmt));
+	    streamer_write_enum (ob->main_stream, internal_fn,
+				 IFN_LAST, gimple_call_internal_fn (stmt));
 	  else
 	    stream_write_tree (ob, gimple_call_fntype (stmt), true);
 	}
@@ -163,16 +164,16 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn)
 {
   gimple_stmt_iterator bsi = gsi_start_bb (bb);
 
-  output_record_start (ob,
-		       (!gsi_end_p (bsi)) || phi_nodes (bb)
-		        ? LTO_bb1
-			: LTO_bb0);
+  streamer_write_record_start (ob,
+			       (!gsi_end_p (bsi)) || phi_nodes (bb)
+			        ? LTO_bb1
+				: LTO_bb0);
 
-  output_uleb128 (ob, bb->index);
-  output_sleb128 (ob, bb->count);
-  output_sleb128 (ob, bb->loop_depth);
-  output_sleb128 (ob, bb->frequency);
-  output_sleb128 (ob, bb->flags);
+  streamer_write_wide_uint (ob, bb->index);
+  streamer_write_wide_int (ob, bb->count);
+  streamer_write_wide_int (ob, bb->loop_depth);
+  streamer_write_wide_int (ob, bb->frequency);
+  streamer_write_wide_int (ob, bb->flags);
 
   if (!gsi_end_p (bsi) || phi_nodes (bb))
     {
@@ -189,14 +190,14 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn)
 	  region = lookup_stmt_eh_lp_fn (fn, stmt);
 	  if (region != 0)
 	    {
-	      output_record_start (ob, LTO_eh_region);
-	      output_sleb128 (ob, region);
+	      streamer_write_record_start (ob, LTO_eh_region);
+	      streamer_write_wide_int (ob, region);
 	    }
 	  else
-	    output_record_start (ob, LTO_null);
+	    streamer_write_record_start (ob, LTO_null);
 	}
 
-      output_record_start (ob, LTO_null);
+      streamer_write_record_start (ob, LTO_null);
 
       for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
@@ -209,6 +210,6 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn)
 	    output_phi (ob, phi);
 	}
 
-      output_record_start (ob, LTO_null);
+      streamer_write_record_start (ob, LTO_null);
     }
 }
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index f3214e2..7881ca3 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2326,7 +2326,7 @@ read_predicate (struct lto_input_block *ib)
   do 
     {
       gcc_assert (k <= MAX_CLAUSES);
-      clause = out.clause[k++] = lto_input_uleb128 (ib);
+      clause = out.clause[k++] = streamer_read_wide_uint (ib);
     }
   while (clause);
 
@@ -2346,9 +2346,9 @@ read_inline_edge_summary (struct lto_input_block *ib, struct cgraph_edge *e)
   struct inline_edge_summary *es = inline_edge_summary (e);
   struct predicate p;
 
-  es->call_stmt_size = lto_input_uleb128 (ib);
-  es->call_stmt_time = lto_input_uleb128 (ib);
-  es->loop_depth = lto_input_uleb128 (ib);
+  es->call_stmt_size = streamer_read_wide_uint (ib);
+  es->call_stmt_time = streamer_read_wide_uint (ib);
+  es->loop_depth = streamer_read_wide_uint (ib);
   p = read_predicate (ib);
   edge_set_predicate (e, &p);
 }
@@ -2376,7 +2376,7 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
   data_in =
     lto_data_in_create (file_data, (const char *) data + string_offset,
 			header->string_size, NULL);
-  f_count = lto_input_uleb128 (&ib);
+  f_count = streamer_read_wide_uint (&ib);
   for (i = 0; i < f_count; i++)
     {
       unsigned int index;
@@ -2386,38 +2386,38 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
       struct bitpack_d bp;
       struct cgraph_edge *e;
 
-      index = lto_input_uleb128 (&ib);
+      index = streamer_read_wide_uint (&ib);
       encoder = file_data->cgraph_node_encoder;
       node = lto_cgraph_encoder_deref (encoder, index);
       info = inline_summary (node);
 
       info->estimated_stack_size
-	= info->estimated_self_stack_size = lto_input_uleb128 (&ib);
-      info->size = info->self_size = lto_input_uleb128 (&ib);
-      info->time = info->self_time = lto_input_uleb128 (&ib);
+	= info->estimated_self_stack_size = streamer_read_wide_uint (&ib);
+      info->size = info->self_size = streamer_read_wide_uint (&ib);
+      info->time = info->self_time = streamer_read_wide_uint (&ib);
 
-      bp = lto_input_bitpack (&ib);
+      bp = streamer_read_bitpack (&ib);
       info->inlinable = bp_unpack_value (&bp, 1);
       info->versionable = bp_unpack_value (&bp, 1);
 
-      count2 = lto_input_uleb128 (&ib);
+      count2 = streamer_read_wide_uint (&ib);
       gcc_assert (!info->conds);
       for (j = 0; j < count2; j++)
 	{
 	  struct condition c;
-	  c.operand_num = lto_input_uleb128 (&ib);
-	  c.code = (enum tree_code) lto_input_uleb128 (&ib);
+	  c.operand_num = streamer_read_wide_uint (&ib);
+	  c.code = (enum tree_code) streamer_read_wide_uint (&ib);
 	  c.val = stream_read_tree (&ib, data_in);
 	  VEC_safe_push (condition, gc, info->conds, &c);
 	}
-      count2 = lto_input_uleb128 (&ib);
+      count2 = streamer_read_wide_uint (&ib);
       gcc_assert (!info->entry);
       for (j = 0; j < count2; j++)
 	{
 	  struct size_time_entry e;
 
-	  e.size = lto_input_uleb128 (&ib);
-	  e.time = lto_input_uleb128 (&ib);
+	  e.size = streamer_read_wide_uint (&ib);
+	  e.time = streamer_read_wide_uint (&ib);
 	  e.predicate = read_predicate (&ib);
 
 	  VEC_safe_push (size_time_entry, gc, info->entry, &e);
@@ -2480,10 +2480,9 @@ write_predicate (struct output_block *ob, struct predicate *p)
     for (j = 0; p->clause[j]; j++)
       {
 	 gcc_assert (j < MAX_CLAUSES);
-	 lto_output_uleb128_stream (ob->main_stream,
-				    p->clause[j]);
+	 streamer_write_wide_uint (ob, p->clause[j]);
       }
-  lto_output_uleb128_stream (ob->main_stream, 0);
+  streamer_write_wide_uint (ob, 0);
 }
 
 
@@ -2493,9 +2492,9 @@ static void
 write_inline_edge_summary (struct output_block *ob, struct cgraph_edge *e)
 {
   struct inline_edge_summary *es = inline_edge_summary (e);
-  lto_output_uleb128_stream (ob->main_stream, es->call_stmt_size);
-  lto_output_uleb128_stream (ob->main_stream, es->call_stmt_time);
-  lto_output_uleb128_stream (ob->main_stream, es->loop_depth);
+  streamer_write_wide_uint (ob, es->call_stmt_size);
+  streamer_write_wide_uint (ob, es->call_stmt_time);
+  streamer_write_wide_uint (ob, es->loop_depth);
   write_predicate (ob, es->predicate);
 }
 
@@ -2517,7 +2516,7 @@ inline_write_summary (cgraph_node_set set,
   for (i = 0; i < lto_cgraph_encoder_size (encoder); i++)
     if (lto_cgraph_encoder_deref (encoder, i)->analyzed)
       count++;
-  lto_output_uleb128_stream (ob->main_stream, count);
+  streamer_write_wide_uint (ob, count);
 
   for (i = 0; i < lto_cgraph_encoder_size (encoder); i++)
     {
@@ -2532,38 +2531,30 @@ inline_write_summary (cgraph_node_set set,
 	  struct condition *c;
 	  
 
-	  lto_output_uleb128_stream (ob->main_stream,
-				     lto_cgraph_encoder_encode (encoder, node));
-	  lto_output_sleb128_stream (ob->main_stream,
-				     info->estimated_self_stack_size);
-	  lto_output_sleb128_stream (ob->main_stream,
-				     info->self_size);
-	  lto_output_sleb128_stream (ob->main_stream,
-				     info->self_time);
+	  streamer_write_wide_uint (ob,
+				    lto_cgraph_encoder_encode (encoder, node));
+	  streamer_write_wide_int (ob, info->estimated_self_stack_size);
+	  streamer_write_wide_int (ob, info->self_size);
+	  streamer_write_wide_int (ob, info->self_time);
 	  bp = bitpack_create (ob->main_stream);
 	  bp_pack_value (&bp, info->inlinable, 1);
 	  bp_pack_value (&bp, info->versionable, 1);
-	  lto_output_bitpack (&bp);
-	  lto_output_uleb128_stream (ob->main_stream,
-				     VEC_length (condition, info->conds));
+	  streamer_write_bitpack (&bp);
+	  streamer_write_wide_uint (ob, VEC_length (condition, info->conds));
 	  for (i = 0; VEC_iterate (condition, info->conds, i, c); i++)
 	    {
-	      lto_output_uleb128_stream (ob->main_stream,
-					 c->operand_num);
-	      lto_output_uleb128_stream (ob->main_stream,
-					 c->code);
+	      streamer_write_wide_uint (ob, c->operand_num);
+	      streamer_write_wide_uint (ob, c->code);
 	      stream_write_tree (ob, c->val, true);
 	    }
-	  lto_output_uleb128_stream (ob->main_stream,
-				     VEC_length (size_time_entry, info->entry));
+	  streamer_write_wide_uint (ob, VEC_length (size_time_entry,
+		                                    info->entry));
 	  for (i = 0;
 	       VEC_iterate (size_time_entry, info->entry, i, e);
 	       i++)
 	    {
-	      lto_output_uleb128_stream (ob->main_stream,
-					 e->size);
-	      lto_output_uleb128_stream (ob->main_stream,
-					 e->time);
+	      streamer_write_wide_uint (ob, e->size);
+	      streamer_write_wide_uint (ob, e->time);
 	      write_predicate (ob, &e->predicate);
 	    }
 	  for (edge = node->callees; edge; edge = edge->next_callee)
@@ -2572,7 +2563,7 @@ inline_write_summary (cgraph_node_set set,
 	    write_inline_edge_summary (ob, edge);
 	}
     }
-  lto_output_1_stream (ob->main_stream, 0);
+  streamer_write_char_stream (ob->main_stream, 0);
   produce_asm (ob, NULL);
   destroy_output_block (ob);
 
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 0997cf5..51cd344 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -2644,8 +2644,7 @@ static void
 ipa_write_jump_function (struct output_block *ob,
 			 struct ipa_jump_func *jump_func)
 {
-  lto_output_uleb128_stream (ob->main_stream,
-			     jump_func->type);
+  streamer_write_wide_uint (ob, jump_func->type);
 
   switch (jump_func->type)
     {
@@ -2659,17 +2658,13 @@ ipa_write_jump_function (struct output_block *ob,
       break;
     case IPA_JF_PASS_THROUGH:
       stream_write_tree (ob, jump_func->value.pass_through.operand, true);
-      lto_output_uleb128_stream (ob->main_stream,
-				 jump_func->value.pass_through.formal_id);
-      lto_output_uleb128_stream (ob->main_stream,
-				 jump_func->value.pass_through.operation);
+      streamer_write_wide_uint (ob, jump_func->value.pass_through.formal_id);
+      streamer_write_wide_uint (ob, jump_func->value.pass_through.operation);
       break;
     case IPA_JF_ANCESTOR:
-      lto_output_uleb128_stream (ob->main_stream,
-				 jump_func->value.ancestor.offset);
+      streamer_write_wide_uint (ob, jump_func->value.ancestor.offset);
       stream_write_tree (ob, jump_func->value.ancestor.type, true);
-      lto_output_uleb128_stream (ob->main_stream,
-				 jump_func->value.ancestor.formal_id);
+      streamer_write_wide_uint (ob, jump_func->value.ancestor.formal_id);
       break;
     case IPA_JF_CONST_MEMBER_PTR:
       stream_write_tree (ob, jump_func->value.member_cst.pfn, true);
@@ -2685,7 +2680,7 @@ ipa_read_jump_function (struct lto_input_block *ib,
 			struct ipa_jump_func *jump_func,
 			struct data_in *data_in)
 {
-  jump_func->type = (enum jump_func_type) lto_input_uleb128 (ib);
+  jump_func->type = (enum jump_func_type) streamer_read_wide_uint (ib);
 
   switch (jump_func->type)
     {
@@ -2699,13 +2694,14 @@ ipa_read_jump_function (struct lto_input_block *ib,
       break;
     case IPA_JF_PASS_THROUGH:
       jump_func->value.pass_through.operand = stream_read_tree (ib, data_in);
-      jump_func->value.pass_through.formal_id = lto_input_uleb128 (ib);
-      jump_func->value.pass_through.operation = (enum tree_code) lto_input_uleb128 (ib);
+      jump_func->value.pass_through.formal_id = streamer_read_wide_uint (ib);
+      jump_func->value.pass_through.operation
+	= (enum tree_code) streamer_read_wide_uint (ib);
       break;
     case IPA_JF_ANCESTOR:
-      jump_func->value.ancestor.offset = lto_input_uleb128 (ib);
+      jump_func->value.ancestor.offset = streamer_read_wide_uint (ib);
       jump_func->value.ancestor.type = stream_read_tree (ib, data_in);
-      jump_func->value.ancestor.formal_id = lto_input_uleb128 (ib);
+      jump_func->value.ancestor.formal_id = streamer_read_wide_uint (ib);
       break;
     case IPA_JF_CONST_MEMBER_PTR:
       jump_func->value.member_cst.pfn = stream_read_tree (ib, data_in);
@@ -2724,15 +2720,15 @@ ipa_write_indirect_edge_info (struct output_block *ob,
   struct cgraph_indirect_call_info *ii = cs->indirect_info;
   struct bitpack_d bp;
 
-  lto_output_sleb128_stream (ob->main_stream, ii->param_index);
-  lto_output_sleb128_stream (ob->main_stream, ii->anc_offset);
+  streamer_write_wide_int (ob, ii->param_index);
+  streamer_write_wide_int (ob, ii->anc_offset);
   bp = bitpack_create (ob->main_stream);
   bp_pack_value (&bp, ii->polymorphic, 1);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
 
   if (ii->polymorphic)
     {
-      lto_output_sleb128_stream (ob->main_stream, ii->otr_token);
+      streamer_write_wide_int (ob, ii->otr_token);
       stream_write_tree (ob, ii->otr_type, true);
     }
 }
@@ -2748,13 +2744,13 @@ ipa_read_indirect_edge_info (struct lto_input_block *ib,
   struct cgraph_indirect_call_info *ii = cs->indirect_info;
   struct bitpack_d bp;
 
-  ii->param_index = (int) lto_input_sleb128 (ib);
-  ii->anc_offset = (HOST_WIDE_INT) lto_input_sleb128 (ib);
-  bp = lto_input_bitpack (ib);
+  ii->param_index = (int) streamer_read_wide_int (ib);
+  ii->anc_offset = (HOST_WIDE_INT) streamer_read_wide_int (ib);
+  bp = streamer_read_bitpack (ib);
   ii->polymorphic = bp_unpack_value (&bp, 1);
   if (ii->polymorphic)
     {
-      ii->otr_token = (HOST_WIDE_INT) lto_input_sleb128 (ib);
+      ii->otr_token = (HOST_WIDE_INT) streamer_read_wide_int (ib);
       ii->otr_type = stream_read_tree (ib, data_in);
     }
 }
@@ -2773,7 +2769,7 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node)
 
   encoder = ob->decl_state->cgraph_node_encoder;
   node_ref = lto_cgraph_encoder_encode (encoder, node);
-  lto_output_uleb128_stream (ob->main_stream, node_ref);
+  streamer_write_wide_uint (ob, node_ref);
 
   bp = bitpack_create (ob->main_stream);
   gcc_assert (info->uses_analysis_done
@@ -2782,13 +2778,12 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node)
   gcc_assert (!info->ipcp_orig_node);
   for (j = 0; j < ipa_get_param_count (info); j++)
     bp_pack_value (&bp, ipa_is_param_used (info, j), 1);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
   for (e = node->callees; e; e = e->next_callee)
     {
       struct ipa_edge_args *args = IPA_EDGE_REF (e);
 
-      lto_output_uleb128_stream (ob->main_stream,
-				 ipa_get_cs_argument_count (args));
+      streamer_write_wide_uint (ob, ipa_get_cs_argument_count (args));
       for (j = 0; j < ipa_get_cs_argument_count (args); j++)
 	ipa_write_jump_function (ob, ipa_get_ith_jump_func (args, j));
     }
@@ -2796,8 +2791,7 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node)
     {
       struct ipa_edge_args *args = IPA_EDGE_REF (e);
 
-      lto_output_uleb128_stream (ob->main_stream,
-				 ipa_get_cs_argument_count (args));
+      streamer_write_wide_uint (ob, ipa_get_cs_argument_count (args));
       for (j = 0; j < ipa_get_cs_argument_count (args); j++)
 	ipa_write_jump_function (ob, ipa_get_ith_jump_func (args, j));
       ipa_write_indirect_edge_info (ob, e);
@@ -2817,7 +2811,7 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
 
   ipa_initialize_node_params (node);
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   if (ipa_get_param_count (info) != 0)
     info->uses_analysis_done = true;
   info->node_enqueued = false;
@@ -2826,7 +2820,7 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
   for (e = node->callees; e; e = e->next_callee)
     {
       struct ipa_edge_args *args = IPA_EDGE_REF (e);
-      int count = lto_input_uleb128 (ib);
+      int count = streamer_read_wide_uint (ib);
 
       ipa_set_cs_argument_count (args, count);
       if (!count)
@@ -2840,7 +2834,7 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
   for (e = node->indirect_calls; e; e = e->next_callee)
     {
       struct ipa_edge_args *args = IPA_EDGE_REF (e);
-      int count = lto_input_uleb128 (ib);
+      int count = streamer_read_wide_uint (ib);
 
       ipa_set_cs_argument_count (args, count);
       if (count)
@@ -2877,7 +2871,7 @@ ipa_prop_write_jump_functions (cgraph_node_set set)
 	count++;
     }
 
-  lto_output_uleb128_stream (ob->main_stream, count);
+  streamer_write_wide_uint (ob, count);
 
   /* Process all of the functions.  */
   for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
@@ -2887,7 +2881,7 @@ ipa_prop_write_jump_functions (cgraph_node_set set)
 	  && IPA_NODE_REF (node) != NULL)
         ipa_write_node_info (ob, node);
     }
-  lto_output_1_stream (ob->main_stream, 0);
+  streamer_write_char_stream (ob->main_stream, 0);
   produce_asm (ob, NULL);
   destroy_output_block (ob);
 }
@@ -2914,7 +2908,7 @@ ipa_prop_read_section (struct lto_file_decl_data *file_data, const char *data,
   data_in =
     lto_data_in_create (file_data, (const char *) data + string_offset,
 			header->string_size, NULL);
-  count = lto_input_uleb128 (&ib_main);
+  count = streamer_read_wide_uint (&ib_main);
 
   for (i = 0; i < count; i++)
     {
@@ -2922,7 +2916,7 @@ ipa_prop_read_section (struct lto_file_decl_data *file_data, const char *data,
       struct cgraph_node *node;
       lto_cgraph_encoder_t encoder;
 
-      index = lto_input_uleb128 (&ib_main);
+      index = streamer_read_wide_uint (&ib_main);
       encoder = file_data->cgraph_node_encoder;
       node = lto_cgraph_encoder_deref (encoder, index);
       gcc_assert (node->analyzed);
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 4f02c7b..052a0b2 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -950,7 +950,7 @@ pure_const_write_summary (cgraph_node_set set,
 	count++;
     }
 
-  lto_output_uleb128_stream (ob->main_stream, count);
+  streamer_write_wide_uint_stream (ob->main_stream, count);
 
   /* Process all of the functions.  */
   for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
@@ -967,7 +967,7 @@ pure_const_write_summary (cgraph_node_set set,
 
 	  encoder = ob->decl_state->cgraph_node_encoder;
 	  node_ref = lto_cgraph_encoder_encode (encoder, node);
-	  lto_output_uleb128_stream (ob->main_stream, node_ref);
+	  streamer_write_wide_uint_stream (ob->main_stream, node_ref);
 
 	  /* Note that flags will need to be read in the opposite
 	     order as we are pushing the bitflags into FLAGS.  */
@@ -977,7 +977,7 @@ pure_const_write_summary (cgraph_node_set set,
 	  bp_pack_value (&bp, fs->looping_previously_known, 1);
 	  bp_pack_value (&bp, fs->looping, 1);
 	  bp_pack_value (&bp, fs->can_throw, 1);
-	  lto_output_bitpack (&bp);
+	  streamer_write_bitpack (&bp);
 	}
     }
 
@@ -1006,7 +1006,7 @@ pure_const_read_summary (void)
       if (ib)
 	{
 	  unsigned int i;
-	  unsigned int count = lto_input_uleb128 (ib);
+	  unsigned int count = streamer_read_wide_uint (ib);
 
 	  for (i = 0; i < count; i++)
 	    {
@@ -1017,7 +1017,7 @@ pure_const_read_summary (void)
 	      lto_cgraph_encoder_t encoder;
 
 	      fs = XCNEW (struct funct_state_d);
-	      index = lto_input_uleb128 (ib);
+	      index = streamer_read_wide_uint (ib);
 	      encoder = file_data->cgraph_node_encoder;
 	      node = lto_cgraph_encoder_deref (encoder, index);
 	      set_function_state (node, fs);
@@ -1025,7 +1025,7 @@ pure_const_read_summary (void)
 	      /* Note that the flags must be read in the opposite
 		 order in which they were written (the bitflags were
 		 pushed into FLAGS).  */
-	      bp = lto_input_bitpack (ib);
+	      bp = streamer_read_bitpack (ib);
 	      fs->pure_const_state
 			= (enum pure_const_state_e) bp_unpack_value (&bp, 2);
 	      fs->state_previously_known
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 05024b4..ca82ff5 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "timevar.h"
 #include "diagnostic.h"
 #include "langhooks.h"
+#include "data-streamer.h"
 #include "lto-streamer.h"
 
 static void remove_node_data (struct cgraph_node *node,
@@ -992,17 +993,17 @@ stream_out_bitmap (struct lto_simple_output_block *ob,
   bitmap_iterator bi;
   if (bits == all_module_statics)
     {
-      lto_output_sleb128_stream (ob->main_stream, -1);
+      streamer_write_wide_int_stream (ob->main_stream, -1);
       return;
     }
   EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi)
     count ++;
   if (count == ltrans_statics_bitcount)
     {
-      lto_output_sleb128_stream (ob->main_stream, -1);
+      streamer_write_wide_int_stream (ob->main_stream, -1);
       return;
     }
-  lto_output_sleb128_stream (ob->main_stream, count);
+  streamer_write_wide_int_stream (ob->main_stream, count);
   if (!count)
     return;
   EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi)
@@ -1054,7 +1055,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set,
 				set, vset, ltrans_statics))
 	  count++;
 
-  lto_output_uleb128_stream (ob->main_stream, count);
+  streamer_write_wide_uint_stream (ob->main_stream, count);
   if (count)
     stream_out_bitmap (ob, ltrans_statics, ltrans_statics,
 		       -1);
@@ -1071,7 +1072,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set,
 
 	    info = get_reference_optimization_summary (node);
 	    node_ref = lto_cgraph_encoder_encode (encoder, node);
-	    lto_output_uleb128_stream (ob->main_stream, node_ref);
+	    streamer_write_wide_uint_stream (ob->main_stream, node_ref);
 
 	    stream_out_bitmap (ob, info->statics_not_read, ltrans_statics,
 			       ltrans_statics_bitcount);
@@ -1112,16 +1113,16 @@ ipa_reference_read_optimization_summary (void)
       if (ib)
 	{
 	  unsigned int i;
-	  unsigned int f_count = lto_input_uleb128 (ib);
+	  unsigned int f_count = streamer_read_wide_uint (ib);
 	  int b_count;
 	  if (!f_count)
 	    continue;
-	  b_count = lto_input_sleb128 (ib);
+	  b_count = streamer_read_wide_int (ib);
 	  if (dump_file)
 	    fprintf (dump_file, "all module statics:");
 	  for (i = 0; i < (unsigned int)b_count; i++)
 	    {
-	      unsigned int var_index = lto_input_uleb128 (ib);
+	      unsigned int var_index = streamer_read_wide_uint (ib);
 	      tree v_decl = lto_file_decl_data_get_var_decl (file_data,
 							     var_index);
 	      bitmap_set_bit (all_module_statics, DECL_UID (v_decl));
@@ -1138,7 +1139,7 @@ ipa_reference_read_optimization_summary (void)
 	      int v_count;
 	      lto_cgraph_encoder_t encoder;
 
-	      index = lto_input_uleb128 (ib);
+	      index = streamer_read_wide_uint (ib);
 	      encoder = file_data->cgraph_node_encoder;
 	      node = lto_cgraph_encoder_deref (encoder, index);
 	      info = XCNEW (struct ipa_reference_optimization_summary_d);
@@ -1151,7 +1152,7 @@ ipa_reference_read_optimization_summary (void)
 			 cgraph_node_name (node), node->uid);
 
 	      /* Set the statics not read.  */
-	      v_count = lto_input_sleb128 (ib);
+	      v_count = streamer_read_wide_int (ib);
 	      if (v_count == -1)
 		{
 		  info->statics_not_read = all_module_statics;
@@ -1161,7 +1162,7 @@ ipa_reference_read_optimization_summary (void)
 	      else
 		for (j = 0; j < (unsigned int)v_count; j++)
 		  {
-		    unsigned int var_index = lto_input_uleb128 (ib);
+		    unsigned int var_index = streamer_read_wide_uint (ib);
 		    tree v_decl = lto_file_decl_data_get_var_decl (file_data,
 								   var_index);
 		    bitmap_set_bit (info->statics_not_read, DECL_UID (v_decl));
@@ -1174,7 +1175,7 @@ ipa_reference_read_optimization_summary (void)
 		fprintf (dump_file,
 			 "\n  static not written:");
 	      /* Set the statics not written.  */
-	      v_count = lto_input_sleb128 (ib);
+	      v_count = streamer_read_wide_int (ib);
 	      if (v_count == -1)
 		{
 		  info->statics_not_written = all_module_statics;
@@ -1184,7 +1185,7 @@ ipa_reference_read_optimization_summary (void)
 	      else
 		for (j = 0; j < (unsigned int)v_count; j++)
 		  {
-		    unsigned int var_index = lto_input_uleb128 (ib);
+		    unsigned int var_index = streamer_read_wide_uint (ib);
 		    tree v_decl = lto_file_decl_data_get_var_decl (file_data,
 								   var_index);
 		    bitmap_set_bit (info->statics_not_written, DECL_UID (v_decl));
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 00462d8..9cab164 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -267,24 +267,24 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
   struct bitpack_d bp;
 
   if (edge->indirect_unknown_callee)
-    lto_output_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag,
-		     LTO_cgraph_indirect_edge);
+    streamer_write_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag,
+			 LTO_cgraph_indirect_edge);
   else
-    lto_output_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag,
-		     LTO_cgraph_edge);
+    streamer_write_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag,
+			 LTO_cgraph_edge);
 
   ref = lto_cgraph_encoder_lookup (encoder, edge->caller);
   gcc_assert (ref != LCC_NOT_FOUND);
-  lto_output_sleb128_stream (ob->main_stream, ref);
+  streamer_write_wide_int_stream (ob->main_stream, ref);
 
   if (!edge->indirect_unknown_callee)
     {
       ref = lto_cgraph_encoder_lookup (encoder, edge->callee);
       gcc_assert (ref != LCC_NOT_FOUND);
-      lto_output_sleb128_stream (ob->main_stream, ref);
+      streamer_write_wide_int_stream (ob->main_stream, ref);
     }
 
-  lto_output_sleb128_stream (ob->main_stream, edge->count);
+  streamer_write_wide_int_stream (ob->main_stream, edge->count);
 
   bp = bitpack_create (ob->main_stream);
   uid = (!gimple_has_body_p (edge->caller->decl)
@@ -312,7 +312,7 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
 			     | ECF_LEAF
 			     | ECF_NOVOPS)));
     }
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
 }
 
 /* Return if LIST contain references from other partitions.  */
@@ -423,7 +423,8 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
   else
     tag = LTO_cgraph_unavail_node;
 
-  lto_output_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, tag);
+  streamer_write_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag,
+		       tag);
 
   /* In WPA mode, we only output part of the call-graph.  Also, we
      fake cgraph node attributes.  There are two cases that we care.
@@ -459,14 +460,14 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
   if (LTO_cgraph_analyzed_node)
     gcc_assert (clone_of || !node->clone_of);
   if (!clone_of)
-    lto_output_sleb128_stream (ob->main_stream, LCC_NOT_FOUND);
+    streamer_write_wide_int_stream (ob->main_stream, LCC_NOT_FOUND);
   else
-    lto_output_sleb128_stream (ob->main_stream, ref);
+    streamer_write_wide_int_stream (ob->main_stream, ref);
 
 
   lto_output_fn_decl_index (ob->decl_state, ob->main_stream, node->decl);
-  lto_output_sleb128_stream (ob->main_stream, node->count);
-  lto_output_sleb128_stream (ob->main_stream, node->count_materialization_scale);
+  streamer_write_wide_int_stream (ob->main_stream, node->count);
+  streamer_write_wide_int_stream (ob->main_stream, node->count_materialization_scale);
 
   if (tag == LTO_cgraph_analyzed_node)
     {
@@ -478,7 +479,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
       else
 	ref = LCC_NOT_FOUND;
 
-      lto_output_sleb128_stream (ob->main_stream, ref);
+      streamer_write_wide_int_stream (ob->main_stream, ref);
     }
 
   if (node->same_comdat_group && !boundary_p)
@@ -488,7 +489,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
     }
   else
     ref = LCC_NOT_FOUND;
-  lto_output_sleb128_stream (ob->main_stream, ref);
+  streamer_write_wide_int_stream (ob->main_stream, ref);
 
   bp = bitpack_create (ob->main_stream);
   bp_pack_value (&bp, node->local.local, 1);
@@ -513,23 +514,21 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
   bp_pack_value (&bp, node->thunk.thunk_p && !boundary_p, 1);
   bp_pack_enum (&bp, ld_plugin_symbol_resolution,
 	        LDPR_NUM_KNOWN, node->resolution);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
 
   if (node->thunk.thunk_p && !boundary_p)
     {
-      lto_output_uleb128_stream
+      streamer_write_wide_uint_stream
 	 (ob->main_stream,
 	  1 + (node->thunk.this_adjusting != 0) * 2
 	  + (node->thunk.virtual_offset_p != 0) * 4);
-      lto_output_uleb128_stream (ob->main_stream,
-				 node->thunk.fixed_offset);
-      lto_output_uleb128_stream (ob->main_stream,
-				 node->thunk.virtual_value);
+      streamer_write_wide_uint_stream (ob->main_stream, node->thunk.fixed_offset);
+      streamer_write_wide_uint_stream (ob->main_stream, node->thunk.virtual_value);
     }
   if ((node->alias || node->thunk.thunk_p) && !boundary_p)
     {
-      lto_output_int_in_range (ob->main_stream, 0, 1,
-			       node->thunk.alias != NULL);
+      streamer_write_wide_int_in_range (ob->main_stream, 0, 1,
+					node->thunk.alias != NULL);
       if (node->thunk.alias != NULL)
         lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
 			          node->thunk.alias);
@@ -573,7 +572,7 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node
 							   set, vset), 1);
       bp_pack_value (&bp, boundary_p, 1);  /* in_other_partition.  */
     }
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
   if (node->alias_of)
     lto_output_var_decl_index (ob->decl_state, ob->main_stream, node->alias_of);
   if (node->same_comdat_group && !boundary_p)
@@ -583,9 +582,9 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node
     }
   else
     ref = LCC_NOT_FOUND;
-  lto_output_sleb128_stream (ob->main_stream, ref);
-  lto_output_enum (ob->main_stream, ld_plugin_symbol_resolution,
-		   LDPR_NUM_KNOWN, node->resolution);
+  streamer_write_wide_int_stream (ob->main_stream, ref);
+  streamer_write_enum (ob->main_stream, ld_plugin_symbol_resolution,
+		       LDPR_NUM_KNOWN, node->resolution);
 }
 
 /* Output the varpool NODE to OB. 
@@ -600,19 +599,19 @@ lto_output_ref (struct lto_simple_output_block *ob, struct ipa_ref *ref,
   bp = bitpack_create (ob->main_stream);
   bp_pack_value (&bp, ref->refered_type, 1);
   bp_pack_value (&bp, ref->use, 2);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
   if (ref->refered_type == IPA_REF_CGRAPH)
     {
       int nref = lto_cgraph_encoder_lookup (encoder, ipa_ref_node (ref));
       gcc_assert (nref != LCC_NOT_FOUND);
-      lto_output_sleb128_stream (ob->main_stream, nref);
+      streamer_write_wide_int_stream (ob->main_stream, nref);
     }
   else
     {
       int nref = lto_varpool_encoder_lookup (varpool_encoder,
 				             ipa_ref_varpool_node (ref));
       gcc_assert (nref != LCC_NOT_FOUND);
-      lto_output_sleb128_stream (ob->main_stream, nref);
+      streamer_write_wide_int_stream (ob->main_stream, nref);
     }
 }
 
@@ -627,11 +626,11 @@ output_profile_summary (struct lto_simple_output_block *ob)
 	 GCC profile feedback and they are difficult to merge from multiple
 	 units.  */
       gcc_assert (profile_info->runs);
-      lto_output_uleb128_stream (ob->main_stream, profile_info->runs);
-      lto_output_uleb128_stream (ob->main_stream, profile_info->sum_max);
+      streamer_write_wide_uint_stream (ob->main_stream, profile_info->runs);
+      streamer_write_wide_uint_stream (ob->main_stream, profile_info->sum_max);
     }
   else
-    lto_output_uleb128_stream (ob->main_stream, 0);
+    streamer_write_wide_uint_stream (ob->main_stream, 0);
 }
 
 /* Add NODE into encoder as well as nodes it is cloned from.
@@ -709,15 +708,15 @@ output_refs (cgraph_node_set set, varpool_node_set vset,
       count = ipa_ref_list_nreferences (&node->ref_list);
       if (count)
 	{
-	  lto_output_uleb128_stream (ob->main_stream, count);
-	  lto_output_uleb128_stream (ob->main_stream,
+	  streamer_write_wide_uint_stream (ob->main_stream, count);
+	  streamer_write_wide_uint_stream (ob->main_stream,
 				     lto_cgraph_encoder_lookup (encoder, node));
 	  for (i = 0; ipa_ref_list_reference_iterate (&node->ref_list, i, ref); i++)
 	    lto_output_ref (ob, ref, encoder, varpool_encoder);
 	}
     }
 
-  lto_output_uleb128_stream (ob->main_stream, 0);
+  streamer_write_wide_uint_stream (ob->main_stream, 0);
 
   for (vsi = vsi_start (vset); !vsi_end_p (vsi); vsi_next (&vsi))
     {
@@ -726,8 +725,8 @@ output_refs (cgraph_node_set set, varpool_node_set vset,
       count = ipa_ref_list_nreferences (&node->ref_list);
       if (count)
 	{
-	  lto_output_uleb128_stream (ob->main_stream, count);
-	  lto_output_uleb128_stream (ob->main_stream,
+	  streamer_write_wide_uint_stream (ob->main_stream, count);
+	  streamer_write_wide_uint_stream (ob->main_stream,
 				     lto_varpool_encoder_lookup (varpool_encoder,
 								 node));
 	  for (i = 0; ipa_ref_list_reference_iterate (&node->ref_list, i, ref); i++)
@@ -735,7 +734,7 @@ output_refs (cgraph_node_set set, varpool_node_set vset,
 	}
     }
 
-  lto_output_uleb128_stream (ob->main_stream, 0);
+  streamer_write_wide_uint_stream (ob->main_stream, 0);
 
   lto_destroy_simple_output_block (ob);
 }
@@ -852,7 +851,7 @@ output_cgraph (cgraph_node_set set, varpool_node_set vset)
       output_outgoing_cgraph_edges (node->indirect_calls, ob, encoder);
     }
 
-  lto_output_uleb128_stream (ob->main_stream, 0);
+  streamer_write_wide_uint_stream (ob->main_stream, 0);
 
   /* Emit toplevel asms.
      When doing WPA we must output every asm just once.  Since we do not partition asm
@@ -864,14 +863,14 @@ output_cgraph (cgraph_node_set set, varpool_node_set vset)
       for (can = cgraph_asm_nodes; can; can = can->next)
 	{
 	  int len = TREE_STRING_LENGTH (can->asm_str);
-	  lto_output_uleb128_stream (ob->main_stream, len);
+	  streamer_write_wide_uint_stream (ob->main_stream, len);
 	  for (i = 0; i < len; ++i)
-	    lto_output_1_stream (ob->main_stream,
-				 TREE_STRING_POINTER (can->asm_str)[i]);
+	    streamer_write_char_stream (ob->main_stream,
+					TREE_STRING_POINTER (can->asm_str)[i]);
 	}
     }
 
-  lto_output_uleb128_stream (ob->main_stream, 0);
+  streamer_write_wide_uint_stream (ob->main_stream, 0);
 
   lto_destroy_simple_output_block (ob);
   output_varpool (set, vset);
@@ -938,7 +937,7 @@ output_varpool (cgraph_node_set set, varpool_node_set vset)
   lto_varpool_encoder_t varpool_encoder = ob->decl_state->varpool_node_encoder;
   int len = lto_varpool_encoder_size (varpool_encoder), i;
 
-  lto_output_uleb128_stream (ob->main_stream, len);
+  streamer_write_wide_uint_stream (ob->main_stream, len);
 
   /* Write out the nodes.  We must first output a node and then its clones,
      otherwise at a time reading back the node there would be nothing to clone
@@ -969,9 +968,9 @@ input_node (struct lto_file_decl_data *file_data,
   int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
   int clone_ref;
 
-  clone_ref = lto_input_sleb128 (ib);
+  clone_ref = streamer_read_wide_int (ib);
 
-  decl_index = lto_input_uleb128 (ib);
+  decl_index = streamer_read_wide_uint (ib);
   fn_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index);
 
   if (clone_ref != LCC_NOT_FOUND)
@@ -982,13 +981,13 @@ input_node (struct lto_file_decl_data *file_data,
   else
     node = cgraph_get_create_node (fn_decl);
 
-  node->count = lto_input_sleb128 (ib);
-  node->count_materialization_scale = lto_input_sleb128 (ib);
+  node->count = streamer_read_wide_int (ib);
+  node->count_materialization_scale = streamer_read_wide_int (ib);
 
   if (tag == LTO_cgraph_analyzed_node)
-    ref = lto_input_sleb128 (ib);
+    ref = streamer_read_wide_int (ib);
 
-  ref2 = lto_input_sleb128 (ib);
+  ref2 = streamer_read_wide_int (ib);
 
   /* Make sure that we have not read this node before.  Nodes that
      have already been read will have their tag stored in the 'aux'
@@ -998,7 +997,7 @@ input_node (struct lto_file_decl_data *file_data,
     internal_error ("bytecode stream: found multiple instances of cgraph "
 		    "node %d", node->uid);
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   input_overwrite_node (file_data, node, tag, &bp);
 
   /* Store a reference for now, and fix up later to be a pointer.  */
@@ -1009,9 +1008,9 @@ input_node (struct lto_file_decl_data *file_data,
 
   if (node->thunk.thunk_p)
     {
-      int type = lto_input_uleb128 (ib);
-      HOST_WIDE_INT fixed_offset = lto_input_uleb128 (ib);
-      HOST_WIDE_INT virtual_value = lto_input_uleb128 (ib);
+      int type = streamer_read_wide_uint (ib);
+      HOST_WIDE_INT fixed_offset = streamer_read_wide_uint (ib);
+      HOST_WIDE_INT virtual_value = streamer_read_wide_uint (ib);
 
       node->thunk.fixed_offset = fixed_offset;
       node->thunk.this_adjusting = (type & 2);
@@ -1020,9 +1019,9 @@ input_node (struct lto_file_decl_data *file_data,
     }
   if (node->thunk.thunk_p || node->alias)
     {
-      if (lto_input_int_in_range (ib, "alias nonzero flag", 0, 1))
+      if (streamer_read_wide_int_in_range (ib, "alias nonzero flag", 0, 1))
 	{
-          decl_index = lto_input_uleb128 (ib);
+          decl_index = streamer_read_wide_uint (ib);
           node->thunk.alias = lto_file_decl_data_get_fn_decl (file_data,
 							      decl_index);
 	}
@@ -1044,12 +1043,12 @@ input_varpool_node (struct lto_file_decl_data *file_data,
   int ref = LCC_NOT_FOUND;
   bool non_null_aliasof;
 
-  decl_index = lto_input_uleb128 (ib);
+  decl_index = streamer_read_wide_uint (ib);
   var_decl = lto_file_decl_data_get_var_decl (file_data, decl_index);
   node = varpool_node (var_decl);
   node->lto_file_data = file_data;
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   node->externally_visible = bp_unpack_value (&bp, 1);
   node->force_output = bp_unpack_value (&bp, 1);
   node->finalized = bp_unpack_value (&bp, 1);
@@ -1067,10 +1066,10 @@ input_varpool_node (struct lto_file_decl_data *file_data,
     varpool_mark_needed_node (node);
   if (non_null_aliasof)
     {
-      decl_index = lto_input_uleb128 (ib);
+      decl_index = streamer_read_wide_uint (ib);
       node->alias_of = lto_file_decl_data_get_var_decl (file_data, decl_index);
     }
-  ref = lto_input_sleb128 (ib);
+  ref = streamer_read_wide_int (ib);
   /* Store a reference for now, and fix up later to be a pointer.  */
   node->same_comdat_group = (struct varpool_node *) (intptr_t) ref;
   node->resolution = lto_input_enum (ib, ld_plugin_symbol_resolution,
@@ -1095,13 +1094,14 @@ input_ref (struct lto_input_block *ib,
   enum ipa_ref_type type;
   enum ipa_ref_use use;
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   type = (enum ipa_ref_type) bp_unpack_value (&bp, 1);
   use = (enum ipa_ref_use) bp_unpack_value (&bp, 2);
   if (type == IPA_REF_CGRAPH)
-    node = VEC_index (cgraph_node_ptr, nodes, lto_input_sleb128 (ib));
+    node = VEC_index (cgraph_node_ptr, nodes, streamer_read_wide_int (ib));
   else
-    varpool_node = VEC_index (varpool_node_ptr, varpool_nodes, lto_input_sleb128 (ib));
+    varpool_node = VEC_index (varpool_node_ptr, varpool_nodes,
+			      streamer_read_wide_int (ib));
   ipa_record_reference (refering_node, refering_varpool_node,
 		        node, varpool_node, use, NULL);
 }
@@ -1124,22 +1124,22 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes,
   struct bitpack_d bp;
   int ecf_flags = 0;
 
-  caller = VEC_index (cgraph_node_ptr, nodes, lto_input_sleb128 (ib));
+  caller = VEC_index (cgraph_node_ptr, nodes, streamer_read_wide_int (ib));
   if (caller == NULL || caller->decl == NULL_TREE)
     internal_error ("bytecode stream: no caller found while reading edge");
 
   if (!indirect)
     {
-      callee = VEC_index (cgraph_node_ptr, nodes, lto_input_sleb128 (ib));
+      callee = VEC_index (cgraph_node_ptr, nodes, streamer_read_wide_int (ib));
       if (callee == NULL || callee->decl == NULL_TREE)
 	internal_error ("bytecode stream: no callee found while reading edge");
     }
   else
     callee = NULL;
 
-  count = (gcov_type) lto_input_sleb128 (ib);
+  count = (gcov_type) streamer_read_wide_int (ib);
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   inline_failed = bp_unpack_enum (&bp, cgraph_inline_failed_enum, CIF_N_REASONS);
   stmt_id = bp_unpack_var_len_unsigned (&bp);
   freq = (int) bp_unpack_var_len_unsigned (&bp);
@@ -1205,16 +1205,16 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
     }
 
   /* Input toplevel asms.  */
-  len = lto_input_uleb128 (ib);
+  len = streamer_read_wide_uint (ib);
   while (len)
     {
       char *str = (char *)xmalloc (len + 1);
       for (i = 0; i < len; ++i)
-	str[i] = lto_input_1_unsigned (ib);
+	str[i] = streamer_read_uchar (ib);
       cgraph_add_asm_node (build_string (len, str));
       free (str);
 
-      len = lto_input_uleb128 (ib);
+      len = streamer_read_wide_uint (ib);
     }
   /* AUX pointers should be all non-zero for nodes read from the stream.  */
 #ifdef ENABLE_CHECKING
@@ -1260,7 +1260,7 @@ input_varpool_1 (struct lto_file_decl_data *file_data,
   int i;
   struct varpool_node *node;
 
-  len = lto_input_uleb128 (ib);
+  len = streamer_read_wide_uint (ib);
   while (len)
     {
       VEC_safe_push (varpool_node_ptr, heap, varpool,
@@ -1302,10 +1302,10 @@ input_refs (struct lto_input_block *ib,
   while (true)
     {
       struct cgraph_node *node;
-      count = lto_input_uleb128 (ib);
+      count = streamer_read_wide_uint (ib);
       if (!count)
 	break;
-      idx = lto_input_uleb128 (ib);
+      idx = streamer_read_wide_uint (ib);
       node = VEC_index (cgraph_node_ptr, nodes, idx);
       while (count)
 	{
@@ -1316,10 +1316,11 @@ input_refs (struct lto_input_block *ib,
   while (true)
     {
       struct varpool_node *node;
-      count = lto_input_uleb128 (ib);
+      count = streamer_read_wide_uint (ib);
       if (!count)
 	break;
-      node = VEC_index (varpool_node_ptr, varpool, lto_input_uleb128 (ib));
+      node = VEC_index (varpool_node_ptr, varpool,
+			streamer_read_wide_uint (ib));
       while (count)
 	{
 	  input_ref (ib, NULL, node, nodes, varpool);
@@ -1336,11 +1337,11 @@ static void
 input_profile_summary (struct lto_input_block *ib,
 		       struct lto_file_decl_data *file_data)
 {
-  unsigned int runs = lto_input_uleb128 (ib);
+  unsigned int runs = streamer_read_wide_uint (ib);
   if (runs)
     {
       file_data->profile_info.runs = runs;
-      file_data->profile_info.sum_max = lto_input_uleb128 (ib);
+      file_data->profile_info.sum_max = streamer_read_wide_uint (ib);
     }
 
 }
@@ -1528,10 +1529,9 @@ output_edge_opt_summary (struct output_block *ob,
 			 struct cgraph_edge *edge)
 {
   if (edge->indirect_info)
-    lto_output_sleb128_stream (ob->main_stream,
-			       edge->indirect_info->thunk_delta);
+    streamer_write_wide_int (ob, edge->indirect_info->thunk_delta);
   else
-    lto_output_sleb128_stream (ob->main_stream, 0);
+    streamer_write_wide_int (ob, 0);
 }
 
 /* Output optimization summary for NODE to OB.  */
@@ -1550,24 +1550,25 @@ output_node_opt_summary (struct output_block *ob,
 
   if (node->clone.args_to_skip)
     {
-      lto_output_uleb128_stream (ob->main_stream,
-				 bitmap_count_bits (node->clone.args_to_skip));
+      streamer_write_wide_uint (ob,
+				bitmap_count_bits (node->clone.args_to_skip));
       EXECUTE_IF_SET_IN_BITMAP (node->clone.args_to_skip, 0, index, bi)
-	lto_output_uleb128_stream (ob->main_stream, index);
+	streamer_write_wide_uint (ob, index);
     }
   else
-    lto_output_uleb128_stream (ob->main_stream, 0);
+    streamer_write_wide_uint (ob, 0);
   if (node->clone.combined_args_to_skip)
     {
-      lto_output_uleb128_stream (ob->main_stream,
+      streamer_write_wide_uint (ob,
 				 bitmap_count_bits (node->clone.combined_args_to_skip));
       EXECUTE_IF_SET_IN_BITMAP (node->clone.combined_args_to_skip, 0, index, bi)
-	lto_output_uleb128_stream (ob->main_stream, index);
+	streamer_write_wide_uint (ob, index);
     }
   else
-    lto_output_uleb128_stream (ob->main_stream, 0);
-  lto_output_uleb128_stream (ob->main_stream,
-		             VEC_length (ipa_replace_map_p, node->clone.tree_map));
+    streamer_write_wide_uint (ob, 0);
+  streamer_write_wide_uint (ob,
+		            VEC_length (ipa_replace_map_p,
+			                node->clone.tree_map));
   FOR_EACH_VEC_ELT (ipa_replace_map_p, node->clone.tree_map, i, map)
     {
       int parm_num;
@@ -1580,12 +1581,12 @@ output_node_opt_summary (struct output_block *ob,
       /* At the moment we assume all old trees to be PARM_DECLs, because we have no
          mechanism to store function local declarations into summaries.  */
       gcc_assert (parm);
-      lto_output_uleb128_stream (ob->main_stream, parm_num);
+      streamer_write_wide_uint (ob, parm_num);
       stream_write_tree (ob, map->new_tree, true);
       bp = bitpack_create (ob->main_stream);
       bp_pack_value (&bp, map->replace_p, 1);
       bp_pack_value (&bp, map->ref_p, 1);
-      lto_output_bitpack (&bp);
+      streamer_write_bitpack (&bp);
     }
 
   if (cgraph_node_in_set_p (node, set))
@@ -1616,13 +1617,13 @@ output_cgraph_opt_summary (cgraph_node_set set)
     if (output_cgraph_opt_summary_p (lto_cgraph_encoder_deref (encoder, i),
 				     set))
       count++;
-  lto_output_uleb128_stream (ob->main_stream, count);
+  streamer_write_wide_uint (ob, count);
   for (i = 0; i < n_nodes; i++)
     {
       node = lto_cgraph_encoder_deref (encoder, i);
       if (output_cgraph_opt_summary_p (node, set))
 	{
-	  lto_output_uleb128_stream (ob->main_stream, i);
+	  streamer_write_wide_uint (ob, i);
 	  output_node_opt_summary (ob, node, set);
 	}
     }
@@ -1637,7 +1638,7 @@ input_edge_opt_summary (struct cgraph_edge *edge,
 			struct lto_input_block *ib_main)
 {
   HOST_WIDE_INT thunk_delta;
-  thunk_delta = lto_input_sleb128 (ib_main);
+  thunk_delta = streamer_read_wide_int (ib_main);
   if (thunk_delta != 0)
     {
       gcc_assert (!edge->indirect_info);
@@ -1659,23 +1660,23 @@ input_node_opt_summary (struct cgraph_node *node,
   struct bitpack_d bp;
   struct cgraph_edge *e;
 
-  count = lto_input_uleb128 (ib_main);
+  count = streamer_read_wide_uint (ib_main);
   if (count)
     node->clone.args_to_skip = BITMAP_GGC_ALLOC ();
   for (i = 0; i < count; i++)
     {
-      bit = lto_input_uleb128 (ib_main);
+      bit = streamer_read_wide_uint (ib_main);
       bitmap_set_bit (node->clone.args_to_skip, bit);
     }
-  count = lto_input_uleb128 (ib_main);
+  count = streamer_read_wide_uint (ib_main);
   if (count)
     node->clone.combined_args_to_skip = BITMAP_GGC_ALLOC ();
   for (i = 0; i < count; i++)
     {
-      bit = lto_input_uleb128 (ib_main);
+      bit = streamer_read_wide_uint (ib_main);
       bitmap_set_bit (node->clone.combined_args_to_skip, bit);
     }
-  count = lto_input_uleb128 (ib_main);
+  count = streamer_read_wide_uint (ib_main);
   for (i = 0; i < count; i++)
     {
       int parm_num;
@@ -1686,10 +1687,10 @@ input_node_opt_summary (struct cgraph_node *node,
       for (parm_num = 0, parm = DECL_ARGUMENTS (node->decl); parm_num;
 	   parm = DECL_CHAIN (parm))
 	parm_num --;
-      map->parm_num = lto_input_uleb128 (ib_main);
+      map->parm_num = streamer_read_wide_uint (ib_main);
       map->old_tree = NULL;
       map->new_tree = stream_read_tree (ib_main, data_in);
-      bp = lto_input_bitpack (ib_main);
+      bp = streamer_read_bitpack (ib_main);
       map->replace_p = bp_unpack_value (&bp, 1);
       map->ref_p = bp_unpack_value (&bp, 1);
     }
@@ -1722,11 +1723,11 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data,
   data_in =
     lto_data_in_create (file_data, (const char *) data + string_offset,
 			header->string_size, NULL);
-  count = lto_input_uleb128 (&ib_main);
+  count = streamer_read_wide_uint (&ib_main);
 
   for (i = 0; i < count; i++)
     {
-      int ref = lto_input_uleb128 (&ib_main);
+      int ref = streamer_read_wide_uint (&ib_main);
       input_node_opt_summary (VEC_index (cgraph_node_ptr, nodes, ref),
 			      &ib_main, data_in);
     }
diff --git a/gcc/lto-section-out.c b/gcc/lto-section-out.c
index 7f44d6e..33ab122 100644
--- a/gcc/lto-section-out.c
+++ b/gcc/lto-section-out.c
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "pointer-set.h"
 #include "bitmap.h"
 #include "langhooks.h"
+#include "data-streamer.h"
 #include "lto-streamer.h"
 #include "lto-compress.h"
 
@@ -303,7 +304,7 @@ lto_output_decl_index (struct lto_output_stream *obs,
     }
 
   if (obs)
-    lto_output_uleb128_stream (obs, index);
+    streamer_write_wide_uint_stream (obs, index);
   *this_index = index;
   return new_entry_p;
 }
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index e43ff28..dc4bdb8 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -87,7 +87,7 @@ lto_input_data_block (struct lto_input_block *ib, void *addr, size_t length)
   unsigned char *const buffer = (unsigned char *const) addr;
 
   for (i = 0; i < length; i++)
-    buffer[i] = lto_input_1_unsigned (ib);
+    buffer[i] = streamer_read_uchar (ib);
 }
 
 
@@ -194,7 +194,7 @@ lto_input_location (struct lto_input_block *ib, struct data_in *data_in)
     {
       struct bitpack_d bp;
 
-      bp = lto_input_bitpack (ib);
+      bp = streamer_read_bitpack (ib);
       return lto_input_location_bitpack (data_in, &bp);
     }
 }
@@ -219,32 +219,32 @@ lto_input_tree_ref (struct lto_input_block *ib, struct data_in *data_in,
   switch (tag)
     {
     case LTO_type_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = lto_file_decl_data_get_type (data_in->file_data, ix_u);
       break;
 
     case LTO_ssa_name_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = VEC_index (tree, SSANAMES (fn), ix_u);
       break;
 
     case LTO_field_decl_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = lto_file_decl_data_get_field_decl (data_in->file_data, ix_u);
       break;
 
     case LTO_function_decl_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = lto_file_decl_data_get_fn_decl (data_in->file_data, ix_u);
       break;
 
     case LTO_type_decl_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = lto_file_decl_data_get_type_decl (data_in->file_data, ix_u);
       break;
 
     case LTO_namespace_decl_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = lto_file_decl_data_get_namespace_decl (data_in->file_data, ix_u);
       break;
 
@@ -254,7 +254,7 @@ lto_input_tree_ref (struct lto_input_block *ib, struct data_in *data_in,
     case LTO_imported_decl_ref:
     case LTO_label_decl_ref:
     case LTO_translation_unit_decl_ref:
-      ix_u = lto_input_uleb128 (ib);
+      ix_u = streamer_read_wide_uint (ib);
       result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u);
       break;
 
@@ -279,7 +279,7 @@ lto_input_eh_catch_list (struct lto_input_block *ib, struct data_in *data_in,
   enum LTO_tags tag;
 
   *last_p = first = NULL;
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   while (tag)
     {
       tree list;
@@ -307,7 +307,7 @@ lto_input_eh_catch_list (struct lto_input_block *ib, struct data_in *data_in,
       if (first == NULL)
 	first = n;
 
-      tag = input_record_start (ib);
+      tag = streamer_read_record_start (ib);
     }
 
   return first;
@@ -324,20 +324,20 @@ input_eh_region (struct lto_input_block *ib, struct data_in *data_in, int ix)
   eh_region r;
 
   /* Read the region header.  */
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   if (tag == LTO_null)
     return NULL;
 
   r = ggc_alloc_cleared_eh_region_d ();
-  r->index = lto_input_sleb128 (ib);
+  r->index = streamer_read_wide_int (ib);
 
   gcc_assert (r->index == ix);
 
   /* Read all the region pointers as region numbers.  We'll fix up
      the pointers once the whole array has been read.  */
-  r->outer = (eh_region) (intptr_t) lto_input_sleb128 (ib);
-  r->inner = (eh_region) (intptr_t) lto_input_sleb128 (ib);
-  r->next_peer = (eh_region) (intptr_t) lto_input_sleb128 (ib);
+  r->outer = (eh_region) (intptr_t) streamer_read_wide_int (ib);
+  r->inner = (eh_region) (intptr_t) streamer_read_wide_int (ib);
+  r->next_peer = (eh_region) (intptr_t) streamer_read_wide_int (ib);
 
   switch (tag)
     {
@@ -362,7 +362,7 @@ input_eh_region (struct lto_input_block *ib, struct data_in *data_in, int ix)
 	  r->type = ERT_ALLOWED_EXCEPTIONS;
 	  r->u.allowed.type_list = stream_read_tree (ib, data_in);
 	  r->u.allowed.label = stream_read_tree (ib, data_in);
-	  r->u.allowed.filter = lto_input_uleb128 (ib);
+	  r->u.allowed.filter = streamer_read_wide_uint (ib);
 
 	  for (l = r->u.allowed.type_list; l ; l = TREE_CHAIN (l))
 	    add_type_for_runtime (TREE_VALUE (l));
@@ -379,7 +379,7 @@ input_eh_region (struct lto_input_block *ib, struct data_in *data_in, int ix)
 	gcc_unreachable ();
     }
 
-  r->landing_pads = (eh_landing_pad) (intptr_t) lto_input_sleb128 (ib);
+  r->landing_pads = (eh_landing_pad) (intptr_t) streamer_read_wide_int (ib);
 
   return r;
 }
@@ -395,17 +395,17 @@ input_eh_lp (struct lto_input_block *ib, struct data_in *data_in, int ix)
   eh_landing_pad lp;
 
   /* Read the landing pad header.  */
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   if (tag == LTO_null)
     return NULL;
 
   lto_tag_check_range (tag, LTO_eh_landing_pad, LTO_eh_landing_pad);
 
   lp = ggc_alloc_cleared_eh_landing_pad_d ();
-  lp->index = lto_input_sleb128 (ib);
+  lp->index = streamer_read_wide_int (ib);
   gcc_assert (lp->index == ix);
-  lp->next_lp = (eh_landing_pad) (intptr_t) lto_input_sleb128 (ib);
-  lp->region = (eh_region) (intptr_t) lto_input_sleb128 (ib);
+  lp->next_lp = (eh_landing_pad) (intptr_t) streamer_read_wide_int (ib);
+  lp->region = (eh_region) (intptr_t) streamer_read_wide_int (ib);
   lp->post_landing_pad = stream_read_tree (ib, data_in);
 
   return lp;
@@ -501,7 +501,7 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
   HOST_WIDE_INT i, root_region, len;
   enum LTO_tags tag;
 
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   if (tag == LTO_null)
     return;
 
@@ -514,11 +514,11 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
 
   gcc_assert (fn->eh);
 
-  root_region = lto_input_sleb128 (ib);
+  root_region = streamer_read_wide_int (ib);
   gcc_assert (root_region == (int) root_region);
 
   /* Read the EH region array.  */
-  len = lto_input_sleb128 (ib);
+  len = streamer_read_wide_int (ib);
   gcc_assert (len == (int) len);
   if (len > 0)
     {
@@ -531,7 +531,7 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
     }
 
   /* Read the landing pads.  */
-  len = lto_input_sleb128 (ib);
+  len = streamer_read_wide_int (ib);
   gcc_assert (len == (int) len);
   if (len > 0)
     {
@@ -544,7 +544,7 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
     }
 
   /* Read the runtime type data.  */
-  len = lto_input_sleb128 (ib);
+  len = streamer_read_wide_int (ib);
   gcc_assert (len == (int) len);
   if (len > 0)
     {
@@ -557,7 +557,7 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
     }
 
   /* Read the table of action chains.  */
-  len = lto_input_sleb128 (ib);
+  len = streamer_read_wide_int (ib);
   gcc_assert (len == (int) len);
   if (len > 0)
     {
@@ -575,7 +575,7 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
 	  VEC_safe_grow (uchar, gc, fn->eh->ehspec_data.other, len);
 	  for (i = 0; i < len; i++)
 	    {
-	      uchar c = lto_input_1_unsigned (ib);
+	      uchar c = streamer_read_uchar (ib);
 	      VEC_replace (uchar, fn->eh->ehspec_data.other, i, c);
 	    }
 	}
@@ -585,7 +585,7 @@ input_eh_regions (struct lto_input_block *ib, struct data_in *data_in,
      pointers.  */
   fixup_eh_region_pointers (fn, root_region);
 
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   lto_tag_check_range (tag, LTO_null, LTO_null);
 }
 
@@ -622,7 +622,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
 
   profile_status_for_function (fn) = lto_input_enum (ib, profile_status_d, PROFILE_LAST);
 
-  bb_count = lto_input_uleb128 (ib);
+  bb_count = streamer_read_wide_uint (ib);
 
   last_basic_block_for_function (fn) = bb_count;
   if (bb_count > VEC_length (basic_block, basic_block_info_for_function (fn)))
@@ -633,7 +633,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
     VEC_safe_grow_cleared (basic_block, gc,
 			   label_to_block_map_for_function (fn), bb_count);
 
-  index = lto_input_sleb128 (ib);
+  index = streamer_read_wide_int (ib);
   while (index != -1)
     {
       basic_block bb = BASIC_BLOCK_FOR_FUNCTION (fn, index);
@@ -642,7 +642,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
       if (bb == NULL)
 	bb = make_new_block (fn, index);
 
-      edge_count = lto_input_uleb128 (ib);
+      edge_count = streamer_read_wide_uint (ib);
 
       /* Connect up the CFG.  */
       for (i = 0; i < edge_count; i++)
@@ -654,11 +654,11 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
 	  gcov_type count;
 	  edge e;
 
-	  dest_index = lto_input_uleb128 (ib);
-	  probability = (int) lto_input_sleb128 (ib);
-	  count = ((gcov_type) lto_input_sleb128 (ib) * count_materialization_scale
+	  dest_index = streamer_read_wide_uint (ib);
+	  probability = (int) streamer_read_wide_int (ib);
+	  count = ((gcov_type) streamer_read_wide_int (ib) * count_materialization_scale
 		   + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
-	  edge_flags = lto_input_uleb128 (ib);
+	  edge_flags = streamer_read_wide_uint (ib);
 
 	  dest = BASIC_BLOCK_FOR_FUNCTION (fn, dest_index);
 
@@ -670,18 +670,18 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
 	  e->count = count;
 	}
 
-      index = lto_input_sleb128 (ib);
+      index = streamer_read_wide_int (ib);
     }
 
   p_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(fn);
-  index = lto_input_sleb128 (ib);
+  index = streamer_read_wide_int (ib);
   while (index != -1)
     {
       basic_block bb = BASIC_BLOCK_FOR_FUNCTION (fn, index);
       bb->prev_bb = p_bb;
       p_bb->next_bb = bb;
       p_bb = bb;
-      index = lto_input_sleb128 (ib);
+      index = streamer_read_wide_int (ib);
     }
 }
 
@@ -695,10 +695,10 @@ input_ssa_names (struct lto_input_block *ib, struct data_in *data_in,
 {
   unsigned int i, size;
 
-  size = lto_input_uleb128 (ib);
+  size = streamer_read_wide_uint (ib);
   init_ssanames (fn, size);
 
-  i = lto_input_uleb128 (ib);
+  i = streamer_read_wide_uint (ib);
   while (i)
     {
       tree ssa_name, name;
@@ -708,14 +708,14 @@ input_ssa_names (struct lto_input_block *ib, struct data_in *data_in,
       while (VEC_length (tree, SSANAMES (fn)) < i)
 	VEC_quick_push (tree, SSANAMES (fn), NULL_TREE);
 
-      is_default_def = (lto_input_1_unsigned (ib) != 0);
+      is_default_def = (streamer_read_uchar (ib) != 0);
       name = stream_read_tree (ib, data_in);
       ssa_name = make_ssa_name_fn (fn, name, gimple_build_nop ());
 
       if (is_default_def)
 	set_default_def (SSA_NAME_VAR (ssa_name), ssa_name);
 
-      i = lto_input_uleb128 (ib);
+      i = streamer_read_wide_uint (ib);
     }
 }
 
@@ -787,7 +787,7 @@ input_struct_function_base (struct function *fn, struct data_in *data_in,
   fn->nonlocal_goto_save_area = stream_read_tree (ib, data_in);
 
   /* Read all the local symbols.  */
-  len = lto_input_sleb128 (ib);
+  len = streamer_read_wide_int (ib);
   if (len > 0)
     {
       int i;
@@ -810,10 +810,10 @@ input_struct_function_base (struct function *fn, struct data_in *data_in,
   fn->function_end_locus = lto_input_location (ib, data_in);
 
   /* Input the current IL state of the function.  */
-  fn->curr_properties = lto_input_uleb128 (ib);
+  fn->curr_properties = streamer_read_wide_uint (ib);
 
   /* Read all the attributes for FN.  */
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   fn->is_thunk = bp_unpack_value (&bp, 1);
   fn->has_local_explicit_reg_vars = bp_unpack_value (&bp, 1);
   fn->after_tree_profile = bp_unpack_value (&bp, 1);
@@ -845,7 +845,7 @@ input_function (tree fn_decl, struct data_in *data_in,
   tree args, narg, oarg;
 
   fn = DECL_STRUCT_FUNCTION (fn_decl);
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   clear_line_info (data_in);
 
   gimple_register_cfg_hooks ();
@@ -862,10 +862,10 @@ input_function (tree fn_decl, struct data_in *data_in,
     {
       unsigned ix;
       bool res;
-      res = lto_streamer_cache_lookup (data_in->reader_cache, oarg, &ix);
+      res = streamer_tree_cache_lookup (data_in->reader_cache, oarg, &ix);
       gcc_assert (res);
       /* Replace the argument in the streamer cache.  */
-      lto_streamer_cache_insert_at (data_in->reader_cache, narg, ix);
+      streamer_tree_cache_insert_at (data_in->reader_cache, narg, ix);
     }
   gcc_assert (!oarg && !narg);
 
@@ -882,12 +882,12 @@ input_function (tree fn_decl, struct data_in *data_in,
   node = cgraph_get_create_node (fn_decl);
 
   /* Read all the basic blocks.  */
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   while (tag)
     {
       input_bb (ib, tag, data_in, fn,
 		node->count_materialization_scale);
-      tag = input_record_start (ib);
+      tag = streamer_read_record_start (ib);
     }
 
   /* Fix up the call statements that are mentioned in the callgraph
@@ -1089,20 +1089,20 @@ lto_read_tree (struct lto_input_block *ib, struct data_in *data_in,
 	       enum LTO_tags tag)
 {
   /* Instantiate a new tree node.  */
-  tree result = lto_materialize_tree (ib, data_in, tag);
+  tree result = streamer_alloc_tree (ib, data_in, tag);
 
   /* Enter RESULT in the reader cache.  This will make RESULT
      available so that circular references in the rest of the tree
      structure can be resolved in subsequent calls to stream_read_tree.  */
-  lto_streamer_cache_append (data_in->reader_cache, result);
+  streamer_tree_cache_append (data_in->reader_cache, result);
 
   /* Read all the bitfield values in RESULT.  Note that for LTO, we
      only write language-independent bitfields, so no more unpacking is
      needed.  */
-  tree_read_bitfields (ib, result);
+  streamer_read_tree_bitfields (ib, result);
 
   /* Read all the pointer fields in RESULT.  */
-  lto_input_tree_pointers (ib, data_in, result);
+  streamer_read_tree_body (ib, data_in, result);
 
   /* Read any LTO-specific data not read by the tree streamer.  */
   if (DECL_P (result)
@@ -1112,13 +1112,13 @@ lto_read_tree (struct lto_input_block *ib, struct data_in *data_in,
 
   /* We should never try to instantiate an MD or NORMAL builtin here.  */
   if (TREE_CODE (result) == FUNCTION_DECL)
-    gcc_assert (!lto_stream_as_builtin_p (result));
+    gcc_assert (!streamer_handle_as_builtin_p (result));
 
-  /* end_marker = */ lto_input_1_unsigned (ib);
+  /* end_marker = */ streamer_read_uchar (ib);
 
 #ifdef LTO_STREAMER_DEBUG
   /* Remove the mapping to RESULT's original address set by
-     lto_materialize_tree.  */
+     streamer_alloc_tree.  */
   lto_orig_address_remove (result);
 #endif
 
@@ -1136,7 +1136,7 @@ lto_input_tree (struct lto_input_block *ib, struct data_in *data_in)
   enum LTO_tags tag;
   tree result;
 
-  tag = input_record_start (ib);
+  tag = streamer_read_record_start (ib);
   gcc_assert ((unsigned) tag < (unsigned) LTO_NUM_TAGS);
 
   if (tag == LTO_null)
@@ -1152,19 +1152,19 @@ lto_input_tree (struct lto_input_block *ib, struct data_in *data_in)
     {
       /* If TAG is a reference to a previously read tree, look it up in
 	 the reader cache.  */
-      result = lto_get_pickled_tree (ib, data_in);
+      result = streamer_get_pickled_tree (ib, data_in);
     }
   else if (tag == LTO_builtin_decl)
     {
       /* If we are going to read a built-in function, all we need is
 	 the code and class.  */
-      result = lto_get_builtin_tree (ib, data_in);
+      result = streamer_get_builtin_tree (ib, data_in);
     }
   else if (tag == lto_tree_code_to_tag (INTEGER_CST))
     {
       /* For integer constants we only need the type and its hi/low
 	 words.  */
-      result = lto_input_integer_cst (ib, data_in);
+      result = streamer_read_integer_cst (ib, data_in);
     }
   else
     {
@@ -1201,7 +1201,7 @@ lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings,
   data_in->strings = strings;
   data_in->strings_len = len;
   data_in->globals_resolution = resolutions;
-  data_in->reader_cache = lto_streamer_cache_create ();
+  data_in->reader_cache = streamer_tree_cache_create ();
 
   return data_in;
 }
@@ -1213,7 +1213,7 @@ void
 lto_data_in_delete (struct data_in *data_in)
 {
   VEC_free (ld_plugin_symbol_resolution_t, heap, data_in->globals_resolution);
-  lto_streamer_cache_delete (data_in->reader_cache);
+  streamer_tree_cache_delete (data_in->reader_cache);
   free (data_in->labels);
   free (data_in);
 }
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index cfd3365..2f975c4 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -70,7 +70,7 @@ create_output_block (enum lto_section_type section_type)
   ob->decl_state = lto_get_out_decl_state ();
   ob->main_stream = XCNEW (struct lto_output_stream);
   ob->string_stream = XCNEW (struct lto_output_stream);
-  ob->writer_cache = lto_streamer_cache_create ();
+  ob->writer_cache = streamer_tree_cache_create ();
 
   if (section_type == LTO_section_function_body)
     ob->cfg_stream = XCNEW (struct lto_output_stream);
@@ -99,7 +99,7 @@ destroy_output_block (struct output_block *ob)
   if (section_type == LTO_section_function_body)
     free (ob->cfg_stream);
 
-  lto_streamer_cache_delete (ob->writer_cache);
+  streamer_tree_cache_delete (ob->writer_cache);
   obstack_free (&ob->obstack, NULL);
 
   free (ob);
@@ -111,7 +111,7 @@ destroy_output_block (struct output_block *ob)
 static void
 output_type_ref (struct output_block *ob, tree node)
 {
-  output_record_start (ob, LTO_type_ref);
+  streamer_write_record_start (ob, LTO_type_ref);
   lto_output_type_ref_index (ob->decl_state, ob->main_stream, node);
 }
 
@@ -153,10 +153,10 @@ lto_output_location_bitpack (struct bitpack_d *bp,
 
   bp_pack_value (bp, ob->current_file != xloc.file, 1);
   if (ob->current_file != xloc.file)
-    bp_pack_var_len_unsigned (bp, lto_string_index (ob,
-					            xloc.file,
-						    strlen (xloc.file) + 1,
-						    true));
+    bp_pack_var_len_unsigned (bp,
+	                      streamer_string_index (ob, xloc.file,
+						     strlen (xloc.file) + 1,
+						     true));
   ob->current_file = xloc.file;
 
   bp_pack_value (bp, ob->current_line != xloc.line, 1);
@@ -185,7 +185,7 @@ lto_output_location (struct output_block *ob, location_t loc)
     {
       struct bitpack_d bp = bitpack_create (ob->main_stream);
       lto_output_location_bitpack (&bp, ob, loc);
-      lto_output_bitpack (&bp);
+      streamer_write_bitpack (&bp);
     }
 }
 
@@ -209,60 +209,60 @@ lto_output_tree_ref (struct output_block *ob, tree expr)
   switch (code)
     {
     case SSA_NAME:
-      output_record_start (ob, LTO_ssa_name_ref);
-      output_uleb128 (ob, SSA_NAME_VERSION (expr));
+      streamer_write_record_start (ob, LTO_ssa_name_ref);
+      streamer_write_wide_uint (ob, SSA_NAME_VERSION (expr));
       break;
 
     case FIELD_DECL:
-      output_record_start (ob, LTO_field_decl_ref);
+      streamer_write_record_start (ob, LTO_field_decl_ref);
       lto_output_field_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case FUNCTION_DECL:
-      output_record_start (ob, LTO_function_decl_ref);
+      streamer_write_record_start (ob, LTO_function_decl_ref);
       lto_output_fn_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case VAR_DECL:
     case DEBUG_EXPR_DECL:
       gcc_assert (decl_function_context (expr) == NULL || TREE_STATIC (expr));
-      output_record_start (ob, LTO_global_decl_ref);
+      streamer_write_record_start (ob, LTO_global_decl_ref);
       lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case CONST_DECL:
-      output_record_start (ob, LTO_const_decl_ref);
+      streamer_write_record_start (ob, LTO_const_decl_ref);
       lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case IMPORTED_DECL:
       gcc_assert (decl_function_context (expr) == NULL);
-      output_record_start (ob, LTO_imported_decl_ref);
+      streamer_write_record_start (ob, LTO_imported_decl_ref);
       lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case TYPE_DECL:
-      output_record_start (ob, LTO_type_decl_ref);
+      streamer_write_record_start (ob, LTO_type_decl_ref);
       lto_output_type_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case NAMESPACE_DECL:
-      output_record_start (ob, LTO_namespace_decl_ref);
+      streamer_write_record_start (ob, LTO_namespace_decl_ref);
       lto_output_namespace_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case LABEL_DECL:
-      output_record_start (ob, LTO_label_decl_ref);
+      streamer_write_record_start (ob, LTO_label_decl_ref);
       lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case RESULT_DECL:
-      output_record_start (ob, LTO_result_decl_ref);
+      streamer_write_record_start (ob, LTO_result_decl_ref);
       lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
     case TRANSLATION_UNIT_DECL:
-      output_record_start (ob, LTO_translation_unit_decl_ref);
+      streamer_write_record_start (ob, LTO_translation_unit_decl_ref);
       lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
       break;
 
@@ -317,16 +317,16 @@ lto_write_tree (struct output_block *ob, tree expr, bool ref_p)
 
   /* Write the header, containing everything needed to materialize
      EXPR on the reading side.  */
-  lto_output_tree_header (ob, expr);
+  streamer_write_tree_header (ob, expr);
 
   /* Pack all the non-pointer fields in EXPR into a bitpack and write
      the resulting bitpack.  */
   bp = bitpack_create (ob->main_stream);
-  pack_value_fields (&bp, expr);
-  lto_output_bitpack (&bp);
+  streamer_pack_tree_bitfields (&bp, expr);
+  streamer_write_bitpack (&bp);
 
   /* Write all the pointer fields in EXPR.  */
-  lto_output_tree_pointers (ob, expr, ref_p);
+  streamer_write_tree_body (ob, expr, ref_p);
 
   /* Write any LTO-specific data to OB.  */
   if (DECL_P (expr)
@@ -355,7 +355,7 @@ lto_write_tree (struct output_block *ob, tree expr, bool ref_p)
     }
 
   /* Mark the end of EXPR.  */
-  output_zero (ob);
+  streamer_write_zero (ob);
 }
 
 
@@ -371,7 +371,7 @@ lto_output_tree (struct output_block *ob, tree expr, bool ref_p)
 
   if (expr == NULL_TREE)
     {
-      output_record_start (ob, LTO_null);
+      streamer_write_record_start (ob, LTO_null);
       return;
     }
 
@@ -385,29 +385,29 @@ lto_output_tree (struct output_block *ob, tree expr, bool ref_p)
      to be materialized by the reader (to implement TYPE_CACHED_VALUES).  */
   if (TREE_CODE (expr) == INTEGER_CST)
     {
-      lto_output_integer_cst (ob, expr, ref_p);
+      streamer_write_integer_cst (ob, expr, ref_p);
       return;
     }
 
-  existed_p = lto_streamer_cache_insert (ob->writer_cache, expr, &ix);
+  existed_p = streamer_tree_cache_insert (ob->writer_cache, expr, &ix);
   if (existed_p)
     {
       /* If a node has already been streamed out, make sure that
 	 we don't write it more than once.  Otherwise, the reader
 	 will instantiate two different nodes for the same object.  */
-      output_record_start (ob, LTO_tree_pickle_reference);
-      output_uleb128 (ob, ix);
-      lto_output_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS,
-		       lto_tree_code_to_tag (TREE_CODE (expr)));
+      streamer_write_record_start (ob, LTO_tree_pickle_reference);
+      streamer_write_wide_uint (ob, ix);
+      streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS,
+			   lto_tree_code_to_tag (TREE_CODE (expr)));
     }
-  else if (lto_stream_as_builtin_p (expr))
+  else if (streamer_handle_as_builtin_p (expr))
     {
       /* MD and NORMAL builtins do not need to be written out
 	 completely as they are always instantiated by the
 	 compiler on startup.  The only builtins that need to
 	 be written out are BUILT_IN_FRONTEND.  For all other
 	 builtins, we simply write the class and code.  */
-      lto_output_builtin_tree (ob, expr);
+      streamer_write_builtin (ob, expr);
     }
   else
     {
@@ -427,13 +427,13 @@ output_eh_try_list (struct output_block *ob, eh_catch first)
 
   for (n = first; n; n = n->next_catch)
     {
-      output_record_start (ob, LTO_eh_catch);
+      streamer_write_record_start (ob, LTO_eh_catch);
       stream_write_tree (ob, n->type_list, true);
       stream_write_tree (ob, n->filter_list, true);
       stream_write_tree (ob, n->label, true);
     }
 
-  output_record_start (ob, LTO_null);
+  streamer_write_record_start (ob, LTO_null);
 }
 
 
@@ -448,7 +448,7 @@ output_eh_region (struct output_block *ob, eh_region r)
 
   if (r == NULL)
     {
-      output_record_start (ob, LTO_null);
+      streamer_write_record_start (ob, LTO_null);
       return;
     }
 
@@ -463,23 +463,23 @@ output_eh_region (struct output_block *ob, eh_region r)
   else
     gcc_unreachable ();
 
-  output_record_start (ob, tag);
-  output_sleb128 (ob, r->index);
+  streamer_write_record_start (ob, tag);
+  streamer_write_wide_int (ob, r->index);
 
   if (r->outer)
-    output_sleb128 (ob, r->outer->index);
+    streamer_write_wide_int (ob, r->outer->index);
   else
-    output_zero (ob);
+    streamer_write_zero (ob);
 
   if (r->inner)
-    output_sleb128 (ob, r->inner->index);
+    streamer_write_wide_int (ob, r->inner->index);
   else
-    output_zero (ob);
+    streamer_write_zero (ob);
 
   if (r->next_peer)
-    output_sleb128 (ob, r->next_peer->index);
+    streamer_write_wide_int (ob, r->next_peer->index);
   else
-    output_zero (ob);
+    streamer_write_zero (ob);
 
   if (r->type == ERT_TRY)
     {
@@ -489,7 +489,7 @@ output_eh_region (struct output_block *ob, eh_region r)
     {
       stream_write_tree (ob, r->u.allowed.type_list, true);
       stream_write_tree (ob, r->u.allowed.label, true);
-      output_uleb128 (ob, r->u.allowed.filter);
+      streamer_write_wide_uint (ob, r->u.allowed.filter);
     }
   else if (r->type == ERT_MUST_NOT_THROW)
     {
@@ -498,9 +498,9 @@ output_eh_region (struct output_block *ob, eh_region r)
     }
 
   if (r->landing_pads)
-    output_sleb128 (ob, r->landing_pads->index);
+    streamer_write_wide_int (ob, r->landing_pads->index);
   else
-    output_zero (ob);
+    streamer_write_zero (ob);
 }
 
 
@@ -511,21 +511,21 @@ output_eh_lp (struct output_block *ob, eh_landing_pad lp)
 {
   if (lp == NULL)
     {
-      output_record_start (ob, LTO_null);
+      streamer_write_record_start (ob, LTO_null);
       return;
     }
 
-  output_record_start (ob, LTO_eh_landing_pad);
-  output_sleb128 (ob, lp->index);
+  streamer_write_record_start (ob, LTO_eh_landing_pad);
+  streamer_write_wide_int (ob, lp->index);
   if (lp->next_lp)
-    output_sleb128 (ob, lp->next_lp->index);
+    streamer_write_wide_int (ob, lp->next_lp->index);
   else
-    output_zero (ob);
+    streamer_write_zero (ob);
 
   if (lp->region)
-    output_sleb128 (ob, lp->region->index);
+    streamer_write_wide_int (ob, lp->region->index);
   else
-    output_zero (ob);
+    streamer_write_zero (ob);
 
   stream_write_tree (ob, lp->post_landing_pad, true);
 }
@@ -543,23 +543,25 @@ output_eh_regions (struct output_block *ob, struct function *fn)
       eh_landing_pad lp;
       tree ttype;
 
-      output_record_start (ob, LTO_eh_table);
+      streamer_write_record_start (ob, LTO_eh_table);
 
       /* Emit the index of the root of the EH region tree.  */
-      output_sleb128 (ob, fn->eh->region_tree->index);
+      streamer_write_wide_int (ob, fn->eh->region_tree->index);
 
       /* Emit all the EH regions in the region array.  */
-      output_sleb128 (ob, VEC_length (eh_region, fn->eh->region_array));
+      streamer_write_wide_int (ob, VEC_length (eh_region,
+	                                       fn->eh->region_array));
       FOR_EACH_VEC_ELT (eh_region, fn->eh->region_array, i, eh)
 	output_eh_region (ob, eh);
 
       /* Emit all landing pads.  */
-      output_sleb128 (ob, VEC_length (eh_landing_pad, fn->eh->lp_array));
+      streamer_write_wide_int (ob, VEC_length (eh_landing_pad,
+	                                       fn->eh->lp_array));
       FOR_EACH_VEC_ELT (eh_landing_pad, fn->eh->lp_array, i, lp)
 	output_eh_lp (ob, lp);
 
       /* Emit all the runtime type data.  */
-      output_sleb128 (ob, VEC_length (tree, fn->eh->ttype_data));
+      streamer_write_wide_int (ob, VEC_length (tree, fn->eh->ttype_data));
       FOR_EACH_VEC_ELT (tree, fn->eh->ttype_data, i, ttype)
 	stream_write_tree (ob, ttype, true);
 
@@ -567,22 +569,26 @@ output_eh_regions (struct output_block *ob, struct function *fn)
       if (targetm.arm_eabi_unwinder)
 	{
 	  tree t;
-	  output_sleb128 (ob, VEC_length (tree, fn->eh->ehspec_data.arm_eabi));
+	  streamer_write_wide_int (ob,
+	                           VEC_length (tree,
+				               fn->eh->ehspec_data.arm_eabi));
 	  FOR_EACH_VEC_ELT (tree, fn->eh->ehspec_data.arm_eabi, i, t)
 	    stream_write_tree (ob, t, true);
 	}
       else
 	{
 	  uchar c;
-	  output_sleb128 (ob, VEC_length (uchar, fn->eh->ehspec_data.other));
+	  streamer_write_wide_int (ob,
+	                           VEC_length (uchar,
+				               fn->eh->ehspec_data.other));
 	  FOR_EACH_VEC_ELT (uchar, fn->eh->ehspec_data.other, i, c)
-	    lto_output_1_stream (ob->main_stream, c);
+	    streamer_write_char_stream (ob->main_stream, c);
 	}
     }
 
   /* The LTO_null either terminates the record or indicates that there
      are no eh_records at all.  */
-  output_record_start (ob, LTO_null);
+  streamer_write_record_start (ob, LTO_null);
 }
 
 
@@ -594,7 +600,7 @@ output_ssa_names (struct output_block *ob, struct function *fn)
   unsigned int i, len;
 
   len = VEC_length (tree, SSANAMES (fn));
-  output_uleb128 (ob, len);
+  streamer_write_wide_uint (ob, len);
 
   for (i = 1; i < len; i++)
     {
@@ -605,12 +611,13 @@ output_ssa_names (struct output_block *ob, struct function *fn)
 	  || !is_gimple_reg (ptr))
 	continue;
 
-      output_uleb128 (ob, i);
-      lto_output_1_stream (ob->main_stream, SSA_NAME_IS_DEFAULT_DEF (ptr));
+      streamer_write_wide_uint (ob, i);
+      streamer_write_char_stream (ob->main_stream,
+				  SSA_NAME_IS_DEFAULT_DEF (ptr));
       stream_write_tree (ob, SSA_NAME_VAR (ptr), true);
     }
 
-  output_zero (ob);
+  streamer_write_zero (ob);
 }
 
 
@@ -624,40 +631,40 @@ output_cfg (struct output_block *ob, struct function *fn)
 
   ob->main_stream = ob->cfg_stream;
 
-  lto_output_enum (ob->main_stream, profile_status_d, PROFILE_LAST,
-		   profile_status_for_function (fn));
+  streamer_write_enum (ob->main_stream, profile_status_d, PROFILE_LAST,
+		       profile_status_for_function (fn));
 
   /* Output the number of the highest basic block.  */
-  output_uleb128 (ob, last_basic_block_for_function (fn));
+  streamer_write_wide_uint (ob, last_basic_block_for_function (fn));
 
   FOR_ALL_BB_FN (bb, fn)
     {
       edge_iterator ei;
       edge e;
 
-      output_sleb128 (ob, bb->index);
+      streamer_write_wide_int (ob, bb->index);
 
       /* Output the successors and the edge flags.  */
-      output_uleb128 (ob, EDGE_COUNT (bb->succs));
+      streamer_write_wide_uint (ob, EDGE_COUNT (bb->succs));
       FOR_EACH_EDGE (e, ei, bb->succs)
 	{
-	  output_uleb128 (ob, e->dest->index);
-	  output_sleb128 (ob, e->probability);
-	  output_sleb128 (ob, e->count);
-	  output_uleb128 (ob, e->flags);
+	  streamer_write_wide_uint (ob, e->dest->index);
+	  streamer_write_wide_int (ob, e->probability);
+	  streamer_write_wide_int (ob, e->count);
+	  streamer_write_wide_uint (ob, e->flags);
 	}
     }
 
-  output_sleb128 (ob, -1);
+  streamer_write_wide_int (ob, -1);
 
   bb = ENTRY_BLOCK_PTR;
   while (bb->next_bb)
     {
-      output_sleb128 (ob, bb->next_bb->index);
+      streamer_write_wide_int (ob, bb->next_bb->index);
       bb = bb->next_bb;
     }
 
-  output_sleb128 (ob, -1);
+  streamer_write_wide_int (ob, -1);
 
   ob->main_stream = tmp_stream;
 }
@@ -739,7 +746,7 @@ output_struct_function_base (struct output_block *ob, struct function *fn)
   stream_write_tree (ob, fn->nonlocal_goto_save_area, true);
 
   /* Output all the local variables in the function.  */
-  output_sleb128 (ob, VEC_length (tree, fn->local_decls));
+  streamer_write_wide_int (ob, VEC_length (tree, fn->local_decls));
   FOR_EACH_VEC_ELT (tree, fn->local_decls, i, t)
     stream_write_tree (ob, t, true);
 
@@ -754,7 +761,7 @@ output_struct_function_base (struct output_block *ob, struct function *fn)
   lto_output_location (ob, fn->function_end_locus);
 
   /* Output current IL state of the function.  */
-  output_uleb128 (ob, fn->curr_properties);
+  streamer_write_wide_uint (ob, fn->curr_properties);
 
   /* unsigned int last_verified;			-- ignored */
   /* const char *cannot_be_copied_reason;		-- ignored */
@@ -776,7 +783,7 @@ output_struct_function_base (struct output_block *ob, struct function *fn)
   bp_pack_value (&bp, fn->calls_setjmp, 1);
   bp_pack_value (&bp, fn->va_list_fpr_size, 8);
   bp_pack_value (&bp, fn->va_list_gpr_size, 8);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
 }
 
 
@@ -804,9 +811,9 @@ output_function (struct cgraph_node *node)
   push_cfun (fn);
 
   /* Make string 0 be a NULL string.  */
-  lto_output_1_stream (ob->string_stream, 0);
+  streamer_write_char_stream (ob->string_stream, 0);
 
-  output_record_start (ob, LTO_function);
+  streamer_write_record_start (ob, LTO_function);
 
   output_struct_function_base (ob, fn);
 
@@ -845,7 +852,7 @@ output_function (struct cgraph_node *node)
     output_bb (ob, bb, fn);
 
   /* The terminator for this function.  */
-  output_record_start (ob, LTO_null);
+  streamer_write_record_start (ob, LTO_null);
 
   output_cfg (ob, fn);
 
@@ -942,7 +949,7 @@ output_unreferenced_globals (cgraph_node_set set, varpool_node_set vset)
   clear_line_info (ob);
 
   /* Make string 0 be a NULL string.  */
-  lto_output_1_stream (ob->string_stream, 0);
+  streamer_write_char_stream (ob->string_stream, 0);
 
   /* We really need to propagate in both directoins:
      for normal aliases we propagate from first defined alias to
@@ -959,7 +966,7 @@ output_unreferenced_globals (cgraph_node_set set, varpool_node_set vset)
       }
   symbol_alias_set_destroy (defined);
 
-  output_record_start (ob, LTO_null);
+  streamer_write_record_start (ob, LTO_null);
 
   produce_asm (ob, NULL);
   destroy_output_block (ob);
@@ -1124,7 +1131,7 @@ write_global_stream (struct output_block *ob,
   for (index = 0; index < size; index++)
     {
       t = lto_tree_ref_encoder_get_tree (encoder, index);
-      if (!lto_streamer_cache_lookup (ob->writer_cache, t, NULL))
+      if (!streamer_tree_cache_lookup (ob->writer_cache, t, NULL))
 	stream_write_tree (ob, t, false);
     }
 }
@@ -1152,7 +1159,7 @@ write_global_references (struct output_block *ob,
       uint32_t slot_num;
 
       t = lto_tree_ref_encoder_get_tree (encoder, index);
-      lto_streamer_cache_lookup (ob->writer_cache, t, &slot_num);
+      streamer_tree_cache_lookup (ob->writer_cache, t, &slot_num);
       gcc_assert (slot_num != (unsigned)-1);
       lto_output_data_stream (ref_stream, &slot_num, sizeof slot_num);
     }
@@ -1188,7 +1195,7 @@ lto_output_decl_state_refs (struct output_block *ob,
   /* Write reference to FUNCTION_DECL.  If there is not function,
      write reference to void_type_node. */
   decl = (state->fn_decl) ? state->fn_decl : void_type_node;
-  lto_streamer_cache_lookup (ob->writer_cache, decl, &ref);
+  streamer_tree_cache_lookup (ob->writer_cache, decl, &ref);
   gcc_assert (ref != (unsigned)-1);
   lto_output_data_stream (out_stream, &ref, sizeof (uint32_t));
 
@@ -1220,7 +1227,7 @@ lto_out_decl_state_written_size (struct lto_out_decl_state *state)
    so far.  */
 
 static void
-write_symbol (struct lto_streamer_cache_d *cache,
+write_symbol (struct streamer_tree_cache_d *cache,
 	      struct lto_output_stream *stream,
 	      tree t, struct pointer_set_t *seen, bool alias)
 {
@@ -1253,7 +1260,7 @@ write_symbol (struct lto_streamer_cache_d *cache,
     return;
   pointer_set_insert (seen, name);
 
-  lto_streamer_cache_lookup (cache, t, &slot_num);
+  streamer_tree_cache_lookup (cache, t, &slot_num);
   gcc_assert (slot_num != (unsigned)-1);
 
   if (DECL_EXTERNAL (t))
@@ -1342,7 +1349,7 @@ static void
 produce_symtab (struct output_block *ob,
 	        cgraph_node_set set, varpool_node_set vset)
 {
-  struct lto_streamer_cache_d *cache = ob->writer_cache;
+  struct streamer_tree_cache_d *cache = ob->writer_cache;
   char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL);
   struct pointer_set_t *seen;
   struct cgraph_node *node;
@@ -1473,7 +1480,7 @@ produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset)
   free (section_name);
 
   /* Make string 0 be a NULL string.  */
-  lto_output_1_stream (ob->string_stream, 0);
+  streamer_write_char_stream (ob->string_stream, 0);
 
   /* Write the global symbols.  */
   out_state = lto_get_out_decl_state ();
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index 01a681f..633c3ce 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -291,7 +291,7 @@ lto_streamer_init (void)
      match exactly the structures defined in treestruct.def.  When a
      new TS_* astructure is added, the streamer should be updated to
      handle it.  */
-  check_handled_ts_structures ();
+  streamer_check_handled_ts_structures ();
 
 #ifdef LTO_STREAMER_DEBUG
   tree_htab = htab_create (31, hash_tree, eq_tree, NULL);
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index fc0255f..886c6c0 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -655,7 +655,7 @@ struct output_block
   bool global;
 
   /* Cache of nodes written in this section.  */
-  struct lto_streamer_cache_d *writer_cache;
+  struct streamer_tree_cache_d *writer_cache;
 
   /* Any other streamer-specific data needed by the streamer.  */
   void *sdata;
@@ -696,7 +696,7 @@ struct data_in
   VEC(ld_plugin_symbol_resolution_t,heap) *globals_resolution;
 
   /* Cache of pickled nodes.  */
-  struct lto_streamer_cache_d *reader_cache;
+  struct streamer_tree_cache_d *reader_cache;
 
   /* Any other streamer-specific data needed by the streamer.  */
   void *sdata;
@@ -721,10 +721,6 @@ extern const char *lto_get_section_data (struct lto_file_decl_data *,
 extern void lto_free_section_data (struct lto_file_decl_data *,
 				   enum lto_section_type,
 				   const char *, const char *, size_t);
-extern unsigned HOST_WIDE_INT lto_input_uleb128 (struct lto_input_block *);
-extern unsigned HOST_WIDEST_INT lto_input_widest_uint_uleb128 (
-						struct lto_input_block *);
-extern HOST_WIDE_INT lto_input_sleb128 (struct lto_input_block *);
 extern htab_t lto_create_renaming_table (void);
 extern void lto_record_renamed_decl (struct lto_file_decl_data *,
 				     const char *, const char *);
@@ -751,12 +747,6 @@ extern void lto_end_section (void);
 extern void lto_write_stream (struct lto_output_stream *);
 extern void lto_output_data_stream (struct lto_output_stream *, const void *,
 				    size_t);
-extern void lto_output_uleb128_stream (struct lto_output_stream *,
-       				       unsigned HOST_WIDE_INT);
-extern void lto_output_widest_uint_uleb128_stream (struct lto_output_stream *,
-       					           unsigned HOST_WIDEST_INT);
-extern void lto_output_sleb128_stream (struct lto_output_stream *,
-				       HOST_WIDE_INT);
 extern bool lto_output_decl_index (struct lto_output_stream *,
 			    struct lto_tree_ref_encoder *,
 			    tree, unsigned int *);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index bf2aab1..0b1dcb9 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -204,7 +204,7 @@ lto_read_in_decl_state (struct data_in *data_in, const uint32_t *data,
   uint32_t i, j;
   
   ix = *data++;
-  decl = lto_streamer_cache_get (data_in->reader_cache, ix);
+  decl = streamer_tree_cache_get (data_in->reader_cache, ix);
   if (TREE_CODE (decl) != FUNCTION_DECL)
     {
       gcc_assert (decl == void_type_node);
@@ -218,7 +218,7 @@ lto_read_in_decl_state (struct data_in *data_in, const uint32_t *data,
       tree *decls = ggc_alloc_vec_tree (size);
 
       for (j = 0; j < size; j++)
-	decls[j] = lto_streamer_cache_get (data_in->reader_cache, data[j]);
+	decls[j] = streamer_tree_cache_get (data_in->reader_cache, data[j]);
 
       state->streams[i].size = size;
       state->streams[i].trees = decls;
@@ -563,7 +563,7 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
   if (TREE_PUBLIC (decl))
     {
       unsigned ix;
-      if (!lto_streamer_cache_lookup (data_in->reader_cache, decl, &ix))
+      if (!streamer_tree_cache_lookup (data_in->reader_cache, decl, &ix))
 	gcc_unreachable ();
       lto_symtab_register_decl (decl, get_resolution (data_in, ix),
 				data_in->file_data);
@@ -629,7 +629,7 @@ lto_register_function_decl_in_symtab (struct data_in *data_in, tree decl)
   if (TREE_PUBLIC (decl) && !DECL_ABSTRACT (decl))
     {
       unsigned ix;
-      if (!lto_streamer_cache_lookup (data_in->reader_cache, decl, &ix))
+      if (!streamer_tree_cache_lookup (data_in->reader_cache, decl, &ix))
 	gcc_unreachable ();
       lto_symtab_register_decl (decl, get_resolution (data_in, ix),
 				data_in->file_data);
@@ -645,7 +645,7 @@ lto_register_function_decl_in_symtab (struct data_in *data_in, tree decl)
 static void
 uniquify_nodes (struct data_in *data_in, unsigned from)
 {
-  struct lto_streamer_cache_d *cache = data_in->reader_cache;
+  struct streamer_tree_cache_d *cache = data_in->reader_cache;
   unsigned len = VEC_length (tree, cache->nodes);
   unsigned i;
 
@@ -756,7 +756,7 @@ uniquify_nodes (struct data_in *data_in, unsigned from)
 		  {
 		    unsigned ix;
 		    gcc_assert (f1 != f2 && DECL_NAME (f1) == DECL_NAME (f2));
-		    if (!lto_streamer_cache_lookup (cache, f2, &ix))
+		    if (!streamer_tree_cache_lookup (cache, f2, &ix))
 		      gcc_unreachable ();
 		    /* If we're going to replace an element which we'd
 		       still visit in the next iterations, we wouldn't
@@ -772,14 +772,14 @@ uniquify_nodes (struct data_in *data_in, unsigned from)
 		       operand handling.  */
 		    if (ix < i)
 		      lto_fixup_types (f2);
-		    lto_streamer_cache_insert_at (cache, f1, ix);
+		    streamer_tree_cache_insert_at (cache, f1, ix);
 		  }
 	    }
 
 	  /* If we found a tree that is equal to oldt replace it in the
 	     cache, so that further users (in the various LTO sections)
 	     make use of it.  */
-	  lto_streamer_cache_insert_at (cache, t, i);
+	  streamer_tree_cache_insert_at (cache, t, i);
 	}
     }
 
diff --git a/gcc/streamer-hooks.h b/gcc/streamer-hooks.h
index 16c7361..0c1d483 100644
--- a/gcc/streamer-hooks.h
+++ b/gcc/streamer-hooks.h
@@ -29,8 +29,6 @@ along with GCC; see the file COPYING3.  If not see
 struct output_block;
 struct lto_input_block;
 struct data_in;
-struct bitpack_d;
-struct lto_streamer_cache_d;
 
 /* Streamer hooks.  These functions do additional processing as
    needed by the module.  There are two types of callbacks, those that
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index 43bbe0e..3705ded 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -34,12 +34,12 @@ along with GCC; see the file COPYING3.  If not see
    block IB.  */
 
 tree
-input_string_cst (struct data_in *data_in, struct lto_input_block *ib)
+streamer_read_string_cst (struct data_in *data_in, struct lto_input_block *ib)
 {
   unsigned int len;
   const char * ptr;
 
-  ptr = input_string_internal (data_in, ib, &len);
+  ptr = streamer_read_indexed_string (data_in, ib, &len);
   if (!ptr)
     return NULL;
   return build_string (len, ptr);
@@ -55,7 +55,7 @@ input_identifier (struct data_in *data_in, struct lto_input_block *ib)
   unsigned int len;
   const char *ptr;
 
-  ptr = input_string_internal (data_in, ib, &len);
+  ptr = streamer_read_indexed_string (data_in, ib, &len);
   if (!ptr)
     return NULL;
   return get_identifier_with_length (ptr, len);
@@ -66,13 +66,13 @@ input_identifier (struct data_in *data_in, struct lto_input_block *ib)
    tables and descriptors for the file being read.  */
 
 tree
-lto_input_chain (struct lto_input_block *ib, struct data_in *data_in)
+streamer_read_chain (struct lto_input_block *ib, struct data_in *data_in)
 {
   int i, count;
   tree first, prev, curr;
 
   first = prev = NULL_TREE;
-  count = lto_input_sleb128 (ib);
+  count = streamer_read_wide_int (ib);
   for (i = 0; i < count; i++)
     {
       curr = stream_read_tree (ib, data_in);
@@ -96,7 +96,7 @@ static void
 unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
 {
   /* Note that the code for EXPR has already been unpacked to create EXPR in
-     lto_materialize_tree.  */
+     streamer_alloc_tree.  */
   if (!TYPE_P (expr))
     {
       TREE_SIDE_EFFECTS (expr) = (unsigned) bp_unpack_value (bp, 1);
@@ -412,13 +412,13 @@ unpack_value_fields (struct bitpack_d *bp, tree expr)
    bitfield values that the writer may have written.  */
 
 struct bitpack_d
-tree_read_bitfields (struct lto_input_block *ib, tree expr)
+streamer_read_tree_bitfields (struct lto_input_block *ib, tree expr)
 {
   enum tree_code code;
   struct bitpack_d bp;
 
   /* Read the bitpack of non-pointer values from IB.  */
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
 
   /* The first word in BP contains the code of the tree that we
      are about to read.  */
@@ -438,8 +438,8 @@ tree_read_bitfields (struct lto_input_block *ib, tree expr)
    *IX_P the index into the reader cache where the new tree is stored.  */
 
 tree
-lto_materialize_tree (struct lto_input_block *ib, struct data_in *data_in,
-		      enum LTO_tags tag)
+streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
+		     enum LTO_tags tag)
 {
   enum tree_code code;
   tree result;
@@ -453,7 +453,7 @@ lto_materialize_tree (struct lto_input_block *ib, struct data_in *data_in,
   /* Read the word representing the memory address for the tree
      as it was written by the writer.  This is useful when
      debugging differences between the writer and reader.  */
-  orig_address_in_writer = lto_input_sleb128 (ib);
+  orig_address_in_writer = streamer_read_wide_int (ib);
   gcc_assert ((intptr_t) orig_address_in_writer == orig_address_in_writer);
 #endif
 
@@ -465,22 +465,22 @@ lto_materialize_tree (struct lto_input_block *ib, struct data_in *data_in,
 
   /* Instantiate a new tree using the header data.  */
   if (CODE_CONTAINS_STRUCT (code, TS_STRING))
-    result = input_string_cst (data_in, ib);
+    result = streamer_read_string_cst (data_in, ib);
   else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
     result = input_identifier (data_in, ib);
   else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
     {
-      HOST_WIDE_INT len = lto_input_sleb128 (ib);
+      HOST_WIDE_INT len = streamer_read_wide_int (ib);
       result = make_tree_vec (len);
     }
   else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
     {
-      unsigned HOST_WIDE_INT len = lto_input_uleb128 (ib);
+      unsigned HOST_WIDE_INT len = streamer_read_wide_uint (ib);
       result = make_tree_binfo (len);
     }
   else if (code == CALL_EXPR)
     {
-      unsigned HOST_WIDE_INT nargs = lto_input_uleb128 (ib);
+      unsigned HOST_WIDE_INT nargs = streamer_read_wide_uint (ib);
       return build_vl_exp (CALL_EXPR, nargs + 3);
     }
   else
@@ -525,7 +525,7 @@ static void
 lto_input_ts_vector_tree_pointers (struct lto_input_block *ib,
 				   struct data_in *data_in, tree expr)
 {
-  TREE_VECTOR_CST_ELTS (expr) = lto_input_chain (ib, data_in);
+  TREE_VECTOR_CST_ELTS (expr) = streamer_read_chain (ib, data_in);
 }
 
 
@@ -573,7 +573,7 @@ lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib,
      dwarf2out.c.  */
 
   if (TREE_CODE (expr) == PARM_DECL)
-    TREE_CHAIN (expr) = lto_input_chain (ib, data_in);
+    TREE_CHAIN (expr) = streamer_read_chain (ib, data_in);
 
   if ((TREE_CODE (expr) == VAR_DECL
        || TREE_CODE (expr) == PARM_DECL)
@@ -641,7 +641,7 @@ lto_input_ts_field_decl_tree_pointers (struct lto_input_block *ib,
   DECL_QUALIFIER (expr) = stream_read_tree (ib, data_in);
   DECL_FIELD_BIT_OFFSET (expr) = stream_read_tree (ib, data_in);
   DECL_FCONTEXT (expr) = stream_read_tree (ib, data_in);
-  TREE_CHAIN (expr) = lto_input_chain (ib, data_in);
+  TREE_CHAIN (expr) = streamer_read_chain (ib, data_in);
 }
 
 
@@ -727,7 +727,7 @@ lto_input_ts_list_tree_pointers (struct lto_input_block *ib,
 {
   TREE_PURPOSE (expr) = stream_read_tree (ib, data_in);
   TREE_VALUE (expr) = stream_read_tree (ib, data_in);
-  TREE_CHAIN (expr) = lto_input_chain (ib, data_in);
+  TREE_CHAIN (expr) = streamer_read_chain (ib, data_in);
 }
 
 
@@ -741,7 +741,7 @@ lto_input_ts_vec_tree_pointers (struct lto_input_block *ib,
 {
   int i;
 
-  /* Note that TREE_VEC_LENGTH was read by lto_materialize_tree to
+  /* Note that TREE_VEC_LENGTH was read by streamer_alloc_tree to
      instantiate EXPR.  */
   for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
     TREE_VEC_ELT (expr, i) = stream_read_tree (ib, data_in);
@@ -760,7 +760,7 @@ lto_input_ts_exp_tree_pointers (struct lto_input_block *ib,
   int i, length;
   location_t loc;
 
-  length = lto_input_sleb128 (ib);
+  length = streamer_read_wide_int (ib);
   gcc_assert (length == TREE_OPERAND_LENGTH (expr));
 
   for (i = 0; i < length; i++)
@@ -783,7 +783,7 @@ lto_input_ts_block_tree_pointers (struct lto_input_block *ib,
   /* Do not stream BLOCK_SOURCE_LOCATION.  We cannot handle debug information
      for early inlining so drop it on the floor instead of ICEing in
      dwarf2out.c.  */
-  BLOCK_VARS (expr) = lto_input_chain (ib, data_in);
+  BLOCK_VARS (expr) = streamer_read_chain (ib, data_in);
 
   /* Do not stream BLOCK_NONLOCALIZED_VARS.  We cannot handle debug information
      for early inlining so drop it on the floor instead of ICEing in
@@ -830,7 +830,7 @@ lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
   tree t;
 
   /* Note that the number of slots in EXPR was read in
-     lto_materialize_tree when instantiating EXPR.  However, the
+     streamer_alloc_tree when instantiating EXPR.  However, the
      vector is empty so we cannot rely on VEC_length to know how many
      elements to read.  So, this list is emitted as a 0-terminated
      list on the writer side.  */
@@ -847,7 +847,7 @@ lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
   BINFO_VIRTUALS (expr) = stream_read_tree (ib, data_in);
   BINFO_VPTR_FIELD (expr) = stream_read_tree (ib, data_in);
 
-  len = lto_input_uleb128 (ib);
+  len = streamer_read_wide_uint (ib);
   if (len > 0)
     {
       VEC_reserve_exact (tree, gc, BINFO_BASE_ACCESSES (expr), len);
@@ -874,7 +874,7 @@ lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
 {
   unsigned i, len;
 
-  len = lto_input_uleb128 (ib);
+  len = streamer_read_wide_uint (ib);
   for (i = 0; i < len; i++)
     {
       tree index, value;
@@ -895,7 +895,7 @@ lto_input_ts_target_option (struct lto_input_block *ib, tree expr)
   struct bitpack_d bp;
   struct cl_target_option *t = TREE_TARGET_OPTION (expr);
 
-  bp = lto_input_bitpack (ib);
+  bp = streamer_read_bitpack (ib);
   len = sizeof (struct cl_target_option);
   for (i = 0; i < len; i++)
     ((unsigned char *)t)[i] = bp_unpack_value (&bp, 8);
@@ -910,7 +910,7 @@ lto_input_ts_translation_unit_decl_tree_pointers (struct lto_input_block *ib,
 						  struct data_in *data_in,
 						  tree expr)
 {
-  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (lto_input_string (data_in, ib));
+  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (streamer_read_string (data_in, ib));
   VEC_safe_push (tree, gc, all_translation_units, expr);
 }
 
@@ -918,7 +918,7 @@ lto_input_ts_translation_unit_decl_tree_pointers (struct lto_input_block *ib,
    contains tables and descriptors for the file being read.  */
 
 void
-lto_input_tree_pointers (struct lto_input_block *ib, struct data_in *data_in,
+streamer_read_tree_body (struct lto_input_block *ib, struct data_in *data_in,
 			 tree expr)
 {
   enum tree_code code;
@@ -988,16 +988,16 @@ lto_input_tree_pointers (struct lto_input_block *ib, struct data_in *data_in,
    context in DATA_IN.  */
 
 tree
-lto_input_integer_cst (struct lto_input_block *ib, struct data_in *data_in)
+streamer_read_integer_cst (struct lto_input_block *ib, struct data_in *data_in)
 {
   tree result, type;
   HOST_WIDE_INT low, high;
   bool overflow_p;
 
   type = stream_read_tree (ib, data_in);
-  overflow_p = (lto_input_1_unsigned (ib) != 0);
-  low = lto_input_uleb128 (ib);
-  high = lto_input_uleb128 (ib);
+  overflow_p = (streamer_read_uchar (ib) != 0);
+  low = streamer_read_wide_uint (ib);
+  high = streamer_read_wide_uint (ib);
   result = build_int_cst_wide (type, low, high);
 
   /* If the original constant had overflown, build a replica of RESULT to
@@ -1016,16 +1016,16 @@ lto_input_integer_cst (struct lto_input_block *ib, struct data_in *data_in)
    DATA_IN->FILE_DATA->GLOBALS_INDEX[IX].  */
 
 tree
-lto_get_pickled_tree (struct lto_input_block *ib, struct data_in *data_in)
+streamer_get_pickled_tree (struct lto_input_block *ib, struct data_in *data_in)
 {
   unsigned HOST_WIDE_INT ix;
   tree result;
   enum LTO_tags expected_tag;
 
-  ix = lto_input_uleb128 (ib);
+  ix = streamer_read_wide_uint (ib);
   expected_tag = lto_input_enum (ib, LTO_tags, LTO_NUM_TAGS);
 
-  result = lto_streamer_cache_get (data_in->reader_cache, ix);
+  result = streamer_tree_cache_get (data_in->reader_cache, ix);
   gcc_assert (result
               && TREE_CODE (result) == lto_tag_to_tree_code (expected_tag));
 
@@ -1037,7 +1037,7 @@ lto_get_pickled_tree (struct lto_input_block *ib, struct data_in *data_in)
    corresponding builtin.  DATA_IN is as in stream_read_tree.  */
 
 tree
-lto_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
+streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
 {
   enum built_in_class fclass;
   enum built_in_function fcode;
@@ -1047,7 +1047,7 @@ lto_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
   fclass = lto_input_enum (ib, built_in_class, BUILT_IN_LAST);
   gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD);
 
-  fcode = (enum built_in_function) lto_input_uleb128 (ib);
+  fcode = (enum built_in_function) streamer_read_wide_uint (ib);
 
   if (fclass == BUILT_IN_NORMAL)
     {
@@ -1065,11 +1065,11 @@ lto_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
   else
     gcc_unreachable ();
 
-  asmname = lto_input_string (data_in, ib);
+  asmname = streamer_read_string (data_in, ib);
   if (asmname)
     set_builtin_user_assembler_name (result, asmname);
 
-  lto_streamer_cache_append (data_in->reader_cache, result);
+  streamer_tree_cache_append (data_in->reader_cache, result);
 
   return result;
 }
diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c
index 29867ca..f528de3 100644
--- a/gcc/tree-streamer-out.c
+++ b/gcc/tree-streamer-out.c
@@ -32,14 +32,14 @@ along with GCC; see the file COPYING3.  If not see
    table in OB.  Then put the index onto the INDEX_STREAM.  */
 
 static void
-output_string_cst (struct output_block *ob,
+write_string_cst (struct output_block *ob,
 		   struct lto_output_stream *index_stream,
 		   tree string)
 {
-  lto_output_string_with_length (ob, index_stream,
-				 TREE_STRING_POINTER (string),
-				 TREE_STRING_LENGTH (string),
-				 true);
+  streamer_write_string_with_length (ob, index_stream,
+				     TREE_STRING_POINTER (string),
+				     TREE_STRING_LENGTH (string),
+				     true);
 }
 
 
@@ -47,14 +47,14 @@ output_string_cst (struct output_block *ob,
    table in OB.  Then put the index onto the INDEX_STREAM.  */
 
 static void
-output_identifier (struct output_block *ob,
+write_identifier (struct output_block *ob,
 		   struct lto_output_stream *index_stream,
 		   tree id)
 {
-  lto_output_string_with_length (ob, index_stream,
-				 IDENTIFIER_POINTER (id),
-				 IDENTIFIER_LENGTH (id),
-				 true);
+  streamer_write_string_with_length (ob, index_stream,
+				     IDENTIFIER_POINTER (id),
+				     IDENTIFIER_LENGTH (id),
+				     true);
 }
 
 
@@ -238,7 +238,7 @@ pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
 {
   /* For normal/md builtins we only write the class and code, so they
      should never be handled here.  */
-  gcc_assert (!lto_stream_as_builtin_p (expr));
+  gcc_assert (!streamer_handle_as_builtin_p (expr));
 
   bp_pack_enum (bp, built_in_class, BUILT_IN_LAST,
 		DECL_BUILT_IN_CLASS (expr));
@@ -306,10 +306,11 @@ pack_ts_translation_unit_decl_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSE
 {
 }
 
-/* Pack all the non-pointer fields in EXPR into a bit pack.  */
+
+/* Pack all the bitfields in EXPR into a bit pack.  */
 
 void
-pack_value_fields (struct bitpack_d *bp, tree expr)
+streamer_pack_tree_bitfields (struct bitpack_d *bp, tree expr)
 {
   enum tree_code code;
 
@@ -352,19 +353,19 @@ pack_value_fields (struct bitpack_d *bp, tree expr)
    the index into the streamer cache where EXPR is stored.*/
 
 void
-lto_output_builtin_tree (struct output_block *ob, tree expr)
+streamer_write_builtin (struct output_block *ob, tree expr)
 {
-  gcc_assert (lto_stream_as_builtin_p (expr));
+  gcc_assert (streamer_handle_as_builtin_p (expr));
 
   if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD
       && !targetm.builtin_decl)
-    sorry ("gimple bytecode streams do not support machine specific builtin "
+    sorry ("tree bytecode streams do not support machine specific builtin "
 	   "functions on this target");
 
-  output_record_start (ob, LTO_builtin_decl);
-  lto_output_enum (ob->main_stream, built_in_class, BUILT_IN_LAST,
-		   DECL_BUILT_IN_CLASS (expr));
-  output_uleb128 (ob, DECL_FUNCTION_CODE (expr));
+  streamer_write_record_start (ob, LTO_builtin_decl);
+  streamer_write_enum (ob->main_stream, built_in_class, BUILT_IN_LAST,
+		       DECL_BUILT_IN_CLASS (expr));
+  streamer_write_wide_uint (ob, DECL_FUNCTION_CODE (expr));
 
   if (DECL_ASSEMBLER_NAME_SET_P (expr))
     {
@@ -374,12 +375,12 @@ lto_output_builtin_tree (struct output_block *ob, tree expr)
 	 reader side from adding a second '*', we omit it here.  */
       const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (expr));
       if (strlen (str) > 1 && str[0] == '*')
-	lto_output_string (ob, ob->main_stream, &str[1], true);
+	streamer_write_string (ob, ob->main_stream, &str[1], true);
       else
-	lto_output_string (ob, ob->main_stream, NULL, true);
+	streamer_write_string (ob, ob->main_stream, NULL, true);
     }
   else
-    lto_output_string (ob, ob->main_stream, NULL, true);
+    streamer_write_string (ob, ob->main_stream, NULL, true);
 }
 
 
@@ -388,12 +389,12 @@ lto_output_builtin_tree (struct output_block *ob, tree expr)
    as references.  */
 
 void
-lto_output_chain (struct output_block *ob, tree t, bool ref_p)
+streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
 {
   int i, count;
 
   count = list_length (t);
-  output_sleb128 (ob, count);
+  streamer_write_wide_int (ob, count);
   for (i = 0; i < count; i++)
     {
       tree saved_chain;
@@ -416,8 +417,7 @@ lto_output_chain (struct output_block *ob, tree t, bool ref_p)
    fields.  */
 
 static void
-lto_output_ts_common_tree_pointers (struct output_block *ob, tree expr,
-				    bool ref_p)
+write_ts_common_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   if (TREE_CODE (expr) != IDENTIFIER_NODE)
     stream_write_tree (ob, TREE_TYPE (expr), ref_p);
@@ -429,10 +429,9 @@ lto_output_ts_common_tree_pointers (struct output_block *ob, tree expr,
    fields.  */
 
 static void
-lto_output_ts_vector_tree_pointers (struct output_block *ob, tree expr,
-				    bool ref_p)
+write_ts_vector_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
-  lto_output_chain (ob, TREE_VECTOR_CST_ELTS (expr), ref_p);
+  streamer_write_chain (ob, TREE_VECTOR_CST_ELTS (expr), ref_p);
 }
 
 
@@ -441,8 +440,7 @@ lto_output_ts_vector_tree_pointers (struct output_block *ob, tree expr,
    fields.  */
 
 static void
-lto_output_ts_complex_tree_pointers (struct output_block *ob, tree expr,
-				     bool ref_p)
+write_ts_complex_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   stream_write_tree (ob, TREE_REALPART (expr), ref_p);
   stream_write_tree (ob, TREE_IMAGPART (expr), ref_p);
@@ -454,8 +452,8 @@ lto_output_ts_complex_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_decl_minimal_tree_pointers (struct output_block *ob, tree expr,
-					  bool ref_p)
+write_ts_decl_minimal_tree_pointers (struct output_block *ob, tree expr,
+				     bool ref_p)
 {
   stream_write_tree (ob, DECL_NAME (expr), ref_p);
   stream_write_tree (ob, DECL_CONTEXT (expr), ref_p);
@@ -468,8 +466,8 @@ lto_output_ts_decl_minimal_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
-					 bool ref_p)
+write_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
+				    bool ref_p)
 {
   stream_write_tree (ob, DECL_SIZE (expr), ref_p);
   stream_write_tree (ob, DECL_SIZE_UNIT (expr), ref_p);
@@ -484,7 +482,7 @@ lto_output_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
      dwarf2out.c.  */
 
   if (TREE_CODE (expr) == PARM_DECL)
-    lto_output_chain (ob, TREE_CHAIN (expr), ref_p);
+    streamer_write_chain (ob, TREE_CHAIN (expr), ref_p);
 
   if ((TREE_CODE (expr) == VAR_DECL
        || TREE_CODE (expr) == PARM_DECL)
@@ -501,8 +499,8 @@ lto_output_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_decl_non_common_tree_pointers (struct output_block *ob,
-					     tree expr, bool ref_p)
+write_ts_decl_non_common_tree_pointers (struct output_block *ob, tree expr,
+				        bool ref_p)
 {
   if (TREE_CODE (expr) == FUNCTION_DECL)
     {
@@ -518,8 +516,8 @@ lto_output_ts_decl_non_common_tree_pointers (struct output_block *ob,
    pointer fields.  */
 
 static void
-lto_output_ts_decl_with_vis_tree_pointers (struct output_block *ob, tree expr,
-					   bool ref_p)
+write_ts_decl_with_vis_tree_pointers (struct output_block *ob, tree expr,
+			              bool ref_p)
 {
   /* Make sure we don't inadvertently set the assembler name.  */
   if (DECL_ASSEMBLER_NAME_SET_P (expr))
@@ -537,15 +535,15 @@ lto_output_ts_decl_with_vis_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_field_decl_tree_pointers (struct output_block *ob, tree expr,
-					bool ref_p)
+write_ts_field_decl_tree_pointers (struct output_block *ob, tree expr,
+				   bool ref_p)
 {
   stream_write_tree (ob, DECL_FIELD_OFFSET (expr), ref_p);
   stream_write_tree (ob, DECL_BIT_FIELD_TYPE (expr), ref_p);
   stream_write_tree (ob, DECL_QUALIFIER (expr), ref_p);
   stream_write_tree (ob, DECL_FIELD_BIT_OFFSET (expr), ref_p);
   stream_write_tree (ob, DECL_FCONTEXT (expr), ref_p);
-  lto_output_chain (ob, TREE_CHAIN (expr), ref_p);
+  streamer_write_chain (ob, TREE_CHAIN (expr), ref_p);
 }
 
 
@@ -554,8 +552,8 @@ lto_output_ts_field_decl_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
-					   bool ref_p)
+write_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
+				      bool ref_p)
 {
   /* DECL_STRUCT_FUNCTION is handled by lto_output_function.  FIXME lto,
      maybe it should be handled here?  */
@@ -570,8 +568,8 @@ lto_output_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_type_common_tree_pointers (struct output_block *ob, tree expr,
-					 bool ref_p)
+write_ts_type_common_tree_pointers (struct output_block *ob, tree expr,
+				    bool ref_p)
 {
   stream_write_tree (ob, TYPE_SIZE (expr), ref_p);
   stream_write_tree (ob, TYPE_SIZE_UNIT (expr), ref_p);
@@ -593,8 +591,8 @@ lto_output_ts_type_common_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_type_non_common_tree_pointers (struct output_block *ob,
-					     tree expr, bool ref_p)
+write_ts_type_non_common_tree_pointers (struct output_block *ob, tree expr,
+					bool ref_p)
 {
   if (TREE_CODE (expr) == ENUMERAL_TYPE)
     stream_write_tree (ob, TYPE_VALUES (expr), ref_p);
@@ -619,12 +617,11 @@ lto_output_ts_type_non_common_tree_pointers (struct output_block *ob,
    fields.  */
 
 static void
-lto_output_ts_list_tree_pointers (struct output_block *ob, tree expr,
-				  bool ref_p)
+write_ts_list_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   stream_write_tree (ob, TREE_PURPOSE (expr), ref_p);
   stream_write_tree (ob, TREE_VALUE (expr), ref_p);
-  lto_output_chain (ob, TREE_CHAIN (expr), ref_p);
+  streamer_write_chain (ob, TREE_CHAIN (expr), ref_p);
 }
 
 
@@ -633,12 +630,12 @@ lto_output_ts_list_tree_pointers (struct output_block *ob, tree expr,
    fields.  */
 
 static void
-lto_output_ts_vec_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
+write_ts_vec_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   int i;
 
   /* Note that the number of slots for EXPR has already been emitted
-     in EXPR's header (see lto_output_tree_header).  */
+     in EXPR's header (see streamer_write_tree_header).  */
   for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
     stream_write_tree (ob, TREE_VEC_ELT (expr, i), ref_p);
 }
@@ -649,11 +646,11 @@ lto_output_ts_vec_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
    fields.  */
 
 static void
-lto_output_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
+write_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   int i;
 
-  output_sleb128 (ob, TREE_OPERAND_LENGTH (expr));
+  streamer_write_wide_int (ob, TREE_OPERAND_LENGTH (expr));
   for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
     stream_write_tree (ob, TREE_OPERAND (expr, i), ref_p);
   lto_output_location (ob, EXPR_LOCATION (expr));
@@ -666,13 +663,12 @@ lto_output_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
    fields.  */
 
 static void
-lto_output_ts_block_tree_pointers (struct output_block *ob, tree expr,
-				   bool ref_p)
+write_ts_block_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   /* Do not stream BLOCK_SOURCE_LOCATION.  We cannot handle debug information
      for early inlining so drop it on the floor instead of ICEing in
      dwarf2out.c.  */
-  lto_output_chain (ob, BLOCK_VARS (expr), ref_p);
+  streamer_write_chain (ob, BLOCK_VARS (expr), ref_p);
 
   /* Do not stream BLOCK_NONLOCALIZED_VARS.  We cannot handle debug information
      for early inlining so drop it on the floor instead of ICEing in
@@ -694,14 +690,13 @@ lto_output_ts_block_tree_pointers (struct output_block *ob, tree expr,
    fields.  */
 
 static void
-lto_output_ts_binfo_tree_pointers (struct output_block *ob, tree expr,
-				   bool ref_p)
+write_ts_binfo_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   unsigned i;
   tree t;
 
   /* Note that the number of BINFO slots has already been emitted in
-     EXPR's header (see lto_output_tree_header) because this length
+     EXPR's header (see streamer_write_tree_header) because this length
      is needed to build the empty BINFO node on the reader side.  */
   FOR_EACH_VEC_ELT (tree, BINFO_BASE_BINFOS (expr), i, t)
     stream_write_tree (ob, t, ref_p);
@@ -716,7 +711,7 @@ lto_output_ts_binfo_tree_pointers (struct output_block *ob, tree expr,
   stream_write_tree (ob, flag_wpa ? NULL : BINFO_VIRTUALS (expr), ref_p);
   stream_write_tree (ob, BINFO_VPTR_FIELD (expr), ref_p);
 
-  output_uleb128 (ob, VEC_length (tree, BINFO_BASE_ACCESSES (expr)));
+  streamer_write_wide_uint (ob, VEC_length (tree, BINFO_BASE_ACCESSES (expr)));
   FOR_EACH_VEC_ELT (tree, BINFO_BASE_ACCESSES (expr), i, t)
     stream_write_tree (ob, t, ref_p);
 
@@ -731,13 +726,13 @@ lto_output_ts_binfo_tree_pointers (struct output_block *ob, tree expr,
    pointer fields.  */
 
 static void
-lto_output_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
-					 bool ref_p)
+write_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
+				    bool ref_p)
 {
   unsigned i;
   tree index, value;
 
-  output_uleb128 (ob, CONSTRUCTOR_NELTS (expr));
+  streamer_write_wide_uint (ob, CONSTRUCTOR_NELTS (expr));
   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value)
     {
       stream_write_tree (ob, index, ref_p);
@@ -748,7 +743,7 @@ lto_output_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
 /* Write a TS_TARGET_OPTION tree in EXPR to OB.  */
 
 static void
-lto_output_ts_target_option (struct output_block *ob, tree expr)
+write_ts_target_option (struct output_block *ob, tree expr)
 {
   struct cl_target_option *t = TREE_TARGET_OPTION (expr);
   struct bitpack_d bp;
@@ -763,85 +758,85 @@ lto_output_ts_target_option (struct output_block *ob, tree expr)
     bp_pack_value (&bp, ((unsigned char *)t)[i], 8);
   /* Catch struct size mismatches between reader and writer. */
   bp_pack_value (&bp, 0x12345678, 32);
-  lto_output_bitpack (&bp);
+  streamer_write_bitpack (&bp);
 }
 
 /* Write a TS_TRANSLATION_UNIT_DECL tree in EXPR to OB.  */
 
 static void
-lto_output_ts_translation_unit_decl_tree_pointers (struct output_block *ob,
-						   tree expr)
+write_ts_translation_unit_decl_tree_pointers (struct output_block *ob,
+					      tree expr)
 {
-  lto_output_string (ob, ob->main_stream,
-		     TRANSLATION_UNIT_LANGUAGE (expr), true);
+  streamer_write_string (ob, ob->main_stream,
+			 TRANSLATION_UNIT_LANGUAGE (expr), true);
 }
 
 /* Write all pointer fields in EXPR to output block OB.  If REF_P is true,
    the leaves of EXPR are emitted as references.  */
 
 void
-lto_output_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
+streamer_write_tree_body (struct output_block *ob, tree expr, bool ref_p)
 {
   enum tree_code code;
 
   code = TREE_CODE (expr);
 
   if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
-    lto_output_ts_common_tree_pointers (ob, expr, ref_p);
+    write_ts_common_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
-    lto_output_ts_vector_tree_pointers (ob, expr, ref_p);
+    write_ts_vector_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
-    lto_output_ts_complex_tree_pointers (ob, expr, ref_p);
+    write_ts_complex_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
-    lto_output_ts_decl_minimal_tree_pointers (ob, expr, ref_p);
+    write_ts_decl_minimal_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
-    lto_output_ts_decl_common_tree_pointers (ob, expr, ref_p);
+    write_ts_decl_common_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
-    lto_output_ts_decl_non_common_tree_pointers (ob, expr, ref_p);
+    write_ts_decl_non_common_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
-    lto_output_ts_decl_with_vis_tree_pointers (ob, expr, ref_p);
+    write_ts_decl_with_vis_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
-    lto_output_ts_field_decl_tree_pointers (ob, expr, ref_p);
+    write_ts_field_decl_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
-    lto_output_ts_function_decl_tree_pointers (ob, expr, ref_p);
+    write_ts_function_decl_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
-    lto_output_ts_type_common_tree_pointers (ob, expr, ref_p);
+    write_ts_type_common_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
-    lto_output_ts_type_non_common_tree_pointers (ob, expr, ref_p);
+    write_ts_type_non_common_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_LIST))
-    lto_output_ts_list_tree_pointers (ob, expr, ref_p);
+    write_ts_list_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_VEC))
-    lto_output_ts_vec_tree_pointers (ob, expr, ref_p);
+    write_ts_vec_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_EXP))
-    lto_output_ts_exp_tree_pointers (ob, expr, ref_p);
+    write_ts_exp_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
-    lto_output_ts_block_tree_pointers (ob, expr, ref_p);
+    write_ts_block_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
-    lto_output_ts_binfo_tree_pointers (ob, expr, ref_p);
+    write_ts_binfo_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
-    lto_output_ts_constructor_tree_pointers (ob, expr, ref_p);
+    write_ts_constructor_tree_pointers (ob, expr, ref_p);
 
   if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
-    lto_output_ts_target_option (ob, expr);
+    write_ts_target_option (ob, expr);
 
   if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
-    lto_output_ts_translation_unit_decl_tree_pointers (ob, expr);
+    write_ts_translation_unit_decl_tree_pointers (ob, expr);
 }
 
 
@@ -851,7 +846,7 @@ lto_output_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
    where EXPR is stored.  */
 
 void
-lto_output_tree_header (struct output_block *ob, tree expr)
+streamer_write_tree_header (struct output_block *ob, tree expr)
 {
   enum LTO_tags tag;
   enum tree_code code;
@@ -864,7 +859,7 @@ lto_output_tree_header (struct output_block *ob, tree expr)
      EXPR on the reading side (such as the number of slots in
      variable sized nodes).  */
   tag = lto_tree_code_to_tag (code);
-  output_record_start (ob, tag);
+  streamer_write_record_start (ob, tag);
 
   /* The following will cause bootstrap miscomparisons.  Enable with care.  */
 #ifdef LTO_STREAMER_DEBUG
@@ -873,21 +868,21 @@ lto_output_tree_header (struct output_block *ob, tree expr)
      value for EXPR can be used to track down the differences in
      the debugger.  */
   gcc_assert ((HOST_WIDEST_INT) (intptr_t) expr == (intptr_t) expr);
-  output_sleb128 (ob, (HOST_WIDEST_INT) (intptr_t) expr);
+  streamer_write_wide_int (ob, (HOST_WIDEST_INT) (intptr_t) expr);
 #endif
 
   /* The text in strings and identifiers are completely emitted in
      the header.  */
   if (CODE_CONTAINS_STRUCT (code, TS_STRING))
-    output_string_cst (ob, ob->main_stream, expr);
+    write_string_cst (ob, ob->main_stream, expr);
   else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
-    output_identifier (ob, ob->main_stream, expr);
+    write_identifier (ob, ob->main_stream, expr);
   else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
-    output_sleb128 (ob, TREE_VEC_LENGTH (expr));
+    streamer_write_wide_int (ob, TREE_VEC_LENGTH (expr));
   else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
-    output_uleb128 (ob, BINFO_N_BASE_BINFOS (expr));
+    streamer_write_wide_uint (ob, BINFO_N_BASE_BINFOS (expr));
   else if (TREE_CODE (expr) == CALL_EXPR)
-    output_uleb128 (ob, call_expr_nargs (expr));
+    streamer_write_wide_uint (ob, call_expr_nargs (expr));
 }
 
 
@@ -895,11 +890,11 @@ lto_output_tree_header (struct output_block *ob, tree expr)
    CST's type will be emitted as a reference.  */
 
 void
-lto_output_integer_cst (struct output_block *ob, tree cst, bool ref_p)
+streamer_write_integer_cst (struct output_block *ob, tree cst, bool ref_p)
 {
-  output_record_start (ob, lto_tree_code_to_tag (INTEGER_CST));
+  streamer_write_record_start (ob, lto_tree_code_to_tag (INTEGER_CST));
   stream_write_tree (ob, TREE_TYPE (cst), ref_p);
-  lto_output_1_stream (ob->main_stream, TREE_OVERFLOW_P (cst));
-  output_uleb128 (ob, TREE_INT_CST_LOW (cst));
-  output_uleb128 (ob, TREE_INT_CST_HIGH (cst));
+  streamer_write_char_stream (ob->main_stream, TREE_OVERFLOW_P (cst));
+  streamer_write_wide_uint (ob, TREE_INT_CST_LOW (cst));
+  streamer_write_wide_uint (ob, TREE_INT_CST_HIGH (cst));
 }
diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c
index 0517441..94d540b 100644
--- a/gcc/tree-streamer.c
+++ b/gcc/tree-streamer.c
@@ -26,12 +26,12 @@ along with GCC; see the file COPYING3.  If not see
 #include "streamer-hooks.h"
 #include "tree-streamer.h"
 
-/* Check that all the TS_* structures handled by the lto_output_* and
-   lto_input_* routines are exactly ALL the structures defined in
+/* Check that all the TS_* structures handled by the streamer_write_* and
+   streamer_read_* routines are exactly ALL the structures defined in
    treestruct.def.  */
 
 void
-check_handled_ts_structures (void)
+streamer_check_handled_ts_structures (void)
 {
   bool handled_p[LAST_TS_ENUM];
   unsigned i;
@@ -87,12 +87,12 @@ check_handled_ts_structures (void)
 }
 
 
-/* Helper for lto_streamer_cache_insert_1.  Add T to CACHE->NODES at
+/* Helper for streamer_tree_cache_insert_1.  Add T to CACHE->NODES at
    slot IX.  */
 
 static void
-lto_streamer_cache_add_to_node_array (struct lto_streamer_cache_d *cache,
-				      unsigned ix, tree t)
+streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache,
+				       unsigned ix, tree t)
 {
   /* Make sure we're either replacing an old element or
      appending consecutively.  */
@@ -105,8 +105,8 @@ lto_streamer_cache_add_to_node_array (struct lto_streamer_cache_d *cache,
 }
 
 
-/* Helper for lto_streamer_cache_insert and lto_streamer_cache_insert_at.
-   CACHE, T, and IX_P are as in lto_streamer_cache_insert.
+/* Helper for streamer_tree_cache_insert and streamer_tree_cache_insert_at.
+   CACHE, T, and IX_P are as in streamer_tree_cache_insert.
 
    If INSERT_AT_NEXT_SLOT_P is true, T is inserted at the next available
    slot in the cache.  Otherwise, T is inserted at the position indicated
@@ -116,9 +116,9 @@ lto_streamer_cache_add_to_node_array (struct lto_streamer_cache_d *cache,
    return false.  */
 
 static bool
-lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
-			     tree t, unsigned *ix_p,
-			     bool insert_at_next_slot_p)
+streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache,
+			      tree t, unsigned *ix_p,
+			      bool insert_at_next_slot_p)
 {
   void **slot;
   unsigned ix;
@@ -136,7 +136,7 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
 	ix = *ix_p;
        *slot = (void *)(size_t) (ix + 1);
 
-      lto_streamer_cache_add_to_node_array (cache, ix, t);
+      streamer_tree_cache_add_to_node_array (cache, ix, t);
 
       /* Indicate that the item was not present in the cache.  */
       existed_p = false;
@@ -151,7 +151,7 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
 	     location, and ENTRY->TO does not match *IX_P, add T to
 	     the requested location slot.  */
 	  ix = *ix_p;
-	  lto_streamer_cache_add_to_node_array (cache, ix, t);
+	  streamer_tree_cache_add_to_node_array (cache, ix, t);
 	}
 
       /* Indicate that T was already in the cache.  */
@@ -172,10 +172,10 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
    T has been stored.  */
 
 bool
-lto_streamer_cache_insert (struct lto_streamer_cache_d *cache, tree t,
-			   unsigned *ix_p)
+streamer_tree_cache_insert (struct streamer_tree_cache_d *cache, tree t,
+			    unsigned *ix_p)
 {
-  return lto_streamer_cache_insert_1 (cache, t, ix_p, true);
+  return streamer_tree_cache_insert_1 (cache, t, ix_p, true);
 }
 
 
@@ -183,20 +183,20 @@ lto_streamer_cache_insert (struct lto_streamer_cache_d *cache, tree t,
    existed in the cache return true.  Otherwise, return false.  */
 
 bool
-lto_streamer_cache_insert_at (struct lto_streamer_cache_d *cache,
-			      tree t, unsigned ix)
+streamer_tree_cache_insert_at (struct streamer_tree_cache_d *cache,
+			       tree t, unsigned ix)
 {
-  return lto_streamer_cache_insert_1 (cache, t, &ix, false);
+  return streamer_tree_cache_insert_1 (cache, t, &ix, false);
 }
 
 
 /* Appends tree node T to CACHE, even if T already existed in it.  */
 
 void
-lto_streamer_cache_append (struct lto_streamer_cache_d *cache, tree t)
+streamer_tree_cache_append (struct streamer_tree_cache_d *cache, tree t)
 {
   unsigned ix = VEC_length (tree, cache->nodes);
-  lto_streamer_cache_insert_1 (cache, t, &ix, false);
+  streamer_tree_cache_insert_1 (cache, t, &ix, false);
 }
 
 /* Return true if tree node T exists in CACHE, otherwise false.  If IX_P is
@@ -204,8 +204,8 @@ lto_streamer_cache_append (struct lto_streamer_cache_d *cache, tree t)
    ((unsigned)-1 if T is not found).  */
 
 bool
-lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t,
-			   unsigned *ix_p)
+streamer_tree_cache_lookup (struct streamer_tree_cache_d *cache, tree t,
+			    unsigned *ix_p)
 {
   void **slot;
   bool retval;
@@ -235,7 +235,7 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t,
 /* Return the tree node at slot IX in CACHE.  */
 
 tree
-lto_streamer_cache_get (struct lto_streamer_cache_d *cache, unsigned ix)
+streamer_tree_cache_get (struct streamer_tree_cache_d *cache, unsigned ix)
 {
   gcc_assert (cache);
 
@@ -249,7 +249,7 @@ lto_streamer_cache_get (struct lto_streamer_cache_d *cache, unsigned ix)
 /* Record NODE in CACHE.  */
 
 static void
-lto_record_common_node (struct lto_streamer_cache_d *cache, tree node)
+record_common_node (struct streamer_tree_cache_d *cache, tree node)
 {
   /* We have to make sure to fill exactly the same number of
      elements for all frontends.  That can include NULL trees.
@@ -260,12 +260,12 @@ lto_record_common_node (struct lto_streamer_cache_d *cache, tree node)
   if (!node)
     node = error_mark_node;
 
-  lto_streamer_cache_append (cache, node);
+  streamer_tree_cache_append (cache, node);
 
   if (POINTER_TYPE_P (node)
       || TREE_CODE (node) == COMPLEX_TYPE
       || TREE_CODE (node) == ARRAY_TYPE)
-    lto_record_common_node (cache, TREE_TYPE (node));
+    record_common_node (cache, TREE_TYPE (node));
   else if (TREE_CODE (node) == RECORD_TYPE)
     {
       /* The FIELD_DECLs of structures should be shared, so that every
@@ -275,7 +275,7 @@ lto_record_common_node (struct lto_streamer_cache_d *cache, tree node)
 	 nonoverlapping_component_refs_p).  */
       tree f;
       for (f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
-	lto_record_common_node (cache, f);
+	record_common_node (cache, f);
     }
 }
 
@@ -284,35 +284,35 @@ lto_record_common_node (struct lto_streamer_cache_d *cache, tree node)
    properly according to the gimple type table.  */
 
 static void
-preload_common_nodes (struct lto_streamer_cache_d *cache)
+preload_common_nodes (struct streamer_tree_cache_d *cache)
 {
   unsigned i;
 
   for (i = 0; i < itk_none; i++)
     /* Skip itk_char.  char_type_node is dependent on -f[un]signed-char.  */
     if (i != itk_char)
-      lto_record_common_node (cache, integer_types[i]);
+      record_common_node (cache, integer_types[i]);
 
   for (i = 0; i < TYPE_KIND_LAST; i++)
-    lto_record_common_node (cache, sizetype_tab[i]);
+    record_common_node (cache, sizetype_tab[i]);
 
   for (i = 0; i < TI_MAX; i++)
     /* Skip boolean type and constants, they are frontend dependent.  */
     if (i != TI_BOOLEAN_TYPE
 	&& i != TI_BOOLEAN_FALSE
 	&& i != TI_BOOLEAN_TRUE)
-      lto_record_common_node (cache, global_trees[i]);
+      record_common_node (cache, global_trees[i]);
 }
 
 
 /* Create a cache of pickled nodes.  */
 
-struct lto_streamer_cache_d *
-lto_streamer_cache_create (void)
+struct streamer_tree_cache_d *
+streamer_tree_cache_create (void)
 {
-  struct lto_streamer_cache_d *cache;
+  struct streamer_tree_cache_d *cache;
 
-  cache = XCNEW (struct lto_streamer_cache_d);
+  cache = XCNEW (struct streamer_tree_cache_d);
 
   cache->node_map = pointer_map_create ();
 
@@ -328,7 +328,7 @@ lto_streamer_cache_create (void)
 /* Delete the streamer cache C.  */
 
 void
-lto_streamer_cache_delete (struct lto_streamer_cache_d *c)
+streamer_tree_cache_delete (struct streamer_tree_cache_d *c)
 {
   if (c == NULL)
     return;
diff --git a/gcc/tree-streamer.h b/gcc/tree-streamer.h
index a3de831..b8f2d1f 100644
--- a/gcc/tree-streamer.h
+++ b/gcc/tree-streamer.h
@@ -43,7 +43,7 @@ along with GCC; see the file COPYING3.  If not see
      T.  The reconstructed T is inserted in some array so that when
      the reference index for T is found in the input stream, it can be
      used to look up into the array to get the reconstructed T.  */
-struct lto_streamer_cache_d
+struct streamer_tree_cache_d
 {
   /* The mapping between tree nodes and slots into the nodes array.  */
   struct pointer_map_t *node_map;
@@ -55,7 +55,7 @@ struct lto_streamer_cache_d
 /* Return true if tree node EXPR should be streamed as a builtin.  For
    these nodes, we just emit the class and function code.  */
 static inline bool
-lto_stream_as_builtin_p (tree expr)
+streamer_handle_as_builtin_p (tree expr)
 {
   return (TREE_CODE (expr) == FUNCTION_DECL
 	  && DECL_IS_BUILTIN (expr)
@@ -64,36 +64,35 @@ lto_stream_as_builtin_p (tree expr)
 }
 
 /* In tree-streamer-in.c.  */
-tree input_string_cst (struct data_in *, struct lto_input_block *);
-void lto_streamer_read_tree (struct lto_input_block *, struct data_in *, tree);
-tree lto_input_chain (struct lto_input_block *, struct data_in *);
-tree lto_materialize_tree (struct lto_input_block *, struct data_in *,
-			   enum LTO_tags);
-void lto_input_tree_pointers (struct lto_input_block *, struct data_in *, tree);
-tree lto_get_pickled_tree (struct lto_input_block *, struct data_in *);
-tree lto_get_builtin_tree (struct lto_input_block *, struct data_in *);
-tree lto_input_integer_cst (struct lto_input_block *, struct data_in *);
-struct bitpack_d tree_read_bitfields (struct lto_input_block *, tree);
+tree streamer_read_string_cst (struct data_in *, struct lto_input_block *);
+tree streamer_read_chain (struct lto_input_block *, struct data_in *);
+tree streamer_alloc_tree (struct lto_input_block *, struct data_in *,
+		          enum LTO_tags);
+void streamer_read_tree_body (struct lto_input_block *, struct data_in *, tree);
+tree streamer_get_pickled_tree (struct lto_input_block *, struct data_in *);
+tree streamer_get_builtin_tree (struct lto_input_block *, struct data_in *);
+tree streamer_read_integer_cst (struct lto_input_block *, struct data_in *);
+struct bitpack_d streamer_read_tree_bitfields (struct lto_input_block *, tree);
 
 /* In tree-streamer-out.c.  */
-void lto_output_chain (struct output_block *, tree, bool);
-void lto_output_tree_header (struct output_block *, tree);
-void pack_value_fields (struct bitpack_d *, tree);
-void lto_output_tree_pointers (struct output_block *, tree, bool);
-void lto_output_integer_cst (struct output_block *, tree, bool);
-void lto_output_builtin_tree (struct output_block *, tree);
+void streamer_write_chain (struct output_block *, tree, bool);
+void streamer_write_tree_header (struct output_block *, tree);
+void streamer_pack_tree_bitfields (struct bitpack_d *, tree);
+void streamer_write_tree_body (struct output_block *, tree, bool);
+void streamer_write_integer_cst (struct output_block *, tree, bool);
+void streamer_write_builtin (struct output_block *, tree);
 
 /* In tree-streamer.c.  */
-void check_handled_ts_structures (void);
-bool lto_streamer_cache_insert (struct lto_streamer_cache_d *, tree,
- 			        unsigned *);
-bool lto_streamer_cache_insert_at (struct lto_streamer_cache_d *, tree,
- 				   unsigned);
-void lto_streamer_cache_append (struct lto_streamer_cache_d *, tree);
-bool lto_streamer_cache_lookup (struct lto_streamer_cache_d *, tree,
- 			        unsigned *);
-tree lto_streamer_cache_get (struct lto_streamer_cache_d *, unsigned);
-struct lto_streamer_cache_d *lto_streamer_cache_create (void);
-void lto_streamer_cache_delete (struct lto_streamer_cache_d *);
+void streamer_check_handled_ts_structures (void);
+bool streamer_tree_cache_insert (struct streamer_tree_cache_d *, tree,
+				 unsigned *);
+bool streamer_tree_cache_insert_at (struct streamer_tree_cache_d *, tree,
+				    unsigned);
+void streamer_tree_cache_append (struct streamer_tree_cache_d *, tree);
+bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree,
+				 unsigned *);
+tree streamer_tree_cache_get (struct streamer_tree_cache_d *, unsigned);
+struct streamer_tree_cache_d *streamer_tree_cache_create (void);
+void streamer_tree_cache_delete (struct streamer_tree_cache_d *);
 
 #endif  /* GCC_TREE_STREAMER_H  */
