Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(804)

Issue 5245043: [pph] De-inline streamer functions. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 7 months ago by Lawrence Crowl
Modified:
9 years, 11 months ago
Reviewers:
Diego Novillo
CC:
gcc-patches_gcc.gnu.org
Base URL:
svn+ssh://gcc.gnu.org/svn/gcc/branches/pph/
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+241 lines, -52 lines) Patch
M gcc/cp/pph-streamer.h View 10 chunks +20 lines, -50 lines 0 comments Download
M gcc/cp/pph-streamer-in.c View 3 chunks +109 lines, -0 lines 0 comments Download
M gcc/cp/pph-streamer-out.c View 5 chunks +112 lines, -2 lines 0 comments Download

Messages

Total messages: 1
Lawrence Crowl
10 years, 7 months ago (2011-10-07 19:09:37 UTC) #1
Move several static inline functions from pph-streamer.h to
pph-streamer-{out,in}.c.  This is part 1 of several patches,
and minimizes diffs.


Index: gcc/cp/ChangeLog.pph

2011-10-07   Lawrence Crowl  <crowl@google.com>
	* pph-streamer.h (pph_out_tree_array): Remove unused.
	(pph_in_tree_array): Remove unused.
	(pph_in_tree_VEC): Remove unused.
	(pph_out_uint): Moved to pph-streamer-out.c as extern.
	(pph_out_record_marker): Likewise.
	(pph_out_chain): Moved to pph-streamer-out.c as static.
	(pph_out_mergeable_chain): Likewise.
	(pph_out_bitpack): Likewise.
	(pph_in_uint): Moved to pph-streamer-in.c as extern.
	(pph_in_location): Likewise.
	(pph_in_tree): Likewise.
	(pph_in_record_marker): Likewise.
	(pph_in_uhwi): Moved to pph-streamer-in.c as static.
	(pph_in_hwi): Likewise.
	(pph_in_uchar): Likewise.
	(pph_in_bytes): Likewise.


Index: gcc/cp/pph-streamer-in.c
===================================================================
--- gcc/cp/pph-streamer-in.c	(revision 179636)
+++ gcc/cp/pph-streamer-in.c	(working copy)
@@ -146,6 +146,89 @@ pph_init_read (pph_stream *stream)
 }
 
 
+/* Read an unsigned char VALUE to STREAM.  */
+static unsigned char
+pph_in_uchar (pph_stream *stream)
+{
+  unsigned char n = streamer_read_uchar (stream->encoder.r.ib);
+  if (flag_pph_tracer >= 4)
+    pph_trace_uint (stream, n);
+  return n;
+}
+
+/* Read a HOST_WIDE_INT from STREAM.  */
+static inline HOST_WIDE_INT
+pph_in_hwi (pph_stream *stream)
+{
+  return streamer_read_hwi (stream->encoder.r.ib);
+}
+
+
+/* Read an unsigned HOST_WIDE_INT from STREAM.  */
+static inline unsigned HOST_WIDE_INT
+pph_in_uhwi (pph_stream *stream)
+{
+  return streamer_read_uhwi (stream->encoder.r.ib);
+}
+
+
+/* Read an unsigned integer from STREAM.  */
+unsigned int
+pph_in_uint (pph_stream *stream)
+{
+  HOST_WIDE_INT unsigned n = streamer_read_uhwi (stream->encoder.r.ib);
+  gcc_assert (n == (unsigned) n);
+  if (flag_pph_tracer >= 4)
+    pph_trace_uint (stream, n);
+  return (unsigned) n;
+}
+
+
+/* Read N bytes from STREAM into P.  The caller is responsible for
+   allocating a sufficiently large buffer.  */
+static void
+pph_in_bytes (pph_stream *stream, void *p, size_t n)
+{
+  lto_input_data_block (stream->encoder.r.ib, p, n);
+  if (flag_pph_tracer >= 4)
+    pph_trace_bytes (stream, p, n);
+}
+
+
+/* Read and return a string from STREAM.  */
+
+static const char *
+pph_in_string (pph_stream *stream)
+{
+  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;
+}
+
+
+/* Read and return a record marker from STREAM.  On return, *TAG_P will
+   contain the tag for the data type stored in this record.  */
+enum pph_record_marker
+pph_in_record_marker (pph_stream *stream, enum pph_tag *tag_p)
+{
+  enum pph_record_marker m = (enum pph_record_marker) pph_in_uchar (stream);
+  gcc_assert (m == PPH_RECORD_START
+              || m == PPH_RECORD_START_NO_CACHE
+              || m == PPH_RECORD_START_MUTATED
+              || m == PPH_RECORD_END
+              || m == PPH_RECORD_IREF
+              || m == PPH_RECORD_XREF
+              || m == PPH_RECORD_PREF);
+
+  *tag_p = (enum pph_tag) pph_in_uint (stream);
+  gcc_assert ((unsigned) *tag_p < (unsigned) PPH_NUM_TAGS);
+
+  return m;
+}
+
+
 /* Read and return a record header from STREAM.  EXPECTED_TAG indicates
    the data type that should be stored in this record.  When a
    PPH_RECORD_START marker is read, the next word read is an index
@@ -237,6 +320,22 @@ pph_read_location (struct lto_input_bloc
 }
 
 
+/* Read and return a location_t from STREAM.
+   FIXME pph: If pph_trace didn't depend on STREAM, we could avoid having to
+   call this function, only for it to call lto_input_location, which calls the
+   streamer hook back to pph_read_location.  */
+
+location_t
+pph_in_location (pph_stream *stream)
+{
+  location_t loc = pph_read_location (stream->encoder.r.ib,
+                                       stream->encoder.r.data_in);
+  if (flag_pph_tracer >= 4)
+    pph_trace_location (stream, loc);
+  return loc;
+}
+
+
 /* Load the tree value associated with TOKEN from STREAM.  */
 
 static void
