diff gcc/lto-streamer.h @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
line wrap: on
line diff
--- a/gcc/lto-streamer.h	Tue May 25 18:58:51 2010 +0900
+++ b/gcc/lto-streamer.h	Tue Mar 22 17:18:12 2011 +0900
@@ -31,6 +31,7 @@
 #include "vec.h"
 #include "vecprim.h"
 #include "alloc-pool.h"
+#include "gcov-io.h"
 
 /* Define when debugging the LTO streamer.  This causes the writer
    to output the numeric value for the memory address of the tree node
@@ -139,7 +140,7 @@
    sections a '.' and the section type are appended.  */
 #define LTO_SECTION_NAME_PREFIX         ".gnu.lto_"
 
-#define LTO_major_version 1
+#define LTO_major_version 2
 #define LTO_minor_version 0
 
 typedef unsigned char	lto_decl_flags_t;
@@ -156,17 +157,14 @@
 
 struct bitpack_d
 {
-  /* Total number of bits packed/unpacked so far.  */
-  size_t num_bits;
+  /* The position of the first unused or unconsumed bit in the word.  */
+  unsigned pos;
 
-  /* Values are stored contiguously, so there may be internal
-     fragmentation (words with unused bits).  Therefore, we need to
-     keep track of the first available bit in the last word of the
-     bitpack.  */
-  size_t first_unused_bit;
+  /* The current word we are (un)packing.  */
+  bitpack_word_t word;
 
-  /* Vector of words holding the packed values.  */
-  VEC(bitpack_word_t, heap) *values;
+  /* The lto_output_stream or the lto_input_block we are streaming to/from.  */
+  void *stream;
 };
 
 /* Tags representing the various IL objects written to the bytecode file
@@ -238,6 +236,7 @@
   LTO_type_ref,
   LTO_const_decl_ref,
   LTO_imported_decl_ref,
+  LTO_translation_unit_decl_ref,
   LTO_global_decl_ref,			/* Do not change.  */
 
   /* This tag must always be last.  */
@@ -498,6 +497,14 @@
 };
 typedef struct lto_varpool_encoder_d *lto_varpool_encoder_t;
 
+/* Return number of encoded nodes in ENCODER.  */
+
+static inline int
+lto_varpool_encoder_size (lto_varpool_encoder_t encoder)
+{
+  return VEC_length (varpool_node_ptr, encoder->nodes);
+}
+
 /* Mapping from indices to trees.  */
 struct GTY(()) lto_tree_ref_table
 {
@@ -595,8 +602,21 @@
 
   /* Hash new name of renamed global declaration to its original name.  */
   htab_t GTY((skip)) renaming_hash_table;
+
+  /* Linked list used temporarily in reader */
+  struct lto_file_decl_data *next;
+
+  /* Sub ID for merged objects. */
+  unsigned id;
+
+  /* Symbol resolutions for this file */
+  VEC(ld_plugin_symbol_resolution_t,heap) * GTY((skip)) resolutions;
+
+  struct gcov_ctr_summary GTY((skip)) profile_info;
 };
 
