]>
Commit | Line | Data |
---|---|---|
f0efc7aa DN |
1 | /* Data structures and functions for streaming trees. |
2 | ||
3 | Copyright 2011 Free Software Foundation, Inc. | |
4 | Contributed by Diego Novillo <dnovillo@google.com> | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #ifndef GCC_TREE_STREAMER_H | |
23 | #define GCC_TREE_STREAMER_H | |
24 | ||
25 | #include "tree.h" | |
b9393656 | 26 | #include "streamer-hooks.h" |
f0efc7aa DN |
27 | #include "lto-streamer.h" |
28 | ||
29 | /* Cache of pickled nodes. Used to avoid writing the same node more | |
30 | than once. The first time a tree node is streamed out, it is | |
31 | entered in this cache. Subsequent references to the same node are | |
32 | resolved by looking it up in this cache. | |
33 | ||
34 | This is used in two ways: | |
35 | ||
36 | - On the writing side, the first time T is added to STREAMER_CACHE, | |
37 | a new reference index is created for T and T is emitted on the | |
38 | stream. If T needs to be emitted again to the stream, instead of | |
39 | pickling it again, the reference index is emitted. | |
40 | ||
41 | - On the reading side, the first time T is read from the stream, it | |
42 | is reconstructed in memory and a new reference index created for | |
43 | T. The reconstructed T is inserted in some array so that when | |
44 | the reference index for T is found in the input stream, it can be | |
45 | used to look up into the array to get the reconstructed T. */ | |
46 | struct lto_streamer_cache_d | |
47 | { | |
48 | /* The mapping between tree nodes and slots into the nodes array. */ | |
49 | struct pointer_map_t *node_map; | |
50 | ||
51 | /* The nodes pickled so far. */ | |
52 | VEC(tree,heap) *nodes; | |
53 | }; | |
54 | ||
b9393656 DN |
55 | /* Return true if tree node EXPR should be streamed as a builtin. For |
56 | these nodes, we just emit the class and function code. */ | |
57 | static inline bool | |
58 | lto_stream_as_builtin_p (tree expr) | |
59 | { | |
60 | return (TREE_CODE (expr) == FUNCTION_DECL | |
61 | && DECL_IS_BUILTIN (expr) | |
62 | && (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_NORMAL | |
63 | || DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD)); | |
64 | } | |
65 | ||
f0efc7aa DN |
66 | /* In tree-streamer-in.c. */ |
67 | tree input_string_cst (struct data_in *, struct lto_input_block *); | |
b9393656 DN |
68 | void lto_streamer_read_tree (struct lto_input_block *, struct data_in *, tree); |
69 | tree lto_materialize_tree (struct lto_input_block *, struct data_in *, | |
70 | enum LTO_tags); | |
71 | void lto_input_tree_pointers (struct lto_input_block *, struct data_in *, tree); | |
72 | tree lto_get_pickled_tree (struct lto_input_block *, struct data_in *); | |
73 | tree lto_get_builtin_tree (struct lto_input_block *, struct data_in *); | |
74 | tree lto_input_integer_cst (struct lto_input_block *, struct data_in *); | |
75 | struct bitpack_d tree_read_bitfields (struct lto_input_block *, tree); | |
f0efc7aa DN |
76 | |
77 | /* In tree-streamer-out.c. */ | |
b9393656 DN |
78 | void lto_output_chain (struct output_block *, tree, bool); |
79 | void lto_output_tree_header (struct output_block *, tree); | |
80 | void pack_value_fields (struct bitpack_d *, tree); | |
81 | void lto_output_tree_pointers (struct output_block *, tree, bool); | |
82 | void lto_output_integer_cst (struct output_block *, tree, bool); | |
83 | void lto_output_builtin_tree (struct output_block *, tree); | |
f0efc7aa DN |
84 | |
85 | /* In tree-streamer.c. */ | |
86 | void check_handled_ts_structures (void); | |
87 | bool lto_streamer_cache_insert (struct lto_streamer_cache_d *, tree, | |
88 | unsigned *); | |
89 | bool lto_streamer_cache_insert_at (struct lto_streamer_cache_d *, tree, | |
90 | unsigned); | |
91 | void lto_streamer_cache_append (struct lto_streamer_cache_d *, tree); | |
92 | bool lto_streamer_cache_lookup (struct lto_streamer_cache_d *, tree, | |
93 | unsigned *); | |
94 | tree lto_streamer_cache_get (struct lto_streamer_cache_d *, unsigned); | |
95 | struct lto_streamer_cache_d *lto_streamer_cache_create (void); | |
96 | void lto_streamer_cache_delete (struct lto_streamer_cache_d *); | |
97 | ||
98 | #endif /* GCC_TREE_STREAMER_H */ |