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