+typedef struct lto_file_decl_data *lto_file_decl_data_ptr;
+
 struct lto_char_ptr_base
 {
   char *ptr;
@@ -808,12 +828,8 @@
 extern const char *lto_tag_name (enum LTO_tags);
 extern bitmap lto_bitmap_alloc (void);
 extern void lto_bitmap_free (bitmap);
-extern char *lto_get_section_name (int, const char *);
+extern char *lto_get_section_name (int, const char *, struct lto_file_decl_data *);
 extern void print_lto_report (void);
-extern struct bitpack_d *bitpack_create (void);
-extern void bitpack_delete (struct bitpack_d *);
-extern void bp_pack_value (struct bitpack_d *, bitpack_word_t, unsigned);
-extern bitpack_word_t bp_unpack_value (struct bitpack_d *, unsigned);
 extern bool lto_streamer_cache_insert (struct lto_streamer_cache_d *, tree,
 				       int *, unsigned *);
 extern bool lto_streamer_cache_insert_at (struct lto_streamer_cache_d *, tree,
@@ -841,7 +857,6 @@
 				     const char *);
 extern void lto_input_constructors_and_inits (struct lto_file_decl_data *,
 					      const char *);
-extern struct bitpack_d *lto_input_bitpack (struct lto_input_block *);
 extern void lto_init_reader (void);
 extern struct data_in *lto_data_in_create (struct lto_file_decl_data *,
 				    const char *, unsigned,
@@ -854,7 +869,6 @@
 extern struct output_block *create_output_block (enum lto_section_type);
 extern void destroy_output_block (struct output_block *);
 extern void lto_output_tree (struct output_block *, tree, bool);
-extern void lto_output_bitpack (struct lto_output_stream *, struct bitpack_d *);
 extern void produce_asm (struct output_block *ob, tree fn);
 
 
@@ -900,6 +914,7 @@
 extern tree lto_symtab_prevailing_decl (tree decl);
 extern enum ld_plugin_symbol_resolution lto_symtab_get_resolution (tree decl);
 extern void lto_symtab_free (void);
+extern GTY(()) VEC(tree,gc) *lto_global_var_decls;
 
 
 /* In lto-opts.c.  */
@@ -1067,4 +1082,85 @@
 DEFINE_DECL_STREAM_FUNCS (NAMESPACE_DECL, namespace_decl)
 DEFINE_DECL_STREAM_FUNCS (LABEL_DECL, label_decl)
 
+/* Returns a new bit-packing context for bit-packing into S.  */
+static inline struct bitpack_d
+bitpack_create (struct lto_output_stream *s)
+{
+  struct bitpack_d bp;
+  bp.pos = 0;
+  bp.word = 0;
+  bp.stream = (void *)s;
+  return bp;
+}
+
+/* Pack the NBITS bit sized value VAL into the bit-packing context BP.  */
+static inline void
+bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits)
+{
+  bitpack_word_t word = bp->word;
+  int pos = bp->pos;
+  /* If val does not fit into the current bitpack word switch to the
+     next one.  */
+  if (pos + nbits > BITS_PER_BITPACK_WORD)
+    {
+      lto_output_uleb128_stream ((struct lto_output_stream *) bp->stream, word);
+      word = val;
+      pos = nbits;
+    }
+  else
+    {
+      word |= val << pos;
+      pos += nbits;
+    }
+  bp->word = word;
+  bp->pos = pos;
+}
+
+/* Finishes bit-packing of BP.  */
+static inline void
+lto_output_bitpack (struct bitpack_d *bp)
+{
+  lto_output_uleb128_stream ((struct lto_output_stream *) bp->stream,
+			     bp->word);
+  bp->word = 0;
+  bp->pos = 0;
+}
+
+/* Returns a new bit-packing context for bit-unpacking from IB.  */
+static inline struct bitpack_d
+lto_input_bitpack (struct lto_input_block *ib)
+{
+  struct bitpack_d bp;
+  bp.word = lto_input_uleb128 (ib);
+  bp.pos = 0;
+  bp.stream = (void *)ib;
+  return bp;
+}
+
+/* Unpacks NBITS bits from the bit-packing context BP and returns them.  */
+static inline bitpack_word_t
+bp_unpack_value (struct bitpack_d *bp, unsigned nbits)
+{
+  bitpack_word_t mask, val;
+  int pos = bp->pos;
+
+  mask = (nbits == BITS_PER_BITPACK_WORD
+	  ? (bitpack_word_t) -1
+	  : ((bitpack_word_t) 1 << nbits) - 1);
+
+  /* If there are not continuous nbits in the current bitpack word
+     switch to the next one.  */
+  if (pos + nbits > BITS_PER_BITPACK_WORD)
+    {
+      bp->word = val = lto_input_uleb128 ((struct lto_input_block *)bp->stream);
+      bp->pos = nbits;
+      return val & mask;
+    }
+  val = bp->word;
+  val >>= pos;
+  bp->pos = pos + nbits;
+
+  return val & mask;
+}
+
 #endif /* GCC_LTO_STREAMER_H  */