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