gcc/gcc/tree-streamer.h

99 lines
4.0 KiB
C
Raw Normal View History

2011-08-08 18:49:34 +02:00
/* Data structures and functions for streaming trees.
Copyright 2011 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@google.com>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_TREE_STREAMER_H
#define GCC_TREE_STREAMER_H
#include "tree.h"
tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. * tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. (lto_output_ts_binfo_tree_pointers): Likewise. * streamer-hooks.h (stream_write_tree): Move from tree-streamer.h. Convert it to a macro. (stream_read_tree): Likewise. * lto-streamer.h (lto_stream_as_builtin_p): Move ... * tree-streamer.h (lto_stream_as_builtin_p): ... here. * lto-streamer-in.c (lto_read_tree): Call lto_streamer_cache_append and tree_read_bitfields. * lto-streamer-out.c (lto_is_streamable): Move from lto-streamer.c (lto_write_tree): Call it. * lto-streamer.c (lto_is_streamable): Move to lto-streamer-out.c * streamer-hooks.h (struct streamer_hooks): Remove fields name, is_streamable and alloc_tree. Update all users. * tree-streamer-in.c (tree_read_bitfields): Factor out of ... (lto_materialize_tree): ... here. Handle CALL_EXPR codes. Remove call to lto_streamer_cache_append. * tree-streamer-out.c (lto_output_tree_header): Handle CALL_EXPR nodes. * tree-streamer.h (tree_read_bitfields): Declare. * Makefile.in (TREE_STREAMER_H): Add STREAMER_HOOKS_H. (gimple-streamer-in.o): Add dependency on TREE_STREAMER_H. * tree-streamer.h (stream_read_tree): New. Replace all calls to lto_input_tree with it. (stream_write_tree): New. Replace all calls to lto_output_tree, lto_output_tree_ref and lto_output_tree_or_ref with it. * lto-streamer-in.c (lto_read_tree): Inline code from lto_streamer_read_tree. (lto_input_tree): Move from tree-streamer-in.c. * lto-streamer-out.c (lto_output_tree_ref): Make static. Remove handling of NULL values for EXPR. Do not handle EXPRs that are not indexable. (lto_write_tree): Move from tree-streamer-out.c. Inline lto_streamer_write_tree. (lto_output_tree): Move from tree-streamer-out.c. If REF_P is true and EXPR is indexable, call lto_output_tree_ref. * lto-streamer.c (lto_record_common_node): Move to tree-streamer.c. (lto_preload_common_nodes): Likewise. Remove assertions and adjustments for nodes main_identifier_node, ptrdiff_type_node and fileptr_type_node. (lto_streamer_hooks_init): Set streamer_hooks.write_tree to lto_output_tree and streamer_hooks.read_tree to lto_input_tree. * lto-streamer.h (lto_input_tree): Declare. (lto_output_tree_ref): Remove. * streamer-hooks.h (struct streamer_hooks): Remove fields preload_common_nodes, indexable_with_decls_p, pack_value_fields, unpack_value_fields, output_tree_header and has_unique_integer_csts_p. Update all users. * tree-streamer-in.c (lto_materialize_tree): Make extern. (lto_input_tree_pointers): Likewise. (lto_read_tree): Move to lto-streamer-in.c. (lto_input_integer_cst): Make extern. (lto_get_pickled_tree): Likewise. (lto_get_builtin_tree): Likewise. (lto_input_tree): Move to lto-streamer-in.c. * tree-streamer-out.c (pack_value_fields): Make extern. (lto_output_tree_or_ref): Remove. Replace all callers with calls to stream_write_tree. (lto_output_builtin_tree): Make extern. (lto_streamer_write_tree): Inline into lto_write_tree. (lto_output_tree_pointers): Make extern. (lto_output_tree_header): Likewise. (lto_output_integer_cst): Likewise. (lto_write_tree): Move to lto-streamer-out.c. (lto_output_tree): Likewise. * tree-streamer.c (lto_record_common_node): Move from lto-streamer.c (preload_common_nodes): Likewise. (lto_streamer_cache_create): Call it. * tree-streamer.h: Include streamer-hooks.h. (stream_write_tree): New. (stream_read_tree): New. (lto_input_tree): Remove. (lto_materialize_tree): Declare. (lto_input_tree_pointers): Declare. (lto_get_pickled_tree): Declare. (lto_get_builtin_tree): Declare. (lto_input_integer_cst): Declare. (lto_output_tree_header): Declare. (pack_value_fields): Declare. (lto_output_tree_pointers): Declare. (lto_output_integer_cst): Declare. (lto_output_builtin_tree): Declare. From-SVN: r177661
2011-08-11 14:02:34 +02:00
#include "streamer-hooks.h"
2011-08-08 18:49:34 +02:00
#include "lto-streamer.h"
/* Cache of pickled nodes. Used to avoid writing the same node more
than once. The first time a tree node is streamed out, it is
entered in this cache. Subsequent references to the same node are
resolved by looking it up in this cache.
This is used in two ways:
- On the writing side, the first time T is added to STREAMER_CACHE,
a new reference index is created for T and T is emitted on the
stream. If T needs to be emitted again to the stream, instead of
pickling it again, the reference index is emitted.
- On the reading side, the first time T is read from the stream, it
is reconstructed in memory and a new reference index created for
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
{
/* The mapping between tree nodes and slots into the nodes array. */
struct pointer_map_t *node_map;
/* The nodes pickled so far. */
VEC(tree,heap) *nodes;
};
tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. * tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. (lto_output_ts_binfo_tree_pointers): Likewise. * streamer-hooks.h (stream_write_tree): Move from tree-streamer.h. Convert it to a macro. (stream_read_tree): Likewise. * lto-streamer.h (lto_stream_as_builtin_p): Move ... * tree-streamer.h (lto_stream_as_builtin_p): ... here. * lto-streamer-in.c (lto_read_tree): Call lto_streamer_cache_append and tree_read_bitfields. * lto-streamer-out.c (lto_is_streamable): Move from lto-streamer.c (lto_write_tree): Call it. * lto-streamer.c (lto_is_streamable): Move to lto-streamer-out.c * streamer-hooks.h (struct streamer_hooks): Remove fields name, is_streamable and alloc_tree. Update all users. * tree-streamer-in.c (tree_read_bitfields): Factor out of ... (lto_materialize_tree): ... here. Handle CALL_EXPR codes. Remove call to lto_streamer_cache_append. * tree-streamer-out.c (lto_output_tree_header): Handle CALL_EXPR nodes. * tree-streamer.h (tree_read_bitfields): Declare. * Makefile.in (TREE_STREAMER_H): Add STREAMER_HOOKS_H. (gimple-streamer-in.o): Add dependency on TREE_STREAMER_H. * tree-streamer.h (stream_read_tree): New. Replace all calls to lto_input_tree with it. (stream_write_tree): New. Replace all calls to lto_output_tree, lto_output_tree_ref and lto_output_tree_or_ref with it. * lto-streamer-in.c (lto_read_tree): Inline code from lto_streamer_read_tree. (lto_input_tree): Move from tree-streamer-in.c. * lto-streamer-out.c (lto_output_tree_ref): Make static. Remove handling of NULL values for EXPR. Do not handle EXPRs that are not indexable. (lto_write_tree): Move from tree-streamer-out.c. Inline lto_streamer_write_tree. (lto_output_tree): Move from tree-streamer-out.c. If REF_P is true and EXPR is indexable, call lto_output_tree_ref. * lto-streamer.c (lto_record_common_node): Move to tree-streamer.c. (lto_preload_common_nodes): Likewise. Remove assertions and adjustments for nodes main_identifier_node, ptrdiff_type_node and fileptr_type_node. (lto_streamer_hooks_init): Set streamer_hooks.write_tree to lto_output_tree and streamer_hooks.read_tree to lto_input_tree. * lto-streamer.h (lto_input_tree): Declare. (lto_output_tree_ref): Remove. * streamer-hooks.h (struct streamer_hooks): Remove fields preload_common_nodes, indexable_with_decls_p, pack_value_fields, unpack_value_fields, output_tree_header and has_unique_integer_csts_p. Update all users. * tree-streamer-in.c (lto_materialize_tree): Make extern. (lto_input_tree_pointers): Likewise. (lto_read_tree): Move to lto-streamer-in.c. (lto_input_integer_cst): Make extern. (lto_get_pickled_tree): Likewise. (lto_get_builtin_tree): Likewise. (lto_input_tree): Move to lto-streamer-in.c. * tree-streamer-out.c (pack_value_fields): Make extern. (lto_output_tree_or_ref): Remove. Replace all callers with calls to stream_write_tree. (lto_output_builtin_tree): Make extern. (lto_streamer_write_tree): Inline into lto_write_tree. (lto_output_tree_pointers): Make extern. (lto_output_tree_header): Likewise. (lto_output_integer_cst): Likewise. (lto_write_tree): Move to lto-streamer-out.c. (lto_output_tree): Likewise. * tree-streamer.c (lto_record_common_node): Move from lto-streamer.c (preload_common_nodes): Likewise. (lto_streamer_cache_create): Call it. * tree-streamer.h: Include streamer-hooks.h. (stream_write_tree): New. (stream_read_tree): New. (lto_input_tree): Remove. (lto_materialize_tree): Declare. (lto_input_tree_pointers): Declare. (lto_get_pickled_tree): Declare. (lto_get_builtin_tree): Declare. (lto_input_integer_cst): Declare. (lto_output_tree_header): Declare. (pack_value_fields): Declare. (lto_output_tree_pointers): Declare. (lto_output_integer_cst): Declare. (lto_output_builtin_tree): Declare. From-SVN: r177661
2011-08-11 14:02:34 +02:00
/* 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)
{
return (TREE_CODE (expr) == FUNCTION_DECL
&& DECL_IS_BUILTIN (expr)
&& (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_NORMAL
|| DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD));
}
2011-08-08 18:49:34 +02:00
/* In tree-streamer-in.c. */
tree input_string_cst (struct data_in *, struct lto_input_block *);
tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. * tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. (lto_output_ts_binfo_tree_pointers): Likewise. * streamer-hooks.h (stream_write_tree): Move from tree-streamer.h. Convert it to a macro. (stream_read_tree): Likewise. * lto-streamer.h (lto_stream_as_builtin_p): Move ... * tree-streamer.h (lto_stream_as_builtin_p): ... here. * lto-streamer-in.c (lto_read_tree): Call lto_streamer_cache_append and tree_read_bitfields. * lto-streamer-out.c (lto_is_streamable): Move from lto-streamer.c (lto_write_tree): Call it. * lto-streamer.c (lto_is_streamable): Move to lto-streamer-out.c * streamer-hooks.h (struct streamer_hooks): Remove fields name, is_streamable and alloc_tree. Update all users. * tree-streamer-in.c (tree_read_bitfields): Factor out of ... (lto_materialize_tree): ... here. Handle CALL_EXPR codes. Remove call to lto_streamer_cache_append. * tree-streamer-out.c (lto_output_tree_header): Handle CALL_EXPR nodes. * tree-streamer.h (tree_read_bitfields): Declare. * Makefile.in (TREE_STREAMER_H): Add STREAMER_HOOKS_H. (gimple-streamer-in.o): Add dependency on TREE_STREAMER_H. * tree-streamer.h (stream_read_tree): New. Replace all calls to lto_input_tree with it. (stream_write_tree): New. Replace all calls to lto_output_tree, lto_output_tree_ref and lto_output_tree_or_ref with it. * lto-streamer-in.c (lto_read_tree): Inline code from lto_streamer_read_tree. (lto_input_tree): Move from tree-streamer-in.c. * lto-streamer-out.c (lto_output_tree_ref): Make static. Remove handling of NULL values for EXPR. Do not handle EXPRs that are not indexable. (lto_write_tree): Move from tree-streamer-out.c. Inline lto_streamer_write_tree. (lto_output_tree): Move from tree-streamer-out.c. If REF_P is true and EXPR is indexable, call lto_output_tree_ref. * lto-streamer.c (lto_record_common_node): Move to tree-streamer.c. (lto_preload_common_nodes): Likewise. Remove assertions and adjustments for nodes main_identifier_node, ptrdiff_type_node and fileptr_type_node. (lto_streamer_hooks_init): Set streamer_hooks.write_tree to lto_output_tree and streamer_hooks.read_tree to lto_input_tree. * lto-streamer.h (lto_input_tree): Declare. (lto_output_tree_ref): Remove. * streamer-hooks.h (struct streamer_hooks): Remove fields preload_common_nodes, indexable_with_decls_p, pack_value_fields, unpack_value_fields, output_tree_header and has_unique_integer_csts_p. Update all users. * tree-streamer-in.c (lto_materialize_tree): Make extern. (lto_input_tree_pointers): Likewise. (lto_read_tree): Move to lto-streamer-in.c. (lto_input_integer_cst): Make extern. (lto_get_pickled_tree): Likewise. (lto_get_builtin_tree): Likewise. (lto_input_tree): Move to lto-streamer-in.c. * tree-streamer-out.c (pack_value_fields): Make extern. (lto_output_tree_or_ref): Remove. Replace all callers with calls to stream_write_tree. (lto_output_builtin_tree): Make extern. (lto_streamer_write_tree): Inline into lto_write_tree. (lto_output_tree_pointers): Make extern. (lto_output_tree_header): Likewise. (lto_output_integer_cst): Likewise. (lto_write_tree): Move to lto-streamer-out.c. (lto_output_tree): Likewise. * tree-streamer.c (lto_record_common_node): Move from lto-streamer.c (preload_common_nodes): Likewise. (lto_streamer_cache_create): Call it. * tree-streamer.h: Include streamer-hooks.h. (stream_write_tree): New. (stream_read_tree): New. (lto_input_tree): Remove. (lto_materialize_tree): Declare. (lto_input_tree_pointers): Declare. (lto_get_pickled_tree): Declare. (lto_get_builtin_tree): Declare. (lto_input_integer_cst): Declare. (lto_output_tree_header): Declare. (pack_value_fields): Declare. (lto_output_tree_pointers): Declare. (lto_output_integer_cst): Declare. (lto_output_builtin_tree): Declare. From-SVN: r177661
2011-08-11 14:02:34 +02:00
void lto_streamer_read_tree (struct lto_input_block *, struct data_in *, tree);
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);
2011-08-08 18:49:34 +02:00
/* In tree-streamer-out.c. */
tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. * tree-streamer-out.c (lto_output_ts_decl_with_vis_tree_pointers): Call stream_write_tree instead of output_record_start. (lto_output_ts_binfo_tree_pointers): Likewise. * streamer-hooks.h (stream_write_tree): Move from tree-streamer.h. Convert it to a macro. (stream_read_tree): Likewise. * lto-streamer.h (lto_stream_as_builtin_p): Move ... * tree-streamer.h (lto_stream_as_builtin_p): ... here. * lto-streamer-in.c (lto_read_tree): Call lto_streamer_cache_append and tree_read_bitfields. * lto-streamer-out.c (lto_is_streamable): Move from lto-streamer.c (lto_write_tree): Call it. * lto-streamer.c (lto_is_streamable): Move to lto-streamer-out.c * streamer-hooks.h (struct streamer_hooks): Remove fields name, is_streamable and alloc_tree. Update all users. * tree-streamer-in.c (tree_read_bitfields): Factor out of ... (lto_materialize_tree): ... here. Handle CALL_EXPR codes. Remove call to lto_streamer_cache_append. * tree-streamer-out.c (lto_output_tree_header): Handle CALL_EXPR nodes. * tree-streamer.h (tree_read_bitfields): Declare. * Makefile.in (TREE_STREAMER_H): Add STREAMER_HOOKS_H. (gimple-streamer-in.o): Add dependency on TREE_STREAMER_H. * tree-streamer.h (stream_read_tree): New. Replace all calls to lto_input_tree with it. (stream_write_tree): New. Replace all calls to lto_output_tree, lto_output_tree_ref and lto_output_tree_or_ref with it. * lto-streamer-in.c (lto_read_tree): Inline code from lto_streamer_read_tree. (lto_input_tree): Move from tree-streamer-in.c. * lto-streamer-out.c (lto_output_tree_ref): Make static. Remove handling of NULL values for EXPR. Do not handle EXPRs that are not indexable. (lto_write_tree): Move from tree-streamer-out.c. Inline lto_streamer_write_tree. (lto_output_tree): Move from tree-streamer-out.c. If REF_P is true and EXPR is indexable, call lto_output_tree_ref. * lto-streamer.c (lto_record_common_node): Move to tree-streamer.c. (lto_preload_common_nodes): Likewise. Remove assertions and adjustments for nodes main_identifier_node, ptrdiff_type_node and fileptr_type_node. (lto_streamer_hooks_init): Set streamer_hooks.write_tree to lto_output_tree and streamer_hooks.read_tree to lto_input_tree. * lto-streamer.h (lto_input_tree): Declare. (lto_output_tree_ref): Remove. * streamer-hooks.h (struct streamer_hooks): Remove fields preload_common_nodes, indexable_with_decls_p, pack_value_fields, unpack_value_fields, output_tree_header and has_unique_integer_csts_p. Update all users. * tree-streamer-in.c (lto_materialize_tree): Make extern. (lto_input_tree_pointers): Likewise. (lto_read_tree): Move to lto-streamer-in.c. (lto_input_integer_cst): Make extern. (lto_get_pickled_tree): Likewise. (lto_get_builtin_tree): Likewise. (lto_input_tree): Move to lto-streamer-in.c. * tree-streamer-out.c (pack_value_fields): Make extern. (lto_output_tree_or_ref): Remove. Replace all callers with calls to stream_write_tree. (lto_output_builtin_tree): Make extern. (lto_streamer_write_tree): Inline into lto_write_tree. (lto_output_tree_pointers): Make extern. (lto_output_tree_header): Likewise. (lto_output_integer_cst): Likewise. (lto_write_tree): Move to lto-streamer-out.c. (lto_output_tree): Likewise. * tree-streamer.c (lto_record_common_node): Move from lto-streamer.c (preload_common_nodes): Likewise. (lto_streamer_cache_create): Call it. * tree-streamer.h: Include streamer-hooks.h. (stream_write_tree): New. (stream_read_tree): New. (lto_input_tree): Remove. (lto_materialize_tree): Declare. (lto_input_tree_pointers): Declare. (lto_get_pickled_tree): Declare. (lto_get_builtin_tree): Declare. (lto_input_integer_cst): Declare. (lto_output_tree_header): Declare. (pack_value_fields): Declare. (lto_output_tree_pointers): Declare. (lto_output_integer_cst): Declare. (lto_output_builtin_tree): Declare. From-SVN: r177661
2011-08-11 14:02:34 +02:00
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);
2011-08-08 18:49:34 +02:00
/* 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 *);
#endif /* GCC_TREE_STREAMER_H */