OSDN Git Service

* config/i386/winnt.c (ix86_handle_dll_attribute): Set
[pf3gnuchains/gcc-fork.git] / gcc / varasm.c
index e13efe0..edd0262 100644 (file)
@@ -36,10 +36,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "expr.h"
 #include "hard-reg-set.h"
 #include "regs.h"
-#include "output.h"
 #include "real.h"
+#include "output.h"
 #include "toplev.h"
-#include "obstack.h"
 #include "hashtab.h"
 #include "c-pragma.h"
 #include "c-tree.h"
@@ -66,17 +65,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 const char *first_global_object_name;
 const char *weak_global_object_name;
 
-extern struct obstack permanent_obstack;
-#define obstack_chunk_alloc xmalloc
-
 struct addr_const;
-struct constant_descriptor;
+struct constant_descriptor_rtx;
 struct rtx_const;
 struct pool_constant;
 
 #define MAX_RTX_HASH_TABLE 61
 
-struct varasm_status
+struct varasm_status GTY(())
 {
   /* Hash facility for making memory-constants
      from constant rtl-expressions.  It is used on RISC machines
@@ -86,11 +82,14 @@ struct varasm_status
      This pool of constants is reinitialized for each function
      so each function gets its own constants-pool that comes right before
      it.  */
-  struct constant_descriptor **x_const_rtx_hash_table;
-  struct pool_constant **x_const_rtx_sym_hash_table;
+  struct constant_descriptor_rtx ** GTY ((length ("MAX_RTX_HASH_TABLE")))
+    x_const_rtx_hash_table;
+  struct pool_constant ** GTY ((length ("MAX_RTX_HASH_TABLE")))
+    x_const_rtx_sym_hash_table;
 
   /* Pointers to first and last constant in pool.  */
-  struct pool_constant *x_first_pool, *x_last_pool;
+  struct pool_constant *x_first_pool;
+  struct pool_constant *x_last_pool;
 
   /* Current offset in constant pool (does not include any machine-specific
      header).  */
@@ -138,20 +137,16 @@ static const char *strip_reg_name PARAMS ((const char *));
 static int contains_pointers_p         PARAMS ((tree));
 static void decode_addr_const          PARAMS ((tree, struct addr_const *));
 static int const_hash                  PARAMS ((tree));
-static int compare_constant            PARAMS ((tree,
-                                              struct constant_descriptor *));
-static const unsigned char *compare_constant_1  PARAMS ((tree, const unsigned char *));
-static struct constant_descriptor *record_constant PARAMS ((tree));
-static void record_constant_1          PARAMS ((tree));
+static int compare_constant            PARAMS ((tree, tree));
 static tree copy_constant              PARAMS ((tree));
 static void output_constant_def_contents  PARAMS ((tree, int, int));
 static void decode_rtx_const           PARAMS ((enum machine_mode, rtx,
                                               struct rtx_const *));
 static int const_hash_rtx              PARAMS ((enum machine_mode, rtx));
-static int compare_constant_rtx                PARAMS ((enum machine_mode, rtx,
-                                              struct constant_descriptor *));
-static struct constant_descriptor *record_constant_rtx PARAMS ((enum machine_mode,
-                                                             rtx));
+static int compare_constant_rtx
+  PARAMS ((enum machine_mode, rtx, struct constant_descriptor_rtx *));
+static struct constant_descriptor_rtx * record_constant_rtx
+  PARAMS ((enum machine_mode, rtx));
 static struct pool_constant *find_pool_constant PARAMS ((struct function *, rtx));
 static void mark_constant_pool         PARAMS ((void));
 static void mark_constants             PARAMS ((rtx));
@@ -175,14 +170,9 @@ static void asm_output_aligned_bss PARAMS ((FILE *, tree, const char *,
                                                 int, int));
 #endif
 #endif /* BSS_SECTION_ASM_OP */
-static void mark_pool_constant          PARAMS ((struct pool_constant *));
-static void mark_const_hash_entry      PARAMS ((void *));
-static int mark_const_str_htab_1       PARAMS ((void **, void *));
-static void mark_const_str_htab                PARAMS ((void *));
 static hashval_t const_str_htab_hash   PARAMS ((const void *x));
 static int const_str_htab_eq           PARAMS ((const void *x, const void *y));
-static void const_str_htab_del         PARAMS ((void *));
-static void asm_emit_uninitialised     PARAMS ((tree, const char*, int, int));
+static bool asm_emit_uninitialised     PARAMS ((tree, const char*, int, int));
 static void resolve_unique_section     PARAMS ((tree, int, int));
 static void mark_weak                   PARAMS ((tree));
 \f
@@ -196,6 +186,9 @@ static enum in_section { no_section, in_text, in_data, in_named
 #ifdef DTORS_SECTION_ASM_OP
   , in_dtors
 #endif
+#ifdef READONLY_DATA_SECTION_ASM_OP
+  , in_readonly_data
+#endif
 #ifdef EXTRA_SECTIONS
   , EXTRA_SECTIONS
 #endif
@@ -234,12 +227,12 @@ text_section ()
 {
   if (in_section != in_text)
     {
+      in_section = in_text;
 #ifdef TEXT_SECTION
       TEXT_SECTION ();
 #else
       fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
 #endif
-      in_section = in_text;
     }
 }
 
@@ -250,6 +243,7 @@ data_section ()
 {
   if (in_section != in_data)
     {
+      in_section = in_data;
       if (flag_shared_data)
        {
 #ifdef SHARED_SECTION_ASM_OP
@@ -260,8 +254,6 @@ data_section ()
        }
       else
        fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
-
-      in_section = in_data;
     }
 }
 
@@ -284,8 +276,17 @@ readonly_data_section ()
 #ifdef READONLY_DATA_SECTION
   READONLY_DATA_SECTION ();  /* Note this can call data_section.  */
 #else
+#ifdef READONLY_DATA_SECTION_ASM_OP
+  if (in_section != in_readonly_data)
+    {
+      in_section = in_readonly_data;
+      fputs (READONLY_DATA_SECTION_ASM_OP, asm_out_file);
+      fputc ('\n', asm_out_file);
+    }
+#else
   text_section ();
 #endif
+#endif
 }
 
 /* Determine if we're in the text section.  */
@@ -505,7 +506,7 @@ asm_output_bss (file, decl, name, size, rounded)
      const char *name;
      int size ATTRIBUTE_UNUSED, rounded;
 {
-  ASM_GLOBALIZE_LABEL (file, name);
+  (*targetm.asm_out.globalize_label) (file, name);
   bss_section ();
 #ifdef ASM_DECLARE_OBJECT_NAME
   last_assemble_variable_decl = decl;
@@ -514,7 +515,7 @@ asm_output_bss (file, decl, name, size, rounded)
   /* Standard thing is just output label for the object.  */
   ASM_OUTPUT_LABEL (file, name);
 #endif /* ASM_DECLARE_OBJECT_NAME */
-  ASM_OUTPUT_SKIP (file, rounded);
+  ASM_OUTPUT_SKIP (file, rounded ? rounded : 1);
 }
 
 #endif
@@ -533,7 +534,7 @@ asm_output_aligned_bss (file, decl, name, size, align)
      const char *name;
      int size, align;
 {
-  ASM_GLOBALIZE_LABEL (file, name);
+  (*targetm.asm_out.globalize_label) (file, name);
   bss_section ();
   ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
 #ifdef ASM_DECLARE_OBJECT_NAME
@@ -822,14 +823,15 @@ make_decl_rtl (decl, asmspec)
        SET_DECL_RTL (decl, adjust_address_nv (DECL_RTL (decl),
                                               DECL_MODE (decl), 0));
 
-      /* ??? Another way to do this would be to do what halfpic.c does
-        and maintain a hashed table of such critters.  */
+      /* ??? Another way to do this would be to maintain a hashed
+        table of such critters.  Instead of adding stuff to a DECL
+        to give certain attributes to it, we could use an external
+        hash map from DECL to set of attributes.  */
+
       /* Let the target reassign the RTL if it wants.
         This is necessary, for example, when one machine specific
         decl attribute overrides another.  */
-#ifdef ENCODE_SECTION_INFO
-      ENCODE_SECTION_INFO (decl, false);
-#endif
+      (* targetm.encode_section_info) (decl, false);
       return;
     }
 
@@ -913,6 +915,10 @@ make_decl_rtl (decl, asmspec)
       && DECL_COMMON (decl))
     DECL_COMMON (decl) = 0;
 
