tree-streamer-out.c 34 KB

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