@@ -137,14 +137,40 @@ pph_stream_init_write (pph_stream *stream)
}
+/* Callback for writing ASTs to a stream. This writes all the fields
+ that are not processed by default by the common tree pickler.
+ OB and REF_P are as in lto_write_tree. EXPR is the tree to write. */
+
+static void
+pph_stream_write_tree (struct output_block *ob, tree expr, bool ref_p)
+{
+ if (TREE_CODE (expr) == FUNCTION_DECL)
+ lto_output_tree_or_ref (ob, DECL_SAVED_TREE (expr), ref_p);
+}
+
+
+/* Callback for reading ASTs from a stream. This reads all the fields
+ that are not processed by default by the common tree pickler.
+ IB, DATA_IN are as in lto_read_tree. EXPR is the partially materialized
+ tree. */
+
+static void
+pph_stream_read_tree (struct lto_input_block *ib, struct data_in *data_in,
+ tree expr)
+{
+ if (TREE_CODE (expr) == FUNCTION_DECL)
+ DECL_SAVED_TREE (expr) = lto_input_tree (ib, data_in);
+}
+
+
/* Initialize all the streamer hooks used for streaming ASTs. */
static void
pph_streamer_hooks_init (void)
{
lto_streamer_hooks *h = streamer_hooks_init ();
- h->reader_init = NULL;
- h->writer_init = NULL;
+ h->write_tree = pph_stream_write_tree;
+ h->read_tree = pph_stream_read_tree;
}
@@ -1983,11 +1983,7 @@ lto_input_ts_decl_minimal_tree_pointers (struct lto_input_block *ib,
/* Read all pointer fields in the TS_DECL_COMMON structure of EXPR from
input block IB. DATA_IN contains tables and descriptors for the
- file being read.
-
- Fields that should be handled by a callback:
- DECL_INITIAL
- DECL_ABSTRACT_ORIGIN. */
+ file being read. */
static void
lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib,
@@ -2020,10 +2016,7 @@ lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib,
/* Read all pointer fields in the TS_DECL_NON_COMMON structure of
EXPR from input block IB. DATA_IN contains tables and descriptors for the
- file being read.
-
- Fields that should be handled by a callback:
- DECL_SAVED_TREE. */
+ file being read. */
static void
lto_input_ts_decl_non_common_tree_pointers (struct lto_input_block *ib,
@@ -743,7 +743,7 @@ lto_output_tree_ref (struct output_block *ob, tree expr)
/* If REF_P is true, emit a reference to EXPR in output block OB,
otherwise emit the physical representation of EXPR in OB. */
-static inline void
+void
lto_output_tree_or_ref (struct output_block *ob, tree expr, bool ref_p)
{
if (ref_p)
@@ -835,11 +835,7 @@ lto_output_ts_decl_minimal_tree_pointers (struct output_block *ob, tree expr,
/* Write all pointer fields in the TS_DECL_COMMON structure of EXPR to
output block OB. If REF_P is true, write a reference to EXPR's
- pointer fields.
-
- Fields that should be handled by a callback:
- DECL_INITIAL
- DECL_ABSTRACT_ORIGIN. */
+ pointer fields. */
static void
lto_output_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
@@ -871,10 +867,7 @@ lto_output_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
/* Write all pointer fields in the TS_DECL_NON_COMMON structure of
EXPR to output block OB. If REF_P is true, write a reference to EXPR's
- pointer fields.
-
- Fields that should be handled by a callback:
- DECL_SAVED_TREE. */
+ pointer fields. */
static void
lto_output_ts_decl_non_common_tree_pointers (struct output_block *ob,
@@ -60,7 +60,17 @@ typedef struct lto_streamer_hooks {
/* Called by lto_write_tree after writing all the common parts of
a tree. If defined, the callback is in charge of writing all
the fields that lto_write_tree did not write out. Arguments
- are as in lto_write_tree. */
+ are as in lto_write_tree.
+
+ The following tree fields are not handled by common code:
+
+ DECL_ABSTRACT_ORIGIN
+ DECL_INITIAL
+ DECL_SAVED_TREE
+
+ Callbacks may choose to ignore or handle them. If handled,
+ the reader should read them in the exact same sequence written
+ by the writer. */
void (*write_tree) (struct output_block *, tree, bool);
/* Called by lto_read_tree after reading all the common parts of
@@ -908,6 +918,7 @@ extern void lto_register_decl_definition (tree, struct lto_file_decl_data *);
extern struct output_block *create_output_block (enum lto_section_type);
extern void destroy_output_block (struct output_block *);
extern void lto_output_tree (struct output_block *, tree, bool);
+extern void lto_output_tree_or_ref (struct output_block *, tree, bool);
extern void produce_asm (struct output_block *ob, tree fn);
extern void lto_output_string (struct output_block *,
struct lto_output_stream *,