+  /* Variables can't be both common and weak.  */
+  if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (decl))
+    DECL_COMMON (decl) = 0;
+
   /* Can't use just the variable's own name for a variable
      whose scope is less than the whole file, unless it's a member
      of a local class (which will already be unambiguous).
@@ -953,9 +959,7 @@ make_decl_rtl (decl, asmspec)
      such as that it is a function name.
      If the name is changed, the macro ASM_OUTPUT_LABELREF
      will have to know how to strip this information.  */
-#ifdef ENCODE_SECTION_INFO
-  ENCODE_SECTION_INFO (decl, true);
-#endif
+  (* targetm.encode_section_info) (decl, true);
 }
 
 /* Make the rtl for variable VAR be volatile.
@@ -1200,9 +1204,8 @@ assemble_start_function (decl, fnname)
          const char *p;
          char *name;
 
-         STRIP_NAME_ENCODING (p, fnname);
-         name = permalloc (strlen (p) + 1);
-         strcpy (name, p);
+         p = (* targetm.strip_name_encoding) (fnname);
+         name = xstrdup (p);
 
          if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))
            first_global_object_name = name;
@@ -1346,7 +1349,7 @@ assemble_string (p, size)
 #endif
 #endif
 
-static void
+static bool
 asm_emit_uninitialised (decl, name, size, rounded)
      tree decl;
      const char *name;
@@ -1361,13 +1364,17 @@ asm_emit_uninitialised (decl, name, size, rounded)
   }
   destination = asm_dest_local;
 
+  /* ??? We should handle .bss via select_section mechanisms rather than
+     via special target hooks.  That would eliminate this special case.  */
   if (TREE_PUBLIC (decl))
     {
-#if defined ASM_EMIT_BSS
-      if (! DECL_COMMON (decl))
+      if (!DECL_COMMON (decl))
+#ifdef ASM_EMIT_BSS
        destination = asm_dest_bss;
-      else
+#else
+       return false;
 #endif
+      else
        destination = asm_dest_common;
     }
 
@@ -1416,7 +1423,7 @@ asm_emit_uninitialised (decl, name, size, rounded)
       abort ();
     }
 
-  return;
+  return true;
 }
 
 /* Assemble everything that is needed for a variable or function declaration.
@@ -1490,7 +1497,8 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
   if (TREE_ASM_WRITTEN (decl))
     return;
 
-  /* Make sure ENCODE_SECTION_INFO is invoked before we set ASM_WRITTEN.  */
+  /* Make sure targetm.encode_section_info is invoked before we set
+     ASM_WRITTEN.  */
   decl_rtl = DECL_RTL (decl);
 
   TREE_ASM_WRITTEN (decl) = 1;
@@ -1519,9 +1527,8 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
       const char *p;
       char *xname;
 
-      STRIP_NAME_ENCODING (p, name);
-      xname = permalloc (strlen (p) + 1);
-      strcpy (xname, p);
+      p = (* targetm.strip_name_encoding) (name);
+      xname = xstrdup (p);
       first_global_object_name = xname;
     }
 
@@ -1545,7 +1552,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
     {
       warning_with_decl (decl,
        "alignment of `%s' is greater than maximum object file alignment. Using %d",
-                    MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
+                        MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
       align = MAX_OFILE_ALIGNMENT;
     }
 
@@ -1557,7 +1564,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
 #endif
 #ifdef CONSTANT_ALIGNMENT
       if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
-        align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
+       align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
 #endif
     }
 
@@ -1578,19 +1585,20 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
 
   /* Handle uninitialized definitions.  */
 
-  if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node
-#if defined ASM_EMIT_BSS
-       || (flag_zero_initialized_in_bss
-          && initializer_zerop (DECL_INITIAL (decl)))
-#endif
-       )
-      /* If the target can't output uninitialized but not common global data
-        in .bss, then we have to use .data.  */
-#if ! defined ASM_EMIT_BSS
-      && DECL_COMMON (decl)
-#endif
-      && DECL_SECTION_NAME (decl) == NULL_TREE
-      && ! dont_output_data)
+  /* If the decl has been given an explicit section name, then it
+     isn't common, and shouldn't be handled as such.  */
+  if (DECL_SECTION_NAME (decl) || dont_output_data)
+    ;
+  /* We don't implement common thread-local data at present.  */
+  else if (DECL_THREAD_LOCAL (decl))
+    {
+      if (DECL_COMMON (decl))
+       sorry ("thread-local COMMON data not implemented");
+    }
+  else if (DECL_INITIAL (decl) == 0
+          || DECL_INITIAL (decl) == error_mark_node
+          || (flag_zero_initialized_in_bss
+              && initializer_zerop (DECL_INITIAL (decl))))
     {
       unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);
       unsigned HOST_WIDE_INT rounded = size;
@@ -1606,16 +1614,16 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
       rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
                 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
 
-/* Don't continue this line--convex cc version 4.1 would lose.  */
 #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
       if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded)
-         warning_with_decl
-           (decl, "requested alignment for %s is greater than implemented alignment of %d",rounded);
+       warning_with_decl
+         (decl, "requested alignment for %s is greater than implemented alignment of %d",rounded);
 #endif
 
-      asm_emit_uninitialised (decl, name, size, rounded);
-
-      return;
+      /* If the target cannot output uninitialized but not common global data
+        in .bss, then we have to use .data, so fall through.  */
+      if (asm_emit_uninitialised (decl, name, size, rounded))
+       return;
     }
 
   /* Handle initialized definitions.
@@ -1746,15 +1754,6 @@ assemble_external_libcall (fun)
 #endif
 }
 
-/* Declare the label NAME global.  */
-
-void
-assemble_global (name)
-     const char *name ATTRIBUTE_UNUSED;
-{
-  ASM_GLOBALIZE_LABEL (asm_out_file, name);
-}
-
 /* Assemble a label named NAME.  */
 
 void
@@ -1778,7 +1777,7 @@ assemble_name (file, name)
   const char *real_name;
   tree id;
 
-  STRIP_NAME_ENCODING (real_name, name);
+  real_name = (* targetm.strip_name_encoding) (name);
 
   id = maybe_get_identifier (real_name);
   if (id)
@@ -2083,7 +2082,7 @@ assemble_real (d, mode, align)
    Store them both in the structure *VALUE.
    Abort if EXP does not reduce.  */
 
-struct addr_const
+struct addr_const GTY(())
 {
   rtx base;
   HOST_WIDE_INT offset;
@@ -2154,51 +2153,50 @@ decode_addr_const (exp, value)
 }
 \f
 /* We do RTX_UNSPEC + XINT (blah), so nothing can go after RTX_UNSPEC.  */
