Oranize the PPH tree switch into tcc_* chunks, in each of four sections:
[official-gcc.git] / gcc / cp / pph-streamer-in.c
blobb47f8f7eb0d37ce562bee18224f4943ff8a70107
1 /* Routines for reading PPH data.
2 Copyright (C) 2011 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@google.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree.h"
25 #include "langhooks.h"
26 #include "tree-iterator.h"
27 #include "tree-pretty-print.h"
28 #include "lto-streamer.h"
29 #include "pph-streamer.h"
30 #include "pph.h"
31 #include "tree-pass.h"
32 #include "version.h"
33 #include "cppbuiltin.h"
35 /* Callback for unpacking value fields in ASTs. BP is the bitpack
36 we are unpacking from. EXPR is the tree to unpack. */
38 void
39 pph_stream_unpack_value_fields (struct bitpack_d *bp, tree expr)
41 if (TYPE_P (expr))
43 TYPE_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
44 TYPE_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
45 TYPE_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
46 TYPE_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
47 TYPE_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
48 TYPE_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
49 TYPE_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
51 else if (DECL_P (expr))
53 DECL_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
54 DECL_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
55 DECL_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
56 DECL_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
57 DECL_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
58 DECL_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
59 DECL_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
60 DECL_LANG_FLAG_7 (expr) = bp_unpack_value (bp, 1);
61 DECL_LANG_FLAG_8 (expr) = bp_unpack_value (bp, 1);
64 TREE_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
65 TREE_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
66 TREE_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
67 TREE_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
68 TREE_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
69 TREE_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
70 TREE_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
74 /* Get the section with name NAME and type SECTION_TYPE from FILE_DATA.
75 Return a pointer to the start of the section contents and store
76 the length of the section in *LEN_P.
78 FIXME pph, this does not currently handle multiple sections. It
79 assumes that the file has exactly one section. */
81 static const char *
82 pph_get_section_data (struct lto_file_decl_data *file_data,
83 enum lto_section_type section_type ATTRIBUTE_UNUSED,
84 const char *name ATTRIBUTE_UNUSED,
85 size_t *len)
87 /* FIXME pph - Stop abusing lto_file_decl_data fields. */
88 const pph_stream *stream = (const pph_stream *) file_data->file_name;
89 *len = stream->file_size - sizeof (pph_file_header);
90 return (const char *) stream->file_data + sizeof (pph_file_header);
94 /* Free the section data from FILE_DATA of SECTION_TYPE and NAME that
95 starts at OFFSET and has LEN bytes. */
97 static void
98 pph_free_section_data (struct lto_file_decl_data *file_data,
99 enum lto_section_type section_type ATTRIBUTE_UNUSED,
100 const char *name ATTRIBUTE_UNUSED,
101 const char *offset ATTRIBUTE_UNUSED,
102 size_t len ATTRIBUTE_UNUSED)
104 /* FIXME pph - Stop abusing lto_file_decl_data fields. */
105 const pph_stream *stream = (const pph_stream *) file_data->file_name;
106 free (stream->file_data);
110 /* Read into memory the contents of the file in STREAM. Initialize
111 internal tables and data structures needed to re-construct the
112 ASTs in the file. */
114 void
115 pph_stream_init_read (pph_stream *stream)
117 struct stat st;
118 size_t i, bytes_read, strtab_size, body_size;
119 int retcode;
120 pph_file_header *header;
121 const char *strtab, *body;
123 lto_reader_init ();
125 /* Read STREAM->NAME into the memory buffer STREAM->FILE_DATA.
126 FIXME pph, we are reading the whole file at once. This seems
127 wasteful. */
128 retcode = fstat (fileno (stream->file), &st);
129 gcc_assert (retcode == 0);
130 stream->file_size = (size_t) st.st_size;
131 stream->file_data = XCNEWVEC (char, stream->file_size);
132 bytes_read = fread (stream->file_data, 1, stream->file_size, stream->file);
133 gcc_assert (bytes_read == stream->file_size);
135 /* Set LTO callbacks to read the PPH file. */
136 stream->pph_sections = XCNEWVEC (struct lto_file_decl_data *,
137 PPH_NUM_SECTIONS);
138 for (i = 0; i < PPH_NUM_SECTIONS; i++)
140 stream->pph_sections[i] = XCNEW (struct lto_file_decl_data);
141 /* FIXME pph - Stop abusing fields in lto_file_decl_data. */
142 stream->pph_sections[i]->file_name = (const char *) stream;
145 lto_set_in_hooks (stream->pph_sections, pph_get_section_data,
146 pph_free_section_data);
148 header = (pph_file_header *) stream->file_data;
149 strtab = (const char *) header + sizeof (pph_file_header);
150 strtab_size = header->strtab_size;
151 body = strtab + strtab_size;
152 gcc_assert (stream->file_size >= strtab_size + sizeof (pph_file_header));
153 body_size = stream->file_size - strtab_size - sizeof (pph_file_header);
155 /* Create an input block structure pointing right after the string
156 table. */
157 stream->ib = XCNEW (struct lto_input_block);
158 LTO_INIT_INPUT_BLOCK_PTR (stream->ib, body, 0, body_size);
159 stream->data_in = lto_data_in_create (stream->pph_sections[0], strtab,
160 strtab_size, NULL);
162 /* Associate STREAM with STREAM->DATA_IN so we can recover it from
163 the streamer hooks. */
164 stream->data_in->sdata = (void *) stream;
168 /* Read and return a record marker from STREAM. The marker
169 must be one of PPH_RECORD_START or PPH_RECORD_END. If PPH_RECORD_END
170 is read, return false. Otherwise, return true. */
172 static inline bool
173 pph_start_record (pph_stream *stream)
175 unsigned char marker = pph_input_uchar (stream);
176 gcc_assert (marker == PPH_RECORD_START || marker == PPH_RECORD_END);
177 return (marker == PPH_RECORD_START);
181 /* Read all fields in lang_decl_base instance LDB from STREAM. */
183 static void
184 pph_stream_read_ld_base (pph_stream *stream, struct lang_decl_base *ldb)
186 struct bitpack_d bp;
188 if (!pph_start_record (stream))
189 return;
191 bp = pph_input_bitpack (stream);
192 ldb->selector = bp_unpack_value (&bp, 16);
193 ldb->language = (enum languages) bp_unpack_value (&bp, 4);
194 ldb->use_template = bp_unpack_value (&bp, 2);
195 ldb->not_really_extern = bp_unpack_value (&bp, 1);
196 ldb->initialized_in_class = bp_unpack_value (&bp, 1);
197 ldb->repo_available_p = bp_unpack_value (&bp, 1);
198 ldb->threadprivate_or_deleted_p = bp_unpack_value (&bp, 1);
199 ldb->anticipated_p = bp_unpack_value (&bp, 1);
200 ldb->friend_attr = bp_unpack_value (&bp, 1);
201 ldb->template_conv_p = bp_unpack_value (&bp, 1);
202 ldb->odr_used = bp_unpack_value (&bp, 1);
203 ldb->u2sel = bp_unpack_value (&bp, 1);
207 /* Read all the fields in lang_decl_min instance LDM from STREAM. */
209 static void
210 pph_stream_read_ld_min (pph_stream *stream, struct lang_decl_min *ldm)
212 if (!pph_start_record (stream))
213 return;
215 gcc_assert (ldm->base.selector == 0);
217 ldm->template_info = pph_input_tree (stream);
218 if (ldm->base.u2sel == 0)
219 ldm->u2.access = pph_input_tree (stream);
220 else if (ldm->base.u2sel == 1)
221 ldm->u2.discriminator = pph_input_uint (stream);
222 else
223 gcc_unreachable ();
227 /* Read and return a gc VEC of trees from STREAM. */
229 VEC(tree,gc) *
230 pph_stream_read_tree_vec (pph_stream *stream)
232 unsigned i, num;
233 VEC(tree,gc) *v;
235 num = pph_input_uint (stream);
236 v = NULL;
237 for (i = 0; i < num; i++)
239 tree t = pph_input_tree (stream);
240 VEC_safe_push (tree, gc, v, t);
243 return v;
247 /* Read and return a gc VEC of qualified_typedef_usage_t from STREAM. */
249 static VEC(qualified_typedef_usage_t,gc) *
250 pph_stream_read_qual_use_vec (pph_stream *stream)
252 unsigned i, num;
253 VEC(qualified_typedef_usage_t,gc) *v;
255 num = pph_input_uint (stream);
256 v = NULL;
257 for (i = 0; i < num; i++)
259 qualified_typedef_usage_t q;
260 q.typedef_decl = pph_input_tree (stream);
261 q.context = pph_input_tree (stream);
262 /* FIXME pph: also read location. */
263 VEC_safe_push (qualified_typedef_usage_t, gc, v, &q);
266 return v;
270 /* Forward declaration to break cyclic dependencies. */
271 static struct cp_binding_level *pph_stream_read_binding_level (pph_stream *);
273 /* Helper for pph_stream_read_cxx_binding. Read and return a cxx_binding
274 instance from STREAM. */
276 static cxx_binding *
277 pph_stream_read_cxx_binding_1 (pph_stream *stream)
279 struct bitpack_d bp;
280 cxx_binding *cb;
281 tree value, type;
283 if (!pph_start_record (stream))
284 return NULL;
286 value = pph_input_tree (stream);
287 type = pph_input_tree (stream);
288 cb = cxx_binding_make (value, type);
289 cb->scope = pph_stream_read_binding_level (stream);
290 bp = pph_input_bitpack (stream);
291 cb->value_is_inherited = bp_unpack_value (&bp, 1);
292 cb->is_local = bp_unpack_value (&bp, 1);
294 return cb;
298 /* Read and return an instance of cxx_binding from STREAM. */
300 static cxx_binding *
301 pph_stream_read_cxx_binding (pph_stream *stream)
303 unsigned i, num_bindings;
304 cxx_binding *curr, *cb;
306 if (!pph_start_record (stream))
307 return NULL;
309 /* Read the list of previous bindings. */
310 num_bindings = pph_input_uint (stream);
311 for (curr = NULL, i = 0; i < num_bindings; i++)
313 cxx_binding *prev = pph_stream_read_cxx_binding_1 (stream);
314 if (curr)
315 curr->previous = prev;
316 curr = prev;
319 /* Read the current binding at the end. */
320 cb = pph_stream_read_cxx_binding_1 (stream);
321 cb->previous = curr;
323 return cb;
327 /* Read all the fields of cp_class_binding instance CB to OB. REF_P
328 is true if the tree fields should be written as references. */
330 static cp_class_binding *
331 pph_stream_read_class_binding (pph_stream *stream)
333 cp_class_binding *cb;
335 if (!pph_start_record (stream))
336 return NULL;
338 cb = ggc_alloc_cleared_cp_class_binding ();
339 memcpy (&cb->base, pph_stream_read_cxx_binding (stream),
340 sizeof (cxx_binding));
341 cb->identifier = pph_input_tree (stream);
343 return cb;
347 /* Read and return an instance of cp_label_binding from STREAM. */
349 static cp_label_binding *
350 pph_stream_read_label_binding (pph_stream *stream)
352 cp_label_binding *lb;
354 if (!pph_start_record (stream))
355 return NULL;
357 lb = ggc_alloc_cleared_cp_label_binding ();
358 lb->label = pph_input_tree (stream);
359 lb->prev_value = pph_input_tree (stream);
361 return lb;
365 /* Read and return an instance of cp_binding_level from STREAM. */
367 static struct cp_binding_level *
368 pph_stream_read_binding_level (pph_stream *stream)
370 unsigned i, num;
371 cp_label_binding *sl;
372 struct cp_binding_level *bl;
373 struct bitpack_d bp;
375 if (!pph_start_record (stream))
376 return NULL;
378 bl = ggc_alloc_cleared_cp_binding_level ();
379 bl->names = pph_input_chain (stream);
380 bl->names_size = pph_input_uint (stream);
381 bl->namespaces = pph_input_chain (stream);
383 bl->static_decls = pph_stream_read_tree_vec (stream);
385 bl->usings = pph_input_chain (stream);
386 bl->using_directives = pph_input_chain (stream);
388 num = pph_input_uint (stream);
389 bl->class_shadowed = NULL;
390 for (i = 0; i < num; i++)
392 cp_class_binding *cb = pph_stream_read_class_binding (stream);
393 VEC_safe_push (cp_class_binding, gc, bl->class_shadowed, cb);
396 bl->type_shadowed = pph_input_tree (stream);
398 num = pph_input_uint (stream);
399 bl->shadowed_labels = NULL;
400 for (i = 0; VEC_iterate (cp_label_binding, bl->shadowed_labels, i, sl); i++)
402 cp_label_binding *sl = pph_stream_read_label_binding (stream);
403 VEC_safe_push (cp_label_binding, gc, bl->shadowed_labels, sl);
406 bl->blocks = pph_input_chain (stream);
407 bl->this_entity = pph_input_tree (stream);
408 bl->level_chain = pph_stream_read_binding_level (stream);
409 bl->dead_vars_from_for = pph_stream_read_tree_vec (stream);
410 bl->statement_list = pph_input_chain (stream);
411 bl->binding_depth = pph_input_uint (stream);
413 bp = pph_input_bitpack (stream);
414 bl->kind = (enum scope_kind) bp_unpack_value (&bp, 4);
415 bl->keep = bp_unpack_value (&bp, 1);
416 bl->more_cleanups_ok = bp_unpack_value (&bp, 1);
417 bl->have_cleanups = bp_unpack_value (&bp, 1);
419 return bl;
423 /* Read and return an instance of struct c_language_function from STREAM. */
425 static struct c_language_function *
426 pph_stream_read_c_language_function (pph_stream *stream)
428 struct c_language_function *clf;
430 if (!pph_start_record (stream))
431 return NULL;
433 clf = ggc_alloc_cleared_c_language_function ();
434 clf->x_stmt_tree.x_cur_stmt_list = pph_input_tree (stream);
435 clf->x_stmt_tree.stmts_are_full_exprs_p = pph_input_uint (stream);
437 return clf;
441 /* Read and return an instance of struct language_function from STREAM. */
443 static struct language_function *
444 pph_stream_read_language_function (pph_stream *stream)
446 struct bitpack_d bp;
447 struct language_function *lf;
449 if (!pph_start_record (stream))
450 return NULL;
452 lf = ggc_alloc_cleared_language_function ();
453 memcpy (&lf->base, pph_stream_read_c_language_function (stream),
454 sizeof (struct c_language_function));
455 lf->x_cdtor_label = pph_input_tree (stream);
456 lf->x_current_class_ptr = pph_input_tree (stream);
457 lf->x_current_class_ref = pph_input_tree (stream);
458 lf->x_eh_spec_block = pph_input_tree (stream);
459 lf->x_in_charge_parm = pph_input_tree (stream);
460 lf->x_vtt_parm = pph_input_tree (stream);
461 lf->x_return_value = pph_input_tree (stream);
462 bp = pph_input_bitpack (stream);
463 lf->x_returns_value = bp_unpack_value (&bp, 1);
464 lf->x_returns_null = bp_unpack_value (&bp, 1);
465 lf->x_returns_abnormally = bp_unpack_value (&bp, 1);
466 lf->x_in_function_try_handler = bp_unpack_value (&bp, 1);
467 lf->x_in_base_initializer = bp_unpack_value (&bp, 1);
468 lf->can_throw = bp_unpack_value (&bp, 1);
470 /* FIXME pph. We are not reading lf->x_named_labels. */
472 lf->bindings = pph_stream_read_binding_level (stream);
473 lf->x_local_names = pph_stream_read_tree_vec (stream);
475 /* FIXME pph. We are not reading lf->extern_decl_map. */
477 return lf;
481 /* Read all the fields of lang_decl_fn instance LDF from STREAM. */
483 static void
484 pph_stream_read_ld_fn (pph_stream *stream, struct lang_decl_fn *ldf)
486 struct bitpack_d bp;
488 if (!pph_start_record (stream))
489 return;
491 bp = pph_input_bitpack (stream);
492 ldf->operator_code = (enum tree_code) bp_unpack_value (&bp, 16);
493 ldf->global_ctor_p = bp_unpack_value (&bp, 1);
494 ldf->global_dtor_p = bp_unpack_value (&bp, 1);
495 ldf->constructor_attr = bp_unpack_value (&bp, 1);
496 ldf->destructor_attr = bp_unpack_value (&bp, 1);
497 ldf->assignment_operator_p = bp_unpack_value (&bp, 1);
498 ldf->static_function = bp_unpack_value (&bp, 1);
499 ldf->pure_virtual = bp_unpack_value (&bp, 1);
500 ldf->defaulted_p = bp_unpack_value (&bp, 1);
501 ldf->has_in_charge_parm_p = bp_unpack_value (&bp, 1);
502 ldf->has_vtt_parm_p = bp_unpack_value (&bp, 1);
503 ldf->pending_inline_p = bp_unpack_value (&bp, 1);
504 ldf->nonconverting = bp_unpack_value (&bp, 1);
505 ldf->thunk_p = bp_unpack_value (&bp, 1);
506 ldf->this_thunk_p = bp_unpack_value (&bp, 1);
507 ldf->hidden_friend_p = bp_unpack_value (&bp, 1);
509 ldf->befriending_classes = pph_input_tree (stream);
510 ldf->context = pph_input_tree (stream);
512 if (ldf->thunk_p == 0)
513 ldf->u5.cloned_function = pph_input_tree (stream);
514 else if (ldf->thunk_p == 1)
515 ldf->u5.fixed_offset = pph_input_uint (stream);
516 else
517 gcc_unreachable ();
519 if (ldf->pending_inline_p == 1)
520 ldf->u.pending_inline_info = pth_load_token_cache (stream);
521 else if (ldf->pending_inline_p == 0)
522 ldf->u.saved_language_function = pph_stream_read_language_function (stream);
526 /* Read all the fields of lang_decl_ns instance LDNS from STREAM. */
528 static void
529 pph_stream_read_ld_ns (pph_stream *stream, struct lang_decl_ns *ldns)
531 if (!pph_start_record (stream))
532 return;
534 ldns->level = pph_stream_read_binding_level (stream);
538 /* Read all the fields of lang_decl_parm instance LDP from STREAM. */
540 static void
541 pph_stream_read_ld_parm (pph_stream *stream, struct lang_decl_parm *ldp)
543 if (!pph_start_record (stream))
544 return;
546 ldp->level = pph_input_uint (stream);
547 ldp->index = pph_input_uint (stream);
551 /* Read language specific data in DECL from STREAM. */
553 static void
554 pph_stream_read_lang_specific (pph_stream *stream, tree decl)
556 struct lang_decl *ld;
557 struct lang_decl_base *ldb;
559 if (!pph_start_record (stream))
560 return;
562 /* Allocate a lang_decl structure for DECL. */
563 retrofit_lang_decl (decl);
565 ld = DECL_LANG_SPECIFIC (decl);
566 ldb = &ld->u.base;
568 /* Read all the fields in lang_decl_base. */
569 pph_stream_read_ld_base (stream, ldb);
571 if (ldb->selector == 0)
573 /* Read all the fields in lang_decl_min. */
574 pph_stream_read_ld_min (stream, &ld->u.min);
576 else if (ldb->selector == 1)
578 /* Read all the fields in lang_decl_fn. */
579 pph_stream_read_ld_fn (stream, &ld->u.fn);
581 else if (ldb->selector == 2)
583 /* Read all the fields in lang_decl_ns. */
584 pph_stream_read_ld_ns (stream, &ld->u.ns);
586 else if (ldb->selector == 3)
588 /* Read all the fields in lang_decl_parm. */
589 pph_stream_read_ld_parm (stream, &ld->u.parm);
591 else
592 gcc_unreachable ();
596 /* Allocate a tree node with code CODE. IB and DATA_IN are used to
597 read more data from the stream, if needed to build this node.
598 Return NULL if we did not want to handle this node. In that case,
599 the caller will call make_node to allocate this tree. */
601 tree
602 pph_stream_alloc_tree (enum tree_code code,
603 struct lto_input_block *ib ATTRIBUTE_UNUSED,
604 struct data_in *data_in)
606 pph_stream *stream = (pph_stream *) data_in->sdata;
608 if (code == CALL_EXPR)
610 unsigned nargs = pph_input_uint (stream);
611 return build_vl_exp (CALL_EXPR, nargs + 3);
614 return NULL_TREE;
618 /* Read all the fields in lang_type_header instance LTH from STREAM. */
620 static void
621 pph_stream_read_lang_type_header (pph_stream *stream,
622 struct lang_type_header *lth)
624 struct bitpack_d bp;
626 if (!pph_start_record (stream))
627 return;
629 bp = pph_input_bitpack (stream);
630 lth->is_lang_type_class = bp_unpack_value (&bp, 1);
631 lth->has_type_conversion = bp_unpack_value (&bp, 1);
632 lth->has_copy_ctor = bp_unpack_value (&bp, 1);
633 lth->has_default_ctor = bp_unpack_value (&bp, 1);
634 lth->const_needs_init = bp_unpack_value (&bp, 1);
635 lth->ref_needs_init = bp_unpack_value (&bp, 1);
636 lth->has_const_copy_assign = bp_unpack_value (&bp, 1);
640 /* Read the vector V of tree_pair_s instances from STREAM. */
642 static VEC(tree_pair_s,gc) *
643 pph_stream_read_tree_pair_vec (pph_stream *stream)
645 unsigned i, num;
646 VEC(tree_pair_s,gc) *v;
648 num = pph_input_uint (stream);
649 for (i = 0, v = NULL; i < num; i++)
651 tree_pair_s p;
652 p.purpose = pph_input_tree (stream);
653 p.value = pph_input_tree (stream);
654 VEC_safe_push (tree_pair_s, gc, v, &p);
657 return v;
661 /* Read a struct sorted_fields_type instance SFT to STREAM. REF_P is
662 true if the tree nodes should be written as references. */
664 static struct sorted_fields_type *
665 pph_stream_read_sorted_fields_type (pph_stream *stream)
667 unsigned i, num_fields;
668 struct sorted_fields_type *v;
670 if (!pph_start_record (stream))
671 return NULL;
673 num_fields = pph_input_uint (stream);
674 v = sorted_fields_type_new (num_fields);
675 for (i = 0; i < num_fields; i++)
676 v->elts[i] = pph_input_tree (stream);
678 return v;
682 /* Read all the fields in lang_type_class instance LTC to STREAM.
683 REF_P is true if all the trees in the structure should be written
684 as references. */
686 static void
687 pph_stream_read_lang_type_class (pph_stream *stream,
688 struct lang_type_class *ltc)
690 struct bitpack_d bp;
692 if (!pph_start_record (stream))
693 return;
695 ltc->align = pph_input_uchar (stream);
697 bp = pph_input_bitpack (stream);
698 ltc->has_mutable = bp_unpack_value (&bp, 1);
699 ltc->com_interface = bp_unpack_value (&bp, 1);
700 ltc->non_pod_class = bp_unpack_value (&bp, 1);
701 ltc->nearly_empty_p = bp_unpack_value (&bp, 1);
702 ltc->user_align = bp_unpack_value (&bp, 1);
703 ltc->has_copy_assign = bp_unpack_value (&bp, 1);
704 ltc->has_new = bp_unpack_value (&bp, 1);
705 ltc->has_array_new = bp_unpack_value (&bp, 1);
706 ltc->gets_delete = bp_unpack_value (&bp, 2);
707 ltc->interface_only = bp_unpack_value (&bp, 1);
708 ltc->interface_unknown = bp_unpack_value (&bp, 1);
709 ltc->contains_empty_class_p = bp_unpack_value (&bp, 1);
710 ltc->anon_aggr = bp_unpack_value (&bp, 1);
711 ltc->non_zero_init = bp_unpack_value (&bp, 1);
712 ltc->empty_p = bp_unpack_value (&bp, 1);
713 ltc->vec_new_uses_cookie = bp_unpack_value (&bp, 1);
714 ltc->declared_class = bp_unpack_value (&bp, 1);
715 ltc->diamond_shaped = bp_unpack_value (&bp, 1);
716 ltc->repeated_base = bp_unpack_value (&bp, 1);
717 ltc->being_defined = bp_unpack_value (&bp, 1);
718 ltc->java_interface = bp_unpack_value (&bp, 1);
719 ltc->debug_requested = bp_unpack_value (&bp, 1);
720 ltc->fields_readonly = bp_unpack_value (&bp, 1);
721 ltc->use_template = bp_unpack_value (&bp, 2);
722 ltc->ptrmemfunc_flag = bp_unpack_value (&bp, 1);
723 ltc->was_anonymous = bp_unpack_value (&bp, 1);
724 ltc->lazy_default_ctor = bp_unpack_value (&bp, 1);
725 ltc->lazy_copy_ctor = bp_unpack_value (&bp, 1);
726 ltc->lazy_copy_assign = bp_unpack_value (&bp, 1);
727 ltc->lazy_destructor = bp_unpack_value (&bp, 1);
728 ltc->has_const_copy_ctor = bp_unpack_value (&bp, 1);
729 ltc->has_complex_copy_ctor = bp_unpack_value (&bp, 1);
730 ltc->has_complex_copy_assign = bp_unpack_value (&bp, 1);
731 ltc->non_aggregate = bp_unpack_value (&bp, 1);
732 ltc->has_complex_dflt = bp_unpack_value (&bp, 1);
733 ltc->has_list_ctor = bp_unpack_value (&bp, 1);
734 ltc->non_std_layout = bp_unpack_value (&bp, 1);
735 ltc->is_literal = bp_unpack_value (&bp, 1);
736 ltc->lazy_move_ctor = bp_unpack_value (&bp, 1);
737 ltc->lazy_move_assign = bp_unpack_value (&bp, 1);
738 ltc->has_complex_move_ctor = bp_unpack_value (&bp, 1);
739 ltc->has_complex_move_assign = bp_unpack_value (&bp, 1);
740 ltc->has_constexpr_ctor = bp_unpack_value (&bp, 1);
742 ltc->primary_base = pph_input_tree (stream);
743 ltc->vcall_indices = pph_stream_read_tree_pair_vec (stream);
744 ltc->vtables = pph_input_tree (stream);
745 ltc->typeinfo_var = pph_input_tree (stream);
746 ltc->vbases = pph_stream_read_tree_vec (stream);
747 if (pph_start_record (stream))
748 ltc->nested_udts = pph_stream_read_binding_table (stream);
749 ltc->as_base = pph_input_tree (stream);
750 ltc->pure_virtuals = pph_stream_read_tree_vec (stream);
751 ltc->friend_classes = pph_input_tree (stream);
752 ltc->methods = pph_stream_read_tree_vec (stream);
753 ltc->key_method = pph_input_tree (stream);
754 ltc->decl_list = pph_input_tree (stream);
755 ltc->template_info = pph_input_tree (stream);
756 ltc->befriending_classes = pph_input_tree (stream);
757 ltc->objc_info = pph_input_tree (stream);
758 ltc->sorted_fields = pph_stream_read_sorted_fields_type (stream);
759 ltc->lambda_expr = pph_input_tree (stream);
763 /* Read all fields of struct lang_type_ptrmem instance LTP from STREAM. */
765 static void
766 pph_stream_read_lang_type_ptrmem (pph_stream *stream,
767 struct lang_type_ptrmem *ltp)
769 if (!pph_start_record (stream))
770 return;
772 ltp->record = pph_input_tree (stream);
776 /* Read all the lang-specific fields of TYPE from STREAM. */
778 static void
779 pph_stream_read_lang_type (pph_stream *stream, tree type)
781 struct lang_type *lt;
783 if (!pph_start_record (stream))
784 return;
786 lt = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
787 TYPE_LANG_SPECIFIC (type) = lt;
789 pph_stream_read_lang_type_header (stream, &lt->u.h);
790 if (lt->u.h.is_lang_type_class)
791 pph_stream_read_lang_type_class (stream, &lt->u.c);
792 else
793 pph_stream_read_lang_type_ptrmem (stream, &lt->u.ptrmem);
797 /* Callback for reading ASTs from a stream. This reads all the fields
798 that are not processed by default by the common tree pickler.
799 IB, DATA_IN are as in lto_read_tree. EXPR is the partially materialized
800 tree. */
802 void
803 pph_stream_read_tree (struct lto_input_block *ib ATTRIBUTE_UNUSED,
804 struct data_in *data_in, tree expr)
806 pph_stream *stream = (pph_stream *) data_in->sdata;
808 switch (TREE_CODE (expr))
810 /* TREES NEEDING EXTRA WORK */
812 /* tcc_declaration */
814 case DEBUG_EXPR_DECL:
815 case IMPORTED_DECL:
816 case LABEL_DECL:
817 case RESULT_DECL:
818 DECL_INITIAL (expr) = pph_input_tree (stream);
819 break;
821 case CONST_DECL:
822 case FIELD_DECL:
823 case NAMESPACE_DECL:
824 case PARM_DECL:
825 case USING_DECL:
826 case VAR_DECL:
827 /* FIXME pph: Should we merge DECL_INITIAL into lang_specific? */
828 DECL_INITIAL (expr) = pph_input_tree (stream);
829 pph_stream_read_lang_specific (stream, expr);
830 break;
832 case FUNCTION_DECL:
833 DECL_INITIAL (expr) = pph_input_tree (stream);
834 pph_stream_read_lang_specific (stream, expr);
835 DECL_SAVED_TREE (expr) = pph_input_tree (stream);
836 break;
838 case TYPE_DECL:
839 DECL_INITIAL (expr) = pph_input_tree (stream);
840 pph_stream_read_lang_specific (stream, expr);
841 DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
842 break;
844 case TEMPLATE_DECL:
845 DECL_INITIAL (expr) = pph_input_tree (stream);
846 pph_stream_read_lang_specific (stream, expr);
847 DECL_TEMPLATE_RESULT (expr) = pph_input_tree (stream);
848 DECL_TEMPLATE_PARMS (expr) = pph_input_tree (stream);
849 DECL_CONTEXT (expr) = pph_input_tree (stream);
850 break;
852 /* tcc_type */
854 case ARRAY_TYPE:
855 case BOOLEAN_TYPE:
856 case COMPLEX_TYPE:
857 case ENUMERAL_TYPE:
858 case FIXED_POINT_TYPE:
859 case FUNCTION_TYPE:
860 case INTEGER_TYPE:
861 case LANG_TYPE:
862 case METHOD_TYPE:
863 case NULLPTR_TYPE:
864 case OFFSET_TYPE:
865 case POINTER_TYPE:
866 case REAL_TYPE:
867 case REFERENCE_TYPE:
868 case VECTOR_TYPE:
869 case VOID_TYPE:
870 pph_stream_read_lang_type (stream, expr);
871 break;
873 case QUAL_UNION_TYPE:
874 case RECORD_TYPE:
875 case UNION_TYPE:
876 pph_stream_read_lang_type (stream, expr);
877 TYPE_BINFO (expr) = pph_input_tree (stream);
878 break;
880 case BOUND_TEMPLATE_TEMPLATE_PARM:
881 case DECLTYPE_TYPE:
882 case TEMPLATE_TEMPLATE_PARM:
883 case TEMPLATE_TYPE_PARM:
884 case TYPENAME_TYPE:
885 case TYPEOF_TYPE:
886 pph_stream_read_lang_type (stream, expr);
887 TYPE_CACHED_VALUES (expr) = pph_input_tree (stream);
888 /* Note that we are using TYPED_CACHED_VALUES for it access to
889 the generic .values field of types. */
890 break;
892 /* tcc_statement */
894 case STATEMENT_LIST:
896 HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
897 for (i = 0; i < num_trees; i++)
899 tree stmt = pph_input_tree (stream);
900 append_to_statement_list (stmt, &expr);
903 break;
905 /* tcc_expression */
907 /* tcc_unary */
909 /* tcc_vl_exp */
911 /* tcc_reference */
913 /* tcc_constant */
915 /* tcc_exceptional */
917 case OVERLOAD:
918 OVL_FUNCTION (expr) = pph_input_tree (stream);
919 break;
921 case IDENTIFIER_NODE:
923 struct lang_identifier *id = LANG_IDENTIFIER_CAST (expr);
924 id->namespace_bindings = pph_stream_read_cxx_binding (stream);
925 id->bindings = pph_stream_read_cxx_binding (stream);
926 id->class_template_info = pph_input_tree (stream);
927 id->label_value = pph_input_tree (stream);
929 break;
931 case BASELINK:
932 BASELINK_BINFO (expr) = pph_input_tree (stream);
933 BASELINK_FUNCTIONS (expr) = pph_input_tree (stream);
934 BASELINK_ACCESS_BINFO (expr) = pph_input_tree (stream);
935 break;
937 case TEMPLATE_INFO:
938 TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr)
939 = pph_stream_read_qual_use_vec (stream);
940 break;
942 case TEMPLATE_PARM_INDEX:
944 template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr);
945 p->index = pph_input_uint (stream);
946 p->level = pph_input_uint (stream);
947 p->orig_level = pph_input_uint (stream);
948 p->num_siblings = pph_input_uint (stream);
949 p->decl = pph_input_tree (stream);
950 /* FIXME pph: Is TEMPLATE_PARM_PARAMETER_PACK using TREE_LANG_FLAG_0
951 already handled? */
953 break;
955 /* TREES ALREADY HANDLED */
957 /* tcc_declaration */
959 case TRANSLATION_UNIT_DECL:
961 /* tcc_exceptional */
963 case TREE_BINFO:
964 case TREE_LIST:
965 case TREE_VEC:
967 break;
969 /* TREES UNIMPLEMENTED */
971 /* tcc_declaration */
973 /* tcc_type */
975 case TYPE_ARGUMENT_PACK:
976 case TYPE_PACK_EXPANSION:
977 case UNBOUND_CLASS_TEMPLATE:
979 /* tcc_statement */
981 case USING_STMT:
982 case TRY_BLOCK:
983 case EH_SPEC_BLOCK:
984 case HANDLER:
985 case CLEANUP_STMT:
986 case IF_STMT:
987 case FOR_STMT:
988 case RANGE_FOR_STMT:
989 case WHILE_STMT:
990 case DO_STMT:
991 case BREAK_STMT:
992 case CONTINUE_STMT:
993 case SWITCH_STMT:
995 /* tcc_expression */
997 case NEW_EXPR:
998 case VEC_NEW_EXPR:
999 case DELETE_EXPR:
1000 case VEC_DELETE_EXPR:
1001 case TYPE_EXPR:
1002 case VEC_INIT_EXPR:
1003 case THROW_EXPR:
1004 case EMPTY_CLASS_EXPR:
1005 case TEMPLATE_ID_EXPR:
1006 case PSEUDO_DTOR_EXPR:
1007 case MODOP_EXPR:
1008 case DOTSTAR_EXPR:
1009 case TYPEID_EXPR:
1010 case NON_DEPENDENT_EXPR:
1011 case CTOR_INITIALIZER:
1012 case MUST_NOT_THROW_EXPR:
1013 case EXPR_STMT:
1014 case TAG_DEFN:
1015 case OFFSETOF_EXPR:
1016 case SIZEOF_EXPR:
1017 case ARROW_EXPR:
1018 case ALIGNOF_EXPR:
1019 case AT_ENCODE_EXPR:
1020 case STMT_EXPR:
1021 case NONTYPE_ARGUMENT_PACK:
1022 case EXPR_PACK_EXPANSION:
1024 /* tcc_unary */
1026 case CAST_EXPR:
1027 case REINTERPRET_CAST_EXPR:
1028 case CONST_CAST_EXPR:
1029 case STATIC_CAST_EXPR:
1030 case DYNAMIC_CAST_EXPR:
1031 case NOEXCEPT_EXPR:
1032 case UNARY_PLUS_EXPR:
1034 /* tcc_reference */
1036 case MEMBER_REF:
1037 case OFFSET_REF:
1038 case SCOPE_REF:
1040 /* tcc_constant */
1042 case PTRMEM_CST:
1044 /* tcc_vl_exp */
1046 case AGGR_INIT_EXPR:
1048 /* tcc_exceptional */
1050 case DEFAULT_ARG:
1051 case STATIC_ASSERT:
1052 case ARGUMENT_PACK_SELECT:
1053 case TRAIT_EXPR:
1054 case LAMBDA_EXPR:
1056 if (flag_pph_untree)
1057 fprintf (pph_logfile, "PPH: unimplemented tree node %s\n",
1058 tree_code_name[TREE_CODE (expr)]);
1059 break;
1061 /* TREES UNRECOGNIZED */
1063 default:
1064 if (flag_pph_untree)
1065 fprintf (pph_logfile, "PPH: unrecognized tree node %s\n",
1066 tree_code_name[TREE_CODE (expr)]);