@@ -2280,6 +2379,16 @@ pph_read_tree (struct lto_input_block *i
 }
 
 
+/* Load an AST from STREAM.  Return the corresponding tree.  */
+tree
+pph_in_tree (pph_stream *stream)
+{
+  tree t = pph_read_any_tree (stream, NULL);
+  if (flag_pph_tracer >= 4)
+    pph_trace_tree (stream, t);
+  return t;
+}
+
 /* Read a mergeable tree from STREAM into CHAIN.  */
 
 tree
Index: gcc/cp/pph-streamer.h
===================================================================
--- gcc/cp/pph-streamer.h	(revision 179636)
+++ gcc/cp/pph-streamer.h	(working copy)
@@ -439,21 +439,6 @@ pph_cache_find (pph_stream *stream, enum
   return e->data;
 }
 
-/* Output array A of cardinality C of ASTs to STREAM.  */
-/* FIXME pph: hold for alternate routine. */
-#if 0
-static inline void
-pph_out_tree_array (pph_stream *stream, tree *a, size_t c)
-{
-  size_t i;
-  for (i = 0; i < c; ++i)
-    {
-      if (flag_pph_tracer >= 1)
-        pph_trace_tree (stream, a[i]);
-      pph_write_tree (stream->encoder.w.ob, a[i]);
-    }
-}
-#endif
 
 /* Output AST T to STREAM.  If -fpph-tracer is set to TLEVEL or
    higher, T is sent to pph_trace_tree.  */
@@ -482,6 +467,7 @@ pph_out_mergeable_tree (pph_stream *stre
   pph_write_mergeable_tree (stream, t);
 }
 
+#if 0
 /* Write an unsigned int VALUE to STREAM.  */
 static inline void
 pph_out_uint (pph_stream *stream, unsigned int value)
@@ -544,6 +530,9 @@ pph_out_string_with_length (pph_stream *
 				     stream->encoder.w.ob->main_stream,
 				     str, len + 1, false);
 }
+#else
+extern void pph_out_uint (pph_stream *stream, unsigned int value);
+#endif
 
 /* Write location LOC of length to STREAM.  */
 static inline void
@@ -554,6 +543,7 @@ pph_out_location (pph_stream *stream, lo
   pph_write_location (stream->encoder.w.ob, loc);
 }
 
+#if 0
 /* Write a chain of ASTs to STREAM starting with FIRST.  */
 static inline void
 pph_out_chain (pph_stream *stream, tree first)
@@ -581,7 +571,9 @@ pph_out_bitpack (pph_stream *stream, str
     pph_trace_bitpack (stream, bp);
   streamer_write_bitpack (bp);
 }