-enum kind { RTX_UNKNOWN, RTX_DOUBLE, RTX_INT, RTX_VECTOR, RTX_UNSPEC };
-struct rtx_const
+enum kind { RTX_UNKNOWN, RTX_DOUBLE, RTX_VECTOR, RTX_INT, RTX_UNSPEC };
+struct rtx_const GTY(())
 {
   ENUM_BITFIELD(kind) kind : 16;
   ENUM_BITFIELD(machine_mode) mode : 16;
-  union {
+  union rtx_const_un {
     REAL_VALUE_TYPE du;
-    struct addr_const addr;
-    struct {HOST_WIDE_INT high, low;} di;
+    struct addr_const GTY ((tag ("1"))) addr;
+    struct rtx_const_u_di {
+      HOST_WIDE_INT high;
+      HOST_WIDE_INT low;
+    } GTY ((tag ("0"))) di;
 
     /* The max vector size we have is 8 wide.  This should be enough.  */
-    HOST_WIDE_INT veclo[16];
-    HOST_WIDE_INT vechi[16];
-  } un;
+    struct rtx_const_vec {
+      HOST_WIDE_INT veclo;
+      HOST_WIDE_INT vechi; 
+    } GTY ((tag ("2"))) vec[16];
+  } GTY ((desc ("%1.kind >= RTX_INT"), descbits ("1"))) un;
 };
 
 /* Uniquize all constants that appear in memory.
    Each constant in memory thus far output is recorded
-   in `const_hash_table' with a `struct constant_descriptor'
-   that contains a polish representation of the value of
-   the constant.
-
-   We cannot store the trees in the hash table
-   because the trees may be temporary.  */
+   in `const_hash_table'.  */
 
-struct constant_descriptor
+struct constant_descriptor_tree GTY(())
 {
-  struct constant_descriptor *next;
+  /* More constant_descriptors with the same hash code.  */
+  struct constant_descriptor_tree *next;
+
+  /* The label of the constant.  */
   const char *label;
+
+  /* A MEM for the constant.  */
   rtx rtl;
-  /* Make sure the data is reasonably aligned.  */
-  union
-  {
-    unsigned char contents[1];
-#ifdef HAVE_LONG_DOUBLE
-    long double d;
-#else
-    double d;
-#endif
-  } u;
+
+  /* The value of the constant.  */
+  tree value;
 };
 
 #define HASHBITS 30
 #define MAX_HASH_TABLE 1009
-static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
+static GTY(()) struct constant_descriptor_tree *
+  const_hash_table[MAX_HASH_TABLE];
 
 /* We maintain a hash table of STRING_CST values.  Unless we are asked to force
    out a string constant, we defer output of the constants until we know
@@ -2207,50 +2205,14 @@ static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
 
 #define STRHASH(x) ((hashval_t) ((long) (x) >> 3))
 
-struct deferred_string
+struct deferred_string GTY(())
 {
   const char *label;
   tree exp;
   int labelno;
 };
 
-static htab_t const_str_htab;
-
-/* Mark a const_hash_table descriptor for GC.  */
-
-static void
-mark_const_hash_entry (ptr)
-     void *ptr;
-{
-  struct constant_descriptor *desc = * (struct constant_descriptor **) ptr;
-
-  while (desc)
-    {
-      ggc_mark_rtx (desc->rtl);
-      desc = desc->next;
-    }
-}
-
-/* Mark the hash-table element X (which is really a pointer to an
-   struct deferred_string *).  */
-
-static int
-mark_const_str_htab_1 (x, data)
-     void **x;
-     void *data ATTRIBUTE_UNUSED;
-{
-  ggc_mark_tree (((struct deferred_string *) *x)->exp);
-  return 1;
-}
-
-/* Mark a const_str_htab for GC.  */
-
-static void
-mark_const_str_htab (htab)
-     void *htab;
-{
-  htab_traverse (*((htab_t *) htab), mark_const_str_htab_1, NULL);
-}
+static GTY ((param_is (struct deferred_string))) htab_t const_str_htab;
 
 /* Returns a hash code for X (which is a really a
    struct deferred_string *).  */
@@ -2274,15 +2236,6 @@ const_str_htab_eq (x, y)
   return (((const struct deferred_string *) x)->label == (const char *) y);
 }
 
-/* Delete the hash table entry dfsp.  */
-
-static void
-const_str_htab_del (dfsp)
-     void *dfsp;
-{
-  free (dfsp);
-}
-
 /* Compute a hash code for a constant expression.  */
 
 static int
@@ -2354,6 +2307,7 @@ const_hash (exp)
        }
 
     case ADDR_EXPR:
+    case FDESC_EXPR:
       {
        struct addr_const value;
 
@@ -2401,457 +2355,159 @@ const_hash (exp)
   hi %= MAX_HASH_TABLE;
   return hi;
 }
-\f
-/* Compare a constant expression EXP with a constant-descriptor DESC.
-   Return 1 if DESC describes a constant with the same value as EXP.  */
 
-static int
-compare_constant (exp, desc)
-     tree exp;
-     struct constant_descriptor *desc;
-{
-  return 0 != compare_constant_1 (exp, desc->u.contents);
-}
+/* Compare t1 and t2, and return 1 only if they are known to result in
+   the same bit pattern on output.  */
 
-/* Compare constant expression EXP with a substring P of a constant descriptor.
-   If they match, return a pointer to the end of the substring matched.
-   If they do not match, return 0.
-
-   Since descriptors are written in polish prefix notation,
-   this function can be used recursively to test one operand of EXP
-   against a subdescriptor, and if it succeeds it returns the
-   address of the subdescriptor for the next operand.  */
-
-static const unsigned char *
-compare_constant_1 (exp, p)
-     tree exp;
-     const unsigned char *p;
+static int
+compare_constant (t1, t2)
+     tree t1;
+     tree t2;
 {
-  const unsigned char *strp;
-  int len;
-  enum tree_code code = TREE_CODE (exp);
+  enum tree_code typecode;
 
-  if (code != (enum tree_code) *p++)
+  if (t1 == NULL_TREE)
+    return t2 == NULL_TREE;
+  if (t2 == NULL_TREE)
     return 0;
 
-  /* Either set STRP, P and LEN to pointers and length to compare and exit the
-     switch, or return the result of the comparison.  */
+  if (TREE_CODE (t1) != TREE_CODE (t2))
+    return 0;
 
-  switch (code)
+  switch (TREE_CODE (t1))
     {
     case INTEGER_CST:
       /* Integer constants are the same only if the same width of type.  */
-      if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
+      if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
        return 0;
-
-      strp = (unsigned char *) &TREE_INT_CST (exp);
-      len = sizeof TREE_INT_CST (exp);
-      break;
+      return tree_int_cst_equal (t1, t2);
 
     case REAL_CST:
       /* Real constants are the same only if the same width of type.  */
-      if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
+      if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
        return 0;
 
-      strp = (unsigned char *) &TREE_REAL_CST (exp);
-      len = sizeof TREE_REAL_CST (exp);
-      break;
+      return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
 
     case STRING_CST:
       if (flag_writable_strings)
        return 0;
 
-      if ((enum machine_mode) *p++ != TYPE_MODE (TREE_TYPE (exp)))
-       return 0;
-
-      strp = (const unsigned char *) TREE_STRING_POINTER (exp);
-      len = TREE_STRING_LENGTH (exp);
-      if (memcmp ((char *) &TREE_STRING_LENGTH (exp), p,
-                 sizeof TREE_STRING_LENGTH (exp)))
+      if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
        return 0;
 
-      p += sizeof TREE_STRING_LENGTH (exp);
-      break;
+      return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
+             && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
+                        TREE_STRING_LENGTH (t1)));
 
     case COMPLEX_CST:
-      p = compare_constant_1 (TREE_REALPART (exp), p);
-      if (p == 0)
-       return 0;
-
-      return compare_constant_1 (TREE_IMAGPART (exp), p);
+      return (compare_constant (TREE_REALPART (t1), TREE_REALPART (t2))
+             && compare_constant (TREE_IMAGPART (t1), TREE_IMAGPART (t2)));
 
     case CONSTRUCTOR:
-      if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
-       {
-         int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
-         unsigned char *tmp = (unsigned char *) alloca (len);
-
-         get_set_constructor_bytes (exp, tmp, len);
-         strp = (unsigned char *) tmp;
-         if (memcmp ((char *) &xlen, p, sizeof xlen))
-           return 0;
+      typecode = TREE_CODE (TREE_TYPE (t1));
+      if (typecode != TREE_CODE (TREE_TYPE (t2)))
+       return 0;
 
-         p += sizeof xlen;
-         break;
-       }
-      else
+      if (typecode == SET_TYPE)
        {
-         tree link;
-         int length = list_length (CONSTRUCTOR_ELTS (exp));
-         tree type;
-         enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
-         int have_purpose = 0;
+         int len = int_size_in_bytes (TREE_TYPE (t2));
+         unsigned char *tmp1, *tmp2;
 
-         for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
-           if (TREE_PURPOSE (link))
-             have_purpose = 1;
-
-         if (memcmp ((char *) &length, p, sizeof length))
+         if (int_size_in_bytes (TREE_TYPE (t1)) != len)
            return 0;
 
-         p += sizeof length;
-
-         /* For record constructors, insist that the types match.
-            For arrays, just verify both constructors are for arrays.
-            Then insist that either both or none have any TREE_PURPOSE
-            values.  */
-         if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
-           type = TREE_TYPE (exp);
-         else
-           type = 0;
+         tmp1 = (unsigned char *) alloca (len);
+         tmp2 = (unsigned char *) alloca (len);
 
-         if (memcmp ((char *) &type, p, sizeof type))
+         if (get_set_constructor_bytes (t1, tmp1, len) != NULL_TREE)
+           return 0;
+         if (get_set_constructor_bytes (t2, tmp2, len) != NULL_TREE)
            return 0;
 
-         if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
+         return memcmp (tmp1, tmp2, len) != 0;
+       }
+      else
+       {
+         tree l1, l2;
+
+         if (typecode == ARRAY_TYPE)
            {
-             if (memcmp ((char *) &mode, p, sizeof mode))
+             HOST_WIDE_INT size_1 = int_size_in_bytes (TREE_TYPE (t1));
+             /* For arrays, check that the sizes all match.  */
+             if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
+                 || size_1 == -1
+                 || size_1 != int_size_in_bytes (TREE_TYPE (t2)))
                return 0;
-
-             p += sizeof mode;
            }
-
-         p += sizeof type;
-
-         if (memcmp ((char *) &have_purpose, p, sizeof have_purpose))
-           return 0;
-
-         p += sizeof have_purpose;
-
-         /* For arrays, insist that the size in bytes match.  */
-         if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
+         else
            {
-             HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
-
-             if (memcmp ((char *) &size, p, sizeof size))
+             /* For record and union constructors, require exact type
+                 equality.  */
+             if (TREE_TYPE (t1) != TREE_TYPE (t2))
                return 0;
-
-             p += sizeof size;
            }
 
-         for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
+         for (l1 = CONSTRUCTOR_ELTS (t1), l2 = CONSTRUCTOR_ELTS (t2);
+              l1 && l2;
+              l1 = TREE_CHAIN (l1), l2 = TREE_CHAIN (l2))
            {
-             if (TREE_VALUE (link))
+             /* Check that each value is the same...  */
+             if (! compare_constant (TREE_VALUE (l1), TREE_VALUE (l2)))
+               return 0;
+             /* ... and that they apply to the same fields!  */
+             if (typecode == ARRAY_TYPE)
                {
-                 if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
+                 if (! compare_constant (TREE_PURPOSE (l1),
+                                         TREE_PURPOSE (l2)))
                    return 0;
                }
              else
                {
-                 tree zero = 0;
-
-                 if (memcmp ((char *) &zero, p, sizeof zero))
-                   return 0;
-
-                 p += sizeof zero;
-               }
-
-             if (TREE_PURPOSE (link)
-                 && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
-               {
-                 if (memcmp ((char *) &TREE_PURPOSE (link), p,
-                             sizeof TREE_PURPOSE (link)))
-                   return 0;
-
-                 p += sizeof TREE_PURPOSE (link);
-               }
-             else if (TREE_PURPOSE (link))
-               {
-                 if ((p = compare_constant_1 (TREE_PURPOSE (link), p)) == 0)
+                 if (TREE_PURPOSE (l1) != TREE_PURPOSE (l2))
                    return 0;
                }
-             else if (have_purpose)
-               {
-                 int zero = 0;
-
-                 if (memcmp ((char *) &zero, p, sizeof zero))
-                   return 0;
-
-                 p += sizeof zero;
-               }
            }
 
-         return p;
+         return l1 == NULL_TREE && l2 == NULL_TREE;
        }
 
     case ADDR_EXPR:
+    case FDESC_EXPR:
       {
-       struct addr_const value;
-
-       decode_addr_const (exp, &value);
-       strp = (unsigned char *) &value.offset;
-       len = sizeof value.offset;
-       /* Compare the offset.  */
-       while (--len >= 0)
-         if (*p++ != *strp++)
-           return 0;
+       struct addr_const value1, value2;
 
-       /* Compare symbol name.  */
-       strp = (const unsigned char *) XSTR (value.base, 0);
-       len = strlen ((const char *) strp) + 1;
+       decode_addr_const (t1, &value1);
+       decode_addr_const (t2, &value2);
+       return (value1.offset == value2.offset
+               && strcmp (XSTR (value1.base, 0), XSTR (value2.base, 0)) == 0);
       }
-      break;
 
     case PLUS_EXPR:
     case MINUS_EXPR:
     case RANGE_EXPR:
-      p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
-      if (p == 0)
-       return 0;
-
-      return compare_constant_1 (TREE_OPERAND (exp, 1), p);
+      return (compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))
+             && compare_constant(TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)));
 
     case NOP_EXPR:
     case CONVERT_EXPR:
     case NON_LVALUE_EXPR:
-      return compare_constant_1 (TREE_OPERAND (exp, 0), p);
+      return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
 
     default:
       {
-       tree new = (*lang_hooks.expand_constant) (exp);
-
-       if (new != exp)
-         return compare_constant_1 (new, p);
+       tree nt1, nt2;
+       nt1 = (*lang_hooks.expand_constant) (t1);
+       nt2 = (*lang_hooks.expand_constant) (t2);
+       if (nt1 != t1 || nt2 != t2)
+         return compare_constant (nt1, nt2);
        else
          return 0;
       }
     }
 
-  /* Compare constant contents.  */
-  while (--len >= 0)
-    if (*p++ != *strp++)
-      return 0;
-
-  return p;
-}
-\f
-/* Construct a constant descriptor for the expression EXP.
-   It is up to the caller to enter the descriptor in the hash table.  */
-
-static struct constant_descriptor *
-record_constant (exp)
-     tree exp;
-{
-  struct constant_descriptor *next = 0;
-  char *label = 0;
-  rtx rtl = 0;
-  int pad;
-
-  /* Make a struct constant_descriptor.  The first three pointers will
-     be filled in later.  Here we just leave space for them.  */
-
-  obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
-  obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
-  obstack_grow (&permanent_obstack, (char *) &rtl, sizeof rtl);
-
-  /* Align the descriptor for the data payload.  */
-  pad = (offsetof (struct constant_descriptor, u)
-        - offsetof(struct constant_descriptor, rtl)
-        - sizeof(next->rtl));
-  if (pad > 0)
-    obstack_blank (&permanent_obstack, pad);
-
-  record_constant_1 (exp);
-  return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
-}
-
-/* Add a description of constant expression EXP
-   to the object growing in `permanent_obstack'.
-   No need to return its address; the caller will get that
-   from the obstack when the object is complete.  */
-
-static void
-record_constant_1 (exp)
-     tree exp;
-{
-  const unsigned char *strp;
-  int len;
-  enum tree_code code = TREE_CODE (exp);
-
-  obstack_1grow (&permanent_obstack, (unsigned int) code);
-
-  switch (code)
-    {
-    case INTEGER_CST:
-      obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
-      strp = (unsigned char *) &TREE_INT_CST (exp);
-      len = sizeof TREE_INT_CST (exp);
-      break;
-
-    case REAL_CST:
-      obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
-      strp = (unsigned char *) &TREE_REAL_CST (exp);
-      len = sizeof TREE_REAL_CST (exp);
-      break;
-
-    case STRING_CST:
-      if (flag_writable_strings)
-       return;
-
-      obstack_1grow (&permanent_obstack, TYPE_MODE (TREE_TYPE (exp)));
-      strp = (const unsigned char *) TREE_STRING_POINTER (exp);
-      len = TREE_STRING_LENGTH (exp);
-      obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
-                   sizeof TREE_STRING_LENGTH (exp));
-      break;
-
-    case COMPLEX_CST:
-      record_constant_1 (TREE_REALPART (exp));
-      record_constant_1 (TREE_IMAGPART (exp));
-      return;
-
-    case CONSTRUCTOR:
-      if (TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
-       {
-         int nbytes = int_size_in_bytes (TREE_TYPE (exp));
-         obstack_grow (&permanent_obstack, &nbytes, sizeof (nbytes));
-         obstack_blank (&permanent_obstack, nbytes);
-         get_set_constructor_bytes
-           (exp, (unsigned char *) permanent_obstack.next_free - nbytes,
-            nbytes);
-         return;
-       }
-      else
-       {
-         tree link;
-         int length = list_length (CONSTRUCTOR_ELTS (exp));
-         enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
-         tree type;
-         int have_purpose = 0;
-
-         for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
-           if (TREE_PURPOSE (link))
-             have_purpose = 1;
-
-         obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
-
-         /* For record constructors, insist that the types match.
-            For arrays, just verify both constructors are for arrays
-            of the same mode.  Then insist that either both or none
-            have any TREE_PURPOSE values.  */
-         if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
-           type = TREE_TYPE (exp);
-         else
-           type = 0;
-
-         obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
-         if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
-           obstack_grow (&permanent_obstack, &mode, sizeof mode);
-
-         obstack_grow (&permanent_obstack, (char *) &have_purpose,
-                       sizeof have_purpose);
-
-         /* For arrays, insist that the size in bytes match.  */
-         if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
-           {
-             HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
-             obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
-           }
-
-         for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
-           {
-             if (TREE_VALUE (link))
-               record_constant_1 (TREE_VALUE (link));
-             else
-               {
-                 tree zero = 0;
-
-                 obstack_grow (&permanent_obstack,
-                               (char *) &zero, sizeof zero);
-               }
-
-             if (TREE_PURPOSE (link)
-                 && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
-               obstack_grow (&permanent_obstack,
-                             (char *) &TREE_PURPOSE (link),
-                             sizeof TREE_PURPOSE (link));
-             else if (TREE_PURPOSE (link))
-               record_constant_1 (TREE_PURPOSE (link));
-             else if (have_purpose)
-               {
-                 int zero = 0;
-
-                 obstack_grow (&permanent_obstack,
-                               (char *) &zero, sizeof zero);
-               }
-           }
-       }
-      return;
-
-    case ADDR_EXPR:
-      {
-       struct addr_const value;
-
-       decode_addr_const (exp, &value);
-       /* Record the offset.  */
-       obstack_grow (&permanent_obstack,
-                     (char *) &value.offset, sizeof value.offset);
-
-       switch (GET_CODE (value.base))
-         {
-         case SYMBOL_REF:
-           /* Record the symbol name.  */
-           obstack_grow (&permanent_obstack, XSTR (value.base, 0),
-                         strlen (XSTR (value.base, 0)) + 1);
-           break;
-         case LABEL_REF:
-           /* Record the address of the CODE_LABEL.  It may not have
-              been emitted yet, so it's UID may be zero.  But pointer
-              identity is good enough.  */
-           obstack_grow (&permanent_obstack, &XEXP (value.base, 0),
-                         sizeof (rtx));
-           break;
-         default:
-           abort ();
-         }
-      }
-      return;
-
-    case PLUS_EXPR:
-    case MINUS_EXPR:
-    case RANGE_EXPR:
-      record_constant_1 (TREE_OPERAND (exp, 0));
-      record_constant_1 (TREE_OPERAND (exp, 1));
-      return;
-
-    case NOP_EXPR:
-    case CONVERT_EXPR:
-    case NON_LVALUE_EXPR:
-      record_constant_1 (TREE_OPERAND (exp, 0));
-      return;
-
-    default:
-      {
-       tree new = (*lang_hooks.expand_constant) (exp);
-
-       if (new != exp)
-         record_constant_1 (new);
-       return;
-      }
-    }
-
-  /* Record constant contents.  */
-  obstack_grow (&permanent_obstack, strp, len);
+  /* Should not get here.  */
+  abort ();
 }
 \f
 /* Record a list of constant expressions that were passed to
@@ -2923,9 +2579,8 @@ output_after_function_constants ()
   after_function_constants = 0;
 }
 
-/* Make a copy of the whole tree structure for a constant.
-   This handles the same types of nodes that compare_constant
-   and record_constant handle.  */
+/* Make a copy of the whole tree structure for a constant.  This
+   handles the same types of nodes that compare_constant handles.  */
 
 static tree
 copy_constant (exp)
@@ -2981,7 +2636,14 @@ copy_constant (exp)
       }
 
     default:
