1e4b17023SJohn Marino /* Routines for reading trees from a file stream.
2e4b17023SJohn Marino
3e4b17023SJohn Marino Copyright 2011 Free Software Foundation, Inc.
4e4b17023SJohn Marino Contributed by Diego Novillo <dnovillo@google.com>
5e4b17023SJohn Marino
6e4b17023SJohn Marino This file is part of GCC.
7e4b17023SJohn Marino
8e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
9e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
10e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
11e4b17023SJohn Marino version.
12e4b17023SJohn Marino
13e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
15e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16e4b17023SJohn Marino for more details.
17e4b17023SJohn Marino
18e4b17023SJohn Marino You should have received a copy of the GNU General Public License
19e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see
20e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */
21e4b17023SJohn Marino
22e4b17023SJohn Marino #include "config.h"
23e4b17023SJohn Marino #include "system.h"
24e4b17023SJohn Marino #include "coretypes.h"
25e4b17023SJohn Marino #include "diagnostic.h"
26e4b17023SJohn Marino #include "tree.h"
27e4b17023SJohn Marino #include "tree-flow.h"
28e4b17023SJohn Marino #include "tree-streamer.h"
29e4b17023SJohn Marino #include "data-streamer.h"
30e4b17023SJohn Marino #include "streamer-hooks.h"
31e4b17023SJohn Marino #include "lto-streamer.h"
32e4b17023SJohn Marino
33e4b17023SJohn Marino /* Read a STRING_CST from the string table in DATA_IN using input
34e4b17023SJohn Marino block IB. */
35e4b17023SJohn Marino
36e4b17023SJohn Marino tree
streamer_read_string_cst(struct data_in * data_in,struct lto_input_block * ib)37e4b17023SJohn Marino streamer_read_string_cst (struct data_in *data_in, struct lto_input_block *ib)
38e4b17023SJohn Marino {
39e4b17023SJohn Marino unsigned int len;
40e4b17023SJohn Marino const char * ptr;
41e4b17023SJohn Marino
42e4b17023SJohn Marino ptr = streamer_read_indexed_string (data_in, ib, &len);
43e4b17023SJohn Marino if (!ptr)
44e4b17023SJohn Marino return NULL;
45e4b17023SJohn Marino return build_string (len, ptr);
46e4b17023SJohn Marino }
47e4b17023SJohn Marino
48e4b17023SJohn Marino
49e4b17023SJohn Marino /* Read an IDENTIFIER from the string table in DATA_IN using input
50e4b17023SJohn Marino block IB. */
51e4b17023SJohn Marino
52e4b17023SJohn Marino static tree
input_identifier(struct data_in * data_in,struct lto_input_block * ib)53e4b17023SJohn Marino input_identifier (struct data_in *data_in, struct lto_input_block *ib)
54e4b17023SJohn Marino {
55e4b17023SJohn Marino unsigned int len;
56e4b17023SJohn Marino const char *ptr;
57e4b17023SJohn Marino
58e4b17023SJohn Marino ptr = streamer_read_indexed_string (data_in, ib, &len);
59e4b17023SJohn Marino if (!ptr)
60e4b17023SJohn Marino return NULL;
61e4b17023SJohn Marino return get_identifier_with_length (ptr, len);
62e4b17023SJohn Marino }
63e4b17023SJohn Marino
64e4b17023SJohn Marino
65e4b17023SJohn Marino /* Read a chain of tree nodes from input block IB. DATA_IN contains
66e4b17023SJohn Marino tables and descriptors for the file being read. */
67e4b17023SJohn Marino
68e4b17023SJohn Marino tree
streamer_read_chain(struct lto_input_block * ib,struct data_in * data_in)69e4b17023SJohn Marino streamer_read_chain (struct lto_input_block *ib, struct data_in *data_in)
70e4b17023SJohn Marino {
71e4b17023SJohn Marino int i, count;
72e4b17023SJohn Marino tree first, prev, curr;
73e4b17023SJohn Marino
74e4b17023SJohn Marino first = prev = NULL_TREE;
75e4b17023SJohn Marino count = streamer_read_hwi (ib);
76e4b17023SJohn Marino for (i = 0; i < count; i++)
77e4b17023SJohn Marino {
78e4b17023SJohn Marino curr = stream_read_tree (ib, data_in);
79e4b17023SJohn Marino if (prev)
80e4b17023SJohn Marino TREE_CHAIN (prev) = curr;
81e4b17023SJohn Marino else
82e4b17023SJohn Marino first = curr;
83e4b17023SJohn Marino
84e4b17023SJohn Marino TREE_CHAIN (curr) = NULL_TREE;
85e4b17023SJohn Marino prev = curr;
86e4b17023SJohn Marino }
87e4b17023SJohn Marino
88e4b17023SJohn Marino return first;
89e4b17023SJohn Marino }
90e4b17023SJohn Marino
91e4b17023SJohn Marino
92e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_BASE structure of
93e4b17023SJohn Marino expression EXPR from bitpack BP. */
94e4b17023SJohn Marino
95e4b17023SJohn Marino static void
unpack_ts_base_value_fields(struct bitpack_d * bp,tree expr)96e4b17023SJohn Marino unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
97e4b17023SJohn Marino {
98e4b17023SJohn Marino /* Note that the code for EXPR has already been unpacked to create EXPR in
99e4b17023SJohn Marino streamer_alloc_tree. */
100e4b17023SJohn Marino if (!TYPE_P (expr))
101e4b17023SJohn Marino {
102e4b17023SJohn Marino TREE_SIDE_EFFECTS (expr) = (unsigned) bp_unpack_value (bp, 1);
103e4b17023SJohn Marino TREE_CONSTANT (expr) = (unsigned) bp_unpack_value (bp, 1);
104e4b17023SJohn Marino TREE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
105e4b17023SJohn Marino
106e4b17023SJohn Marino /* TREE_PUBLIC is used on types to indicate that the type
107e4b17023SJohn Marino has a TYPE_CACHED_VALUES vector. This is not streamed out,
108e4b17023SJohn Marino so we skip it here. */
109e4b17023SJohn Marino TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1);
110e4b17023SJohn Marino }
111e4b17023SJohn Marino else
112e4b17023SJohn Marino bp_unpack_value (bp, 4);
113e4b17023SJohn Marino TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
114e4b17023SJohn Marino TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1);
115e4b17023SJohn Marino if (DECL_P (expr))
116e4b17023SJohn Marino DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
117e4b17023SJohn Marino else if (TYPE_P (expr))
118e4b17023SJohn Marino TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
119e4b17023SJohn Marino else
120e4b17023SJohn Marino bp_unpack_value (bp, 1);
121e4b17023SJohn Marino TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1);
122e4b17023SJohn Marino if (TYPE_P (expr))
123e4b17023SJohn Marino TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
124e4b17023SJohn Marino else
125e4b17023SJohn Marino TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1);
126e4b17023SJohn Marino TREE_USED (expr) = (unsigned) bp_unpack_value (bp, 1);
127e4b17023SJohn Marino TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1);
128e4b17023SJohn Marino TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1);
129e4b17023SJohn Marino TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1);
130e4b17023SJohn Marino TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1);
131e4b17023SJohn Marino TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1);
132e4b17023SJohn Marino if (TYPE_P (expr))
133e4b17023SJohn Marino {
134e4b17023SJohn Marino TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1);
135e4b17023SJohn Marino TYPE_ADDR_SPACE (expr) = (unsigned) bp_unpack_value (bp, 8);
136e4b17023SJohn Marino }
137e4b17023SJohn Marino else if (TREE_CODE (expr) == SSA_NAME)
138e4b17023SJohn Marino SSA_NAME_IS_DEFAULT_DEF (expr) = (unsigned) bp_unpack_value (bp, 1);
139e4b17023SJohn Marino else
140e4b17023SJohn Marino bp_unpack_value (bp, 1);
141e4b17023SJohn Marino }
142e4b17023SJohn Marino
143e4b17023SJohn Marino
144e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_REAL_CST structure of
145e4b17023SJohn Marino expression EXPR from bitpack BP. */
146e4b17023SJohn Marino
147e4b17023SJohn Marino static void
unpack_ts_real_cst_value_fields(struct bitpack_d * bp,tree expr)148e4b17023SJohn Marino unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
149e4b17023SJohn Marino {
150e4b17023SJohn Marino unsigned i;
151e4b17023SJohn Marino REAL_VALUE_TYPE r;
152e4b17023SJohn Marino REAL_VALUE_TYPE *rp;
153e4b17023SJohn Marino
154e4b17023SJohn Marino r.cl = (unsigned) bp_unpack_value (bp, 2);
155e4b17023SJohn Marino r.decimal = (unsigned) bp_unpack_value (bp, 1);
156e4b17023SJohn Marino r.sign = (unsigned) bp_unpack_value (bp, 1);
157e4b17023SJohn Marino r.signalling = (unsigned) bp_unpack_value (bp, 1);
158e4b17023SJohn Marino r.canonical = (unsigned) bp_unpack_value (bp, 1);
159e4b17023SJohn Marino r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
160e4b17023SJohn Marino for (i = 0; i < SIGSZ; i++)
161e4b17023SJohn Marino r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
162e4b17023SJohn Marino
163e4b17023SJohn Marino rp = ggc_alloc_real_value ();
164e4b17023SJohn Marino memcpy (rp, &r, sizeof (REAL_VALUE_TYPE));
165e4b17023SJohn Marino TREE_REAL_CST_PTR (expr) = rp;
166e4b17023SJohn Marino }
167e4b17023SJohn Marino
168e4b17023SJohn Marino
169e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_FIXED_CST structure of
170e4b17023SJohn Marino expression EXPR from bitpack BP. */
171e4b17023SJohn Marino
172e4b17023SJohn Marino static void
unpack_ts_fixed_cst_value_fields(struct bitpack_d * bp,tree expr)173e4b17023SJohn Marino unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
174e4b17023SJohn Marino {
175*95d28233SJohn Marino FIXED_VALUE_TYPE *fp = ggc_alloc_fixed_value ();
176*95d28233SJohn Marino fp->mode = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE);
177*95d28233SJohn Marino fp->data.low = bp_unpack_var_len_int (bp);
178*95d28233SJohn Marino fp->data.high = bp_unpack_var_len_int (bp);
179*95d28233SJohn Marino TREE_FIXED_CST_PTR (expr) = fp;
180e4b17023SJohn Marino }
181e4b17023SJohn Marino
182e4b17023SJohn Marino
183e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_DECL_COMMON structure
184e4b17023SJohn Marino of expression EXPR from bitpack BP. */
185e4b17023SJohn Marino
186e4b17023SJohn Marino static void
unpack_ts_decl_common_value_fields(struct bitpack_d * bp,tree expr)187e4b17023SJohn Marino unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
188e4b17023SJohn Marino {
189e4b17023SJohn Marino DECL_MODE (expr) = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE);
190e4b17023SJohn Marino DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1);
191e4b17023SJohn Marino DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
192e4b17023SJohn Marino DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
193e4b17023SJohn Marino DECL_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1);
194e4b17023SJohn Marino DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
195e4b17023SJohn Marino DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
196e4b17023SJohn Marino DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
197e4b17023SJohn Marino DECL_DEBUG_EXPR_IS_FROM (expr) = (unsigned) bp_unpack_value (bp, 1);
198e4b17023SJohn Marino DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1);
199e4b17023SJohn Marino DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
200e4b17023SJohn Marino DECL_ALIGN (expr) = (unsigned) bp_unpack_var_len_unsigned (bp);
201e4b17023SJohn Marino
202e4b17023SJohn Marino if (TREE_CODE (expr) == LABEL_DECL)
203e4b17023SJohn Marino {
204e4b17023SJohn Marino DECL_ERROR_ISSUED (expr) = (unsigned) bp_unpack_value (bp, 1);
205e4b17023SJohn Marino EH_LANDING_PAD_NR (expr) = (int) bp_unpack_var_len_unsigned (bp);
206e4b17023SJohn Marino
207e4b17023SJohn Marino /* Always assume an initial value of -1 for LABEL_DECL_UID to
208e4b17023SJohn Marino force gimple_set_bb to recreate label_to_block_map. */
209e4b17023SJohn Marino LABEL_DECL_UID (expr) = -1;
210e4b17023SJohn Marino }
211e4b17023SJohn Marino
212e4b17023SJohn Marino if (TREE_CODE (expr) == FIELD_DECL)
213e4b17023SJohn Marino {
214e4b17023SJohn Marino DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
215e4b17023SJohn Marino DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
216e4b17023SJohn Marino expr->decl_common.off_align = bp_unpack_value (bp, 8);
217e4b17023SJohn Marino }
218e4b17023SJohn Marino
219e4b17023SJohn Marino if (TREE_CODE (expr) == RESULT_DECL
220e4b17023SJohn Marino || TREE_CODE (expr) == PARM_DECL
221e4b17023SJohn Marino || TREE_CODE (expr) == VAR_DECL)
222e4b17023SJohn Marino {
223e4b17023SJohn Marino DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1);
224e4b17023SJohn Marino if (TREE_CODE (expr) == VAR_DECL
225e4b17023SJohn Marino || TREE_CODE (expr) == PARM_DECL)
226e4b17023SJohn Marino DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
227e4b17023SJohn Marino DECL_RESTRICTED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
228e4b17023SJohn Marino }
229e4b17023SJohn Marino }
230e4b17023SJohn Marino
231e4b17023SJohn Marino
232e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_DECL_WRTL structure
233e4b17023SJohn Marino of expression EXPR from bitpack BP. */
234e4b17023SJohn Marino
235e4b17023SJohn Marino static void
unpack_ts_decl_wrtl_value_fields(struct bitpack_d * bp,tree expr)236e4b17023SJohn Marino unpack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
237e4b17023SJohn Marino {
238e4b17023SJohn Marino DECL_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
239e4b17023SJohn Marino }
240e4b17023SJohn Marino
241e4b17023SJohn Marino
242e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_DECL_WITH_VIS structure
243e4b17023SJohn Marino of expression EXPR from bitpack BP. */
244e4b17023SJohn Marino
245e4b17023SJohn Marino static void
unpack_ts_decl_with_vis_value_fields(struct bitpack_d * bp,tree expr)246e4b17023SJohn Marino unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
247e4b17023SJohn Marino {
248e4b17023SJohn Marino DECL_DEFER_OUTPUT (expr) = (unsigned) bp_unpack_value (bp, 1);
249e4b17023SJohn Marino DECL_COMMON (expr) = (unsigned) bp_unpack_value (bp, 1);
250e4b17023SJohn Marino DECL_DLLIMPORT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
251e4b17023SJohn Marino DECL_WEAK (expr) = (unsigned) bp_unpack_value (bp, 1);
252e4b17023SJohn Marino DECL_SEEN_IN_BIND_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
253e4b17023SJohn Marino DECL_COMDAT (expr) = (unsigned) bp_unpack_value (bp, 1);
254e4b17023SJohn Marino DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2);
255e4b17023SJohn Marino DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1);
256e4b17023SJohn Marino
257e4b17023SJohn Marino if (TREE_CODE (expr) == VAR_DECL)
258e4b17023SJohn Marino {
259e4b17023SJohn Marino DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
260e4b17023SJohn Marino DECL_IN_TEXT_SECTION (expr) = (unsigned) bp_unpack_value (bp, 1);
261e4b17023SJohn Marino DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1);
262e4b17023SJohn Marino DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp, 3);
263e4b17023SJohn Marino }
264e4b17023SJohn Marino
265e4b17023SJohn Marino if (VAR_OR_FUNCTION_DECL_P (expr))
266e4b17023SJohn Marino {
267e4b17023SJohn Marino priority_type p;
268e4b17023SJohn Marino p = (priority_type) bp_unpack_var_len_unsigned (bp);
269e4b17023SJohn Marino SET_DECL_INIT_PRIORITY (expr, p);
270e4b17023SJohn Marino }
271e4b17023SJohn Marino }
272e4b17023SJohn Marino
273e4b17023SJohn Marino
274e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_FUNCTION_DECL structure
275e4b17023SJohn Marino of expression EXPR from bitpack BP. */
276e4b17023SJohn Marino
277e4b17023SJohn Marino static void
unpack_ts_function_decl_value_fields(struct bitpack_d * bp,tree expr)278e4b17023SJohn Marino unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
279e4b17023SJohn Marino {
280e4b17023SJohn Marino DECL_BUILT_IN_CLASS (expr) = bp_unpack_enum (bp, built_in_class,
281e4b17023SJohn Marino BUILT_IN_LAST);
282e4b17023SJohn Marino DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
283e4b17023SJohn Marino DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
284e4b17023SJohn Marino DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
285e4b17023SJohn Marino DECL_POSSIBLY_INLINED (expr) = (unsigned) bp_unpack_value (bp, 1);
286e4b17023SJohn Marino DECL_IS_NOVOPS (expr) = (unsigned) bp_unpack_value (bp, 1);
287e4b17023SJohn Marino DECL_IS_RETURNS_TWICE (expr) = (unsigned) bp_unpack_value (bp, 1);
288e4b17023SJohn Marino DECL_IS_MALLOC (expr) = (unsigned) bp_unpack_value (bp, 1);
289e4b17023SJohn Marino DECL_IS_OPERATOR_NEW (expr) = (unsigned) bp_unpack_value (bp, 1);
290e4b17023SJohn Marino DECL_DECLARED_INLINE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
291e4b17023SJohn Marino DECL_STATIC_CHAIN (expr) = (unsigned) bp_unpack_value (bp, 1);
292e4b17023SJohn Marino DECL_NO_INLINE_WARNING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
293e4b17023SJohn Marino DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr)
294e4b17023SJohn Marino = (unsigned) bp_unpack_value (bp, 1);
295e4b17023SJohn Marino DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1);
296e4b17023SJohn Marino DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
297e4b17023SJohn Marino DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
298e4b17023SJohn Marino DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
299e4b17023SJohn Marino if (DECL_BUILT_IN_CLASS (expr) != NOT_BUILT_IN)
300e4b17023SJohn Marino {
301e4b17023SJohn Marino DECL_FUNCTION_CODE (expr) = (enum built_in_function) bp_unpack_value (bp,
302e4b17023SJohn Marino 11);
303e4b17023SJohn Marino if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_NORMAL
304e4b17023SJohn Marino && DECL_FUNCTION_CODE (expr) >= END_BUILTINS)
305e4b17023SJohn Marino fatal_error ("machine independent builtin code out of range");
306e4b17023SJohn Marino else if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD)
307e4b17023SJohn Marino {
308e4b17023SJohn Marino tree result = targetm.builtin_decl (DECL_FUNCTION_CODE (expr), true);
309e4b17023SJohn Marino if (!result || result == error_mark_node)
310e4b17023SJohn Marino fatal_error ("target specific builtin not available");
311e4b17023SJohn Marino }
312e4b17023SJohn Marino }
313e4b17023SJohn Marino if (DECL_STATIC_DESTRUCTOR (expr))
314e4b17023SJohn Marino {
315e4b17023SJohn Marino priority_type p;
316e4b17023SJohn Marino p = (priority_type) bp_unpack_var_len_unsigned (bp);
317e4b17023SJohn Marino SET_DECL_FINI_PRIORITY (expr, p);
318e4b17023SJohn Marino }
319e4b17023SJohn Marino }
320e4b17023SJohn Marino
321e4b17023SJohn Marino
322e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_TYPE_COMMON structure
323e4b17023SJohn Marino of expression EXPR from bitpack BP. */
324e4b17023SJohn Marino
325e4b17023SJohn Marino static void
unpack_ts_type_common_value_fields(struct bitpack_d * bp,tree expr)326e4b17023SJohn Marino unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr)
327e4b17023SJohn Marino {
328e4b17023SJohn Marino enum machine_mode mode;
329e4b17023SJohn Marino
330e4b17023SJohn Marino mode = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE);
331e4b17023SJohn Marino SET_TYPE_MODE (expr, mode);
332e4b17023SJohn Marino TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1);
333e4b17023SJohn Marino TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1);
334e4b17023SJohn Marino TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1);
335e4b17023SJohn Marino if (RECORD_OR_UNION_TYPE_P (expr))
336e4b17023SJohn Marino TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
3375ce9237cSJohn Marino else if (TREE_CODE (expr) == ARRAY_TYPE)
3385ce9237cSJohn Marino TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1);
339e4b17023SJohn Marino TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
340e4b17023SJohn Marino TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1);
341e4b17023SJohn Marino TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr)
342e4b17023SJohn Marino = (unsigned) bp_unpack_value (bp, 2);
343e4b17023SJohn Marino TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
344e4b17023SJohn Marino TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
345e4b17023SJohn Marino TYPE_PRECISION (expr) = bp_unpack_var_len_unsigned (bp);
346e4b17023SJohn Marino TYPE_ALIGN (expr) = bp_unpack_var_len_unsigned (bp);
347e4b17023SJohn Marino TYPE_ALIAS_SET (expr) = bp_unpack_var_len_int (bp);
348e4b17023SJohn Marino }
349e4b17023SJohn Marino
350e4b17023SJohn Marino
351e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_BLOCK structure
352e4b17023SJohn Marino of expression EXPR from bitpack BP. */
353e4b17023SJohn Marino
354e4b17023SJohn Marino static void
unpack_ts_block_value_fields(struct bitpack_d * bp,tree expr)355e4b17023SJohn Marino unpack_ts_block_value_fields (struct bitpack_d *bp, tree expr)
356e4b17023SJohn Marino {
357e4b17023SJohn Marino BLOCK_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1);
358e4b17023SJohn Marino /* BLOCK_NUMBER is recomputed. */
359e4b17023SJohn Marino }
360e4b17023SJohn Marino
361e4b17023SJohn Marino /* Unpack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL
362e4b17023SJohn Marino structure of expression EXPR from bitpack BP. */
363e4b17023SJohn Marino
364e4b17023SJohn Marino static void
unpack_ts_translation_unit_decl_value_fields(struct bitpack_d * bp ATTRIBUTE_UNUSED,tree expr ATTRIBUTE_UNUSED)365e4b17023SJohn Marino unpack_ts_translation_unit_decl_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
366e4b17023SJohn Marino {
367e4b17023SJohn Marino }
368e4b17023SJohn Marino
369e4b17023SJohn Marino /* Unpack all the non-pointer fields in EXPR into a bit pack. */
370e4b17023SJohn Marino
371e4b17023SJohn Marino static void
unpack_value_fields(struct bitpack_d * bp,tree expr)372e4b17023SJohn Marino unpack_value_fields (struct bitpack_d *bp, tree expr)
373e4b17023SJohn Marino {
374e4b17023SJohn Marino enum tree_code code;
375e4b17023SJohn Marino
376e4b17023SJohn Marino code = TREE_CODE (expr);
377e4b17023SJohn Marino
378e4b17023SJohn Marino /* Note that all these functions are highly sensitive to changes in
379e4b17023SJohn Marino the types and sizes of each of the fields being packed. */
380e4b17023SJohn Marino unpack_ts_base_value_fields (bp, expr);
381e4b17023SJohn Marino
382e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
383e4b17023SJohn Marino unpack_ts_real_cst_value_fields (bp, expr);
384e4b17023SJohn Marino
385e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
386e4b17023SJohn Marino unpack_ts_fixed_cst_value_fields (bp, expr);
387e4b17023SJohn Marino
388e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
389e4b17023SJohn Marino unpack_ts_decl_common_value_fields (bp, expr);
390e4b17023SJohn Marino
391e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
392e4b17023SJohn Marino unpack_ts_decl_wrtl_value_fields (bp, expr);
393e4b17023SJohn Marino
394e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
395e4b17023SJohn Marino unpack_ts_decl_with_vis_value_fields (bp, expr);
396e4b17023SJohn Marino
397e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
398e4b17023SJohn Marino unpack_ts_function_decl_value_fields (bp, expr);
399e4b17023SJohn Marino
400e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
401e4b17023SJohn Marino unpack_ts_type_common_value_fields (bp, expr);
402e4b17023SJohn Marino
403e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
404e4b17023SJohn Marino unpack_ts_block_value_fields (bp, expr);
405e4b17023SJohn Marino
406e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
407e4b17023SJohn Marino unpack_ts_translation_unit_decl_value_fields (bp, expr);
408e4b17023SJohn Marino }
409e4b17023SJohn Marino
410e4b17023SJohn Marino
411e4b17023SJohn Marino /* Read all the language-independent bitfield values for EXPR from IB.
412e4b17023SJohn Marino Return the partially unpacked bitpack so the caller can unpack any other
413e4b17023SJohn Marino bitfield values that the writer may have written. */
414e4b17023SJohn Marino
415e4b17023SJohn Marino struct bitpack_d
streamer_read_tree_bitfields(struct lto_input_block * ib,tree expr)416e4b17023SJohn Marino streamer_read_tree_bitfields (struct lto_input_block *ib, tree expr)
417e4b17023SJohn Marino {
418e4b17023SJohn Marino enum tree_code code;
419e4b17023SJohn Marino struct bitpack_d bp;
420e4b17023SJohn Marino
421e4b17023SJohn Marino /* Read the bitpack of non-pointer values from IB. */
422e4b17023SJohn Marino bp = streamer_read_bitpack (ib);
423e4b17023SJohn Marino
424e4b17023SJohn Marino /* The first word in BP contains the code of the tree that we
425e4b17023SJohn Marino are about to read. */
426e4b17023SJohn Marino code = (enum tree_code) bp_unpack_value (&bp, 16);
427e4b17023SJohn Marino lto_tag_check (lto_tree_code_to_tag (code),
428e4b17023SJohn Marino lto_tree_code_to_tag (TREE_CODE (expr)));
429e4b17023SJohn Marino
430e4b17023SJohn Marino /* Unpack all the value fields from BP. */
431e4b17023SJohn Marino unpack_value_fields (&bp, expr);
432e4b17023SJohn Marino
433e4b17023SJohn Marino return bp;
434e4b17023SJohn Marino }
435e4b17023SJohn Marino
436e4b17023SJohn Marino
437e4b17023SJohn Marino /* Materialize a new tree from input block IB using descriptors in
438e4b17023SJohn Marino DATA_IN. The code for the new tree should match TAG. Store in
439e4b17023SJohn Marino *IX_P the index into the reader cache where the new tree is stored. */
440e4b17023SJohn Marino
441e4b17023SJohn Marino tree
streamer_alloc_tree(struct lto_input_block * ib,struct data_in * data_in,enum LTO_tags tag)442e4b17023SJohn Marino streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
443e4b17023SJohn Marino enum LTO_tags tag)
444e4b17023SJohn Marino {
445e4b17023SJohn Marino enum tree_code code;
446e4b17023SJohn Marino tree result;
447e4b17023SJohn Marino #ifdef LTO_STREAMER_DEBUG
448e4b17023SJohn Marino HOST_WIDEST_INT orig_address_in_writer;
449e4b17023SJohn Marino #endif
450e4b17023SJohn Marino
451e4b17023SJohn Marino result = NULL_TREE;
452e4b17023SJohn Marino
453e4b17023SJohn Marino #ifdef LTO_STREAMER_DEBUG
454e4b17023SJohn Marino /* Read the word representing the memory address for the tree
455e4b17023SJohn Marino as it was written by the writer. This is useful when
456e4b17023SJohn Marino debugging differences between the writer and reader. */
457e4b17023SJohn Marino orig_address_in_writer = streamer_read_hwi (ib);
458e4b17023SJohn Marino gcc_assert ((intptr_t) orig_address_in_writer == orig_address_in_writer);
459e4b17023SJohn Marino #endif
460e4b17023SJohn Marino
461e4b17023SJohn Marino code = lto_tag_to_tree_code (tag);
462e4b17023SJohn Marino
463e4b17023SJohn Marino /* We should never see an SSA_NAME tree. Only the version numbers of
464e4b17023SJohn Marino SSA names are ever written out. See input_ssa_names. */
465e4b17023SJohn Marino gcc_assert (code != SSA_NAME);
466e4b17023SJohn Marino
467e4b17023SJohn Marino /* Instantiate a new tree using the header data. */
468e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_STRING))
469e4b17023SJohn Marino result = streamer_read_string_cst (data_in, ib);
470e4b17023SJohn Marino else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
471e4b17023SJohn Marino result = input_identifier (data_in, ib);
472e4b17023SJohn Marino else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
473e4b17023SJohn Marino {
474e4b17023SJohn Marino HOST_WIDE_INT len = streamer_read_hwi (ib);
475e4b17023SJohn Marino result = make_tree_vec (len);
476e4b17023SJohn Marino }
477e4b17023SJohn Marino else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
478e4b17023SJohn Marino {
479e4b17023SJohn Marino unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
480e4b17023SJohn Marino result = make_tree_binfo (len);
481e4b17023SJohn Marino }
482e4b17023SJohn Marino else if (code == CALL_EXPR)
483e4b17023SJohn Marino {
484e4b17023SJohn Marino unsigned HOST_WIDE_INT nargs = streamer_read_uhwi (ib);
485e4b17023SJohn Marino return build_vl_exp (CALL_EXPR, nargs + 3);
486e4b17023SJohn Marino }
487e4b17023SJohn Marino else
488e4b17023SJohn Marino {
489e4b17023SJohn Marino /* For all other nodes, materialize the tree with a raw
490e4b17023SJohn Marino make_node call. */
491e4b17023SJohn Marino result = make_node (code);
492e4b17023SJohn Marino }
493e4b17023SJohn Marino
494e4b17023SJohn Marino #ifdef LTO_STREAMER_DEBUG
495e4b17023SJohn Marino /* Store the original address of the tree as seen by the writer
496e4b17023SJohn Marino in RESULT's aux field. This is useful when debugging streaming
497e4b17023SJohn Marino problems. This way, a debugging session can be started on
498e4b17023SJohn Marino both writer and reader with a breakpoint using this address
499e4b17023SJohn Marino value in both. */
500e4b17023SJohn Marino lto_orig_address_map (result, (intptr_t) orig_address_in_writer);
501e4b17023SJohn Marino #endif
502e4b17023SJohn Marino
503e4b17023SJohn Marino return result;
504e4b17023SJohn Marino }
505e4b17023SJohn Marino
506e4b17023SJohn Marino
507e4b17023SJohn Marino /* Read all pointer fields in the TS_COMMON structure of EXPR from input
508e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
509e4b17023SJohn Marino file being read. */
510e4b17023SJohn Marino
511e4b17023SJohn Marino
512e4b17023SJohn Marino static void
lto_input_ts_common_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)513e4b17023SJohn Marino lto_input_ts_common_tree_pointers (struct lto_input_block *ib,
514e4b17023SJohn Marino struct data_in *data_in, tree expr)
515e4b17023SJohn Marino {
516e4b17023SJohn Marino if (TREE_CODE (expr) != IDENTIFIER_NODE)
517e4b17023SJohn Marino TREE_TYPE (expr) = stream_read_tree (ib, data_in);
518e4b17023SJohn Marino }
519e4b17023SJohn Marino
520e4b17023SJohn Marino
521e4b17023SJohn Marino /* Read all pointer fields in the TS_VECTOR structure of EXPR from input
522e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
523e4b17023SJohn Marino file being read. */
524e4b17023SJohn Marino
525e4b17023SJohn Marino static void
lto_input_ts_vector_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)526e4b17023SJohn Marino lto_input_ts_vector_tree_pointers (struct lto_input_block *ib,
527e4b17023SJohn Marino struct data_in *data_in, tree expr)
528e4b17023SJohn Marino {
529e4b17023SJohn Marino TREE_VECTOR_CST_ELTS (expr) = streamer_read_chain (ib, data_in);
530e4b17023SJohn Marino }
531e4b17023SJohn Marino
532e4b17023SJohn Marino
533e4b17023SJohn Marino /* Read all pointer fields in the TS_COMPLEX structure of EXPR from input
534e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
535e4b17023SJohn Marino file being read. */
536e4b17023SJohn Marino
537e4b17023SJohn Marino static void
lto_input_ts_complex_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)538e4b17023SJohn Marino lto_input_ts_complex_tree_pointers (struct lto_input_block *ib,
539e4b17023SJohn Marino struct data_in *data_in, tree expr)
540e4b17023SJohn Marino {
541e4b17023SJohn Marino TREE_REALPART (expr) = stream_read_tree (ib, data_in);
542e4b17023SJohn Marino TREE_IMAGPART (expr) = stream_read_tree (ib, data_in);
543e4b17023SJohn Marino }
544e4b17023SJohn Marino
545e4b17023SJohn Marino
546e4b17023SJohn Marino /* Read all pointer fields in the TS_DECL_MINIMAL structure of EXPR
547e4b17023SJohn Marino from input block IB. DATA_IN contains tables and descriptors for the
548e4b17023SJohn Marino file being read. */
549e4b17023SJohn Marino
550e4b17023SJohn Marino static void
lto_input_ts_decl_minimal_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)551e4b17023SJohn Marino lto_input_ts_decl_minimal_tree_pointers (struct lto_input_block *ib,
552e4b17023SJohn Marino struct data_in *data_in, tree expr)
553e4b17023SJohn Marino {
554e4b17023SJohn Marino DECL_NAME (expr) = stream_read_tree (ib, data_in);
555e4b17023SJohn Marino DECL_CONTEXT (expr) = stream_read_tree (ib, data_in);
556e4b17023SJohn Marino DECL_SOURCE_LOCATION (expr) = lto_input_location (ib, data_in);
557e4b17023SJohn Marino }
558e4b17023SJohn Marino
559e4b17023SJohn Marino
560e4b17023SJohn Marino /* Read all pointer fields in the TS_DECL_COMMON structure of EXPR from
561e4b17023SJohn Marino input block IB. DATA_IN contains tables and descriptors for the
562e4b17023SJohn Marino file being read. */
563e4b17023SJohn Marino
564e4b17023SJohn Marino static void
lto_input_ts_decl_common_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)565e4b17023SJohn Marino lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib,
566e4b17023SJohn Marino struct data_in *data_in, tree expr)
567e4b17023SJohn Marino {
568e4b17023SJohn Marino DECL_SIZE (expr) = stream_read_tree (ib, data_in);
569e4b17023SJohn Marino DECL_SIZE_UNIT (expr) = stream_read_tree (ib, data_in);
570e4b17023SJohn Marino DECL_ATTRIBUTES (expr) = stream_read_tree (ib, data_in);
571e4b17023SJohn Marino
572e4b17023SJohn Marino /* Do not stream DECL_ABSTRACT_ORIGIN. We cannot handle debug information
573e4b17023SJohn Marino for early inlining so drop it on the floor instead of ICEing in
574e4b17023SJohn Marino dwarf2out.c. */
575e4b17023SJohn Marino
576e4b17023SJohn Marino if (TREE_CODE (expr) == PARM_DECL)
577e4b17023SJohn Marino TREE_CHAIN (expr) = streamer_read_chain (ib, data_in);
578e4b17023SJohn Marino
579e4b17023SJohn Marino if ((TREE_CODE (expr) == VAR_DECL
580e4b17023SJohn Marino || TREE_CODE (expr) == PARM_DECL)
581e4b17023SJohn Marino && DECL_HAS_VALUE_EXPR_P (expr))
582e4b17023SJohn Marino SET_DECL_VALUE_EXPR (expr, stream_read_tree (ib, data_in));
583e4b17023SJohn Marino
584e4b17023SJohn Marino if (TREE_CODE (expr) == VAR_DECL)
585e4b17023SJohn Marino {
586e4b17023SJohn Marino tree dexpr = stream_read_tree (ib, data_in);
587e4b17023SJohn Marino if (dexpr)
588e4b17023SJohn Marino SET_DECL_DEBUG_EXPR (expr, dexpr);
589e4b17023SJohn Marino }
590e4b17023SJohn Marino }
591e4b17023SJohn Marino
592e4b17023SJohn Marino
593e4b17023SJohn Marino /* Read all pointer fields in the TS_DECL_NON_COMMON structure of
594e4b17023SJohn Marino EXPR from input block IB. DATA_IN contains tables and descriptors for the
595e4b17023SJohn Marino file being read. */
596e4b17023SJohn Marino
597e4b17023SJohn Marino static void
lto_input_ts_decl_non_common_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)598e4b17023SJohn Marino lto_input_ts_decl_non_common_tree_pointers (struct lto_input_block *ib,
599e4b17023SJohn Marino struct data_in *data_in, tree expr)
600e4b17023SJohn Marino {
601e4b17023SJohn Marino if (TREE_CODE (expr) == FUNCTION_DECL)
602e4b17023SJohn Marino {
603e4b17023SJohn Marino DECL_ARGUMENTS (expr) = stream_read_tree (ib, data_in);
604e4b17023SJohn Marino DECL_RESULT (expr) = stream_read_tree (ib, data_in);
605e4b17023SJohn Marino }
606e4b17023SJohn Marino else if (TREE_CODE (expr) == TYPE_DECL)
607e4b17023SJohn Marino DECL_ORIGINAL_TYPE (expr) = stream_read_tree (ib, data_in);
608e4b17023SJohn Marino DECL_VINDEX (expr) = stream_read_tree (ib, data_in);
609e4b17023SJohn Marino }
610e4b17023SJohn Marino
611e4b17023SJohn Marino
612e4b17023SJohn Marino /* Read all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
613e4b17023SJohn Marino from input block IB. DATA_IN contains tables and descriptors for the
614e4b17023SJohn Marino file being read. */
615e4b17023SJohn Marino
616e4b17023SJohn Marino static void
lto_input_ts_decl_with_vis_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)617e4b17023SJohn Marino lto_input_ts_decl_with_vis_tree_pointers (struct lto_input_block *ib,
618e4b17023SJohn Marino struct data_in *data_in, tree expr)
619e4b17023SJohn Marino {
620e4b17023SJohn Marino tree id;
621e4b17023SJohn Marino
622e4b17023SJohn Marino id = stream_read_tree (ib, data_in);
623e4b17023SJohn Marino if (id)
624e4b17023SJohn Marino {
625e4b17023SJohn Marino gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
626e4b17023SJohn Marino SET_DECL_ASSEMBLER_NAME (expr, id);
627e4b17023SJohn Marino }
628e4b17023SJohn Marino
629e4b17023SJohn Marino DECL_SECTION_NAME (expr) = stream_read_tree (ib, data_in);
630e4b17023SJohn Marino DECL_COMDAT_GROUP (expr) = stream_read_tree (ib, data_in);
631e4b17023SJohn Marino }
632e4b17023SJohn Marino
633e4b17023SJohn Marino
634e4b17023SJohn Marino /* Read all pointer fields in the TS_FIELD_DECL structure of EXPR from
635e4b17023SJohn Marino input block IB. DATA_IN contains tables and descriptors for the
636e4b17023SJohn Marino file being read. */
637e4b17023SJohn Marino
638e4b17023SJohn Marino static void
lto_input_ts_field_decl_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)639e4b17023SJohn Marino lto_input_ts_field_decl_tree_pointers (struct lto_input_block *ib,
640e4b17023SJohn Marino struct data_in *data_in, tree expr)
641e4b17023SJohn Marino {
642e4b17023SJohn Marino DECL_FIELD_OFFSET (expr) = stream_read_tree (ib, data_in);
643e4b17023SJohn Marino DECL_BIT_FIELD_TYPE (expr) = stream_read_tree (ib, data_in);
644e4b17023SJohn Marino DECL_BIT_FIELD_REPRESENTATIVE (expr) = stream_read_tree (ib, data_in);
645e4b17023SJohn Marino DECL_FIELD_BIT_OFFSET (expr) = stream_read_tree (ib, data_in);
646e4b17023SJohn Marino DECL_FCONTEXT (expr) = stream_read_tree (ib, data_in);
647e4b17023SJohn Marino }
648e4b17023SJohn Marino
649e4b17023SJohn Marino
650e4b17023SJohn Marino /* Read all pointer fields in the TS_FUNCTION_DECL structure of EXPR
651e4b17023SJohn Marino from input block IB. DATA_IN contains tables and descriptors for the
652e4b17023SJohn Marino file being read. */
653e4b17023SJohn Marino
654e4b17023SJohn Marino static void
lto_input_ts_function_decl_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)655e4b17023SJohn Marino lto_input_ts_function_decl_tree_pointers (struct lto_input_block *ib,
656e4b17023SJohn Marino struct data_in *data_in, tree expr)
657e4b17023SJohn Marino {
658e4b17023SJohn Marino /* DECL_STRUCT_FUNCTION is handled by lto_input_function. FIXME lto,
659e4b17023SJohn Marino maybe it should be handled here? */
660e4b17023SJohn Marino DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree (ib, data_in);
661e4b17023SJohn Marino DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree (ib, data_in);
662e4b17023SJohn Marino DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = stream_read_tree (ib, data_in);
663e4b17023SJohn Marino
664e4b17023SJohn Marino /* If the file contains a function with an EH personality set,
665e4b17023SJohn Marino then it was compiled with -fexceptions. In that case, initialize
666e4b17023SJohn Marino the backend EH machinery. */
667e4b17023SJohn Marino if (DECL_FUNCTION_PERSONALITY (expr))
668e4b17023SJohn Marino lto_init_eh ();
669e4b17023SJohn Marino }
670e4b17023SJohn Marino
671e4b17023SJohn Marino
672e4b17023SJohn Marino /* Read all pointer fields in the TS_TYPE_COMMON structure of EXPR from
673e4b17023SJohn Marino input block IB. DATA_IN contains tables and descriptors for the file
674e4b17023SJohn Marino being read. */
675e4b17023SJohn Marino
676e4b17023SJohn Marino static void
lto_input_ts_type_common_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)677e4b17023SJohn Marino lto_input_ts_type_common_tree_pointers (struct lto_input_block *ib,
678e4b17023SJohn Marino struct data_in *data_in, tree expr)
679e4b17023SJohn Marino {
680e4b17023SJohn Marino TYPE_SIZE (expr) = stream_read_tree (ib, data_in);
681e4b17023SJohn Marino TYPE_SIZE_UNIT (expr) = stream_read_tree (ib, data_in);
682e4b17023SJohn Marino TYPE_ATTRIBUTES (expr) = stream_read_tree (ib, data_in);
683e4b17023SJohn Marino TYPE_NAME (expr) = stream_read_tree (ib, data_in);
684e4b17023SJohn Marino /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO. They will be
685e4b17023SJohn Marino reconstructed during fixup. */
686e4b17023SJohn Marino /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
687e4b17023SJohn Marino during fixup. */
688e4b17023SJohn Marino TYPE_MAIN_VARIANT (expr) = stream_read_tree (ib, data_in);
689e4b17023SJohn Marino TYPE_CONTEXT (expr) = stream_read_tree (ib, data_in);
690e4b17023SJohn Marino /* TYPE_CANONICAL gets re-computed during type merging. */
691e4b17023SJohn Marino TYPE_CANONICAL (expr) = NULL_TREE;
692e4b17023SJohn Marino TYPE_STUB_DECL (expr) = stream_read_tree (ib, data_in);
693e4b17023SJohn Marino }
694e4b17023SJohn Marino
695e4b17023SJohn Marino /* Read all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
696e4b17023SJohn Marino from input block IB. DATA_IN contains tables and descriptors for the
697e4b17023SJohn Marino file being read. */
698e4b17023SJohn Marino
699e4b17023SJohn Marino static void
lto_input_ts_type_non_common_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)700e4b17023SJohn Marino lto_input_ts_type_non_common_tree_pointers (struct lto_input_block *ib,
701e4b17023SJohn Marino struct data_in *data_in,
702e4b17023SJohn Marino tree expr)
703e4b17023SJohn Marino {
704e4b17023SJohn Marino if (TREE_CODE (expr) == ENUMERAL_TYPE)
705e4b17023SJohn Marino TYPE_VALUES (expr) = stream_read_tree (ib, data_in);
706e4b17023SJohn Marino else if (TREE_CODE (expr) == ARRAY_TYPE)
707e4b17023SJohn Marino TYPE_DOMAIN (expr) = stream_read_tree (ib, data_in);
708e4b17023SJohn Marino else if (RECORD_OR_UNION_TYPE_P (expr))
709e4b17023SJohn Marino TYPE_FIELDS (expr) = streamer_read_chain (ib, data_in);
710e4b17023SJohn Marino else if (TREE_CODE (expr) == FUNCTION_TYPE
711e4b17023SJohn Marino || TREE_CODE (expr) == METHOD_TYPE)
712e4b17023SJohn Marino TYPE_ARG_TYPES (expr) = stream_read_tree (ib, data_in);
713e4b17023SJohn Marino
714e4b17023SJohn Marino if (!POINTER_TYPE_P (expr))
715e4b17023SJohn Marino TYPE_MINVAL (expr) = stream_read_tree (ib, data_in);
716e4b17023SJohn Marino TYPE_MAXVAL (expr) = stream_read_tree (ib, data_in);
717e4b17023SJohn Marino if (RECORD_OR_UNION_TYPE_P (expr))
718e4b17023SJohn Marino TYPE_BINFO (expr) = stream_read_tree (ib, data_in);
719e4b17023SJohn Marino }
720e4b17023SJohn Marino
721e4b17023SJohn Marino
722e4b17023SJohn Marino /* Read all pointer fields in the TS_LIST structure of EXPR from input
723e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
724e4b17023SJohn Marino file being read. */
725e4b17023SJohn Marino
726e4b17023SJohn Marino static void
lto_input_ts_list_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)727e4b17023SJohn Marino lto_input_ts_list_tree_pointers (struct lto_input_block *ib,
728e4b17023SJohn Marino struct data_in *data_in, tree expr)
729e4b17023SJohn Marino {
730e4b17023SJohn Marino TREE_PURPOSE (expr) = stream_read_tree (ib, data_in);
731e4b17023SJohn Marino TREE_VALUE (expr) = stream_read_tree (ib, data_in);
732e4b17023SJohn Marino TREE_CHAIN (expr) = streamer_read_chain (ib, data_in);
733e4b17023SJohn Marino }
734e4b17023SJohn Marino
735e4b17023SJohn Marino
736e4b17023SJohn Marino /* Read all pointer fields in the TS_VEC structure of EXPR from input
737e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
738e4b17023SJohn Marino file being read. */
739e4b17023SJohn Marino
740e4b17023SJohn Marino static void
lto_input_ts_vec_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)741e4b17023SJohn Marino lto_input_ts_vec_tree_pointers (struct lto_input_block *ib,
742e4b17023SJohn Marino struct data_in *data_in, tree expr)
743e4b17023SJohn Marino {
744e4b17023SJohn Marino int i;
745e4b17023SJohn Marino
746e4b17023SJohn Marino /* Note that TREE_VEC_LENGTH was read by streamer_alloc_tree to
747e4b17023SJohn Marino instantiate EXPR. */
748e4b17023SJohn Marino for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
749e4b17023SJohn Marino TREE_VEC_ELT (expr, i) = stream_read_tree (ib, data_in);
750e4b17023SJohn Marino }
751e4b17023SJohn Marino
752e4b17023SJohn Marino
753e4b17023SJohn Marino /* Read all pointer fields in the TS_EXP structure of EXPR from input
754e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
755e4b17023SJohn Marino file being read. */
756e4b17023SJohn Marino
757e4b17023SJohn Marino
758e4b17023SJohn Marino static void
lto_input_ts_exp_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)759e4b17023SJohn Marino lto_input_ts_exp_tree_pointers (struct lto_input_block *ib,
760e4b17023SJohn Marino struct data_in *data_in, tree expr)
761e4b17023SJohn Marino {
762e4b17023SJohn Marino int i, length;
763e4b17023SJohn Marino location_t loc;
764e4b17023SJohn Marino
765e4b17023SJohn Marino length = streamer_read_hwi (ib);
766e4b17023SJohn Marino gcc_assert (length == TREE_OPERAND_LENGTH (expr));
767e4b17023SJohn Marino
768e4b17023SJohn Marino for (i = 0; i < length; i++)
769e4b17023SJohn Marino TREE_OPERAND (expr, i) = stream_read_tree (ib, data_in);
770e4b17023SJohn Marino
771e4b17023SJohn Marino loc = lto_input_location (ib, data_in);
772e4b17023SJohn Marino SET_EXPR_LOCATION (expr, loc);
773e4b17023SJohn Marino TREE_BLOCK (expr) = stream_read_tree (ib, data_in);
774e4b17023SJohn Marino }
775e4b17023SJohn Marino
776e4b17023SJohn Marino
777e4b17023SJohn Marino /* Read all pointer fields in the TS_BLOCK structure of EXPR from input
778e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
779e4b17023SJohn Marino file being read. */
780e4b17023SJohn Marino
781e4b17023SJohn Marino static void
lto_input_ts_block_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)782e4b17023SJohn Marino lto_input_ts_block_tree_pointers (struct lto_input_block *ib,
783e4b17023SJohn Marino struct data_in *data_in, tree expr)
784e4b17023SJohn Marino {
785e4b17023SJohn Marino /* Do not stream BLOCK_SOURCE_LOCATION. We cannot handle debug information
786e4b17023SJohn Marino for early inlining so drop it on the floor instead of ICEing in
787e4b17023SJohn Marino dwarf2out.c. */
788e4b17023SJohn Marino BLOCK_VARS (expr) = streamer_read_chain (ib, data_in);
789e4b17023SJohn Marino
790e4b17023SJohn Marino /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information
791e4b17023SJohn Marino for early inlining so drop it on the floor instead of ICEing in
792e4b17023SJohn Marino dwarf2out.c. */
793e4b17023SJohn Marino
794e4b17023SJohn Marino BLOCK_SUPERCONTEXT (expr) = stream_read_tree (ib, data_in);
795e4b17023SJohn Marino
796e4b17023SJohn Marino /* Do not stream BLOCK_ABSTRACT_ORIGIN. We cannot handle debug information
797e4b17023SJohn Marino for early inlining so drop it on the floor instead of ICEing in
798e4b17023SJohn Marino dwarf2out.c. */
799e4b17023SJohn Marino BLOCK_FRAGMENT_ORIGIN (expr) = stream_read_tree (ib, data_in);
800e4b17023SJohn Marino BLOCK_FRAGMENT_CHAIN (expr) = stream_read_tree (ib, data_in);
801e4b17023SJohn Marino
802e4b17023SJohn Marino /* We re-compute BLOCK_SUBBLOCKS of our parent here instead
803e4b17023SJohn Marino of streaming it. For non-BLOCK BLOCK_SUPERCONTEXTs we still
804e4b17023SJohn Marino stream the child relationship explicitly. */
805e4b17023SJohn Marino if (BLOCK_SUPERCONTEXT (expr)
806e4b17023SJohn Marino && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == BLOCK)
807e4b17023SJohn Marino {
808e4b17023SJohn Marino BLOCK_CHAIN (expr) = BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr));
809e4b17023SJohn Marino BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)) = expr;
810e4b17023SJohn Marino }
811e4b17023SJohn Marino
812e4b17023SJohn Marino /* The global block is rooted at the TU decl. Hook it here to
813e4b17023SJohn Marino avoid the need to stream in this block during WPA time. */
814e4b17023SJohn Marino else if (BLOCK_SUPERCONTEXT (expr)
815e4b17023SJohn Marino && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == TRANSLATION_UNIT_DECL)
816e4b17023SJohn Marino DECL_INITIAL (BLOCK_SUPERCONTEXT (expr)) = expr;
817e4b17023SJohn Marino
818e4b17023SJohn Marino /* The function-level block is connected at the time we read in
819e4b17023SJohn Marino function bodies for the same reason. */
820e4b17023SJohn Marino }
821e4b17023SJohn Marino
822e4b17023SJohn Marino
823e4b17023SJohn Marino /* Read all pointer fields in the TS_BINFO structure of EXPR from input
824e4b17023SJohn Marino block IB. DATA_IN contains tables and descriptors for the
825e4b17023SJohn Marino file being read. */
826e4b17023SJohn Marino
827e4b17023SJohn Marino static void
lto_input_ts_binfo_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)828e4b17023SJohn Marino lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
829e4b17023SJohn Marino struct data_in *data_in, tree expr)
830e4b17023SJohn Marino {
831e4b17023SJohn Marino unsigned i, len;
832e4b17023SJohn Marino tree t;
833e4b17023SJohn Marino
834e4b17023SJohn Marino /* Note that the number of slots in EXPR was read in
835e4b17023SJohn Marino streamer_alloc_tree when instantiating EXPR. However, the
836e4b17023SJohn Marino vector is empty so we cannot rely on VEC_length to know how many
837e4b17023SJohn Marino elements to read. So, this list is emitted as a 0-terminated
838e4b17023SJohn Marino list on the writer side. */
839e4b17023SJohn Marino do
840e4b17023SJohn Marino {
841e4b17023SJohn Marino t = stream_read_tree (ib, data_in);
842e4b17023SJohn Marino if (t)
843e4b17023SJohn Marino VEC_quick_push (tree, BINFO_BASE_BINFOS (expr), t);
844e4b17023SJohn Marino }
845e4b17023SJohn Marino while (t);
846e4b17023SJohn Marino
847e4b17023SJohn Marino BINFO_OFFSET (expr) = stream_read_tree (ib, data_in);
848e4b17023SJohn Marino BINFO_VTABLE (expr) = stream_read_tree (ib, data_in);
849e4b17023SJohn Marino BINFO_VPTR_FIELD (expr) = stream_read_tree (ib, data_in);
850e4b17023SJohn Marino
851e4b17023SJohn Marino len = streamer_read_uhwi (ib);
852e4b17023SJohn Marino if (len > 0)
853e4b17023SJohn Marino {
854e4b17023SJohn Marino VEC_reserve_exact (tree, gc, BINFO_BASE_ACCESSES (expr), len);
855e4b17023SJohn Marino for (i = 0; i < len; i++)
856e4b17023SJohn Marino {
857e4b17023SJohn Marino tree a = stream_read_tree (ib, data_in);
858e4b17023SJohn Marino VEC_quick_push (tree, BINFO_BASE_ACCESSES (expr), a);
859e4b17023SJohn Marino }
860e4b17023SJohn Marino }
861e4b17023SJohn Marino
862e4b17023SJohn Marino BINFO_INHERITANCE_CHAIN (expr) = stream_read_tree (ib, data_in);
863e4b17023SJohn Marino BINFO_SUBVTT_INDEX (expr) = stream_read_tree (ib, data_in);
864e4b17023SJohn Marino BINFO_VPTR_INDEX (expr) = stream_read_tree (ib, data_in);
865e4b17023SJohn Marino }
866e4b17023SJohn Marino
867e4b17023SJohn Marino
868e4b17023SJohn Marino /* Read all pointer fields in the TS_CONSTRUCTOR structure of EXPR from
869e4b17023SJohn Marino input block IB. DATA_IN contains tables and descriptors for the
870e4b17023SJohn Marino file being read. */
871e4b17023SJohn Marino
872e4b17023SJohn Marino static void
lto_input_ts_constructor_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)873e4b17023SJohn Marino lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
874e4b17023SJohn Marino struct data_in *data_in, tree expr)
875e4b17023SJohn Marino {
876e4b17023SJohn Marino unsigned i, len;
877e4b17023SJohn Marino
878e4b17023SJohn Marino len = streamer_read_uhwi (ib);
879e4b17023SJohn Marino for (i = 0; i < len; i++)
880e4b17023SJohn Marino {
881e4b17023SJohn Marino tree index, value;
882e4b17023SJohn Marino
883e4b17023SJohn Marino index = stream_read_tree (ib, data_in);
884e4b17023SJohn Marino value = stream_read_tree (ib, data_in);
885e4b17023SJohn Marino CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (expr), index, value);
886e4b17023SJohn Marino }
887e4b17023SJohn Marino }
888e4b17023SJohn Marino
889e4b17023SJohn Marino
890e4b17023SJohn Marino /* Input a TS_TARGET_OPTION tree from IB into EXPR. */
891e4b17023SJohn Marino
892e4b17023SJohn Marino static void
lto_input_ts_target_option(struct lto_input_block * ib,tree expr)893e4b17023SJohn Marino lto_input_ts_target_option (struct lto_input_block *ib, tree expr)
894e4b17023SJohn Marino {
895e4b17023SJohn Marino unsigned i, len;
896e4b17023SJohn Marino struct bitpack_d bp;
897e4b17023SJohn Marino struct cl_target_option *t = TREE_TARGET_OPTION (expr);
898e4b17023SJohn Marino
899e4b17023SJohn Marino bp = streamer_read_bitpack (ib);
900e4b17023SJohn Marino len = sizeof (struct cl_target_option);
901e4b17023SJohn Marino for (i = 0; i < len; i++)
902e4b17023SJohn Marino ((unsigned char *)t)[i] = bp_unpack_value (&bp, 8);
903e4b17023SJohn Marino if (bp_unpack_value (&bp, 32) != 0x12345678)
904e4b17023SJohn Marino fatal_error ("cl_target_option size mismatch in LTO reader and writer");
905e4b17023SJohn Marino }
906e4b17023SJohn Marino
907e4b17023SJohn Marino /* Input a TS_OPTIMIZATION tree from IB into EXPR. */
908e4b17023SJohn Marino
909e4b17023SJohn Marino static void
lto_input_ts_optimization(struct lto_input_block * ib,tree expr)910e4b17023SJohn Marino lto_input_ts_optimization (struct lto_input_block *ib, tree expr)
911e4b17023SJohn Marino {
912e4b17023SJohn Marino unsigned i, len;
913e4b17023SJohn Marino struct bitpack_d bp;
914e4b17023SJohn Marino struct cl_optimization *t = TREE_OPTIMIZATION (expr);
915e4b17023SJohn Marino
916e4b17023SJohn Marino bp = streamer_read_bitpack (ib);
917e4b17023SJohn Marino len = sizeof (struct cl_optimization);
918e4b17023SJohn Marino for (i = 0; i < len; i++)
919e4b17023SJohn Marino ((unsigned char *)t)[i] = bp_unpack_value (&bp, 8);
920e4b17023SJohn Marino if (bp_unpack_value (&bp, 32) != 0x12345678)
921e4b17023SJohn Marino fatal_error ("cl_optimization size mismatch in LTO reader and writer");
922e4b17023SJohn Marino }
923e4b17023SJohn Marino
924e4b17023SJohn Marino /* Input a TS_TRANSLATION_UNIT_DECL tree from IB and DATA_IN into EXPR. */
925e4b17023SJohn Marino
926e4b17023SJohn Marino static void
lto_input_ts_translation_unit_decl_tree_pointers(struct lto_input_block * ib,struct data_in * data_in,tree expr)927e4b17023SJohn Marino lto_input_ts_translation_unit_decl_tree_pointers (struct lto_input_block *ib,
928e4b17023SJohn Marino struct data_in *data_in,
929e4b17023SJohn Marino tree expr)
930e4b17023SJohn Marino {
931e4b17023SJohn Marino TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (streamer_read_string (data_in, ib));
932e4b17023SJohn Marino VEC_safe_push (tree, gc, all_translation_units, expr);
933e4b17023SJohn Marino }
934e4b17023SJohn Marino
935e4b17023SJohn Marino /* Read all pointer fields in EXPR from input block IB. DATA_IN
936e4b17023SJohn Marino contains tables and descriptors for the file being read. */
937e4b17023SJohn Marino
938e4b17023SJohn Marino void
streamer_read_tree_body(struct lto_input_block * ib,struct data_in * data_in,tree expr)939e4b17023SJohn Marino streamer_read_tree_body (struct lto_input_block *ib, struct data_in *data_in,
940e4b17023SJohn Marino tree expr)
941e4b17023SJohn Marino {
942e4b17023SJohn Marino enum tree_code code;
943e4b17023SJohn Marino
944e4b17023SJohn Marino code = TREE_CODE (expr);
945e4b17023SJohn Marino
946e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
947e4b17023SJohn Marino lto_input_ts_common_tree_pointers (ib, data_in, expr);
948e4b17023SJohn Marino
949e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
950e4b17023SJohn Marino lto_input_ts_vector_tree_pointers (ib, data_in, expr);
951e4b17023SJohn Marino
952e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
953e4b17023SJohn Marino lto_input_ts_complex_tree_pointers (ib, data_in, expr);
954e4b17023SJohn Marino
955e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
956e4b17023SJohn Marino lto_input_ts_decl_minimal_tree_pointers (ib, data_in, expr);
957e4b17023SJohn Marino
958e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
959e4b17023SJohn Marino lto_input_ts_decl_common_tree_pointers (ib, data_in, expr);
960e4b17023SJohn Marino
961e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
962e4b17023SJohn Marino lto_input_ts_decl_non_common_tree_pointers (ib, data_in, expr);
963e4b17023SJohn Marino
964e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
965e4b17023SJohn Marino lto_input_ts_decl_with_vis_tree_pointers (ib, data_in, expr);
966e4b17023SJohn Marino
967e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
968e4b17023SJohn Marino lto_input_ts_field_decl_tree_pointers (ib, data_in, expr);
969e4b17023SJohn Marino
970e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
971e4b17023SJohn Marino lto_input_ts_function_decl_tree_pointers (ib, data_in, expr);
972e4b17023SJohn Marino
973e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
974e4b17023SJohn Marino lto_input_ts_type_common_tree_pointers (ib, data_in, expr);
975e4b17023SJohn Marino
976e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
977e4b17023SJohn Marino lto_input_ts_type_non_common_tree_pointers (ib, data_in, expr);
978e4b17023SJohn Marino
979e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_LIST))
980e4b17023SJohn Marino lto_input_ts_list_tree_pointers (ib, data_in, expr);
981e4b17023SJohn Marino
982e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_VEC))
983e4b17023SJohn Marino lto_input_ts_vec_tree_pointers (ib, data_in, expr);
984e4b17023SJohn Marino
985e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_EXP))
986e4b17023SJohn Marino lto_input_ts_exp_tree_pointers (ib, data_in, expr);
987e4b17023SJohn Marino
988e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
989e4b17023SJohn Marino lto_input_ts_block_tree_pointers (ib, data_in, expr);
990e4b17023SJohn Marino
991e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
992e4b17023SJohn Marino lto_input_ts_binfo_tree_pointers (ib, data_in, expr);
993e4b17023SJohn Marino
994e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
995e4b17023SJohn Marino lto_input_ts_constructor_tree_pointers (ib, data_in, expr);
996e4b17023SJohn Marino
997e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
998e4b17023SJohn Marino lto_input_ts_target_option (ib, expr);
999e4b17023SJohn Marino
1000e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
1001e4b17023SJohn Marino lto_input_ts_optimization (ib, expr);
1002e4b17023SJohn Marino
1003e4b17023SJohn Marino if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
1004e4b17023SJohn Marino lto_input_ts_translation_unit_decl_tree_pointers (ib, data_in, expr);
1005e4b17023SJohn Marino }
1006e4b17023SJohn Marino
1007e4b17023SJohn Marino
1008e4b17023SJohn Marino /* Read and INTEGER_CST node from input block IB using the per-file
1009e4b17023SJohn Marino context in DATA_IN. */
1010e4b17023SJohn Marino
1011e4b17023SJohn Marino tree
streamer_read_integer_cst(struct lto_input_block * ib,struct data_in * data_in)1012e4b17023SJohn Marino streamer_read_integer_cst (struct lto_input_block *ib, struct data_in *data_in)
1013e4b17023SJohn Marino {
1014e4b17023SJohn Marino tree result, type;
1015e4b17023SJohn Marino HOST_WIDE_INT low, high;
1016e4b17023SJohn Marino bool overflow_p;
1017e4b17023SJohn Marino
1018e4b17023SJohn Marino type = stream_read_tree (ib, data_in);
1019e4b17023SJohn Marino overflow_p = (streamer_read_uchar (ib) != 0);
1020e4b17023SJohn Marino low = streamer_read_uhwi (ib);
1021e4b17023SJohn Marino high = streamer_read_uhwi (ib);
1022e4b17023SJohn Marino result = build_int_cst_wide (type, low, high);
1023e4b17023SJohn Marino
1024e4b17023SJohn Marino /* If the original constant had overflown, build a replica of RESULT to
1025e4b17023SJohn Marino avoid modifying the shared constant returned by build_int_cst_wide. */
1026e4b17023SJohn Marino if (overflow_p)
1027e4b17023SJohn Marino {
1028e4b17023SJohn Marino result = copy_node (result);
1029e4b17023SJohn Marino TREE_OVERFLOW (result) = 1;
1030e4b17023SJohn Marino }
1031e4b17023SJohn Marino
1032e4b17023SJohn Marino return result;
1033e4b17023SJohn Marino }
1034e4b17023SJohn Marino
1035e4b17023SJohn Marino
1036e4b17023SJohn Marino /* Read an index IX from input block IB and return the tree node at
1037e4b17023SJohn Marino DATA_IN->FILE_DATA->GLOBALS_INDEX[IX]. */
1038e4b17023SJohn Marino
1039e4b17023SJohn Marino tree
streamer_get_pickled_tree(struct lto_input_block * ib,struct data_in * data_in)1040e4b17023SJohn Marino streamer_get_pickled_tree (struct lto_input_block *ib, struct data_in *data_in)
1041e4b17023SJohn Marino {
1042e4b17023SJohn Marino unsigned HOST_WIDE_INT ix;
1043e4b17023SJohn Marino tree result;
1044e4b17023SJohn Marino enum LTO_tags expected_tag;
1045e4b17023SJohn Marino
1046e4b17023SJohn Marino ix = streamer_read_uhwi (ib);
1047e4b17023SJohn Marino expected_tag = streamer_read_enum (ib, LTO_tags, LTO_NUM_TAGS);
1048e4b17023SJohn Marino
1049e4b17023SJohn Marino result = streamer_tree_cache_get (data_in->reader_cache, ix);
1050e4b17023SJohn Marino gcc_assert (result
1051e4b17023SJohn Marino && TREE_CODE (result) == lto_tag_to_tree_code (expected_tag));
1052e4b17023SJohn Marino
1053e4b17023SJohn Marino return result;
1054e4b17023SJohn Marino }
1055e4b17023SJohn Marino
1056e4b17023SJohn Marino
1057e4b17023SJohn Marino /* Read a code and class from input block IB and return the
1058e4b17023SJohn Marino corresponding builtin. DATA_IN is as in stream_read_tree. */
1059e4b17023SJohn Marino
1060e4b17023SJohn Marino tree
streamer_get_builtin_tree(struct lto_input_block * ib,struct data_in * data_in)1061e4b17023SJohn Marino streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
1062e4b17023SJohn Marino {
1063e4b17023SJohn Marino enum built_in_class fclass;
1064e4b17023SJohn Marino enum built_in_function fcode;
1065e4b17023SJohn Marino const char *asmname;
1066e4b17023SJohn Marino tree result;
1067e4b17023SJohn Marino
1068e4b17023SJohn Marino fclass = streamer_read_enum (ib, built_in_class, BUILT_IN_LAST);
1069e4b17023SJohn Marino gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD);
1070e4b17023SJohn Marino
1071e4b17023SJohn Marino fcode = (enum built_in_function) streamer_read_uhwi (ib);
1072e4b17023SJohn Marino
1073e4b17023SJohn Marino if (fclass == BUILT_IN_NORMAL)
1074e4b17023SJohn Marino {
1075e4b17023SJohn Marino if (fcode >= END_BUILTINS)
1076e4b17023SJohn Marino fatal_error ("machine independent builtin code out of range");
1077e4b17023SJohn Marino result = builtin_decl_explicit (fcode);
1078e4b17023SJohn Marino gcc_assert (result);
1079e4b17023SJohn Marino }
1080e4b17023SJohn Marino else if (fclass == BUILT_IN_MD)
1081e4b17023SJohn Marino {
1082e4b17023SJohn Marino result = targetm.builtin_decl (fcode, true);
1083e4b17023SJohn Marino if (!result || result == error_mark_node)
1084e4b17023SJohn Marino fatal_error ("target specific builtin not available");
1085e4b17023SJohn Marino }
1086e4b17023SJohn Marino else
1087e4b17023SJohn Marino gcc_unreachable ();
1088e4b17023SJohn Marino
1089e4b17023SJohn Marino asmname = streamer_read_string (data_in, ib);
1090e4b17023SJohn Marino if (asmname)
1091e4b17023SJohn Marino set_builtin_user_assembler_name (result, asmname);
1092e4b17023SJohn Marino
1093e4b17023SJohn Marino streamer_tree_cache_append (data_in->reader_cache, result);
1094e4b17023SJohn Marino
1095e4b17023SJohn Marino return result;
1096e4b17023SJohn Marino }
1097