+#endif
 
+#if 0
 /* Read an unsigned integer from STREAM.  */
 static inline unsigned int
 pph_in_uint (pph_stream *stream)
@@ -663,6 +655,11 @@ pph_in_tree (pph_stream *stream)
     pph_trace_tree (stream, t);
   return t;
 }
+#else
+extern unsigned int pph_in_uint (pph_stream *stream);
+extern location_t pph_in_location (pph_stream *stream);
+extern tree pph_in_tree (pph_stream *stream);
+#endif
 
 /* Load an AST in an ENCLOSING_NAMESPACE from STREAM.
    Return the corresponding tree.  */
@@ -674,41 +671,6 @@ pph_in_mergeable_tree (pph_stream *strea
     pph_trace_tree (stream, t);
 }
 
-/* Load into an array A of cardinality C of AST from STREAM.  */
-/* FIXME pph: Hold for later use. */
-#if 0
-static inline void
-pph_in_tree_array (pph_stream *stream, tree *a, size_t c)
-{
-  size_t i;
-  for (i = 0; i < c; ++i)
-    {
-      tree t = pph_read_tree (stream->encoder.r.ib, stream->encoder.r.data_in);
-      if (flag_pph_tracer >= 4)
-        pph_trace_tree (stream, t, false); /* FIXME pph: always false? */
-      a[i] = t;
-    }
-}
-#endif
-
-/* Load into a VEC V of AST from STREAM.  */
-/* FIXME pph: Hold for later use. */
-#if 0
-static inline void
-pph_in_tree_VEC (pph_stream *stream, VEC(tree,gc) *v)
-{
-  size_t i;
-  unsigned int c = pph_in_uint (stream);
-  for (i = 0; i < c; ++i)
-    {
-      tree t = pph_read_tree (stream->encoder.r.ib, stream->encoder.r.data_in);
-      if (flag_pph_tracer >= 4)
-        pph_trace_tree (stream, t, false); /* FIXME pph: always false? */
-      VEC_safe_push (tree, gc, v, t);
-    }
-}
-#endif
-
 /* Read a chain of ASTs from STREAM.  */
 static inline tree
 pph_in_chain (pph_stream *stream)
@@ -737,6 +699,7 @@ pph_in_bitpack (pph_stream *stream)
   return bp;
 }
 