-      abort ();
+      {
+       tree t;
+       t = (*lang_hooks.expand_constant) (exp);
+       if (t != exp)
+         return copy_constant (t);
+       else
+         abort ();
+      }
     }
 }
 \f
@@ -3005,7 +2667,7 @@ output_constant_def (exp, defer)
      int defer;
 {
   int hash;
-  struct constant_descriptor *desc;
+  struct constant_descriptor_tree *desc;
   struct deferred_string **defstr;
   char label[256];
   int reloc;
@@ -3014,8 +2676,8 @@ output_constant_def (exp, defer)
   int labelno = -1;
   rtx rtl;
 
-  /* We can't just use the saved RTL if this is a defererred string constant
-     and we are not to defer anymode.  */
+  /* We can't just use the saved RTL if this is a deferred string constant
+     and we are not to defer anymore.  */
   if (TREE_CODE (exp) != INTEGER_CST && TREE_CST_RTL (exp)
       && (defer || !STRING_POOL_ADDRESS_P (XEXP (TREE_CST_RTL (exp), 0))))
     return TREE_CST_RTL (exp);
@@ -3032,7 +2694,7 @@ output_constant_def (exp, defer)
   hash = const_hash (exp) % MAX_HASH_TABLE;
 
   for (desc = const_hash_table[hash]; desc; desc = desc->next)
-    if (compare_constant (exp, desc))
+    if (compare_constant (exp, desc->value))
       break;
 
   if (desc == 0)
@@ -3046,9 +2708,10 @@ output_constant_def (exp, defer)
       labelno = const_labelno++;
       ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno);
 
