GCC Middle and Back End API Reference
tree-streamer.h
Go to the documentation of this file.
1 /* Data structures and functions for streaming trees.
2 
3  Copyright (C) 2011-2013 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 "streamer-hooks.h"
26 #include "lto-streamer.h"
27 
28 /* Cache of pickled nodes. Used to avoid writing the same node more
29  than once. The first time a tree node is streamed out, it is
30  entered in this cache. Subsequent references to the same node are
31  resolved by looking it up in this cache.
32 
33  This is used in two ways:
34 
35  - On the writing side, the first time T is added to STREAMER_CACHE,
36  a new reference index is created for T and T is emitted on the
37  stream. If T needs to be emitted again to the stream, instead of
38  pickling it again, the reference index is emitted.
39 
40  - On the reading side, the first time T is read from the stream, it
41  is reconstructed in memory and a new reference index created for
42  T. The reconstructed T is inserted in some array so that when
43  the reference index for T is found in the input stream, it can be
44  used to look up into the array to get the reconstructed T. */
45 
47 {
48  /* The mapping between tree nodes and slots into the nodes array. */
50 
51  /* The nodes pickled so far. */
53  /* The node hashes (if available). */
55 };
56 
57 /* Return true if tree node EXPR should be streamed as a builtin. For
58  these nodes, we just emit the class and function code. */
59 static inline bool
61 {
62  return (TREE_CODE (expr) == FUNCTION_DECL
63  && DECL_IS_BUILTIN (expr)
65  || DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD));
66 }
67 
68 /* In tree-streamer-in.c. */
70 tree streamer_read_chain (struct lto_input_block *, struct data_in *);
72  enum LTO_tags);
73 void streamer_read_tree_body (struct lto_input_block *, struct data_in *, tree);
77  struct data_in *, tree);
78 
79 /* In tree-streamer-out.c. */
81  struct lto_output_stream *, tree);
82 void streamer_write_chain (struct output_block *, tree, bool);
84 void streamer_pack_tree_bitfields (struct output_block *, struct bitpack_d *,
85  tree);
86 void streamer_write_tree_body (struct output_block *, tree, bool);
87 void streamer_write_integer_cst (struct output_block *, tree, bool);
89 
90 /* In tree-streamer.c. */
93  hashval_t, unsigned *);
95  unsigned);
97  hashval_t);
99  unsigned *);
102 
103 /* Return the tree node at slot IX in CACHE. */
104 
105 static inline tree
107 {
108  return cache->nodes[ix];
109 }
110 
111 /* Return the tree hash value at slot IX in CACHE. */
112 
113 static inline hashval_t
115 {
116  return cache->hashes[ix];
117 }
118 
119 
120 #endif /* GCC_TREE_STREAMER_H */