OSDN Git Service

* cgraphbuild.c (record_reference_ctx): Add varpool_node.
[pf3gnuchains/gcc-fork.git] / gcc / lto-streamer.h
index c3880b6..4f3d60d 100644 (file)
@@ -1,7 +1,7 @@
 /* Data structures and declarations used for reading and writing
    GIMPLE to a file stream.
 
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
    Contributed by Doug Kwan <dougkwan@google.com>
 
 This file is part of GCC.
@@ -61,7 +61,7 @@ along with GCC; see the file COPYING3.  If not see
       entry, there is word with the offset within the section to the
       entry.
 
-   7) THE LABEL NAMES.  
+   7) THE LABEL NAMES.
 
       Since most labels do not have names, this section my be of zero
       length.  It consists of an array of string table references, one
@@ -70,18 +70,18 @@ along with GCC; see the file COPYING3.  If not see
       the negative ones do not.  The positive index can be used to
       find the name in this array.
 
-   9) THE CFG. 
+   9) THE CFG.
 
    10) Index into the local decls.  Since local decls can have local
       decls inside them, they must be read in randomly in order to
-      properly restore them.  
+      properly restore them.
 
    11-12) GIMPLE FOR THE LOCAL DECLS AND THE FUNCTION BODY.
 
      The gimple consists of a set of records.
 
      THE FUNCTION
-       
+
      At the top level of (8) is the function. It consists of five
      pieces:
 
@@ -172,7 +172,7 @@ struct bitpack_d
    (GIMPLE statements, basic blocks, EH regions, tree nodes, etc).
 
    NOTE, when adding new LTO tags, also update lto_tag_name.  */
-enum LTO_tags 
+enum LTO_tags
 {
   LTO_null = 0,
 
@@ -256,11 +256,12 @@ enum lto_section_type
   LTO_section_function_body,
   LTO_section_static_initializer,
   LTO_section_cgraph,
+  LTO_section_varpool,
+  LTO_section_refs,
   LTO_section_jump_functions,
   LTO_section_ipa_pure_const,
   LTO_section_ipa_reference,
   LTO_section_symtab,
-  LTO_section_wpa_fixup,
   LTO_section_opts,
   LTO_N_SECTION_TYPES          /* Must be last.  */
 };
@@ -284,7 +285,7 @@ DEF_VEC_ALLOC_I(ld_plugin_symbol_resolution_t, heap);
 
 
 /* Macro to define convenience functions for type and decl streams
-   in lto_file_decl_data.  */ 
+   in lto_file_decl_data.  */
 #define DEFINE_DECL_STREAM_FUNCS(UPPER_NAME, name) \
 static inline tree \
 lto_file_decl_data_get_ ## name (struct lto_file_decl_data *data, \
@@ -307,17 +308,17 @@ lto_file_decl_data_num_ ## name ## s (struct lto_file_decl_data *data) \
    or function.  The first parameter is the file data that contains
    the information.  The second parameter is the type of information
    to be obtained.  The third parameter is the name of the function
-   and is only used when finding a function body; otherwise it is 
+   and is only used when finding a function body; otherwise it is
    NULL.  The fourth parameter is the length of the data returned.  */