-      desc = record_constant (exp);
+      desc = ggc_alloc (sizeof (*desc));
       desc->next = const_hash_table[hash];
       desc->label = ggc_strdup (label);
+      desc->value = copy_constant (exp);
       const_hash_table[hash] = desc;
 
       /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
@@ -3071,20 +2734,18 @@ output_constant_def (exp, defer)
   /* Optionally set flags or add text to the name to record information
      such as that it is a function name.  If the name is changed, the macro
      ASM_OUTPUT_LABELREF will have to know how to strip this information.  */
-#ifdef ENCODE_SECTION_INFO
   /* A previously-processed constant would already have section info
      encoded in it.  */
   if (! found)
     {
-      /* Take care not to invoke ENCODE_SECTION_INFO for constants
-        which don't have a TREE_CST_RTL.  */
+      /* Take care not to invoke targetm.encode_section_info for
+        constants which don't have a TREE_CST_RTL.  */
       if (TREE_CODE (exp) != INTEGER_CST)
-       ENCODE_SECTION_INFO (exp, true);
+       (*targetm.encode_section_info) (exp, true);
 
       desc->rtl = rtl;
       desc->label = XSTR (XEXP (desc->rtl, 0), 0);
     }
-#endif
 
 #ifdef CONSTANT_AFTER_FUNCTION_P
   if (current_function_decl != 0
@@ -3120,7 +2781,7 @@ output_constant_def (exp, defer)
            = (struct deferred_constant *)
              xmalloc (sizeof (struct deferred_constant));
 
-         p->exp = copy_constant (exp);
+         p->exp = desc->value;
          p->reloc = reloc;
          p->labelno = labelno;
          if (after_function)
@@ -3153,9 +2814,9 @@ output_constant_def (exp, defer)
                  struct deferred_string *p;
 
                  p = (struct deferred_string *)
-                     xmalloc (sizeof (struct deferred_string));
+                     ggc_alloc (sizeof (struct deferred_string));
 
-                 p->exp = copy_constant (exp);
+                 p->exp = desc->value;
                  p->label = desc->label;
                  p->labelno = labelno;
                  *defstr = p;
@@ -3208,15 +2869,36 @@ output_constant_def_contents (exp, reloc, labelno)
 
 }
 \f
+/* Used in the hash tables to avoid outputting the same constant
+   twice.  Unlike 'struct constant_descriptor_tree', RTX constants
+   are output once per function, not once per file; there seems
+   to be no reason for the difference.  */
+
+struct constant_descriptor_rtx GTY(())
+{
+  /* More constant_descriptors with the same hash code.  */
+  struct constant_descriptor_rtx *next;
+
+  /* The label of the constant.  */
+  const char *label;
+
+  /* A MEM for the constant.  */
+  rtx rtl;
+
+  /* The value of the constant.  */
+  struct rtx_const value;
+};
+
 /* Structure to represent sufficient information about a constant so that
    it can be output when the constant pool is output, so that function
    integration can be done, and to simplify handling on machines that reference
    constant pool as base+displacement.  */
 
