To avoid confusion, I moved the callbacks into pph-streamer.c so they can be internal to ...
13 years, 6 months ago
(2011-10-13 15:45:49 UTC)
#1
To avoid confusion, I moved the callbacks into pph-streamer.c so they
can be internal to that file. They don't need to be called directly
ever.
Tested on x86_64. Committed to branch.
Diego.
* pph-streamer-in.c (pph_in_mergeable_tree): Fix comment.
(pph_read_tree): Move to pph-streamer.c.
(pph_in_location): Rename from pph_read_location.
(pph_read_location): Move to pph-streamer.c.
(pph_in_mergeable_chain): Call pph_in_hwi.
(pph_in_any_tree): Fix comment.
* pph-streamer-out.c (pph_write_tree): Move to pph-streamer.c.
(pph_out_location): Rename from pph_write_location.
(pph_write_location): Move to pph-streamer.c.
* pph-streamer.c (pph_write_tree): Move from pph-streamer-out.c.
Make static.
(pph_read_tree): Move from pph-streamer-in.c. Make static.
(pph_input_location): Move from pph-streamer-in.c. Rename
from pph_read_location.
(pph_output_location): Move from pph-streamer-out.c. Rename
from pph_out_location.
* pph-streamer.h (pph_write_tree): Remove.
(pph_write_location): Remove.
(pph_read_tree): Remove.
(pph_read_location): Remove.
(pph_out_location): Declare.
(pph_out_tree): Declare.
(pph_in_location): Declare.
(pph_in_tree): Declare.
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 3893ad2..f8d6393 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -517,6 +517,7 @@ static tree pph_in_any_tree (pph_stream *stream, tree
*chain);
/* Load an AST from STREAM. Return the corresponding tree. */
+
tree
pph_in_tree (pph_stream *stream)
{
@@ -525,8 +526,7 @@ pph_in_tree (pph_stream *stream)
}
-/* Load an AST in an ENCLOSING_NAMESPACE from STREAM.
- Return the corresponding tree. */
+/* Load an AST into CHAIN from STREAM. */
static void
pph_in_mergeable_tree (pph_stream *stream, tree *chain)
{
@@ -534,41 +534,23 @@ pph_in_mergeable_tree (pph_stream *stream, tree *chain)
}
-/* Callback for reading ASTs from a stream. Instantiate and return a
- new tree from the PPH stream in DATA_IN. */
-
-tree
-pph_read_tree (struct lto_input_block *ib_unused ATTRIBUTE_UNUSED,
- struct data_in *root_data_in)
-{
- /* Find data. */
- pph_stream *stream = (pph_stream *) root_data_in->sdata;
- return pph_in_any_tree (stream, NULL);
-}
-
-
/********************************************************** lexical elements */
-/* Callback for streamer_hooks.input_location. An offset is applied to
- the location_t read in according to the properties of the merged
- line_table. IB and DATA_IN are as in lto_input_location. This function
- should only be called after pph_in_and_merge_line_table was called as
- we expect pph_loc_offset to be set. */
+/* Read and return a location_t from STREAM. */
location_t
-pph_read_location (struct lto_input_block *ib,
- struct data_in *data_in ATTRIBUTE_UNUSED)
+pph_in_location (pph_stream *stream)
{
struct bitpack_d bp;
bool is_builtin;
unsigned HOST_WIDE_INT n;
location_t old_loc;
- bp = streamer_read_bitpack (ib);
+ bp = pph_in_bitpack (stream);
is_builtin = bp_unpack_value (&bp, 1);
- n = streamer_read_uhwi (ib);
+ n = pph_in_uhwi (stream);
old_loc = (location_t) n;
gcc_assert (old_loc == n);
@@ -576,20 +558,6 @@ pph_read_location (struct lto_input_block *ib,
}
-/* Read and return a location_t from STREAM.
- FIXME pph: Tracing doesn't depend on STREAM any more. 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. Say what? */
-
-location_t
-pph_in_location (pph_stream *stream)
-{
- location_t loc = pph_read_location (stream->encoder.r.ib,
- stream->encoder.r.data_in);
- return loc;
-}
-
-
/* Load the tree value associated with TOKEN from STREAM. */
static void
@@ -761,7 +729,7 @@ pph_in_mergeable_chain (pph_stream *stream, tree *chain)
{
int i, count;
- count = streamer_read_hwi (stream->encoder.r.ib);
+ count = pph_in_hwi (stream);
for (i = 0; i < count; i++)
pph_in_mergeable_tree (stream, chain);
}
@@ -1954,8 +1922,8 @@ pph_in_tree_header (pph_stream *stream, enum LTO_tags tag)
}
-/* Read a tree from the STREAM. It ENCLOSING_NAMESPACE is not null,
- the tree may be unified with an existing tree in that namespace. */
+/* Read a tree from the STREAM. If CHAIN is not null, the tree may be
+ unified with an existing tree in that chain. */
static tree
pph_in_any_tree (pph_stream *stream, tree *chain)
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 0c00054..b5020f2 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -641,26 +641,13 @@ pph_out_mergeable_tree (pph_stream *stream, tree t)
}
-/* Callback for writing ASTs to a stream. Write EXPR to the PPH stream
- in OB. */
-
-void
-pph_write_tree (struct output_block *ob, tree expr, bool ref_p
ATTRIBUTE_UNUSED)
-{
- pph_stream *stream = (pph_stream *) ob->sdata;
- pph_out_any_tree (stream, expr, false);
-}
-
-
/********************************************************** lexical elements */
-/* 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. */
+/* Write location LOC of length to STREAM. */
void
-pph_write_location (struct output_block *ob, location_t loc)
+pph_out_location (pph_stream *stream, location_t loc)
{
/* FIXME pph: we are streaming builtin locations, which implies that we are
streaming some builtins, we probably want to figure out what those are and
@@ -670,7 +657,7 @@ pph_write_location (struct output_block *ob, location_t loc)
location_t first_non_builtin_loc =
line_table->maps[PPH_NUM_IGNORED_LINE_TABLE_ENTRIES].start_location;
- bp = bitpack_create (ob->main_stream);
+ bp = bitpack_create (stream->encoder.w.ob->main_stream);
if (loc < first_non_builtin_loc)
{
/* We should never stream out trees with locations between builtins
@@ -687,17 +674,8 @@ pph_write_location (struct output_block *ob, location_t
loc)
bp_pack_value (&bp, false, 1);
}
- streamer_write_bitpack (&bp);
- streamer_write_hwi (ob, loc);
-}
-
-
-/* Write location LOC of length to STREAM. */
-
-void
-pph_out_location (pph_stream *stream, location_t loc)
-{
- pph_write_location (stream->encoder.w.ob, loc);
+ pph_out_bitpack (stream, &bp);
+ pph_out_uhwi (stream, loc);
}
diff --git a/gcc/cp/pph-streamer.c b/gcc/cp/pph-streamer.c
index b2b412f..7bcff92 100644
--- a/gcc/cp/pph-streamer.c
+++ b/gcc/cp/pph-streamer.c
@@ -92,6 +92,52 @@ pph_cache_preload (pph_cache *cache)
}
+/* Callback for writing ASTs to a stream. Write EXPR to the PPH stream
+ in OB. */
+
+static void
+pph_write_tree (struct output_block *ob, tree expr, bool ref_p
ATTRIBUTE_UNUSED)
+{
+ pph_out_tree ((pph_stream *) ob->sdata, expr);
+}
+
+
+/* Callback for reading ASTs from a stream. Instantiate and return a
+ new tree from the PPH stream in DATA_IN. */
+
+static tree
+pph_read_tree (struct lto_input_block *ib ATTRIBUTE_UNUSED,
+ struct data_in *data_in)
+{
+ return pph_in_tree ((pph_stream *) data_in->sdata);
+}
+
+
+/* Callback for streamer_hooks.input_location. An offset is applied to
+ the location_t read in according to the properties of the merged
+ line_table. IB and DATA_IN are as in lto_input_location. This function
+ should only be called after pph_in_and_merge_line_table was called as
+ we expect pph_loc_offset to be set. */
+
+static location_t
+pph_input_location (struct lto_input_block *ib ATTRIBUTE_UNUSED,
+ struct data_in *data_in)
+{
+ return pph_in_location ((pph_stream *) data_in->sdata);
+}
+
+
+/* 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. */
+
+static void
+pph_output_location (struct output_block *ob, location_t loc)
+{
+ pph_out_location ((pph_stream *) ob->sdata, loc);
+}
+
+
/* Initialize all the streamer hooks used for streaming ASTs. */
static void
@@ -100,8 +146,8 @@ pph_hooks_init (void)
streamer_hooks_init ();
streamer_hooks.write_tree = pph_write_tree;
streamer_hooks.read_tree = pph_read_tree;
- streamer_hooks.input_location = pph_read_location;
- streamer_hooks.output_location = pph_write_location;
+ streamer_hooks.input_location = pph_input_location;
+ streamer_hooks.output_location = pph_output_location;
}
diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h
index 0656780..91618a8 100644
--- a/gcc/cp/pph-streamer.h
+++ b/gcc/cp/pph-streamer.h
@@ -243,17 +243,17 @@ tree pph_merge_name (tree expr);
/* In pph-streamer-out.c. */
void pph_flush_buffers (pph_stream *);
void pph_init_write (pph_stream *);
-void pph_write_tree (struct output_block *, tree, bool);
void pph_write_mergeable_chain (pph_stream *, tree);
void pph_writer_init (void);
void pph_writer_finish (void);
-void pph_write_location (struct output_block *, location_t);
+void pph_out_location (pph_stream *, location_t);
+void pph_out_tree (pph_stream *, tree);
/* In pph-streamer-in.c. */
void pph_init_read (pph_stream *);
-tree pph_read_tree (struct lto_input_block *, struct data_in *);
-location_t pph_read_location (struct lto_input_block *, struct data_in *);
+location_t pph_in_location (pph_stream *);
pph_stream *pph_read_file (const char *);
+tree pph_in_tree (pph_stream *stream);
/* Inline functions. */
--
1.7.3.1
--
This patch is available for review at http://codereview.appspot.com/5278043
Issue 5278043: [pph] Make streamer hooks internal
(Closed)
Created 13 years, 6 months ago by Diego Novillo
Modified 13 years, 6 months ago
Reviewers:
Base URL:
Comments: 0