annotate gcc/tree-streamer.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Miscellaneous utilities for tree streaming. Things that are used
kono
parents:
diff changeset
2 in both input and output are here.
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
5 Contributed by Diego Novillo <dnovillo@google.com>
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 This file is part of GCC.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
10 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
11 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
12 version.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
17 for more details.
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
20 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
21 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 #include "config.h"
kono
parents:
diff changeset
24 #include "system.h"
kono
parents:
diff changeset
25 #include "coretypes.h"
kono
parents:
diff changeset
26 #include "backend.h"
kono
parents:
diff changeset
27 #include "tree.h"
kono
parents:
diff changeset
28 #include "gimple.h"
kono
parents:
diff changeset
29 #include "tree-streamer.h"
kono
parents:
diff changeset
30 #include "cgraph.h"
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Table indexed by machine_mode, used for 2 different purposes.
kono
parents:
diff changeset
33 During streaming out we record there non-zero value for all modes
kono
parents:
diff changeset
34 that were streamed out.
kono
parents:
diff changeset
35 During streaming in, we translate the on the disk mode using this
kono
parents:
diff changeset
36 table. For normal LTO it is set to identity, for ACCEL_COMPILER
kono
parents:
diff changeset
37 depending on the mode_table content. */
kono
parents:
diff changeset
38 unsigned char streamer_mode_table[1 << 8];
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* Check that all the TS_* structures handled by the streamer_write_* and
kono
parents:
diff changeset
41 streamer_read_* routines are exactly ALL the structures defined in
kono
parents:
diff changeset
42 treestruct.def. */
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 void
kono
parents:
diff changeset
45 streamer_check_handled_ts_structures (void)
kono
parents:
diff changeset
46 {
kono
parents:
diff changeset
47 bool handled_p[LAST_TS_ENUM];
kono
parents:
diff changeset
48 unsigned i;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 memset (&handled_p, 0, sizeof (handled_p));
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* These are the TS_* structures that are either handled or
kono
parents:
diff changeset
53 explicitly ignored by the streamer routines. */
kono
parents:
diff changeset
54 handled_p[TS_BASE] = true;
kono
parents:
diff changeset
55 handled_p[TS_TYPED] = true;
kono
parents:
diff changeset
56 handled_p[TS_COMMON] = true;
kono
parents:
diff changeset
57 handled_p[TS_INT_CST] = true;
kono
parents:
diff changeset
58 handled_p[TS_REAL_CST] = true;
kono
parents:
diff changeset
59 handled_p[TS_FIXED_CST] = true;
kono
parents:
diff changeset
60 handled_p[TS_VECTOR] = true;
kono
parents:
diff changeset
61 handled_p[TS_STRING] = true;
kono
parents:
diff changeset
62 handled_p[TS_COMPLEX] = true;
kono
parents:
diff changeset
63 handled_p[TS_IDENTIFIER] = true;
kono
parents:
diff changeset
64 handled_p[TS_DECL_MINIMAL] = true;
kono
parents:
diff changeset
65 handled_p[TS_DECL_COMMON] = true;
kono
parents:
diff changeset
66 handled_p[TS_DECL_WRTL] = true;
kono
parents:
diff changeset
67 handled_p[TS_DECL_NON_COMMON] = true;
kono
parents:
diff changeset
68 handled_p[TS_DECL_WITH_VIS] = true;
kono
parents:
diff changeset
69 handled_p[TS_FIELD_DECL] = true;
kono
parents:
diff changeset
70 handled_p[TS_VAR_DECL] = true;
kono
parents:
diff changeset
71 handled_p[TS_PARM_DECL] = true;
kono
parents:
diff changeset
72 handled_p[TS_LABEL_DECL] = true;
kono
parents:
diff changeset
73 handled_p[TS_RESULT_DECL] = true;
kono
parents:
diff changeset
74 handled_p[TS_CONST_DECL] = true;
kono
parents:
diff changeset
75 handled_p[TS_TYPE_DECL] = true;
kono
parents:
diff changeset
76 handled_p[TS_FUNCTION_DECL] = true;
kono
parents:
diff changeset
77 handled_p[TS_TYPE_COMMON] = true;
kono
parents:
diff changeset
78 handled_p[TS_TYPE_WITH_LANG_SPECIFIC] = true;
kono
parents:
diff changeset
79 handled_p[TS_TYPE_NON_COMMON] = true;
kono
parents:
diff changeset
80 handled_p[TS_LIST] = true;
kono
parents:
diff changeset
81 handled_p[TS_VEC] = true;
kono
parents:
diff changeset
82 handled_p[TS_EXP] = true;
kono
parents:
diff changeset
83 handled_p[TS_SSA_NAME] = true;
kono
parents:
diff changeset
84 handled_p[TS_BLOCK] = true;
kono
parents:
diff changeset
85 handled_p[TS_BINFO] = true;
kono
parents:
diff changeset
86 handled_p[TS_STATEMENT_LIST] = true;
kono
parents:
diff changeset
87 handled_p[TS_CONSTRUCTOR] = true;
kono
parents:
diff changeset
88 handled_p[TS_OMP_CLAUSE] = true;
kono
parents:
diff changeset
89 handled_p[TS_OPTIMIZATION] = true;
kono
parents:
diff changeset
90 handled_p[TS_TARGET_OPTION] = true;
kono
parents:
diff changeset
91 handled_p[TS_TRANSLATION_UNIT_DECL] = true;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* Anything not marked above will trigger the following assertion.
kono
parents:
diff changeset
94 If this assertion triggers, it means that there is a new TS_*
kono
parents:
diff changeset
95 structure that should be handled by the streamer. */
kono
parents:
diff changeset
96 for (i = 0; i < LAST_TS_ENUM; i++)
kono
parents:
diff changeset
97 gcc_assert (handled_p[i]);
kono
parents:
diff changeset
98 }
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 /* Helper for streamer_tree_cache_insert_1. Add T to CACHE->NODES at
kono
parents:
diff changeset
102 slot IX. */
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 static void
kono
parents:
diff changeset
105 streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
106 unsigned ix, tree t, hashval_t hash)
kono
parents:
diff changeset
107 {
kono
parents:
diff changeset
108 /* We're either replacing an old element or appending consecutively. */
kono
parents:
diff changeset
109 if (cache->nodes.exists ())
kono
parents:
diff changeset
110 {
kono
parents:
diff changeset
111 if (cache->nodes.length () == ix)
kono
parents:
diff changeset
112 cache->nodes.safe_push (t);
kono
parents:
diff changeset
113 else
kono
parents:
diff changeset
114 cache->nodes[ix] = t;
kono
parents:
diff changeset
115 }
kono
parents:
diff changeset
116 if (cache->hashes.exists ())
kono
parents:
diff changeset
117 {
kono
parents:
diff changeset
118 if (cache->hashes.length () == ix)
kono
parents:
diff changeset
119 cache->hashes.safe_push (hash);
kono
parents:
diff changeset
120 else
kono
parents:
diff changeset
121 cache->hashes[ix] = hash;
kono
parents:
diff changeset
122 }
kono
parents:
diff changeset
123 }
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 /* Helper for streamer_tree_cache_insert and streamer_tree_cache_insert_at.
kono
parents:
diff changeset
127 CACHE, T, and IX_P are as in streamer_tree_cache_insert.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 If INSERT_AT_NEXT_SLOT_P is true, T is inserted at the next available
kono
parents:
diff changeset
130 slot in the cache. Otherwise, T is inserted at the position indicated
kono
parents:
diff changeset
131 in *IX_P.
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 If T already existed in CACHE, return true. Otherwise,
kono
parents:
diff changeset
134 return false. */
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 static bool
kono
parents:
diff changeset
137 streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
138 tree t, hashval_t hash, unsigned *ix_p,
kono
parents:
diff changeset
139 bool insert_at_next_slot_p)
kono
parents:
diff changeset
140 {
kono
parents:
diff changeset
141 bool existed_p;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 gcc_assert (t);
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 unsigned int &ix = cache->node_map->get_or_insert (t, &existed_p);
kono
parents:
diff changeset
146 if (!existed_p)
kono
parents:
diff changeset
147 {
kono
parents:
diff changeset
148 /* Determine the next slot to use in the cache. */
kono
parents:
diff changeset
149 if (insert_at_next_slot_p)
kono
parents:
diff changeset
150 ix = cache->next_idx++;
kono
parents:
diff changeset
151 else
kono
parents:
diff changeset
152 ix = *ix_p;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
155 }
kono
parents:
diff changeset
156 else
kono
parents:
diff changeset
157 {
kono
parents:
diff changeset
158 if (!insert_at_next_slot_p && ix != *ix_p)
kono
parents:
diff changeset
159 {
kono
parents:
diff changeset
160 /* If the caller wants to insert T at a specific slot
kono
parents:
diff changeset
161 location, and ENTRY->TO does not match *IX_P, add T to
kono
parents:
diff changeset
162 the requested location slot. */
kono
parents:
diff changeset
163 ix = *ix_p;
kono
parents:
diff changeset
164 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
165 }
kono
parents:
diff changeset
166 }
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 if (ix_p)
kono
parents:
diff changeset
169 *ix_p = ix;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 return existed_p;
kono
parents:
diff changeset
172 }
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 /* Insert tree node T in CACHE. If T already existed in the cache
kono
parents:
diff changeset
176 return true. Otherwise, return false.
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 If IX_P is non-null, update it with the index into the cache where
kono
parents:
diff changeset
179 T has been stored. */
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 bool
kono
parents:
diff changeset
182 streamer_tree_cache_insert (struct streamer_tree_cache_d *cache, tree t,
kono
parents:
diff changeset
183 hashval_t hash, unsigned *ix_p)
kono
parents:
diff changeset
184 {
kono
parents:
diff changeset
185 return streamer_tree_cache_insert_1 (cache, t, hash, ix_p, true);
kono
parents:
diff changeset
186 }
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 /* Replace the tree node with T in CACHE at slot IX. */
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 void
kono
parents:
diff changeset
192 streamer_tree_cache_replace_tree (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
193 tree t, unsigned ix)
kono
parents:
diff changeset
194 {
kono
parents:
diff changeset
195 hashval_t hash = 0;
kono
parents:
diff changeset
196 if (cache->hashes.exists ())
kono
parents:
diff changeset
197 hash = streamer_tree_cache_get_hash (cache, ix);
kono
parents:
diff changeset
198 if (!cache->node_map)
kono
parents:
diff changeset
199 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
200 else
kono
parents:
diff changeset
201 streamer_tree_cache_insert_1 (cache, t, hash, &ix, false);
kono
parents:
diff changeset
202 }
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 /* Appends tree node T to CACHE, even if T already existed in it. */
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 void
kono
parents:
diff changeset
208 streamer_tree_cache_append (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
209 tree t, hashval_t hash)
kono
parents:
diff changeset
210 {
kono
parents:
diff changeset
211 unsigned ix = cache->next_idx++;
kono
parents:
diff changeset
212 if (!cache->node_map)
kono
parents:
diff changeset
213 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
214 else
kono
parents:
diff changeset
215 streamer_tree_cache_insert_1 (cache, t, hash, &ix, false);
kono
parents:
diff changeset
216 }
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 /* Return true if tree node T exists in CACHE, otherwise false. If IX_P is
kono
parents:
diff changeset
219 not NULL, write to *IX_P the index into the cache where T is stored
kono
parents:
diff changeset
220 ((unsigned)-1 if T is not found). */
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 bool
kono
parents:
diff changeset
223 streamer_tree_cache_lookup (struct streamer_tree_cache_d *cache, tree t,
kono
parents:
diff changeset
224 unsigned *ix_p)
kono
parents:
diff changeset
225 {
kono
parents:
diff changeset
226 unsigned *slot;
kono
parents:
diff changeset
227 bool retval;
kono
parents:
diff changeset
228 unsigned ix;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 gcc_assert (t);
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 slot = cache->node_map->get (t);
kono
parents:
diff changeset
233 if (slot == NULL)
kono
parents:
diff changeset
234 {
kono
parents:
diff changeset
235 retval = false;
kono
parents:
diff changeset
236 ix = -1;
kono
parents:
diff changeset
237 }
kono
parents:
diff changeset
238 else
kono
parents:
diff changeset
239 {
kono
parents:
diff changeset
240 retval = true;
kono
parents:
diff changeset
241 ix = *slot;
kono
parents:
diff changeset
242 }
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 if (ix_p)
kono
parents:
diff changeset
245 *ix_p = ix;
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 return retval;
kono
parents:
diff changeset
248 }
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 /* Verify that NODE is in CACHE. */
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 static void
kono
parents:
diff changeset
254 verify_common_node_recorded (struct streamer_tree_cache_d *cache, tree node)
kono
parents:
diff changeset
255 {
kono
parents:
diff changeset
256 /* Restrict this to flag_checking only because in general violating it is
kono
parents:
diff changeset
257 harmless plus we never know what happens on all targets/frontend/flag(!)
kono
parents:
diff changeset
258 combinations. */
kono
parents:
diff changeset
259 if (!flag_checking)
kono
parents:
diff changeset
260 return;
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 if (cache->node_map)
kono
parents:
diff changeset
263 gcc_assert (streamer_tree_cache_lookup (cache, node, NULL));
kono
parents:
diff changeset
264 else
kono
parents:
diff changeset
265 {
kono
parents:
diff changeset
266 bool found = false;
kono
parents:
diff changeset
267 gcc_assert (cache->nodes.exists ());
kono
parents:
diff changeset
268 /* Linear search... */
kono
parents:
diff changeset
269 for (unsigned i = 0; !found && i < cache->nodes.length (); ++i)
kono
parents:
diff changeset
270 if (cache->nodes[i] == node)
kono
parents:
diff changeset
271 found = true;
kono
parents:
diff changeset
272 gcc_assert (found);
kono
parents:
diff changeset
273 }
kono
parents:
diff changeset
274 }
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 /* Record NODE in CACHE. */
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 static void
kono
parents:
diff changeset
280 record_common_node (struct streamer_tree_cache_d *cache, tree node)
kono
parents:
diff changeset
281 {
kono
parents:
diff changeset
282 /* If we recursively end up at nodes we do not want to preload simply don't.
kono
parents:
diff changeset
283 ??? We'd want to verify that this doesn't happen, or alternatively
kono
parents:
diff changeset
284 do not recurse at all. */
kono
parents:
diff changeset
285 if (node == char_type_node)
kono
parents:
diff changeset
286 return;
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 gcc_checking_assert (node != boolean_type_node
kono
parents:
diff changeset
289 && node != boolean_true_node
kono
parents:
diff changeset
290 && node != boolean_false_node);
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 /* We have to make sure to fill exactly the same number of
kono
parents:
diff changeset
293 elements for all frontends. That can include NULL trees.
kono
parents:
diff changeset
294 As our hash table can't deal with zero entries we'll simply stream
kono
parents:
diff changeset
295 a random other tree. A NULL tree never will be looked up so it
kono
parents:
diff changeset
296 doesn't matter which tree we replace it with, just to be sure
kono
parents:
diff changeset
297 use error_mark_node. */
kono
parents:
diff changeset
298 if (!node)
kono
parents:
diff changeset
299 node = error_mark_node;
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 /* ??? FIXME, devise a better hash value. But the hash needs to be equal
kono
parents:
diff changeset
302 for all frontend and lto1 invocations. So just use the position
kono
parents:
diff changeset
303 in the cache as hash value. */
kono
parents:
diff changeset
304 streamer_tree_cache_append (cache, node, cache->nodes.length ());
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 switch (TREE_CODE (node))
kono
parents:
diff changeset
307 {
kono
parents:
diff changeset
308 case ERROR_MARK:
kono
parents:
diff changeset
309 case FIELD_DECL:
kono
parents:
diff changeset
310 case FIXED_POINT_TYPE:
kono
parents:
diff changeset
311 case IDENTIFIER_NODE:
kono
parents:
diff changeset
312 case INTEGER_CST:
kono
parents:
diff changeset
313 case INTEGER_TYPE:
kono
parents:
diff changeset
314 case POINTER_BOUNDS_TYPE:
kono
parents:
diff changeset
315 case REAL_TYPE:
kono
parents:
diff changeset
316 case TREE_LIST:
kono
parents:
diff changeset
317 case VOID_CST:
kono
parents:
diff changeset
318 case VOID_TYPE:
kono
parents:
diff changeset
319 /* No recursive trees. */
kono
parents:
diff changeset
320 break;
kono
parents:
diff changeset
321 case ARRAY_TYPE:
kono
parents:
diff changeset
322 case POINTER_TYPE:
kono
parents:
diff changeset
323 case REFERENCE_TYPE:
kono
parents:
diff changeset
324 record_common_node (cache, TREE_TYPE (node));
kono
parents:
diff changeset
325 break;
kono
parents:
diff changeset
326 case COMPLEX_TYPE:
kono
parents:
diff changeset
327 /* Verify that a complex type's component type (node_type) has been
kono
parents:
diff changeset
328 handled already (and we thus don't need to recurse here). */
kono
parents:
diff changeset
329 verify_common_node_recorded (cache, TREE_TYPE (node));
kono
parents:
diff changeset
330 break;
kono
parents:
diff changeset
331 case RECORD_TYPE:
kono
parents:
diff changeset
332 /* The FIELD_DECLs of structures should be shared, so that every
kono
parents:
diff changeset
333 COMPONENT_REF uses the same tree node when referencing a field.
kono
parents:
diff changeset
334 Pointer equality between FIELD_DECLs is used by the alias
kono
parents:
diff changeset
335 machinery to compute overlapping component references (see
kono
parents:
diff changeset
336 nonoverlapping_component_refs_p and
kono
parents:
diff changeset
337 nonoverlapping_component_refs_of_decl_p). */
kono
parents:
diff changeset
338 for (tree f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
kono
parents:
diff changeset
339 record_common_node (cache, f);
kono
parents:
diff changeset
340 break;
kono
parents:
diff changeset
341 default:
kono
parents:
diff changeset
342 /* Unexpected tree code. */
kono
parents:
diff changeset
343 gcc_unreachable ();
kono
parents:
diff changeset
344 }
kono
parents:
diff changeset
345 }
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 /* Preload common nodes into CACHE and make sure they are merged
kono
parents:
diff changeset
349 properly according to the gimple type table. */
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 static void
kono
parents:
diff changeset
352 preload_common_nodes (struct streamer_tree_cache_d *cache)
kono
parents:
diff changeset
353 {
kono
parents:
diff changeset
354 unsigned i;
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 for (i = 0; i < itk_none; i++)
kono
parents:
diff changeset
357 /* Skip itk_char. char_type_node is dependent on -f[un]signed-char. */
kono
parents:
diff changeset
358 if (i != itk_char)
kono
parents:
diff changeset
359 record_common_node (cache, integer_types[i]);
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 for (i = 0; i < stk_type_kind_last; i++)
kono
parents:
diff changeset
362 record_common_node (cache, sizetype_tab[i]);
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 for (i = 0; i < TI_MAX; i++)
kono
parents:
diff changeset
365 /* Skip boolean type and constants, they are frontend dependent. */
kono
parents:
diff changeset
366 if (i != TI_BOOLEAN_TYPE
kono
parents:
diff changeset
367 && i != TI_BOOLEAN_FALSE
kono
parents:
diff changeset
368 && i != TI_BOOLEAN_TRUE
kono
parents:
diff changeset
369 /* MAIN_IDENTIFIER is not always initialized by Fortran FE. */
kono
parents:
diff changeset
370 && i != TI_MAIN_IDENTIFIER
kono
parents:
diff changeset
371 /* PID_TYPE is initialized only by C family front-ends. */
kono
parents:
diff changeset
372 && i != TI_PID_TYPE
kono
parents:
diff changeset
373 /* Skip optimization and target option nodes; they depend on flags. */
kono
parents:
diff changeset
374 && i != TI_OPTIMIZATION_DEFAULT
kono
parents:
diff changeset
375 && i != TI_OPTIMIZATION_CURRENT
kono
parents:
diff changeset
376 && i != TI_TARGET_OPTION_DEFAULT
kono
parents:
diff changeset
377 && i != TI_TARGET_OPTION_CURRENT
kono
parents:
diff changeset
378 && i != TI_CURRENT_TARGET_PRAGMA
kono
parents:
diff changeset
379 && i != TI_CURRENT_OPTIMIZE_PRAGMA
kono
parents:
diff changeset
380 /* Skip va_list* related nodes if offloading. For native LTO
kono
parents:
diff changeset
381 we want them to be merged for the stdarg pass, for offloading
kono
parents:
diff changeset
382 they might not be identical between host and offloading target. */
kono
parents:
diff changeset
383 && (!lto_stream_offload_p
kono
parents:
diff changeset
384 || (i != TI_VA_LIST_TYPE
kono
parents:
diff changeset
385 && i != TI_VA_LIST_GPR_COUNTER_FIELD
kono
parents:
diff changeset
386 && i != TI_VA_LIST_FPR_COUNTER_FIELD)))
kono
parents:
diff changeset
387 record_common_node (cache, global_trees[i]);
kono
parents:
diff changeset
388 }
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 /* Create a cache of pickled nodes. */
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393 struct streamer_tree_cache_d *
kono
parents:
diff changeset
394 streamer_tree_cache_create (bool with_hashes, bool with_map, bool with_vec)
kono
parents:
diff changeset
395 {
kono
parents:
diff changeset
396 struct streamer_tree_cache_d *cache;
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 cache = XCNEW (struct streamer_tree_cache_d);
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 if (with_map)
kono
parents:
diff changeset
401 cache->node_map = new hash_map<tree, unsigned> (251);
kono
parents:
diff changeset
402 cache->next_idx = 0;
kono
parents:
diff changeset
403 if (with_vec)
kono
parents:
diff changeset
404 cache->nodes.create (165);
kono
parents:
diff changeset
405 if (with_hashes)
kono
parents:
diff changeset
406 cache->hashes.create (165);
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 /* Load all the well-known tree nodes that are always created by
kono
parents:
diff changeset
409 the compiler on startup. This prevents writing them out
kono
parents:
diff changeset
410 unnecessarily. */
kono
parents:
diff changeset
411 preload_common_nodes (cache);
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 return cache;
kono
parents:
diff changeset
414 }
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 /* Delete the streamer cache C. */
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 void
kono
parents:
diff changeset
420 streamer_tree_cache_delete (struct streamer_tree_cache_d *c)
kono
parents:
diff changeset
421 {
kono
parents:
diff changeset
422 if (c == NULL)
kono
parents:
diff changeset
423 return;
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 delete c->node_map;
kono
parents:
diff changeset
426 c->node_map = NULL;
kono
parents:
diff changeset
427 c->nodes.release ();
kono
parents:
diff changeset
428 c->hashes.release ();
kono
parents:
diff changeset
429 free (c);
kono
parents:
diff changeset
430 }