-struct pool_constant
+struct pool_constant GTY(())
 {
-  struct constant_descriptor *desc;
-  struct pool_constant *next, *next_sym;
+  struct constant_descriptor_rtx *desc;
+  struct pool_constant *next;
+  struct pool_constant *next_sym;
   rtx constant;
   enum machine_mode mode;
   int labelno;
@@ -3238,80 +2920,20 @@ init_varasm_status (f)
      struct function *f;
 {
   struct varasm_status *p;
-  p = (struct varasm_status *) xmalloc (sizeof (struct varasm_status));
+  p = (struct varasm_status *) ggc_alloc (sizeof (struct varasm_status));
   f->varasm = p;
   p->x_const_rtx_hash_table
-    = ((struct constant_descriptor **)
-       xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct constant_descriptor *)));
+    = ((struct constant_descriptor_rtx **)
+       ggc_alloc_cleared (MAX_RTX_HASH_TABLE
+                         * sizeof (struct constant_descriptor_rtx *)));
   p->x_const_rtx_sym_hash_table
     = ((struct pool_constant **)
-       xcalloc (MAX_RTX_HASH_TABLE, sizeof (struct pool_constant *)));
+       ggc_alloc_cleared (MAX_RTX_HASH_TABLE
+                         * sizeof (struct pool_constant *)));
 
   p->x_first_pool = p->x_last_pool = 0;
   p->x_pool_offset = 0;
 }
-
-/* Mark PC for GC.  */
-
-static void
-mark_pool_constant (pc)
-     struct pool_constant *pc;
-{
-  while (pc)
-    {
-      ggc_mark (pc);
-      ggc_mark_rtx (pc->constant);
-      ggc_mark_rtx (pc->desc->rtl);
-      pc = pc->next;
-    }
-}
-
-/* Mark P for GC.  */
-
-void
-mark_varasm_status (p)
-     struct varasm_status *p;
-{
-  if (p == NULL)
-    return;
-
-  mark_pool_constant (p->x_first_pool);
-}
-
-/* Clear out all parts of the state in F that can safely be discarded
-   after the function has been compiled, to let garbage collection
-   reclaim the memory.  */
-
-void
-free_varasm_status (f)
-     struct function *f;
-{
-  struct varasm_status *p;
-  int i;
-
-  p = f->varasm;
-
-  /* Clear out the hash tables.  */
-  for (i = 0; i < MAX_RTX_HASH_TABLE; ++i)
-    {
-      struct constant_descriptor *cd;
-
-      cd = p->x_const_rtx_hash_table[i];
-      while (cd)
-       {
-         struct constant_descriptor *next = cd->next;
-
-         free (cd);
-         cd = next;
-       }
-    }
-
-  free (p->x_const_rtx_hash_table);
-  free (p->x_const_rtx_sym_hash_table);
-  free (p);
-
-  f->varasm = NULL;
-}
 \f
 
 /* Express an rtx for a constant integer (perhaps symbolic)
@@ -3360,13 +2982,13 @@ decode_rtx_const (mode, x, value)
            elt = CONST_VECTOR_ELT (x, i);
            if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
              {
-               value->un.veclo[i] = (HOST_WIDE_INT) INTVAL (elt);
-               value->un.vechi[i] = 0;
+               value->un.vec[i].veclo = (HOST_WIDE_INT) INTVAL (elt);
+               value->un.vec[i].vechi = 0;
              }
            else if (GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT)
              {
-               value->un.veclo[i] = (HOST_WIDE_INT) CONST_DOUBLE_LOW (elt);
-               value->un.vechi[i] = (HOST_WIDE_INT) CONST_DOUBLE_HIGH (elt);
+               value->un.vec[i].veclo = (HOST_WIDE_INT) CONST_DOUBLE_LOW (elt);
+               value->un.vec[i].vechi = (HOST_WIDE_INT) CONST_DOUBLE_HIGH (elt);
              }
            else
              abort ();
@@ -3425,14 +3047,16 @@ decode_rtx_const (mode, x, value)
        }
     }
 
-  if (value->kind > RTX_DOUBLE && value->un.addr.base != 0)
+  if (value->kind > RTX_VECTOR && value->un.addr.base != 0)
     switch (GET_CODE (value->un.addr.base))
       {
+#if 0
       case SYMBOL_REF:
        /* Use the string's address, not the SYMBOL_REF's address,
           for the sake of addresses of library routines.  */
        value->un.addr.base = (rtx) XSTR (value->un.addr.base, 0);
        break;
+#endif
 
       case LABEL_REF:
        /* For a LABEL_REF, compare labels.  */
@@ -3493,39 +3117,28 @@ static int
 compare_constant_rtx (mode, x, desc)
      enum machine_mode mode;
      rtx x;
-     struct constant_descriptor *desc;
+     struct constant_descriptor_rtx *desc;
 {
-  int *p = (int *) desc->u.contents;
-  int *strp;
-  int len;
   struct rtx_const value;
 
   decode_rtx_const (mode, x, &value);
-  strp = (int *) &value;
-  len = sizeof value / sizeof (int);
 
   /* Compare constant contents.  */
-  while (--len >= 0)
-    if (*p++ != *strp++)
-      return 0;
-
-  return 1;
+  return memcmp (&value, &desc->value, sizeof (struct rtx_const)) == 0;
 }
 
 /* Construct a constant descriptor for the rtl-expression X.
    It is up to the caller to enter the descriptor in the hash table.  */
 
-static struct constant_descriptor *
+static struct constant_descriptor_rtx *
 record_constant_rtx (mode, x)
      enum machine_mode mode;
      rtx x;
 {
-  struct constant_descriptor *ptr;
+  struct constant_descriptor_rtx *ptr;
 
-  ptr = ((struct constant_descriptor *)
-        xcalloc (1, (offsetof (struct constant_descriptor, u)
-                     + sizeof (struct rtx_const))));
-  decode_rtx_const (mode, x, (struct rtx_const *) ptr->u.contents);
+  ptr = (struct constant_descriptor_rtx *) ggc_alloc (sizeof (*ptr));
+  decode_rtx_const (mode, x, &ptr->value);
 
   return ptr;
 }
@@ -3538,7 +3151,7 @@ mem_for_const_double (x)
      rtx x;
 {
   enum machine_mode mode = GET_MODE (x);
-  struct constant_descriptor *desc;
+  struct constant_descriptor_rtx *desc;
 
   for (desc = const_rtx_hash_table[const_hash_rtx (mode, x)]; desc;
        desc = desc->next)
@@ -3557,7 +3170,7 @@ force_const_mem (mode, x)
      rtx x;
 {
   int hash;
-  struct constant_descriptor *desc;
+  struct constant_descriptor_rtx *desc;
   char label[256];
   rtx def;
   struct pool_constant *pool;
@@ -3783,11 +3396,7 @@ output_constant_pool (fnname, fndecl)
        }
 
       /* First switch to correct section.  */
-#ifdef SELECT_RTX_SECTION
-      SELECT_RTX_SECTION (pool->mode, x, pool->align);
-#else
-      readonly_data_section ();
-#endif
+      (*targetm.asm_out.select_rtx_section) (pool->mode, x, pool->align);
 
 #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
       ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
@@ -3878,6 +3487,7 @@ static void
 mark_constant_pool ()
 {
   rtx insn;
+  rtx link;
   struct pool_constant *pool;
 
   if (first_pool == 0 && htab_elements (const_str_htab) == 0)
@@ -3890,11 +3500,15 @@ mark_constant_pool ()
     if (INSN_P (insn))
       mark_constants (PATTERN (insn));
 
-  for (insn = current_function_epilogue_delay_list;
-       insn;
-       insn = XEXP (insn, 1))
-    if (INSN_P (insn))
-      mark_constants (PATTERN (insn));
+  for (link = current_function_epilogue_delay_list;
+       link;
+       link = XEXP (link, 1))
+    {
+      insn = XEXP (link, 0);
+
+      if (INSN_P (insn))
+       mark_constants (PATTERN (insn));
+    }
 }
 
 /* Look through appropriate parts of X, marking all entries in the
@@ -3954,6 +3568,7 @@ mark_constants (x)
        case 'w':
        case 'n':
        case 'u':
+       case 'B':
          break;
 
        default:
@@ -4027,6 +3642,7 @@ output_addressed_constants (exp)
   switch (TREE_CODE (exp))
     {
     case ADDR_EXPR:
+    case FDESC_EXPR:
       /* Go inside any operations that get_inner_reference can handle and see
         if what's inside is a constant: no need to do anything here for
         addresses of variables or functions.  */
@@ -4035,8 +3651,8 @@ output_addressed_constants (exp)
        ;
 
       if (TREE_CODE_CLASS (TREE_CODE (tem)) == 'c'
-           || TREE_CODE (tem) == CONSTRUCTOR)
-         output_constant_def (tem, 0);
+         || TREE_CODE (tem) == CONSTRUCTOR)
+       output_constant_def (tem, 0);
 
       if (TREE_PUBLIC (tem))
        reloc |= 2;