+#if 0
 /* Write record MARKER for data type TAG to STREAM.  */
 static inline void
 pph_out_record_marker (pph_stream *stream, enum pph_record_marker marker,
@@ -749,6 +712,7 @@ pph_out_record_marker (pph_stream *strea
   pph_out_uint (stream, tag);
 }
 
+
 /* Read and return a record marker from STREAM.  On return, *TAG_P will
    contain the tag for the data type stored in this record.  */
 static inline enum pph_record_marker
@@ -768,6 +732,12 @@ pph_in_record_marker (pph_stream *stream
 
   return m;
 }
+#else
+extern void pph_out_record_marker (pph_stream *stream,
+		enum pph_record_marker marker, enum pph_tag tag);
+extern enum pph_record_marker pph_in_record_marker (pph_stream *stream,
+		enum pph_tag *tag_p);
+#endif
 
 
 /* Return true if MARKER is PPH_RECORD_IREF, PPH_RECORD_XREF,
Index: gcc/cp/pph-streamer-out.c
===================================================================
--- gcc/cp/pph-streamer-out.c	(revision 179636)
+++ gcc/cp/pph-streamer-out.c	(working copy)
@@ -86,6 +86,87 @@ pph_end_section (void)
 }
 
 
+/* Write an unsigned char VALUE to STREAM.  */
+static void
+pph_out_uchar (pph_stream *stream, unsigned char value)
+{
+  if (flag_pph_tracer >= 4)
+    pph_trace_uint (stream, value);
+  streamer_write_char_stream (stream->encoder.w.ob->main_stream, value);
+}
+
+
+/* Write a HOST_WIDE_INT VALUE to stream.  */
+static inline void
+pph_out_hwi (pph_stream *stream, HOST_WIDE_INT value)
+{
+  streamer_write_hwi (stream->encoder.w.ob, value);
+}
+
+
+/* Write an unsigned HOST_WIDE_INT VALUE to STREAM.  */
+static inline void
+pph_out_uhwi (pph_stream *stream, unsigned HOST_WIDE_INT value)
+{
+  streamer_write_uhwi (stream->encoder.w.ob, value);
+}
+
+
+/* Write an unsigned int VALUE to STREAM.  */
+void
+pph_out_uint (pph_stream *stream, unsigned int value)
+{
+  if (flag_pph_tracer >= 4)
+    pph_trace_uint (stream, value);
+  streamer_write_uhwi (stream->encoder.w.ob, value);
+}
+
+
+/* Write N bytes from P to STREAM.  */
+static void
+pph_out_bytes (pph_stream *stream, const void *p, size_t n)
+{
+  if (flag_pph_tracer >= 4)
+    pph_trace_bytes (stream, p, n);
+  lto_output_data_stream (stream->encoder.w.ob->main_stream, p, n);
+}
+
+
+/* Write string STR to STREAM.  */
+static inline void
+pph_out_string (pph_stream *stream, const char *str)
+{
+  if (flag_pph_tracer >= 4)
+    pph_trace_string (stream, str);
+  streamer_write_string (stream->encoder.w.ob,
+                         stream->encoder.w.ob->main_stream, str, false);
+}
+
+
+/* Write string STR of length LEN to STREAM.  */
+static inline void
+pph_out_string_with_length (pph_stream *stream, const char *str,
+                            unsigned int len)
+{
+  if (flag_pph_tracer >= 4)
+    pph_trace_string_with_length (stream, str, len);
+  streamer_write_string_with_length (stream->encoder.w.ob,
+                                     stream->encoder.w.ob->main_stream,
+                                     str, len + 1, false);
+}
+
+
+/* Write a bitpack BP to STREAM.  */
+static inline void
+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);
+  streamer_write_bitpack (bp);
+}
+
+
 /* Callback for streamer_hooks.output_location.  Output the LOC directly,
    an offset will be applied on input after rebuilding the line_table.
    OB and LOC are as in lto_output_location.  */
@@ -97,6 +178,7 @@ pph_write_location (struct output_block 
      streaming some builtins, we probably want to figure out what those are and
      simply add them to the cache in the preload.  */
   struct bitpack_d bp;
+
   location_t first_non_builtin_loc =
     line_table->maps[PPH_NUM_IGNORED_LINE_TABLE_ENTRIES].start_location;
 
@@ -122,6 +204,16 @@ pph_write_location (struct output_block 
 }
 
 
+/* Write a chain of ASTs to STREAM starting with FIRST.  */
+static void
+pph_out_chain (pph_stream *stream, tree first)
+{
+  if (flag_pph_tracer >= 2)
+    pph_trace_chain (stream, first);
+  streamer_write_chain (stream->encoder.w.ob, first, false);
+}
+
+
 /* Write the header for the PPH file represented by STREAM.  */
 
 static void
@@ -270,6 +362,19 @@ pph_get_marker_for (pph_stream *stream, 
 }
 
 
+/* Write record MARKER for data type TAG to STREAM.  */
+void
+pph_out_record_marker (pph_stream *stream, enum pph_record_marker marker,
+                       enum pph_tag tag)
+{
+  gcc_assert (marker == (enum pph_record_marker)(unsigned char) marker);
+  pph_out_uchar (stream, marker);
+
+  gcc_assert (tag == (enum pph_tag)(unsigned) tag);
+  pph_out_uint (stream, tag);
+}
+
+
 /* Write a reference record on STREAM.  MARKER is the tag indicating
    what kind of reference to write.  TAG indicates the data type to be
    stored in this record.  IX is the cache slot index to write.
@@ -746,9 +851,14 @@ pph_write_mergeable_links (pph_stream *s
    to STREAM.  */
 
 void
-pph_write_mergeable_chain (pph_stream *stream, tree t)
+pph_out_mergeable_chain (pph_stream *stream, tree t)
 {
-  int count = list_length (t);
+  int count;
+
+  if (flag_pph_tracer >= 2)
+    pph_trace_chain (stream, t);
+
+  count = list_length (t);
   streamer_write_hwi (stream->encoder.w.ob, count);
   pph_write_mergeable_links (stream, t);
 }

--
This patch is available for review at http://codereview.appspot.com/5245043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b