Add pph_stream_write_tree and pph_stream_read_tree callbacks. Make them handle DECL_SAVED_TREE. This produces several new failures since ...
13 years, 1 month ago
(2011-03-25 20:32:07 UTC)
#1
Add pph_stream_write_tree and pph_stream_read_tree callbacks.
Make them handle DECL_SAVED_TREE. This produces several new
failures since it exposes more unhandled trees.
Committed on pph branch. Fixes for the introduced failures coming up
in the next patch.
cp/ChangeLog.pph
2011-03-25 Diego Novillo <dnovillo@google.com>
* cp/pph-streamer.c (pph_stream_init_write):
ChangeLog.pph
2011-03-25 Diego Novillo <dnovillo@google.com>
* lto-streamer-in.c (lto_input_ts_decl_minimal_tree_pointers):
(lto_input_ts_decl_common_tree_pointers):
* a/gcc/lto-streamer-out.c (lto_output_tree_ref):
(lto_output_ts_decl_minimal_tree_pointers):
(lto_output_ts_decl_common_tree_pointers):
* a/gcc/lto-streamer.h (typedef):
(extern):
diff --git a/gcc/cp/pph-streamer.c b/gcc/cp/pph-streamer.c
index 07438bd..af9602c 100644
--- a/gcc/cp/pph-streamer.c
+++ b/gcc/cp/pph-streamer.c
@@ -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;
}
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 5d2761e..9574d77 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -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,
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 81beb07..e8390ed 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -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,
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 8ab0714..b58bb62 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -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 *,
--
This patch is available for review at http://codereview.appspot.com/4306053
Issue 4306053: [pph] Add hooks for writing/reading ASTs (1/2)
(Closed)
Created 13 years, 1 month ago by Diego Novillo
Modified 13 years, 1 month ago
Reviewers:
Base URL:
Comments: 0