@@ -4769,7 +4385,7 @@ output_constructor (exp, size, align)
 
 /* This TREE_LIST contains any weak symbol declarations waiting
    to be emitted.  */
-static tree weak_decls;
+static GTY(()) tree weak_decls;
 
 /* Mark DECL as weak.  */
 
@@ -4785,7 +4401,7 @@ mark_weak (decl)
       && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
     SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1;
 }
+
 /* Merge weak status between NEWDECL and OLDDECL.  */
 
 void
@@ -4799,7 +4415,7 @@ merge_weak (newdecl, olddecl)
   if (DECL_WEAK (newdecl))
     {
       tree wd;
-      
+
       /* NEWDECL is weak, but OLDDECL is not.  */
 
       /* If we already output the OLDDECL, we're in trouble; we can't
@@ -4807,7 +4423,7 @@ merge_weak (newdecl, olddecl)
         declare_weak because the NEWDECL and OLDDECL was not yet
         been merged; therefore, TREE_ASM_WRITTEN was not set.  */
       if (TREE_ASM_WRITTEN (olddecl))
-       error_with_decl (newdecl, 
+       error_with_decl (newdecl,
                         "weak declaration of `%s' must precede definition");
 
       /* If we've already generated rtl referencing OLDDECL, we may
@@ -4925,7 +4541,7 @@ globalize_decl (decl)
     }
 #endif
 
-  ASM_GLOBALIZE_LABEL (asm_out_file, name);
+  (*targetm.asm_out.globalize_label) (asm_out_file, name);
 }
 
 /* Emit an assembler directive to make the symbol for DECL an alias to
@@ -4981,13 +4597,14 @@ assemble_alias (decl, target)
    VISIBILITY_TYPE.  */
 
 void
-assemble_visibility (decl, visibility_type)
+default_assemble_visibility (decl, visibility_type)
      tree decl;
      const char *visibility_type ATTRIBUTE_UNUSED;
 {
   const char *name;
 
-  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  name = (* targetm.strip_name_encoding)
+        (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
 
 #ifdef HAVE_GAS_HIDDEN
   fprintf (asm_out_file, "\t.%s\t%s\n", visibility_type, name);
@@ -5007,7 +4624,7 @@ maybe_assemble_visibility (decl)
     {
       const char *type
        = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (visibility)));
-      assemble_visibility (decl, type);
+      (* targetm.asm_out.visibility) (decl, type);
     }
 }
 
@@ -5055,17 +4672,11 @@ make_decl_one_only (decl)
 void
 init_varasm_once ()
 {
-  const_str_htab = htab_create (128, const_str_htab_hash, const_str_htab_eq,
-                               const_str_htab_del);
+  const_str_htab = htab_create_ggc (128, const_str_htab_hash,
+                                   const_str_htab_eq, NULL);
   in_named_htab = htab_create (31, in_named_entry_hash,
                               in_named_entry_eq, NULL);
 
-  ggc_add_root (const_hash_table, MAX_HASH_TABLE, sizeof const_hash_table[0],
-               mark_const_hash_entry);
-  ggc_add_root (&const_str_htab, 1, sizeof const_str_htab,
-               mark_const_str_htab);
-  ggc_add_tree_root (&weak_decls, 1);
-
   const_alias_set = new_alias_set ();
 }
 
@@ -5082,11 +4693,21 @@ default_section_type_flags (decl, name, reloc)
      const char *name;
      int reloc;
 {
+  return default_section_type_flags_1 (decl, name, reloc, flag_pic);
+}
+
+unsigned int
+default_section_type_flags_1 (decl, name, reloc, shlib)
+     tree decl;
+     const char *name;
+     int reloc;
+     int shlib;
+{
   unsigned int flags;
 
   if (decl && TREE_CODE (decl) == FUNCTION_DECL)
     flags = SECTION_CODE;
-  else if (decl && DECL_READONLY_SECTION (decl, reloc))
+  else if (decl && decl_readonly_section_1 (decl, reloc, shlib))
     flags = 0;
   else
     flags = SECTION_WRITE;
@@ -5094,14 +4715,25 @@ default_section_type_flags (decl, name, reloc)
   if (decl && DECL_ONE_ONLY (decl))
     flags |= SECTION_LINKONCE;
 
+  if (decl && TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
+    flags |= SECTION_TLS | SECTION_WRITE;
+
   if (strcmp (name, ".bss") == 0
       || strncmp (name, ".bss.", 5) == 0
       || strncmp (name, ".gnu.linkonce.b.", 16) == 0
       || strcmp (name, ".sbss") == 0
       || strncmp (name, ".sbss.", 6) == 0
-      || strncmp (name, ".gnu.linkonce.sb.", 17) == 0)
+      || strncmp (name, ".gnu.linkonce.sb.", 17) == 0
+      || strcmp (name, ".tbss") == 0
+      || strncmp (name, ".gnu.linkonce.tb.", 17) == 0)
     flags |= SECTION_BSS;
 
+  if (strcmp (name, ".tdata") == 0
+      || strcmp (name, ".tbss") == 0
+      || strncmp (name, ".gnu.linkonce.td.", 17) == 0
+      || strncmp (name, ".gnu.linkonce.tb.", 17) == 0)
+    flags |= SECTION_TLS;
+
   return flags;
 }
 
@@ -5144,6 +4776,8 @@ default_elf_asm_named_section (name, flags)
     *f++ = 'M';
   if (flags & SECTION_STRINGS)
     *f++ = 'S';
+  if (flags & SECTION_TLS)
+    *f++ = 'T';
   *f = '\0';
 
   if (flags & SECTION_BSS)
@@ -5233,7 +4867,7 @@ default_select_section (decl, reloc, align)
 
   if (DECL_P (decl))
     {
-      if (DECL_READONLY_SECTION (decl, reloc))
+      if (decl_readonly_section (decl, reloc))
        readonly = true;
     }
   else if (TREE_CODE (decl) == CONSTRUCTOR)
@@ -5266,6 +4900,7 @@ enum section_category
   SECCAT_RODATA_MERGE_STR,
   SECCAT_RODATA_MERGE_STR_INIT,
   SECCAT_RODATA_MERGE_CONST,
+  SECCAT_SRODATA,
 
   SECCAT_DATA,
 
@@ -5291,12 +4926,14 @@ enum section_category
   SECCAT_TBSS
 };
 
-static enum section_category categorize_decl_for_section PARAMS ((tree, int));
+static enum section_category
+categorize_decl_for_section PARAMS ((tree, int, int));
 
 static enum section_category
-categorize_decl_for_section (decl, reloc)
+categorize_decl_for_section (decl, reloc, shlib)
      tree decl;
      int reloc;
+     int shlib;
 {
   enum section_category ret;
 
@@ -5318,16 +4955,16 @@ categorize_decl_for_section (decl, reloc)
               || TREE_SIDE_EFFECTS (decl)
               || ! TREE_CONSTANT (DECL_INITIAL (decl)))
        {
-         if (flag_pic && (reloc & 2))
+         if (shlib && (reloc & 2))
            ret = SECCAT_DATA_REL;
-         else if (flag_pic && reloc)
+         else if (shlib && reloc)
            ret = SECCAT_DATA_REL_LOCAL;
          else
            ret = SECCAT_DATA;
        }
-      else if (flag_pic && (reloc & 2))
+      else if (shlib && (reloc & 2))
        ret = SECCAT_DATA_REL_RO;
-      else if (flag_pic && reloc)
+      else if (shlib && reloc)
        ret = SECCAT_DATA_REL_RO_LOCAL;
       else if (flag_merge_constants < 2)
        /* C and C++ don't allow different variables to share the same
@@ -5341,7 +4978,7 @@ categorize_decl_for_section (decl, reloc)
     }
   else if (TREE_CODE (decl) == CONSTRUCTOR)
     {
-      if ((flag_pic && reloc)
+      if ((shlib && reloc)
          || TREE_SIDE_EFFECTS (decl)
          || ! TREE_CONSTANT (decl))
        ret = SECCAT_DATA;
@@ -5351,11 +4988,22 @@ categorize_decl_for_section (decl, reloc)
   else
     ret = SECCAT_RODATA;
 
+  /* There are no read-only thread-local sections.  */
+  if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
+    {
+      if (ret == SECCAT_BSS)
+       ret = SECCAT_TBSS;
+      else
+       ret = SECCAT_TDATA;
+    }
+
   /* If the target uses small data sections, select it.  */
