summaryrefslogtreecommitdiff
path: root/gcc/lto-streamer.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-08 16:49:34 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-08 16:49:34 +0000
commit2541503d0742669641111007ac41e8b26fc69794 (patch)
tree71d0dfebe89d85d68e84274293c25cee61f487e2 /gcc/lto-streamer.c
parent82310a30d8c326acabefb8af6f4b943cde02425e (diff)
downloadgcc-2541503d0742669641111007ac41e8b26fc69794.tar.gz
rebase
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177571 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-streamer.c')
-rw-r--r--gcc/lto-streamer.c267
1 files changed, 2 insertions, 265 deletions
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index 0608b33a76b..328e6540047 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -32,14 +32,13 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h"
#include "bitmap.h"
#include "vec.h"
+#include "tree-streamer.h"
#include "lto-streamer.h"
+#include "streamer-hooks.h"
/* Statistics gathered during LTO, WPA and LTRANS. */
struct lto_stats_d lto_stats;
-/* Streamer hooks. */
-struct streamer_hooks streamer_hooks;
-
/* LTO uses bitmaps with different life-times. So use a seperate
obstack for all LTO bitmaps. */
static bitmap_obstack lto_obstack;
@@ -258,226 +257,6 @@ print_lto_report (void)
}
-/* Check that all the TS_* structures handled by the lto_output_* and
- lto_input_* routines are exactly ALL the structures defined in
- treestruct.def. */
-
-static void
-check_handled_ts_structures (void)
-{
- bool handled_p[LAST_TS_ENUM];
- unsigned i;
-
- memset (&handled_p, 0, sizeof (handled_p));
-
- /* These are the TS_* structures that are either handled or
- explicitly ignored by the streamer routines. */
- handled_p[TS_BASE] = true;
- handled_p[TS_TYPED] = true;
- handled_p[TS_COMMON] = true;
- handled_p[TS_INT_CST] = true;
- handled_p[TS_REAL_CST] = true;
- handled_p[TS_FIXED_CST] = true;
- handled_p[TS_VECTOR] = true;
- handled_p[TS_STRING] = true;
- handled_p[TS_COMPLEX] = true;
- handled_p[TS_IDENTIFIER] = true;
- handled_p[TS_DECL_MINIMAL] = true;
- handled_p[TS_DECL_COMMON] = true;
- handled_p[TS_DECL_WRTL] = true;
- handled_p[TS_DECL_NON_COMMON] = true;
- handled_p[TS_DECL_WITH_VIS] = true;
- handled_p[TS_FIELD_DECL] = true;
- handled_p[TS_VAR_DECL] = true;
- handled_p[TS_PARM_DECL] = true;
- handled_p[TS_LABEL_DECL] = true;
- handled_p[TS_RESULT_DECL] = true;
- handled_p[TS_CONST_DECL] = true;
- handled_p[TS_TYPE_DECL] = true;
- handled_p[TS_FUNCTION_DECL] = true;
- handled_p[TS_TYPE_COMMON] = true;
- handled_p[TS_TYPE_WITH_LANG_SPECIFIC] = true;
- handled_p[TS_TYPE_NON_COMMON] = true;
- handled_p[TS_LIST] = true;
- handled_p[TS_VEC] = true;
- handled_p[TS_EXP] = true;
- handled_p[TS_SSA_NAME] = true;
- handled_p[TS_BLOCK] = true;
- handled_p[TS_BINFO] = true;
- handled_p[TS_STATEMENT_LIST] = true;
- handled_p[TS_CONSTRUCTOR] = true;
- handled_p[TS_OMP_CLAUSE] = true;
- handled_p[TS_OPTIMIZATION] = true;
- handled_p[TS_TARGET_OPTION] = true;
- handled_p[TS_TRANSLATION_UNIT_DECL] = true;
-
- /* Anything not marked above will trigger the following assertion.
- If this assertion triggers, it means that there is a new TS_*
- structure that should be handled by the streamer. */
- for (i = 0; i < LAST_TS_ENUM; i++)
- gcc_assert (handled_p[i]);
-}
-
-
-/* Helper for lto_streamer_cache_insert_1. Add T to CACHE->NODES at
- slot IX. */
-
-static void
-lto_streamer_cache_add_to_node_array (struct lto_streamer_cache_d *cache,
- unsigned ix, tree t)
-{
- /* Make sure we're either replacing an old element or
- appending consecutively. */
- gcc_assert (ix <= VEC_length (tree, cache->nodes));
-
- if (ix == VEC_length (tree, cache->nodes))
- VEC_safe_push (tree, heap, cache->nodes, t);
- else
- VEC_replace (tree, cache->nodes, ix, t);
-}
-
-
-/* Helper for lto_streamer_cache_insert and lto_streamer_cache_insert_at.
- CACHE, T, and IX_P are as in lto_streamer_cache_insert.
-
- If INSERT_AT_NEXT_SLOT_P is true, T is inserted at the next available
- slot in the cache. Otherwise, T is inserted at the position indicated
- in *IX_P.
-
- If T already existed in CACHE, return true. Otherwise,
- return false. */
-
-static bool
-lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
- tree t, unsigned *ix_p,
- bool insert_at_next_slot_p)
-{
- void **slot;
- unsigned ix;
- bool existed_p;
-
- gcc_assert (t);
-
- slot = pointer_map_insert (cache->node_map, t);
- if (!*slot)
- {
- /* Determine the next slot to use in the cache. */
- if (insert_at_next_slot_p)
- ix = VEC_length (tree, cache->nodes);
- else
- ix = *ix_p;
- *slot = (void *)(size_t) (ix + 1);
-
- lto_streamer_cache_add_to_node_array (cache, ix, t);
-
- /* Indicate that the item was not present in the cache. */
- existed_p = false;
- }
- else
- {
- ix = (size_t) *slot - 1;
-
- if (!insert_at_next_slot_p && ix != *ix_p)
- {
- /* If the caller wants to insert T at a specific slot
- location, and ENTRY->TO does not match *IX_P, add T to
- the requested location slot. */
- ix = *ix_p;
- lto_streamer_cache_add_to_node_array (cache, ix, t);
- }
-
- /* Indicate that T was already in the cache. */
- existed_p = true;
- }
-
- if (ix_p)
- *ix_p = ix;
-
- return existed_p;
-}
-
-
-/* Insert tree node T in CACHE. If T already existed in the cache
- return true. Otherwise, return false.
-
- If IX_P is non-null, update it with the index into the cache where
- T has been stored. */
-
-bool
-lto_streamer_cache_insert (struct lto_streamer_cache_d *cache, tree t,
- unsigned *ix_p)
-{
- return lto_streamer_cache_insert_1 (cache, t, ix_p, true);
-}
-
-
-/* Insert tree node T in CACHE at slot IX. If T already
- existed in the cache return true. Otherwise, return false. */
-
-bool
-lto_streamer_cache_insert_at (struct lto_streamer_cache_d *cache,
- tree t, unsigned ix)
-{
- return lto_streamer_cache_insert_1 (cache, t, &ix, false);
-}
-
-
-/* Appends tree node T to CACHE, even if T already existed in it. */
-
-void
-lto_streamer_cache_append (struct lto_streamer_cache_d *cache, tree t)
-{
- unsigned ix = VEC_length (tree, cache->nodes);
- lto_streamer_cache_insert_1 (cache, t, &ix, false);
-}
-
-/* Return true if tree node T exists in CACHE, otherwise false. If IX_P is
- not NULL, write to *IX_P the index into the cache where T is stored
- ((unsigned)-1 if T is not found). */
-
-bool
-lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t,
- unsigned *ix_p)
-{
- void **slot;
- bool retval;
- unsigned ix;
-
- gcc_assert (t);
-
- slot = pointer_map_contains (cache->node_map, t);
- if (slot == NULL)
- {
- retval = false;
- ix = -1;
- }
- else
- {
- retval = true;
- ix = (size_t) *slot - 1;
- }
-
- if (ix_p)
- *ix_p = ix;
-
- return retval;
-}
-
-
-/* Return the tree node at slot IX in CACHE. */
-
-tree
-lto_streamer_cache_get (struct lto_streamer_cache_d *cache, unsigned ix)
-{
- gcc_assert (cache);
-
- /* Make sure we're not requesting something we don't have. */
- gcc_assert (ix < VEC_length (tree, cache->nodes));
-
- return VEC_index (tree, cache->nodes, ix);
-}
-
-
/* Record NODE in CACHE. */
static void
@@ -557,39 +336,6 @@ lto_preload_common_nodes (struct lto_streamer_cache_d *cache)
lto_record_common_node (cache, global_trees[i]);
}
-/* Create a cache of pickled nodes. */
-
-struct lto_streamer_cache_d *
-lto_streamer_cache_create (void)
-{
- struct lto_streamer_cache_d *cache;
-
- cache = XCNEW (struct lto_streamer_cache_d);
-
- cache->node_map = pointer_map_create ();
-
- /* Load all the well-known tree nodes that are always created by
- the compiler on startup. This prevents writing them out
- unnecessarily. */
- streamer_hooks.preload_common_nodes (cache);
-
- return cache;
-}
-
-
-/* Delete the streamer cache C. */
-
-void
-lto_streamer_cache_delete (struct lto_streamer_cache_d *c)
-{
- if (c == NULL)
- return;
-
- pointer_map_destroy (c->node_map);
- VEC_free (tree, heap, c->nodes);
- free (c);
-}
-
#ifdef LTO_STREAMER_DEBUG
static htab_t tree_htab;
@@ -756,12 +502,3 @@ lto_streamer_hooks_init (void)
streamer_hooks.write_tree = lto_streamer_write_tree;
streamer_hooks.read_tree = lto_streamer_read_tree;
}
-
-
-/* Initialize the current set of streamer hooks. */
-
-void
-streamer_hooks_init (void)
-{
- memset (&streamer_hooks, 0, sizeof (streamer_hooks));
-}