annotate gcc/tree-streamer.h @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
kono
parents:
diff changeset
1 /* Data structures and functions for streaming trees.
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
4 Contributed by Diego Novillo <dnovillo@google.com>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
11 version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
16 for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #ifndef GCC_TREE_STREAMER_H
kono
parents:
diff changeset
23 #define GCC_TREE_STREAMER_H
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 #include "streamer-hooks.h"
kono
parents:
diff changeset
26 #include "data-streamer.h"
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 /* Cache of pickled nodes. Used to avoid writing the same node more
kono
parents:
diff changeset
29 than once. The first time a tree node is streamed out, it is
kono
parents:
diff changeset
30 entered in this cache. Subsequent references to the same node are
kono
parents:
diff changeset
31 resolved by looking it up in this cache.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 This is used in two ways:
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 - On the writing side, the first time T is added to STREAMER_CACHE,
kono
parents:
diff changeset
36 a new reference index is created for T and T is emitted on the
kono
parents:
diff changeset
37 stream. If T needs to be emitted again to the stream, instead of
kono
parents:
diff changeset
38 pickling it again, the reference index is emitted.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 - On the reading side, the first time T is read from the stream, it
kono
parents:
diff changeset
41 is reconstructed in memory and a new reference index created for
kono
parents:
diff changeset
42 T. The reconstructed T is inserted in some array so that when
kono
parents:
diff changeset
43 the reference index for T is found in the input stream, it can be
kono
parents:
diff changeset
44 used to look up into the array to get the reconstructed T. */
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 struct streamer_tree_cache_d
kono
parents:
diff changeset
47 {
kono
parents:
diff changeset
48 /* The mapping between tree nodes and slots into the nodes array. */
kono
parents:
diff changeset
49 hash_map<tree, unsigned> *node_map;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 /* The nodes pickled so far. */
kono
parents:
diff changeset
52 vec<tree> nodes;
kono
parents:
diff changeset
53 /* The node hashes (if available). */
kono
parents:
diff changeset
54 vec<hashval_t> hashes;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 /* Next index to assign. */
kono
parents:
diff changeset
57 unsigned next_idx;
kono
parents:
diff changeset
58 };
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* In tree-streamer-in.c. */
kono
parents:
diff changeset
61 tree streamer_read_string_cst (struct data_in *, struct lto_input_block *);
kono
parents:
diff changeset
62 tree streamer_read_chain (struct lto_input_block *, struct data_in *);
kono
parents:
diff changeset
63 tree streamer_alloc_tree (struct lto_input_block *, struct data_in *,
kono
parents:
diff changeset
64 enum LTO_tags);
kono
parents:
diff changeset
65 void streamer_read_tree_body (struct lto_input_block *, struct data_in *, tree);
kono
parents:
diff changeset
66 tree streamer_get_pickled_tree (struct lto_input_block *, struct data_in *);
kono
parents:
diff changeset
67 void streamer_read_tree_bitfields (struct lto_input_block *,
kono
parents:
diff changeset
68 struct data_in *, tree);
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 /* In tree-streamer-out.c. */
kono
parents:
diff changeset
71 void streamer_write_string_cst (struct output_block *,
kono
parents:
diff changeset
72 struct lto_output_stream *, tree);
kono
parents:
diff changeset
73 void streamer_write_chain (struct output_block *, tree, bool);
kono
parents:
diff changeset
74 void streamer_write_tree_header (struct output_block *, tree);
kono
parents:
diff changeset
75 void streamer_write_tree_bitfields (struct output_block *, tree);
kono
parents:
diff changeset
76 void streamer_write_tree_body (struct output_block *, tree, bool);
kono
parents:
diff changeset
77 void streamer_write_integer_cst (struct output_block *, tree, bool);
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* In tree-streamer.c. */
kono
parents:
diff changeset
80 extern unsigned char streamer_mode_table[1 << 8];
kono
parents:
diff changeset
81 void streamer_check_handled_ts_structures (void);
kono
parents:
diff changeset
82 bool streamer_tree_cache_insert (struct streamer_tree_cache_d *, tree,
kono
parents:
diff changeset
83 hashval_t, unsigned *);
kono
parents:
diff changeset
84 void streamer_tree_cache_replace_tree (struct streamer_tree_cache_d *, tree,
kono
parents:
diff changeset
85 unsigned);
kono
parents:
diff changeset
86 void streamer_tree_cache_append (struct streamer_tree_cache_d *, tree,
kono
parents:
diff changeset
87 hashval_t);
kono
parents:
diff changeset
88 bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree,
kono
parents:
diff changeset
89 unsigned *);
kono
parents:
diff changeset
90 struct streamer_tree_cache_d *streamer_tree_cache_create (bool, bool, bool);
kono
parents:
diff changeset
91 void streamer_tree_cache_delete (struct streamer_tree_cache_d *);
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* Return the tree node at slot IX in CACHE. */
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 static inline tree
kono
parents:
diff changeset
96 streamer_tree_cache_get_tree (struct streamer_tree_cache_d *cache, unsigned ix)
kono
parents:
diff changeset
97 {
kono
parents:
diff changeset
98 return cache->nodes[ix];
kono
parents:
diff changeset
99 }
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 /* Return the tree hash value at slot IX in CACHE. */
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 static inline hashval_t
kono
parents:
diff changeset
104 streamer_tree_cache_get_hash (struct streamer_tree_cache_d *cache, unsigned ix)
kono
parents:
diff changeset
105 {
kono
parents:
diff changeset
106 return cache->hashes[ix];
kono
parents:
diff changeset
107 }
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 static inline void
kono
parents:
diff changeset
110 bp_pack_machine_mode (struct bitpack_d *bp, machine_mode mode)
kono
parents:
diff changeset
111 {
kono
parents:
diff changeset
112 streamer_mode_table[mode] = 1;
kono
parents:
diff changeset
113 bp_pack_enum (bp, machine_mode, 1 << 8, mode);
kono
parents:
diff changeset
114 }
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 static inline machine_mode
kono
parents:
diff changeset
117 bp_unpack_machine_mode (struct bitpack_d *bp)
kono
parents:
diff changeset
118 {
kono
parents:
diff changeset
119 return (machine_mode)
kono
parents:
diff changeset
120 ((struct lto_input_block *)
kono
parents:
diff changeset
121 bp->stream)->mode_table[bp_unpack_enum (bp, machine_mode, 1 << 8)];
kono
parents:
diff changeset
122 }
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 #endif /* GCC_TREE_STREAMER_H */