]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-streamer-out.c
2015-10-29 Andrew MacLeod <amacleod@redhat.com>
[thirdparty/gcc.git] / gcc / tree-streamer-out.c
CommitLineData
2541503d 1/* Routines for emitting trees to a file stream.
2
d353bf18 3 Copyright (C) 2011-2015 Free Software Foundation, Inc.
2541503d 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"
9ef16211 25#include "backend.h"
7c29e30e 26#include "target.h"
9ef16211 27#include "tree.h"
28#include "gimple.h"
7c29e30e 29#include "tree-streamer.h"
30#include "cgraph.h"
2541503d 31#include "diagnostic.h"
b20a8bb4 32#include "alias.h"
b20a8bb4 33#include "fold-const.h"
9ed99284 34#include "stor-layout.h"
bc61cadb 35#include "internal-fn.h"
ca4c3545 36#include "gomp-constants.h"
37
2541503d 38
39/* Output the STRING constant to the string
40 table in OB. Then put the index onto the INDEX_STREAM. */
41
65d1b157 42void
43streamer_write_string_cst (struct output_block *ob,
44 struct lto_output_stream *index_stream,
45 tree string)
2541503d 46{
7f385784 47 streamer_write_string_with_length (ob, index_stream,
65d1b157 48 string ? TREE_STRING_POINTER (string)
49 : NULL,
50 string ? TREE_STRING_LENGTH (string) : 0,
7f385784 51 true);
2541503d 52}
53
54
55/* Output the identifier ID to the string
56 table in OB. Then put the index onto the INDEX_STREAM. */
57
58static void
7f385784 59write_identifier (struct output_block *ob,
2541503d 60 struct lto_output_stream *index_stream,
61 tree id)
62{
7f385784 63 streamer_write_string_with_length (ob, index_stream,
64 IDENTIFIER_POINTER (id),
65 IDENTIFIER_LENGTH (id),
66 true);
2541503d 67}
68
69
70/* Pack all the non-pointer fields of the TS_BASE structure of
71 expression EXPR into bitpack BP. */
72
c76dc468 73static inline void
2541503d 74pack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
75{
76 bp_pack_value (bp, TREE_CODE (expr), 16);
77 if (!TYPE_P (expr))
78 {
79 bp_pack_value (bp, TREE_SIDE_EFFECTS (expr), 1);
80 bp_pack_value (bp, TREE_CONSTANT (expr), 1);
81 bp_pack_value (bp, TREE_READONLY (expr), 1);
82
83 /* TREE_PUBLIC is used on types to indicate that the type
84 has a TYPE_CACHED_VALUES vector. This is not streamed out,
85 so we skip it here. */
86 bp_pack_value (bp, TREE_PUBLIC (expr), 1);
87 }
88 else
89 bp_pack_value (bp, 0, 4);
90 bp_pack_value (bp, TREE_ADDRESSABLE (expr), 1);
91 bp_pack_value (bp, TREE_THIS_VOLATILE (expr), 1);
92 if (DECL_P (expr))
93 bp_pack_value (bp, DECL_UNSIGNED (expr), 1);
94 else if (TYPE_P (expr))
95 bp_pack_value (bp, TYPE_UNSIGNED (expr), 1);
96 else
97 bp_pack_value (bp, 0, 1);
4b927f54 98 /* We write debug info two times, do not confuse the second one.
99 The only relevant TREE_ASM_WRITTEN use is on SSA names. */
100 bp_pack_value (bp, (TREE_CODE (expr) != SSA_NAME
bace6acf 101 ? 0 : TREE_ASM_WRITTEN (expr)), 1);
2541503d 102 if (TYPE_P (expr))
103 bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1);
104 else
105 bp_pack_value (bp, TREE_NO_WARNING (expr), 1);
2541503d 106 bp_pack_value (bp, TREE_NOTHROW (expr), 1);
107 bp_pack_value (bp, TREE_STATIC (expr), 1);
8ceff600 108 if (TREE_CODE (expr) != TREE_BINFO)
109 bp_pack_value (bp, TREE_PRIVATE (expr), 1);
c76dc468 110 else
111 bp_pack_value (bp, 0, 1);
2541503d 112 bp_pack_value (bp, TREE_PROTECTED (expr), 1);
113 bp_pack_value (bp, TREE_DEPRECATED (expr), 1);
114 if (TYPE_P (expr))
2436e5d5 115 {
116 bp_pack_value (bp, TYPE_SATURATING (expr), 1);
117 bp_pack_value (bp, TYPE_ADDR_SPACE (expr), 8);
118 }
2541503d 119 else if (TREE_CODE (expr) == SSA_NAME)
c76dc468 120 {
121 bp_pack_value (bp, SSA_NAME_IS_DEFAULT_DEF (expr), 1);
122 bp_pack_value (bp, 0, 8);
123 }
2541503d 124 else
c76dc468 125 bp_pack_value (bp, 0, 9);
2541503d 126}
127
128
42603940 129/* Pack all the non-pointer fields of the TS_INTEGER_CST structure of
130 expression EXPR into bitpack BP. */
131
132static void
817489cf 133pack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
42603940 134{
e913b5cd 135 int i;
136 /* Note that the number of elements has already been written out in
137 streamer_write_tree_header. */
271e739a 138 for (i = 0; i < TREE_INT_CST_EXT_NUNITS (expr); i++)
e913b5cd 139 bp_pack_var_len_int (bp, TREE_INT_CST_ELT (expr, i));
42603940 140}
141
142
2541503d 143/* Pack all the non-pointer fields of the TS_REAL_CST structure of
144 expression EXPR into bitpack BP. */
145
146static void
147pack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
148{
149 unsigned i;
150 REAL_VALUE_TYPE r;
151
152 r = TREE_REAL_CST (expr);
153 bp_pack_value (bp, r.cl, 2);
154 bp_pack_value (bp, r.decimal, 1);
155 bp_pack_value (bp, r.sign, 1);
156 bp_pack_value (bp, r.signalling, 1);
157 bp_pack_value (bp, r.canonical, 1);
158 bp_pack_value (bp, r.uexp, EXP_BITS);
159 for (i = 0; i < SIGSZ; i++)
160 bp_pack_value (bp, r.sig[i], HOST_BITS_PER_LONG);
161}
162
163
164/* Pack all the non-pointer fields of the TS_FIXED_CST structure of
165 expression EXPR into bitpack BP. */
166
167static void
168pack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
169{
170 struct fixed_value fv = TREE_FIXED_CST (expr);
2e971afd 171 bp_pack_machine_mode (bp, fv.mode);
2541503d 172 bp_pack_var_len_int (bp, fv.data.low);
173 bp_pack_var_len_int (bp, fv.data.high);
174}
175
2541503d 176/* Pack all the non-pointer fields of the TS_DECL_COMMON structure
177 of expression EXPR into bitpack BP. */
178
179static void
180pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
181{
2e971afd 182 bp_pack_machine_mode (bp, DECL_MODE (expr));
2541503d 183 bp_pack_value (bp, DECL_NONLOCAL (expr), 1);
184 bp_pack_value (bp, DECL_VIRTUAL_P (expr), 1);
185 bp_pack_value (bp, DECL_IGNORED_P (expr), 1);
16d41ae2 186 bp_pack_value (bp, DECL_ABSTRACT_P (expr), 1);
2541503d 187 bp_pack_value (bp, DECL_ARTIFICIAL (expr), 1);
188 bp_pack_value (bp, DECL_USER_ALIGN (expr), 1);
189 bp_pack_value (bp, DECL_PRESERVE_P (expr), 1);
2541503d 190 bp_pack_value (bp, DECL_EXTERNAL (expr), 1);
191 bp_pack_value (bp, DECL_GIMPLE_REG_P (expr), 1);
192 bp_pack_var_len_unsigned (bp, DECL_ALIGN (expr));
193
194 if (TREE_CODE (expr) == LABEL_DECL)
195 {
196 /* Note that we do not write LABEL_DECL_UID. The reader will
197 always assume an initial value of -1 so that the
198 label_to_block_map is recreated by gimple_set_bb. */
2541503d 199 bp_pack_var_len_unsigned (bp, EH_LANDING_PAD_NR (expr));
200 }
201
202 if (TREE_CODE (expr) == FIELD_DECL)
203 {
204 bp_pack_value (bp, DECL_PACKED (expr), 1);
205 bp_pack_value (bp, DECL_NONADDRESSABLE_P (expr), 1);
206 bp_pack_value (bp, expr->decl_common.off_align, 8);
207 }
208
05c14132 209 if (TREE_CODE (expr) == VAR_DECL)
8e966116 210 {
211 bp_pack_value (bp, DECL_HAS_DEBUG_EXPR_P (expr), 1);
212 bp_pack_value (bp, DECL_NONLOCAL_FRAME (expr), 1);
213 }
05c14132 214
2541503d 215 if (TREE_CODE (expr) == RESULT_DECL
216 || TREE_CODE (expr) == PARM_DECL
217 || TREE_CODE (expr) == VAR_DECL)
218 {
219 bp_pack_value (bp, DECL_BY_REFERENCE (expr), 1);
220 if (TREE_CODE (expr) == VAR_DECL
221 || TREE_CODE (expr) == PARM_DECL)
222 bp_pack_value (bp, DECL_HAS_VALUE_EXPR_P (expr), 1);
2541503d 223 }
224}
225
226
227/* Pack all the non-pointer fields of the TS_DECL_WRTL structure
228 of expression EXPR into bitpack BP. */
229
230static void
231pack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
232{
233 bp_pack_value (bp, DECL_REGISTER (expr), 1);
234}
235
236
237/* Pack all the non-pointer fields of the TS_DECL_WITH_VIS structure
238 of expression EXPR into bitpack BP. */
239
240static void
241pack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
242{
2541503d 243 bp_pack_value (bp, DECL_COMMON (expr), 1);
244 bp_pack_value (bp, DECL_DLLIMPORT_P (expr), 1);
245 bp_pack_value (bp, DECL_WEAK (expr), 1);
246 bp_pack_value (bp, DECL_SEEN_IN_BIND_EXPR_P (expr), 1);
247 bp_pack_value (bp, DECL_COMDAT (expr), 1);
248 bp_pack_value (bp, DECL_VISIBILITY (expr), 2);
249 bp_pack_value (bp, DECL_VISIBILITY_SPECIFIED (expr), 1);
250
251 if (TREE_CODE (expr) == VAR_DECL)
252 {
253 bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1);
881fe02c 254 /* DECL_IN_TEXT_SECTION is set during final asm output only. */
2541503d 255 bp_pack_value (bp, DECL_IN_CONSTANT_POOL (expr), 1);
2541503d 256 }
257
2d9cc481 258 if (TREE_CODE (expr) == FUNCTION_DECL)
259 {
260 bp_pack_value (bp, DECL_FINAL_P (expr), 1);
261 bp_pack_value (bp, DECL_CXX_CONSTRUCTOR_P (expr), 1);
262 bp_pack_value (bp, DECL_CXX_DESTRUCTOR_P (expr), 1);
263 }
2541503d 264}
265
266
267/* Pack all the non-pointer fields of the TS_FUNCTION_DECL structure
268 of expression EXPR into bitpack BP. */
269
270static void
271pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
272{
273 /* For normal/md builtins we only write the class and code, so they
274 should never be handled here. */
7f385784 275 gcc_assert (!streamer_handle_as_builtin_p (expr));
2541503d 276
277 bp_pack_enum (bp, built_in_class, BUILT_IN_LAST,
278 DECL_BUILT_IN_CLASS (expr));
279 bp_pack_value (bp, DECL_STATIC_CONSTRUCTOR (expr), 1);
280 bp_pack_value (bp, DECL_STATIC_DESTRUCTOR (expr), 1);
281 bp_pack_value (bp, DECL_UNINLINABLE (expr), 1);
282 bp_pack_value (bp, DECL_POSSIBLY_INLINED (expr), 1);
283 bp_pack_value (bp, DECL_IS_NOVOPS (expr), 1);
284 bp_pack_value (bp, DECL_IS_RETURNS_TWICE (expr), 1);
285 bp_pack_value (bp, DECL_IS_MALLOC (expr), 1);
286 bp_pack_value (bp, DECL_IS_OPERATOR_NEW (expr), 1);
287 bp_pack_value (bp, DECL_DECLARED_INLINE_P (expr), 1);
288 bp_pack_value (bp, DECL_STATIC_CHAIN (expr), 1);
289 bp_pack_value (bp, DECL_NO_INLINE_WARNING_P (expr), 1);
290 bp_pack_value (bp, DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr), 1);
291 bp_pack_value (bp, DECL_NO_LIMIT_STACK (expr), 1);
292 bp_pack_value (bp, DECL_DISREGARD_INLINE_LIMITS (expr), 1);
293 bp_pack_value (bp, DECL_PURE_P (expr), 1);
294 bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1);
295 if (DECL_BUILT_IN_CLASS (expr) != NOT_BUILT_IN)
9a35f424 296 bp_pack_value (bp, DECL_FUNCTION_CODE (expr), 12);
2541503d 297}
298
299
300/* Pack all the non-pointer fields of the TS_TYPE_COMMON structure
301 of expression EXPR into bitpack BP. */
302
303static void
304pack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr)
305{
2e971afd 306 bp_pack_machine_mode (bp, TYPE_MODE (expr));
2541503d 307 bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1);
cb274227 308 /* TYPE_NO_FORCE_BLK is private to stor-layout and need
309 no streaming. */
2541503d 310 bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1);
311 if (RECORD_OR_UNION_TYPE_P (expr))
2d9cc481 312 {
313 bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1);
314 bp_pack_value (bp, TYPE_FINAL_P (expr), 1);
315 }
f7fa455c 316 else if (TREE_CODE (expr) == ARRAY_TYPE)
317 bp_pack_value (bp, TYPE_NONALIASED_COMPONENT (expr), 1);
2541503d 318 bp_pack_value (bp, TYPE_PACKED (expr), 1);
319 bp_pack_value (bp, TYPE_RESTRICT (expr), 1);
2541503d 320 bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1);
321 bp_pack_value (bp, TYPE_READONLY (expr), 1);
322 bp_pack_var_len_unsigned (bp, TYPE_PRECISION (expr));
323 bp_pack_var_len_unsigned (bp, TYPE_ALIGN (expr));
8ceff600 324 /* Make sure to preserve the fact whether the frontend would assign
325 alias-set zero to this type. */
326 bp_pack_var_len_int (bp, (TYPE_ALIAS_SET (expr) == 0
327 || (!in_lto_p
328 && get_alias_set (expr) == 0)) ? 0 : -1);
2541503d 329}
330
331
332/* Pack all the non-pointer fields of the TS_BLOCK structure
333 of expression EXPR into bitpack BP. */
334
335static void
ec180527 336pack_ts_block_value_fields (struct output_block *ob,
337 struct bitpack_d *bp, tree expr)
2541503d 338{
339 bp_pack_value (bp, BLOCK_ABSTRACT (expr), 1);
340 /* BLOCK_NUMBER is recomputed. */
ec180527 341 /* Stream BLOCK_SOURCE_LOCATION for the limited cases we can handle - those
342 that represent inlined function scopes.
343 For the rest them on the floor instead of ICEing in dwarf2out.c. */
344 if (inlined_function_outer_scope_p (expr))
345 stream_output_location (ob, bp, BLOCK_SOURCE_LOCATION (expr));
346 else
347 stream_output_location (ob, bp, UNKNOWN_LOCATION);
2541503d 348}
349
350/* Pack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL structure
351 of expression EXPR into bitpack BP. */
352
353static void
07de37ab 354pack_ts_translation_unit_decl_value_fields (struct output_block *ob,
355 struct bitpack_d *bp, tree expr)
2541503d 356{
07de37ab 357 bp_pack_string (ob, bp, TRANSLATION_UNIT_LANGUAGE (expr), true);
2541503d 358}
359
7f385784 360
fe3e3369 361/* Pack all the non-pointer fields of the TS_OMP_CLAUSE structure
362 of expression EXPR into bitpack BP. */
363
364static void
365pack_ts_omp_clause_value_fields (struct output_block *ob,
366 struct bitpack_d *bp, tree expr)
367{
368 stream_output_location (ob, bp, OMP_CLAUSE_LOCATION (expr));
369 switch (OMP_CLAUSE_CODE (expr))
370 {
371 case OMP_CLAUSE_DEFAULT:
372 bp_pack_enum (bp, omp_clause_default_kind, OMP_CLAUSE_DEFAULT_LAST,
373 OMP_CLAUSE_DEFAULT_KIND (expr));
374 break;
375 case OMP_CLAUSE_SCHEDULE:
376 bp_pack_enum (bp, omp_clause_schedule_kind, OMP_CLAUSE_SCHEDULE_LAST,
377 OMP_CLAUSE_SCHEDULE_KIND (expr));
378 break;
379 case OMP_CLAUSE_DEPEND:
380 bp_pack_enum (bp, omp_clause_depend_kind, OMP_CLAUSE_DEPEND_LAST,
381 OMP_CLAUSE_DEPEND_KIND (expr));
382 break;
383 case OMP_CLAUSE_MAP:
ca4c3545 384 bp_pack_enum (bp, gomp_map_kind, GOMP_MAP_LAST,
fe3e3369 385 OMP_CLAUSE_MAP_KIND (expr));
386 break;
387 case OMP_CLAUSE_PROC_BIND:
388 bp_pack_enum (bp, omp_clause_proc_bind_kind, OMP_CLAUSE_PROC_BIND_LAST,
389 OMP_CLAUSE_PROC_BIND_KIND (expr));
390 break;
391 case OMP_CLAUSE_REDUCTION:
392 bp_pack_enum (bp, tree_code, MAX_TREE_CODES,
393 OMP_CLAUSE_REDUCTION_CODE (expr));
394 break;
395 default:
396 break;
397 }
398}
399
400
7f385784 401/* Pack all the bitfields in EXPR into a bit pack. */
2541503d 402
515cf651 403void
c76dc468 404streamer_write_tree_bitfields (struct output_block *ob, tree expr)
2541503d 405{
c76dc468 406 bitpack_d bp = bitpack_create (ob->main_stream);
2541503d 407 enum tree_code code;
408
409 code = TREE_CODE (expr);
410
411 /* Note that all these functions are highly sensitive to changes in
412 the types and sizes of each of the fields being packed. */
c76dc468 413 pack_ts_base_value_fields (&bp, expr);
2541503d 414
42603940 415 if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
c76dc468 416 pack_ts_int_cst_value_fields (&bp, expr);
42603940 417
2541503d 418 if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
c76dc468 419 pack_ts_real_cst_value_fields (&bp, expr);
2541503d 420
421 if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
c76dc468 422 pack_ts_fixed_cst_value_fields (&bp, expr);
2541503d 423
ec180527 424 if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
c76dc468 425 stream_output_location (ob, &bp, DECL_SOURCE_LOCATION (expr));
ec180527 426
2541503d 427 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
c76dc468 428 pack_ts_decl_common_value_fields (&bp, expr);
2541503d 429
430 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
c76dc468 431 pack_ts_decl_wrtl_value_fields (&bp, expr);
2541503d 432
433 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
c76dc468 434 pack_ts_decl_with_vis_value_fields (&bp, expr);
2541503d 435
436 if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
c76dc468 437 pack_ts_function_decl_value_fields (&bp, expr);
2541503d 438
439 if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
c76dc468 440 pack_ts_type_common_value_fields (&bp, expr);
2541503d 441
ec180527 442 if (CODE_CONTAINS_STRUCT (code, TS_EXP))
62b0a610 443 {
c76dc468 444 stream_output_location (ob, &bp, EXPR_LOCATION (expr));
62b0a610 445 if (code == MEM_REF
446 || code == TARGET_MEM_REF)
447 {
c76dc468 448 bp_pack_value (&bp, MR_DEPENDENCE_CLIQUE (expr), sizeof (short) * 8);
62b0a610 449 if (MR_DEPENDENCE_CLIQUE (expr) != 0)
c76dc468 450 bp_pack_value (&bp, MR_DEPENDENCE_BASE (expr), sizeof (short) * 8);
62b0a610 451 }
452 }
ec180527 453
2541503d 454 if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
c76dc468 455 pack_ts_block_value_fields (ob, &bp, expr);
2541503d 456
457 if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
c76dc468 458 pack_ts_translation_unit_decl_value_fields (ob, &bp, expr);
51136fa7 459
51136fa7 460 if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
c76dc468 461 cl_optimization_stream_out (&bp, TREE_OPTIMIZATION (expr));
e41fac10 462
463 if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
c76dc468 464 bp_pack_var_len_unsigned (&bp, vec_safe_length (BINFO_BASE_ACCESSES (expr)));
e41fac10 465
466 if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
c76dc468 467 bp_pack_var_len_unsigned (&bp, CONSTRUCTOR_NELTS (expr));
fe3e3369 468
ba000093 469 if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)
470 /* Don't stream these when passing things to a different target. */
471 && !lto_stream_offload_p)
c76dc468 472 cl_target_option_stream_out (ob, &bp, TREE_TARGET_OPTION (expr));
ab90b67e 473
fe3e3369 474 if (code == OMP_CLAUSE)
c76dc468 475 pack_ts_omp_clause_value_fields (ob, &bp, expr);
476
477 streamer_write_bitpack (&bp);
2541503d 478}
479
480
481/* Write the code and class of builtin EXPR to output block OB. IX is
482 the index into the streamer cache where EXPR is stored.*/
483
515cf651 484void
7f385784 485streamer_write_builtin (struct output_block *ob, tree expr)
2541503d 486{
7f385784 487 gcc_assert (streamer_handle_as_builtin_p (expr));
2541503d 488
489 if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD
490 && !targetm.builtin_decl)
7f385784 491 sorry ("tree bytecode streams do not support machine specific builtin "
2541503d 492 "functions on this target");
493
7f385784 494 streamer_write_record_start (ob, LTO_builtin_decl);
495 streamer_write_enum (ob->main_stream, built_in_class, BUILT_IN_LAST,
496 DECL_BUILT_IN_CLASS (expr));
497 streamer_write_uhwi (ob, DECL_FUNCTION_CODE (expr));
2541503d 498
499 if (DECL_ASSEMBLER_NAME_SET_P (expr))
500 {
501 /* When the assembler name of a builtin gets a user name,
502 the new name is always prefixed with '*' by
503 set_builtin_user_assembler_name. So, to prevent the
504 reader side from adding a second '*', we omit it here. */
505 const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (expr));
506 if (strlen (str) > 1 && str[0] == '*')
7f385784 507 streamer_write_string (ob, ob->main_stream, &str[1], true);
2541503d 508 else
7f385784 509 streamer_write_string (ob, ob->main_stream, NULL, true);
2541503d 510 }
511 else
7f385784 512 streamer_write_string (ob, ob->main_stream, NULL, true);
2541503d 513}
514
515
2541503d 516/* Emit the chain of tree nodes starting at T. OB is the output block
517 to write to. REF_P is true if chain elements should be emitted
518 as references. */
519
515cf651 520void
7f385784 521streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
2541503d 522{
e41fac10 523 while (t)
2541503d 524 {
c75a2739 525 /* We avoid outputting external vars or functions by reference
526 to the global decls section as we do not want to have them
527 enter decl merging. This is, of course, only for the call
4517f7e7 528 for streaming BLOCK_VARS, but other callers are safe.
529 See also lto-streamer-out.c:DFS_write_tree_body. */
57bcbbf6 530 if (VAR_OR_FUNCTION_DECL_P (t)
531 && DECL_EXTERNAL (t))
4517f7e7 532 stream_write_tree_shallow_non_ref (ob, t, ref_p);
57bcbbf6 533 else
534 stream_write_tree (ob, t, ref_p);
2541503d 535
2541503d 536 t = TREE_CHAIN (t);
537 }
e41fac10 538
539 /* Write a sentinel to terminate the chain. */
540 stream_write_tree (ob, NULL_TREE, ref_p);
2541503d 541}
542
543
544/* Write all pointer fields in the TS_COMMON structure of EXPR to output
545 block OB. If REF_P is true, write a reference to EXPR's pointer
546 fields. */
547
548static void
7f385784 549write_ts_common_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 550{
551 if (TREE_CODE (expr) != IDENTIFIER_NODE)
515cf651 552 stream_write_tree (ob, TREE_TYPE (expr), ref_p);
2541503d 553}
554
555
556/* Write all pointer fields in the TS_VECTOR structure of EXPR to output
557 block OB. If REF_P is true, write a reference to EXPR's pointer
558 fields. */
559
560static void
7f385784 561write_ts_vector_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 562{
fadf62f4 563 unsigned i;
564 /* Note that the number of elements for EXPR has already been emitted
565 in EXPR's header (see streamer_write_tree_header). */
566 for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
567 stream_write_tree (ob, VECTOR_CST_ELT (expr, i), ref_p);
2541503d 568}
569
570
571/* Write all pointer fields in the TS_COMPLEX structure of EXPR to output
572 block OB. If REF_P is true, write a reference to EXPR's pointer
573 fields. */
574
575static void
7f385784 576write_ts_complex_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 577{
515cf651 578 stream_write_tree (ob, TREE_REALPART (expr), ref_p);
579 stream_write_tree (ob, TREE_IMAGPART (expr), ref_p);
2541503d 580}
581
582
583/* Write all pointer fields in the TS_DECL_MINIMAL structure of EXPR
584 to output block OB. If REF_P is true, write a reference to EXPR's
585 pointer fields. */
586
587static void
7f385784 588write_ts_decl_minimal_tree_pointers (struct output_block *ob, tree expr,
589 bool ref_p)
2541503d 590{
8ceff600 591 /* Drop names that were created for anonymous entities. */
592 if (DECL_NAME (expr)
593 && TREE_CODE (DECL_NAME (expr)) == IDENTIFIER_NODE
29e65f8e 594 && anon_aggrname_p (DECL_NAME (expr)))
8ceff600 595 stream_write_tree (ob, NULL_TREE, ref_p);
596 else
597 stream_write_tree (ob, DECL_NAME (expr), ref_p);
515cf651 598 stream_write_tree (ob, DECL_CONTEXT (expr), ref_p);
2541503d 599}
600
601
602/* Write all pointer fields in the TS_DECL_COMMON structure of EXPR to
603 output block OB. If REF_P is true, write a reference to EXPR's
604 pointer fields. */
605
606static void
7f385784 607write_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
608 bool ref_p)
2541503d 609{
515cf651 610 stream_write_tree (ob, DECL_SIZE (expr), ref_p);
611 stream_write_tree (ob, DECL_SIZE_UNIT (expr), ref_p);
2541503d 612
613 /* Note, DECL_INITIAL is not handled here. Since DECL_INITIAL needs
614 special handling in LTO, it must be handled by streamer hooks. */
615
515cf651 616 stream_write_tree (ob, DECL_ATTRIBUTES (expr), ref_p);
2541503d 617
618 /* Do not stream DECL_ABSTRACT_ORIGIN. We cannot handle debug information
619 for early inlining so drop it on the floor instead of ICEing in
620 dwarf2out.c. */
621
2541503d 622 if ((TREE_CODE (expr) == VAR_DECL
623 || TREE_CODE (expr) == PARM_DECL)
624 && DECL_HAS_VALUE_EXPR_P (expr))
515cf651 625 stream_write_tree (ob, DECL_VALUE_EXPR (expr), ref_p);
2541503d 626
627 if (TREE_CODE (expr) == VAR_DECL)
515cf651 628 stream_write_tree (ob, DECL_DEBUG_EXPR (expr), ref_p);
2541503d 629}
630
631
632/* Write all pointer fields in the TS_DECL_NON_COMMON structure of
633 EXPR to output block OB. If REF_P is true, write a reference to EXPR's
634 pointer fields. */
635
636static void
7f385784 637write_ts_decl_non_common_tree_pointers (struct output_block *ob, tree expr,
638 bool ref_p)
2541503d 639{
4df870fd 640 if (TREE_CODE (expr) == TYPE_DECL)
6cd6787c 641 stream_write_tree (ob, DECL_ORIGINAL_TYPE (expr), ref_p);
2541503d 642}
643
644
645/* Write all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
646 to output block OB. If REF_P is true, write a reference to EXPR's
647 pointer fields. */
648
649static void
7f385784 650write_ts_decl_with_vis_tree_pointers (struct output_block *ob, tree expr,
651 bool ref_p)
2541503d 652{
653 /* Make sure we don't inadvertently set the assembler name. */
654 if (DECL_ASSEMBLER_NAME_SET_P (expr))
515cf651 655 stream_write_tree (ob, DECL_ASSEMBLER_NAME (expr), ref_p);
2541503d 656 else
515cf651 657 stream_write_tree (ob, NULL_TREE, false);
2541503d 658}
659
660
661/* Write all pointer fields in the TS_FIELD_DECL structure of EXPR to
662 output block OB. If REF_P is true, write a reference to EXPR's
663 pointer fields. */
664
665static void
7f385784 666write_ts_field_decl_tree_pointers (struct output_block *ob, tree expr,
667 bool ref_p)
2541503d 668{
515cf651 669 stream_write_tree (ob, DECL_FIELD_OFFSET (expr), ref_p);
670 stream_write_tree (ob, DECL_BIT_FIELD_TYPE (expr), ref_p);
8d8a34f9 671 stream_write_tree (ob, DECL_BIT_FIELD_REPRESENTATIVE (expr), ref_p);
515cf651 672 stream_write_tree (ob, DECL_FIELD_BIT_OFFSET (expr), ref_p);
673 stream_write_tree (ob, DECL_FCONTEXT (expr), ref_p);
2541503d 674}
675
676
677/* Write all pointer fields in the TS_FUNCTION_DECL structure of EXPR
678 to output block OB. If REF_P is true, write a reference to EXPR's
679 pointer fields. */
680
681static void
7f385784 682write_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
683 bool ref_p)
2541503d 684{
9c2e58d0 685 stream_write_tree (ob, DECL_VINDEX (expr), ref_p);
73527b1d 686 /* DECL_STRUCT_FUNCTION is handled by lto_output_function. */
515cf651 687 stream_write_tree (ob, DECL_FUNCTION_PERSONALITY (expr), ref_p);
ba000093 688 /* Don't stream these when passing things to a different target. */
689 if (!lto_stream_offload_p)
690 stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_TARGET (expr), ref_p);
515cf651 691 stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr), ref_p);
2541503d 692}
693
694
695/* Write all pointer fields in the TS_TYPE_COMMON structure of EXPR to
696 output block OB. If REF_P is true, write a reference to EXPR's
697 pointer fields. */
698
699static void
7f385784 700write_ts_type_common_tree_pointers (struct output_block *ob, tree expr,
701 bool ref_p)
2541503d 702{
c7be6601 703 stream_write_tree (ob, TYPE_SIZE (expr), ref_p);
704 stream_write_tree (ob, TYPE_SIZE_UNIT (expr), ref_p);
705 stream_write_tree (ob, TYPE_ATTRIBUTES (expr), ref_p);
706 stream_write_tree (ob, TYPE_NAME (expr), ref_p);
707 /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO. They will be
708 reconstructed during fixup. */
2541503d 709 /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
710 during fixup. */
515cf651 711 stream_write_tree (ob, TYPE_MAIN_VARIANT (expr), ref_p);
712 stream_write_tree (ob, TYPE_CONTEXT (expr), ref_p);
2541503d 713 /* TYPE_CANONICAL is re-computed during type merging, so no need
714 to stream it here. */
c7be6601 715 stream_write_tree (ob, TYPE_STUB_DECL (expr), ref_p);
2541503d 716}
717
718/* Write all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
719 to output block OB. If REF_P is true, write a reference to EXPR's
720 pointer fields. */
721
722static void
7f385784 723write_ts_type_non_common_tree_pointers (struct output_block *ob, tree expr,
724 bool ref_p)
2541503d 725{
c7be6601 726 if (TREE_CODE (expr) == ENUMERAL_TYPE)
727 stream_write_tree (ob, TYPE_VALUES (expr), ref_p);
728 else if (TREE_CODE (expr) == ARRAY_TYPE)
729 stream_write_tree (ob, TYPE_DOMAIN (expr), ref_p);
730 else if (RECORD_OR_UNION_TYPE_P (expr))
731 streamer_write_chain (ob, TYPE_FIELDS (expr), ref_p);
732 else if (TREE_CODE (expr) == FUNCTION_TYPE
733 || TREE_CODE (expr) == METHOD_TYPE)
734 stream_write_tree (ob, TYPE_ARG_TYPES (expr), ref_p);
735
736 if (!POINTER_TYPE_P (expr))
737 stream_write_tree (ob, TYPE_MINVAL (expr), ref_p);
738 stream_write_tree (ob, TYPE_MAXVAL (expr), ref_p);
739 if (RECORD_OR_UNION_TYPE_P (expr))
740 stream_write_tree (ob, TYPE_BINFO (expr), ref_p);
2541503d 741}
742
743
744/* Write all pointer fields in the TS_LIST structure of EXPR to output
745 block OB. If REF_P is true, write a reference to EXPR's pointer
746 fields. */
747
748static void
7f385784 749write_ts_list_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 750{
515cf651 751 stream_write_tree (ob, TREE_PURPOSE (expr), ref_p);
752 stream_write_tree (ob, TREE_VALUE (expr), ref_p);
8ceff600 753 stream_write_tree (ob, TREE_CHAIN (expr), ref_p);
2541503d 754}
755
756
757/* Write all pointer fields in the TS_VEC structure of EXPR to output
758 block OB. If REF_P is true, write a reference to EXPR's pointer
759 fields. */
760
761static void
7f385784 762write_ts_vec_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 763{
764 int i;
765
766 /* Note that the number of slots for EXPR has already been emitted
7f385784 767 in EXPR's header (see streamer_write_tree_header). */
2541503d 768 for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
515cf651 769 stream_write_tree (ob, TREE_VEC_ELT (expr, i), ref_p);
2541503d 770}
771
772
773/* Write all pointer fields in the TS_EXP structure of EXPR to output
774 block OB. If REF_P is true, write a reference to EXPR's pointer
775 fields. */
776
777static void
7f385784 778write_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 779{
780 int i;
781
2541503d 782 for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
515cf651 783 stream_write_tree (ob, TREE_OPERAND (expr, i), ref_p);
515cf651 784 stream_write_tree (ob, TREE_BLOCK (expr), ref_p);
2541503d 785}
786
787
788/* Write all pointer fields in the TS_BLOCK structure of EXPR to output
789 block OB. If REF_P is true, write a reference to EXPR's pointer
790 fields. */
791
792static void
7f385784 793write_ts_block_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 794{
7f385784 795 streamer_write_chain (ob, BLOCK_VARS (expr), ref_p);
2541503d 796
ae52f82e 797 stream_write_tree (ob, BLOCK_SUPERCONTEXT (expr), ref_p);
798
ec180527 799 /* Stream BLOCK_ABSTRACT_ORIGIN for the limited cases we can handle - those
800 that represent inlined function scopes.
801 For the rest them on the floor instead of ICEing in dwarf2out.c. */
ae52f82e 802 if (inlined_function_outer_scope_p (expr))
803 {
804 tree ultimate_origin = block_ultimate_origin (expr);
805 stream_write_tree (ob, ultimate_origin, ref_p);
ae52f82e 806 }
807 else
ec180527 808 stream_write_tree (ob, NULL_TREE, ref_p);
2541503d 809 /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information
ae52f82e 810 for early inlined BLOCKs so drop it on the floor instead of ICEing in
2541503d 811 dwarf2out.c. */
812
ae52f82e 813 /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO
814 streaming time. */
815
2541503d 816 /* Do not output BLOCK_SUBBLOCKS. Instead on streaming-in this
817 list is re-constructed from BLOCK_SUPERCONTEXT. */
818}
819
820
821/* Write all pointer fields in the TS_BINFO structure of EXPR to output
822 block OB. If REF_P is true, write a reference to EXPR's pointer
823 fields. */
824
825static void
7f385784 826write_ts_binfo_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
2541503d 827{
828 unsigned i;
829 tree t;
830
831 /* Note that the number of BINFO slots has already been emitted in
7f385784 832 EXPR's header (see streamer_write_tree_header) because this length
2541503d 833 is needed to build the empty BINFO node on the reader side. */
f1f41a6c 834 FOR_EACH_VEC_ELT (*BINFO_BASE_BINFOS (expr), i, t)
515cf651 835 stream_write_tree (ob, t, ref_p);
836 stream_write_tree (ob, NULL_TREE, false);
2541503d 837
515cf651 838 stream_write_tree (ob, BINFO_OFFSET (expr), ref_p);
839 stream_write_tree (ob, BINFO_VTABLE (expr), ref_p);
515cf651 840 stream_write_tree (ob, BINFO_VPTR_FIELD (expr), ref_p);
2541503d 841
e41fac10 842 /* The number of BINFO_BASE_ACCESSES has already been emitted in
843 EXPR's bitfield section. */
f1f41a6c 844 FOR_EACH_VEC_SAFE_ELT (BINFO_BASE_ACCESSES (expr), i, t)
515cf651 845 stream_write_tree (ob, t, ref_p);
2541503d 846
881fe02c 847 /* Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX
848 and BINFO_VPTR_INDEX; these are used by C++ FE only. */
2541503d 849}
850
851
852/* Write all pointer fields in the TS_CONSTRUCTOR structure of EXPR to
853 output block OB. If REF_P is true, write a reference to EXPR's
854 pointer fields. */
855
856static void
7f385784 857write_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
858 bool ref_p)
2541503d 859{
860 unsigned i;
861 tree index, value;
862
2541503d 863 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value)
864 {
515cf651 865 stream_write_tree (ob, index, ref_p);
866 stream_write_tree (ob, value, ref_p);
2541503d 867 }
868}
869
fe3e3369 870
871/* Write all pointer fields in the TS_OMP_CLAUSE structure of EXPR
872 to output block OB. If REF_P is true, write a reference to EXPR's
873 pointer fields. */
874
875static void
876write_ts_omp_clause_tree_pointers (struct output_block *ob, tree expr,
877 bool ref_p)
878{
879 int i;
880 for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (expr)]; i++)
881 stream_write_tree (ob, OMP_CLAUSE_OPERAND (expr, i), ref_p);
882 if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_REDUCTION)
883 {
884 /* We don't stream these right now, handle it if streaming
885 of them is needed. */
886 gcc_assert (OMP_CLAUSE_REDUCTION_GIMPLE_INIT (expr) == NULL);
887 gcc_assert (OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (expr) == NULL);
888 }
889 stream_write_tree (ob, OMP_CLAUSE_CHAIN (expr), ref_p);
890}
891
892
515cf651 893/* Write all pointer fields in EXPR to output block OB. If REF_P is true,
894 the leaves of EXPR are emitted as references. */
2541503d 895
515cf651 896void
7f385784 897streamer_write_tree_body (struct output_block *ob, tree expr, bool ref_p)
2541503d 898{
899 enum tree_code code;
900
8ceff600 901 lto_stats.num_tree_bodies_output++;
902
2541503d 903 code = TREE_CODE (expr);
904
905 if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
7f385784 906 write_ts_common_tree_pointers (ob, expr, ref_p);
2541503d 907
908 if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
7f385784 909 write_ts_vector_tree_pointers (ob, expr, ref_p);
2541503d 910
911 if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
7f385784 912 write_ts_complex_tree_pointers (ob, expr, ref_p);
2541503d 913
914 if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
7f385784 915 write_ts_decl_minimal_tree_pointers (ob, expr, ref_p);
2541503d 916
917 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
7f385784 918 write_ts_decl_common_tree_pointers (ob, expr, ref_p);
2541503d 919
920 if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
7f385784 921 write_ts_decl_non_common_tree_pointers (ob, expr, ref_p);
2541503d 922
923 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
7f385784 924 write_ts_decl_with_vis_tree_pointers (ob, expr, ref_p);
2541503d 925
926 if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
7f385784 927 write_ts_field_decl_tree_pointers (ob, expr, ref_p);
2541503d 928
929 if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
7f385784 930 write_ts_function_decl_tree_pointers (ob, expr, ref_p);
2541503d 931
932 if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
7f385784 933 write_ts_type_common_tree_pointers (ob, expr, ref_p);
2541503d 934
935 if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
7f385784 936 write_ts_type_non_common_tree_pointers (ob, expr, ref_p);
2541503d 937
938 if (CODE_CONTAINS_STRUCT (code, TS_LIST))
7f385784 939 write_ts_list_tree_pointers (ob, expr, ref_p);
2541503d 940
941 if (CODE_CONTAINS_STRUCT (code, TS_VEC))
7f385784 942 write_ts_vec_tree_pointers (ob, expr, ref_p);
2541503d 943
944 if (CODE_CONTAINS_STRUCT (code, TS_EXP))
7f385784 945 write_ts_exp_tree_pointers (ob, expr, ref_p);
2541503d 946
947 if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
7f385784 948 write_ts_block_tree_pointers (ob, expr, ref_p);
2541503d 949
950 if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
7f385784 951 write_ts_binfo_tree_pointers (ob, expr, ref_p);
2541503d 952
953 if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
7f385784 954 write_ts_constructor_tree_pointers (ob, expr, ref_p);
fe3e3369 955
956 if (code == OMP_CLAUSE)
957 write_ts_omp_clause_tree_pointers (ob, expr, ref_p);
2541503d 958}
959
960
961/* Emit header information for tree EXPR to output block OB. The header
962 contains everything needed to instantiate an empty skeleton for
963 EXPR on the reading side. IX is the index into the streamer cache
515cf651 964 where EXPR is stored. */
2541503d 965
515cf651 966void
7f385784 967streamer_write_tree_header (struct output_block *ob, tree expr)
2541503d 968{
969 enum LTO_tags tag;
970 enum tree_code code;
971
972 /* We should not see any tree nodes not handled by the streamer. */
973 code = TREE_CODE (expr);
2541503d 974
975 /* The header of a tree node consists of its tag, the size of
976 the node, and any other information needed to instantiate
977 EXPR on the reading side (such as the number of slots in
978 variable sized nodes). */
979 tag = lto_tree_code_to_tag (code);
7f385784 980 streamer_write_record_start (ob, tag);
2541503d 981
982 /* The following will cause bootstrap miscomparisons. Enable with care. */
983#ifdef LTO_STREAMER_DEBUG
984 /* This is used mainly for debugging purposes. When the reader
985 and the writer do not agree on a streamed node, the pointer
986 value for EXPR can be used to track down the differences in
987 the debugger. */
3a4303e7 988 gcc_assert ((HOST_WIDE_INT) (intptr_t) expr == (intptr_t) expr);
989 streamer_write_hwi (ob, (HOST_WIDE_INT) (intptr_t) expr);
2541503d 990#endif
991
992 /* The text in strings and identifiers are completely emitted in
993 the header. */
994 if (CODE_CONTAINS_STRUCT (code, TS_STRING))
65d1b157 995 streamer_write_string_cst (ob, ob->main_stream, expr);
2541503d 996 else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
7f385784 997 write_identifier (ob, ob->main_stream, expr);
fadf62f4 998 else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
999 streamer_write_hwi (ob, VECTOR_CST_NELTS (expr));
2541503d 1000 else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
7f385784 1001 streamer_write_hwi (ob, TREE_VEC_LENGTH (expr));
2541503d 1002 else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
7f385784 1003 streamer_write_uhwi (ob, BINFO_N_BASE_BINFOS (expr));
515cf651 1004 else if (TREE_CODE (expr) == CALL_EXPR)
7f385784 1005 streamer_write_uhwi (ob, call_expr_nargs (expr));
fe3e3369 1006 else if (TREE_CODE (expr) == OMP_CLAUSE)
1007 streamer_write_uhwi (ob, OMP_CLAUSE_CODE (expr));
e913b5cd 1008 else if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
1009 {
271e739a 1010 gcc_checking_assert (TREE_INT_CST_NUNITS (expr));
1011 streamer_write_uhwi (ob, TREE_INT_CST_NUNITS (expr));
1012 streamer_write_uhwi (ob, TREE_INT_CST_EXT_NUNITS (expr));
e913b5cd 1013 }
2541503d 1014}
1015
1016
1017/* Emit the integer constant CST to output block OB. If REF_P is true,
1018 CST's type will be emitted as a reference. */
1019
515cf651 1020void
7f385784 1021streamer_write_integer_cst (struct output_block *ob, tree cst, bool ref_p)
2541503d 1022{
e913b5cd 1023 int i;
1024 int len = TREE_INT_CST_NUNITS (cst);
42603940 1025 gcc_assert (!TREE_OVERFLOW (cst));
1026 streamer_write_record_start (ob, LTO_integer_cst);
515cf651 1027 stream_write_tree (ob, TREE_TYPE (cst), ref_p);
271e739a 1028 /* We're effectively streaming a non-sign-extended wide_int here,
1029 so there's no need to stream TREE_INT_CST_EXT_NUNITS or any
1030 array members beyond LEN. We'll recreate the tree from the
1031 wide_int and the type. */
e913b5cd 1032 streamer_write_uhwi (ob, len);
1033 for (i = 0; i < len; i++)
1034 streamer_write_hwi (ob, TREE_INT_CST_ELT (cst, i));
2541503d 1035}