-  if ((*targetm.in_small_data_p) (decl))
+  else if ((*targetm.in_small_data_p) (decl))
     {
       if (ret == SECCAT_BSS)
        ret = SECCAT_SBSS;
+      else if (targetm.have_srodata_section && ret == SECCAT_RODATA)
+       ret = SECCAT_SRODATA;
       else
        ret = SECCAT_SDATA;
     }
@@ -5363,6 +5011,35 @@ categorize_decl_for_section (decl, reloc)
   return ret;
 }
 
+bool
+decl_readonly_section (decl, reloc)
+     tree decl;
+     int reloc;
+{
+  return decl_readonly_section_1 (decl, reloc, flag_pic);
+}
+
+bool
+decl_readonly_section_1 (decl, reloc, shlib)
+     tree decl;
+     int reloc;
+     int shlib;
+{
+  switch (categorize_decl_for_section (decl, reloc, shlib))
+    {
+    case SECCAT_RODATA:
+    case SECCAT_RODATA_MERGE_STR:
+    case SECCAT_RODATA_MERGE_STR_INIT:
+    case SECCAT_RODATA_MERGE_CONST:
+    case SECCAT_SRODATA:
+      return true;
+      break;
+    default:
+      return false;
+      break;
+    }
+}
+
 /* Select a section based on the above categorization.  */
 
 void
@@ -5371,7 +5048,17 @@ default_elf_select_section (decl, reloc, align)
      int reloc;
      unsigned HOST_WIDE_INT align;
 {
-  switch (categorize_decl_for_section (decl, reloc))
+  default_elf_select_section_1 (decl, reloc, align, flag_pic);
+}
+
+void
+default_elf_select_section_1 (decl, reloc, align, shlib)
+     tree decl;
+     int reloc;
+     unsigned HOST_WIDE_INT align;
+     int shlib;
+{
+  switch (categorize_decl_for_section (decl, reloc, shlib))
     {
     case SECCAT_TEXT:
       /* We're not supposed to be called on FUNCTION_DECLs.  */
@@ -5388,6 +5075,9 @@ default_elf_select_section (decl, reloc, align)
     case SECCAT_RODATA_MERGE_CONST:
       mergeable_constant_section (DECL_MODE (decl), align, 0);
       break;
+    case SECCAT_SRODATA:
+      named_section (NULL_TREE, ".sdata2", reloc);
+      break;
     case SECCAT_DATA:
       data_section ();
       break;
@@ -5427,7 +5117,7 @@ default_elf_select_section (decl, reloc, align)
     }
 }
 
-/* Construct a unique section name based on the decl name and the 
+/* Construct a unique section name based on the decl name and the
    categorization performed above.  */
 
 void
@@ -5435,12 +5125,21 @@ default_unique_section (decl, reloc)
      tree decl;
      int reloc;
 {
+  default_unique_section_1 (decl, reloc, flag_pic);
+}
+
+void
+default_unique_section_1 (decl, reloc, shlib)
+     tree decl;
+     int reloc;
+     int shlib;
+{
   bool one_only = DECL_ONE_ONLY (decl);
   const char *prefix, *name;
   size_t nlen, plen;
   char *string;
 
-  switch (categorize_decl_for_section (decl, reloc))
+  switch (categorize_decl_for_section (decl, reloc, shlib))
     {
     case SECCAT_TEXT:
       prefix = one_only ? ".gnu.linkonce.t." : ".text.";
@@ -5451,6 +5150,9 @@ default_unique_section (decl, reloc)
     case SECCAT_RODATA_MERGE_CONST:
       prefix = one_only ? ".gnu.linkonce.r." : ".rodata.";
       break;
+    case SECCAT_SRODATA:
+      prefix = one_only ? ".gnu.linkonce.s2." : ".sdata2.";
+      break;
     case SECCAT_DATA:
     case SECCAT_DATA_REL:
     case SECCAT_DATA_REL_LOCAL:
@@ -5468,14 +5170,18 @@ default_unique_section (decl, reloc)
       prefix = one_only ? ".gnu.linkonce.sb." : ".sbss.";
       break;
     case SECCAT_TDATA:
+      prefix = one_only ? ".gnu.linkonce.td." : ".tdata.";
+      break;
     case SECCAT_TBSS:
+      prefix = one_only ? ".gnu.linkonce.tb." : ".tbss.";
+      break;
     default:
       abort ();
     }
   plen = strlen (prefix);
 
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  STRIP_NAME_ENCODING (name, name);
+  name = (* targetm.strip_name_encoding) (name);
   nlen = strlen (name);
 
   string = alloca (nlen + plen + 1);
@@ -5484,3 +5190,129 @@ default_unique_section (decl, reloc)
 
   DECL_SECTION_NAME (decl) = build_string (nlen + plen, string);
 }
+
+void
+default_select_rtx_section (mode, x, align)
+     enum machine_mode mode ATTRIBUTE_UNUSED;
+     rtx x;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (flag_pic)
+    switch (GET_CODE (x))
+      {
+      case CONST:
+      case SYMBOL_REF:
+      case LABEL_REF:
+       data_section ();
+       return;
+
+      default:
+       break;
+      }
+
+  readonly_data_section ();
+}
+
+void
+default_elf_select_rtx_section (mode, x, align)
+     enum machine_mode mode;
+     rtx x;
+     unsigned HOST_WIDE_INT align;
+{
+  /* ??? Handle small data here somehow.  */
+
+  if (flag_pic)
+    switch (GET_CODE (x))
+      {
+      case CONST:
+      case SYMBOL_REF:
+       named_section (NULL_TREE, ".data.rel.ro", 3);
+       return;
+
+      case LABEL_REF:
+       named_section (NULL_TREE, ".data.rel.ro.local", 1);
+       return;
+
+      default:
+       break;
+      }
+
+  mergeable_constant_section (mode, align, 0);
+}
+
+/* By default, we do nothing for encode_section_info, so we need not
+   do anything but discard the '*' marker.  */
+
+const char *
+default_strip_name_encoding (str)
+     const char *str;
+{
+  return str + (*str == '*');
+}
+
+/* Assume ELF-ish defaults, since that's pretty much the most liberal
+   wrt cross-module name binding.  */
+
+bool
+default_binds_local_p (exp)
+     tree exp;
+{
+  return default_binds_local_p_1 (exp, flag_pic);
+}
+
+bool
+default_binds_local_p_1 (exp, shlib)
+     tree exp;
+     int shlib;
+{
+  bool local_p;
+
+  /* A non-decl is an entry in the constant pool.  */
+  if (!DECL_P (exp))
+    local_p = true;
+  /* Static variables are always local.  */
+  else if (! TREE_PUBLIC (exp))
+    local_p = true;
+  /* A variable is local if the user tells us so.  */
+  else if (MODULE_LOCAL_P (exp))
+    local_p = true;
+  /* Otherwise, variables defined outside this object may not be local.  */
+  else if (DECL_EXTERNAL (exp))
+    local_p = false;
+  /* Linkonce and weak data are never local.  */
+  else if (DECL_ONE_ONLY (exp) || DECL_WEAK (exp))
+    local_p = false;
+  /* If PIC, then assume that any global name can be overridden by
+     symbols resolved from other modules.  */
+  else if (shlib)
+    local_p = false;
+  /* Uninitialized COMMON variable may be unified with symbols
+     resolved from other modules.  */
+  else if (DECL_COMMON (exp)
+          && (DECL_INITIAL (exp) == NULL
+              || DECL_INITIAL (exp) == error_mark_node))
+    local_p = false;
+  /* Otherwise we're left with initialized (or non-common) global data
+     which is of necessity defined locally.  */
+  else
+    local_p = true;
+
+  return local_p;
+}
+
+/* Default function to output code that will globalize a label.  A
+   target must define GLOBAL_ASM_OP or provide it's own function to
+   globalize a label.  */
+#ifdef GLOBAL_ASM_OP
+void
+default_globalize_label (stream, name)
+     FILE * stream;
+     const char *name;
+{
+  fputs (GLOBAL_ASM_OP, stream);
+  assemble_name (stream, name);
+  putc ('\n', stream);
+}
+#endif /* GLOBAL_ASM_OP */
+  
+#include "gt-varasm.h"