-typedef const char* (lto_get_section_data_f) (struct lto_file_decl_data *, 
+typedef const char* (lto_get_section_data_f) (struct lto_file_decl_data *,
                                              enum lto_section_type,
-                                             const char *, 
+                                             const char *,
                                              size_t *);
 
 /* Return the data found from the above call.  The first three
    parameters are the same as above.  The fourth parameter is the data
    itself and the fifth is the lenght of the data. */
-typedef void (lto_free_section_data_f) (struct lto_file_decl_data *, 
+typedef void (lto_free_section_data_f) (struct lto_file_decl_data *,
                                        enum lto_section_type,
                                        const char *,
                                        const char *,
@@ -357,7 +358,7 @@ struct lto_streamer_cache_d
 
 
 /* Structure used as buffer for reading an LTO file.  */
-struct lto_input_block 
+struct lto_input_block
 {
   const char *data;
   unsigned int p;
@@ -466,11 +467,25 @@ struct lto_cgraph_encoder_d
 
 typedef struct lto_cgraph_encoder_d *lto_cgraph_encoder_t;
 
+/* Encoder data structure used to stream callgraph nodes.  */
+struct lto_varpool_encoder_d
+{
+  /* Map nodes to reference number. */
+  struct pointer_map_t *map;
+
+  /* Map reference number to node. */
+  VEC(varpool_node_ptr,heap) *nodes;
+
+  /* Map of nodes where we want to output initializer.  */
+  struct pointer_set_t *initializer;
+};
+typedef struct lto_varpool_encoder_d *lto_varpool_encoder_t;
+
 /* Mapping from indices to trees.  */
-struct lto_tree_ref_table
+struct GTY(()) lto_tree_ref_table
 {
   /* Array of referenced trees . */
-  tree *trees;
+  tree * GTY((length ("%h.size"))) trees;
 
   /* Size of array. */
   unsigned int size;
@@ -496,7 +511,7 @@ struct lto_tree_ref_encoder
 
 
 /* Structure to hold states of input scope.  */
-struct lto_in_decl_state
+struct GTY(()) lto_in_decl_state
 {
   /* Array of lto_in_decl_buffers to store type and decls streams. */
   struct lto_tree_ref_table streams[LTO_N_DECL_STREAMS];
@@ -520,6 +535,9 @@ struct lto_out_decl_state
   /* Encoder for cgraph nodes.  */
   lto_cgraph_encoder_t cgraph_node_encoder;
 
+  /* Encoder for varpool nodes.  */
+  lto_varpool_encoder_t varpool_node_encoder;
+
   /* If this out-decl state belongs to a function, fn_decl points to that
      function.  Otherwise, it is NULL. */
   tree fn_decl;
@@ -534,7 +552,7 @@ DEF_VEC_ALLOC_P(lto_out_decl_state_ptr, heap);
    by lto.  This structure contains the tables that are needed by the
    serialized functions and ipa passes to connect themselves to the
    global types and decls as they are reconstituted.  */
-struct lto_file_decl_data
+struct GTY(()) lto_file_decl_data
 {
   /* Decl state currently used. */
   struct lto_in_decl_state *current_decl_state;
@@ -544,22 +562,22 @@ struct lto_file_decl_data
   struct lto_in_decl_state *global_decl_state;
 
   /* Table of cgraph nodes present in this file.  */
-  lto_cgraph_encoder_t cgraph_node_encoder;
+  lto_cgraph_encoder_t GTY((skip)) cgraph_node_encoder;
+
+  /* Table of varpool nodes present in this file.  */
+  lto_varpool_encoder_t GTY((skip)) varpool_node_encoder;
 
   /* Hash table maps lto-related section names to location in file.  */
-  htab_t function_decl_states;
+  htab_t GTY((param_is (struct lto_in_decl_state))) function_decl_states;
 
   /* The .o file that these offsets relate to.  */
-  const char *file_name;
-
-  /* Nonzero if this file should be recompiled with LTRANS.  */
-  unsigned needs_ltrans_p : 1;
+  const char *GTY((skip)) file_name;
 
   /* Hash table maps lto-related section names to location in file.  */
-  htab_t section_hash_table;
+  htab_t GTY((skip)) section_hash_table;
 
   /* Hash new name of renamed global declaration to its original name.  */
-  htab_t renaming_hash_table;
+  htab_t GTY((skip)) renaming_hash_table;
 };
 
 struct lto_char_ptr_base
@@ -673,7 +691,7 @@ struct data_in
 
   /* Number of named labels.  Used to find the index of unnamed labels
      since they share space with the named labels.  */
-  unsigned int num_named_labels;  
+  unsigned int num_named_labels;
 
   /* Number of unnamed labels.  */
   unsigned int num_unnamed_labels;
@@ -692,13 +710,13 @@ struct data_in
 
 /* In lto-section-in.c  */
 extern struct lto_input_block * lto_create_simple_input_block (
-                              struct lto_file_decl_data *, 
+                              struct lto_file_decl_data *,
                               enum lto_section_type, const char **, size_t *);
 extern void
-lto_destroy_simple_input_block (struct lto_file_decl_data *, 
+lto_destroy_simple_input_block (struct lto_file_decl_data *,
                                enum lto_section_type,
                                struct lto_input_block *, const char *, size_t);
-extern void lto_set_in_hooks (struct lto_file_decl_data **, 
+extern void lto_set_in_hooks (struct lto_file_decl_data **,
                              lto_get_section_data_f *,
                              lto_free_section_data_f *);
 extern struct lto_file_decl_data **lto_get_file_decl_data (void);
@@ -767,10 +785,6 @@ extern void lto_push_out_decl_state (struct lto_out_decl_state *);
 extern struct lto_out_decl_state *lto_pop_out_decl_state (void);
 extern void lto_record_function_out_decl_state (tree,
                                                struct lto_out_decl_state *);
-extern void lto_new_extern_inline_states (void);
-extern void lto_delete_extern_inline_states (void);
-extern void lto_force_functions_extern_inline (bitmap decls);
-extern bool lto_forced_extern_inline_p (tree fn_decl);
 
 
 /* In lto-streamer.c.  */
@@ -832,9 +846,19 @@ struct cgraph_node *lto_cgraph_encoder_deref (lto_cgraph_encoder_t, int);
 int lto_cgraph_encoder_lookup (lto_cgraph_encoder_t, struct cgraph_node *);
 lto_cgraph_encoder_t lto_cgraph_encoder_new (void);
 int lto_cgraph_encoder_encode (lto_cgraph_encoder_t, struct cgraph_node *);
-void lto_cgraph_encoder_delete (lto_cgraph_encoder_t encoder);
-void output_cgraph (cgraph_node_set);
+void lto_cgraph_encoder_delete (lto_cgraph_encoder_t);
+struct varpool_node *lto_varpool_encoder_deref (lto_varpool_encoder_t, int);
+int lto_varpool_encoder_lookup (lto_varpool_encoder_t, struct varpool_node *);
+lto_varpool_encoder_t lto_varpool_encoder_new (void);
+int lto_varpool_encoder_encode (lto_varpool_encoder_t, struct varpool_node *);
+void lto_varpool_encoder_delete (lto_varpool_encoder_t);
+bool lto_varpool_encoder_encode_initializer_p (lto_varpool_encoder_t,
+                                              struct varpool_node *);
+void output_cgraph (cgraph_node_set, varpool_node_set);
 void input_cgraph (void);
+bool referenced_from_other_partition_p (struct ipa_ref_list *,
+                                       cgraph_node_set,
+                                       varpool_node_set vset);
 
 
 /* In lto-symtab.c.  */
@@ -924,38 +948,6 @@ lto_tag_to_tree_code (enum LTO_tags tag)
   return (enum tree_code) ((unsigned) tag - 1);
 }
 
-
-/* Return true if FILE needs to be compiled with LTRANS.  */
-static inline bool
-lto_file_needs_ltrans_p (struct lto_file_decl_data *file)
-{
-  return file->needs_ltrans_p != 0;
-}
-
-
-/* Mark FILE to be compiled with LTRANS.  */
-static inline void
-lto_mark_file_for_ltrans (struct lto_file_decl_data *file)
-{
-  file->needs_ltrans_p = 1;
-}
-
-
-/* Return true if any files in node set SET need to be compiled
-   with LTRANS.  */
-static inline bool
-cgraph_node_set_needs_ltrans_p (cgraph_node_set set)
-{
-  cgraph_node_set_iterator csi;
-
-  for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
-    if (lto_file_needs_ltrans_p (csi_node (csi)->local.lto_file_data))
-      return true;
-
-  return false;
-}
-
-
 /* Initialize an lto_out_decl_buffer ENCODER.  */
 static inline void
 lto_init_tree_ref_encoder (struct lto_tree_ref_encoder *encoder,