[rfc] Use two floatformats per type

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[rfc] Use two floatformats per type

Daniel Jacobowitz-2
A cleanup I've been meaning to do for a while.  For integers, we can
just say that a register has type "builtin_type_int32", but for floats
we need to say either builtin_type_ieee_single_big or
builtin_type_ieee_single_little depending on the target endianness.
So there's code in lots of tdep files to return one or the other
depending on TARGET_BYTE_ORDER.

We can elide that.  Just store both a big and little endian
representation in TYPE_FLOATFORMAT, and then all we need is
builtin_type_ieee_single.  Handy for me since I have a place
I want to pick out builtin_type_arm_ext without yet knowing
if the target will be little endian or big endian.

Any comments?  Tested x86_64-linux; this modifies a lot of targets,
but I've proofread it thoroughly.

--
Daniel Jacobowitz
CodeSourcery

2007-01-24  Daniel Jacobowitz  <[hidden email]>

        * doublest.c (floatformat_from_length): Use the right element from
        gdbarch floatformats.
        (floatformat_from_type, extract_typed_floating)
        (store_typed_floating): Likewise.
        * doublest.h: Remove declarations for undefined floatformat arrays.
        * gdbarch.sh (float_format, double_format, long_double_format): Change
        to pairs.
        (pformat): Update for pairs.
        * gdbarch.c, gdbarch.h: Regenerated.
        * gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double)
        (floatformats_ieee_double_littlebyte_bigword)
        (floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext)
        (floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f)
        (floatformats_vax_d): New variables.
        (builtin_type_ieee_single, builtin_type_ieee_double)
        (builtin_type_arm_ext, builtin_type_ia64_spill)
        (builtin_type_ia64_quad): Replace arrays with individual types.
        (builtin_type_ieee_single_big, builtin_type_ieee_single_little)
        (builtin_type_ieee_double_big, builtin_type_ieee_double_little)
        (builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext)
        (builtin_type_m88110_ext, builtin_type_m88110_harris_ext)
        (builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword)
        (builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
        (builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete
        unused and endian-specific types.
        (recursive_dump_type): Update for floatformat pairs.
        (build_flt): Move higher.  Handle bit == -1.  Take a floatformat pair.
        (build_gdbtypes): Use build_flt.
        (_initialize_gdbtypes): Update set of initialized types.
        * gdbtypes.h: Update declarations to match gdbtypes.c.
        (struct main_type): Store a pointer to two floatformats.
        * arch-utils.c (default_float_format, default_double_format): Delete.
        * arch-utils.h (default_float_format, default_double_format): Delete.

        * arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c,
        ia64-tdep.c,  iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c,
        mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c,
        sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c,
        vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.

---
 gdb/alpha-tdep.c       |    4
 gdb/arch-utils.c       |   36 ------
 gdb/arch-utils.h       |    4
 gdb/arm-tdep.c         |   45 ++------
 gdb/avr-tdep.c         |    6 -
 gdb/doublest.c         |   18 +--
 gdb/doublest.h         |    7 -
 gdb/gdbarch.c          |   29 ++---
 gdb/gdbarch.h          |   16 +-
 gdb/gdbarch.sh         |   13 +-
 gdb/gdbtypes.c         |  275 ++++++++++++++++++-------------------------------
 gdb/gdbtypes.h         |   44 +++----
 gdb/hppa-tdep.c        |    6 -
 gdb/hppabsd-tdep.c     |    2
 gdb/i386-tdep.c        |    2
 gdb/ia64-tdep.c        |   10 +
 gdb/iq2000-tdep.c      |    6 -
 gdb/m68k-tdep.c        |    2
 gdb/m88k-tdep.c        |    2
 gdb/mips-linux-tdep.c  |   10 -
 gdb/mips-tdep.c        |   44 ++-----
 gdb/mt-tdep.c          |   20 ---
 gdb/ppc-sysv-tdep.c    |   15 --
 gdb/ppcobsd-tdep.c     |    2
 gdb/sparc-linux-tdep.c |    2
 gdb/sparc-tdep.c       |    4
 gdb/sparcnbsd-tdep.c   |    2
 gdb/spu-tdep.c         |    6 -
 gdb/vax-tdep.c         |    8 -
 29 files changed, 237 insertions(+), 403 deletions(-)

Index: src/gdb/arm-tdep.c
===================================================================
--- src.orig/gdb/arm-tdep.c 2007-01-24 11:52:05.000000000 -0500
+++ src/gdb/arm-tdep.c 2007-01-24 14:00:04.000000000 -0500
@@ -1334,12 +1334,7 @@ static struct type *
 arm_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum >= ARM_F0_REGNUM && regnum < ARM_F0_REGNUM + NUM_FREGS)
-    {
-      if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
- return builtin_type_arm_ext_big;
-      else
- return builtin_type_arm_ext_littlebyte_bigword;
-    }
+    return builtin_type_arm_ext;
   else if (regnum == ARM_SP_REGNUM)
     return builtin_type_void_data_ptr;
   else if (regnum == ARM_PC_REGNUM)
@@ -2833,34 +2828,18 @@ arm_gdbarch_init (struct gdbarch_info in
     set_gdbarch_get_longjmp_target (gdbarch, arm_get_longjmp_target);
 
   /* Floating point sizes and format.  */
-  switch (info.byte_order)
+  set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
+  if (fp_model == ARM_FLOAT_SOFT_FPA || fp_model == ARM_FLOAT_FPA)
     {
-    case BFD_ENDIAN_BIG:
-      set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_big);
-      set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_big);
-      set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
-      break;
-
-    case BFD_ENDIAN_LITTLE:
-      set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_little);
-      if (fp_model == ARM_FLOAT_SOFT_FPA || fp_model == ARM_FLOAT_FPA)
- {
-  set_gdbarch_double_format
-    (gdbarch, &floatformat_ieee_double_littlebyte_bigword);
-  set_gdbarch_long_double_format
-    (gdbarch, &floatformat_ieee_double_littlebyte_bigword);
- }
-      else
- {
-  set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_little);
-  set_gdbarch_long_double_format (gdbarch,
-  &floatformat_ieee_double_little);
- }
-      break;
-
-    default:
-      internal_error (__FILE__, __LINE__,
-      _("arm_gdbarch_init: bad byte order for float format"));
+      set_gdbarch_double_format
+ (gdbarch, floatformats_ieee_double_littlebyte_bigword);
+      set_gdbarch_long_double_format
+ (gdbarch, floatformats_ieee_double_littlebyte_bigword);
+    }
+  else
+    {
+      set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
+      set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
     }
 
   return gdbarch;
Index: src/gdb/avr-tdep.c
===================================================================
--- src.orig/gdb/avr-tdep.c 2007-01-24 11:52:05.000000000 -0500
+++ src/gdb/avr-tdep.c 2007-01-24 14:07:41.000000000 -0500
@@ -1267,9 +1267,9 @@ avr_gdbarch_init (struct gdbarch_info in
   set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
   set_gdbarch_long_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
 
-  set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_little);
-  set_gdbarch_double_format (gdbarch, &floatformat_ieee_single_little);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_single_little);
+  set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
+  set_gdbarch_double_format (gdbarch, floatformats_ieee_single);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_single);
 
   set_gdbarch_read_pc (gdbarch, avr_read_pc);
   set_gdbarch_write_pc (gdbarch, avr_write_pc);
Index: src/gdb/doublest.c
===================================================================
--- src.orig/gdb/doublest.c 2007-01-24 12:08:52.000000000 -0500
+++ src/gdb/doublest.c 2007-01-24 12:10:38.000000000 -0500
@@ -689,19 +689,19 @@ floatformat_from_length (int len)
 {
   const struct floatformat *format;
   if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
-    format = TARGET_FLOAT_FORMAT;
+    format = TARGET_FLOAT_FORMAT[TARGET_BYTE_ORDER];
   else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
-    format = TARGET_DOUBLE_FORMAT;
+    format = TARGET_DOUBLE_FORMAT[TARGET_BYTE_ORDER];
   else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
-    format = TARGET_LONG_DOUBLE_FORMAT;
+    format = TARGET_LONG_DOUBLE_FORMAT[TARGET_BYTE_ORDER];
   /* On i386 the 'long double' type takes 96 bits,
      while the real number of used bits is only 80,
      both in processor and in memory.  
      The code below accepts the real bit size.  */
   else if ((TARGET_LONG_DOUBLE_FORMAT != NULL)
    && (len * TARGET_CHAR_BIT ==
-               TARGET_LONG_DOUBLE_FORMAT->totalsize))
-    format = TARGET_LONG_DOUBLE_FORMAT;
+               TARGET_LONG_DOUBLE_FORMAT[0]->totalsize))
+    format = TARGET_LONG_DOUBLE_FORMAT[TARGET_BYTE_ORDER];
   else
     format = NULL;
   if (format == NULL)
@@ -715,7 +715,7 @@ floatformat_from_type (const struct type
 {
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
   if (TYPE_FLOATFORMAT (type) != NULL)
-    return TYPE_FLOATFORMAT (type);
+    return TYPE_FLOATFORMAT (type)[TARGET_BYTE_ORDER];
   else
     return floatformat_from_length (TYPE_LENGTH (type));
 }
@@ -776,7 +776,8 @@ extract_typed_floating (const void *addr
        specific code? stabs?) so handle that here as a special case.  */
     return extract_floating_by_length (addr, TYPE_LENGTH (type));
 
-  floatformat_to_doublest (TYPE_FLOATFORMAT (type), addr, &retval);
+  floatformat_to_doublest (TYPE_FLOATFORMAT (type)[TARGET_BYTE_ORDER],
+   addr, &retval);
   return retval;
 }
 
@@ -813,7 +814,8 @@ store_typed_floating (void *addr, const
        specific code? stabs?) so handle that here as a special case.  */
     store_floating_by_length (addr, TYPE_LENGTH (type), val);
   else
-    floatformat_from_doublest (TYPE_FLOATFORMAT (type), &val, addr);
+    floatformat_from_doublest (TYPE_FLOATFORMAT (type)[TARGET_BYTE_ORDER],
+       &val, addr);
 }
 
 /* Convert a floating-point number of type FROM_TYPE from a
Index: src/gdb/doublest.h
===================================================================
--- src.orig/gdb/doublest.h 2007-01-24 12:08:45.000000000 -0500
+++ src/gdb/doublest.h 2007-01-24 12:08:47.000000000 -0500
@@ -100,11 +100,4 @@ extern void convert_typed_floating (cons
     const struct type *from_type,
                                     void *to, const struct type *to_type);
 
-/* Table of convenient float-formats.  */
-extern const struct floatformat *floatformat_ieee_single[BFD_ENDIAN_UNKNOWN];
-extern const struct floatformat *floatformat_ieee_double[BFD_ENDIAN_UNKNOWN];
-extern const struct floatformat *floatformat_ieee_quad[BFD_ENDIAN_UNKNOWN];
-extern const struct floatformat *floatformat_arm_ext[BFD_ENDIAN_UNKNOWN];
-extern const struct floatformat *floatformat_ia64_spill[BFD_ENDIAN_UNKNOWN];
-
 #endif
Index: src/gdb/gdbarch.c
===================================================================
--- src.orig/gdb/gdbarch.c 2007-01-24 11:44:38.000000000 -0500
+++ src/gdb/gdbarch.c 2007-01-24 13:50:23.000000000 -0500
@@ -69,12 +69,13 @@ show_gdbarch_debug (struct ui_file *file
 }
 
 static const char *
-pformat (const struct floatformat *format)
+pformat (const struct floatformat **format)
 {
   if (format == NULL)
     return "(null)";
   else
-    return  format->name;
+    /* Just print out one of them - this is only for diagnostics.  */
+    return format[0]->name;
 }
 
 
@@ -136,11 +137,11 @@ struct gdbarch
   int long_bit;
   int long_long_bit;
   int float_bit;
-  const struct floatformat * float_format;
+  const struct floatformat ** float_format;
   int double_bit;
-  const struct floatformat * double_format;
+  const struct floatformat ** double_format;
   int long_double_bit;
-  const struct floatformat * long_double_format;
+  const struct floatformat ** long_double_format;
   int ptr_bit;
   int addr_bit;
   int bfd_vma_bit;
@@ -516,13 +517,13 @@ verify_gdbarch (struct gdbarch *current_
   /* Skip verify of long_long_bit, invalid_p == 0 */
   /* Skip verify of float_bit, invalid_p == 0 */
   if (current_gdbarch->float_format == 0)
-    current_gdbarch->float_format = default_float_format (current_gdbarch);
+    current_gdbarch->float_format = floatformats_ieee_single;
   /* Skip verify of double_bit, invalid_p == 0 */
   if (current_gdbarch->double_format == 0)
-    current_gdbarch->double_format = default_double_format (current_gdbarch);
+    current_gdbarch->double_format = floatformats_ieee_double;
   /* Skip verify of long_double_bit, invalid_p == 0 */
   if (current_gdbarch->long_double_format == 0)
-    current_gdbarch->long_double_format = default_double_format (current_gdbarch);
+    current_gdbarch->long_double_format = floatformats_ieee_double;
   /* Skip verify of ptr_bit, invalid_p == 0 */
   if (current_gdbarch->addr_bit == 0)
     current_gdbarch->addr_bit = TARGET_PTR_BIT;
@@ -1740,7 +1741,7 @@ set_gdbarch_float_bit (struct gdbarch *g
   gdbarch->float_bit = float_bit;
 }
 
-const struct floatformat *
+const struct floatformat **
 gdbarch_float_format (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != NULL);
@@ -1751,7 +1752,7 @@ gdbarch_float_format (struct gdbarch *gd
 
 void
 set_gdbarch_float_format (struct gdbarch *gdbarch,
-                          const struct floatformat * float_format)
+                          const struct floatformat ** float_format)
 {
   gdbarch->float_format = float_format;
 }
@@ -1773,7 +1774,7 @@ set_gdbarch_double_bit (struct gdbarch *
   gdbarch->double_bit = double_bit;
 }
 
-const struct floatformat *
+const struct floatformat **
 gdbarch_double_format (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != NULL);
@@ -1784,7 +1785,7 @@ gdbarch_double_format (struct gdbarch *g
 
 void
 set_gdbarch_double_format (struct gdbarch *gdbarch,
-                           const struct floatformat * double_format)
+                           const struct floatformat ** double_format)
 {
   gdbarch->double_format = double_format;
 }
@@ -1806,7 +1807,7 @@ set_gdbarch_long_double_bit (struct gdba
   gdbarch->long_double_bit = long_double_bit;
 }
 
-const struct floatformat *
+const struct floatformat **
 gdbarch_long_double_format (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != NULL);
@@ -1817,7 +1818,7 @@ gdbarch_long_double_format (struct gdbar
 
 void
 set_gdbarch_long_double_format (struct gdbarch *gdbarch,
-                                const struct floatformat * long_double_format)
+                                const struct floatformat ** long_double_format)
 {
   gdbarch->long_double_format = long_double_format;
 }
Index: src/gdb/gdbarch.h
===================================================================
--- src.orig/gdb/gdbarch.h 2007-01-24 11:44:38.000000000 -0500
+++ src/gdb/gdbarch.h 2007-01-24 11:46:46.000000000 -0500
@@ -141,7 +141,9 @@ extern void set_gdbarch_long_long_bit (s
 
 /* The ABI default bit-size and format for "float", "double", and "long
    double".  These bit/format pairs should eventually be combined into
-   a single object.  For the moment, just initialize them as a pair. */
+   a single object.  For the moment, just initialize them as a pair.
+   Each format describes both the big and little endian layouts (if
+   useful). */
 
 extern int gdbarch_float_bit (struct gdbarch *gdbarch);
 extern void set_gdbarch_float_bit (struct gdbarch *gdbarch, int float_bit);
@@ -152,8 +154,8 @@ extern void set_gdbarch_float_bit (struc
 #define TARGET_FLOAT_BIT (gdbarch_float_bit (current_gdbarch))
 #endif
 
-extern const struct floatformat * gdbarch_float_format (struct gdbarch *gdbarch);
-extern void set_gdbarch_float_format (struct gdbarch *gdbarch, const struct floatformat * float_format);
+extern const struct floatformat ** gdbarch_float_format (struct gdbarch *gdbarch);
+extern void set_gdbarch_float_format (struct gdbarch *gdbarch, const struct floatformat ** float_format);
 #if !defined (GDB_TM_FILE) && defined (TARGET_FLOAT_FORMAT)
 #error "Non multi-arch definition of TARGET_FLOAT_FORMAT"
 #endif
@@ -170,8 +172,8 @@ extern void set_gdbarch_double_bit (stru
 #define TARGET_DOUBLE_BIT (gdbarch_double_bit (current_gdbarch))
 #endif
 
-extern const struct floatformat * gdbarch_double_format (struct gdbarch *gdbarch);
-extern void set_gdbarch_double_format (struct gdbarch *gdbarch, const struct floatformat * double_format);
+extern const struct floatformat ** gdbarch_double_format (struct gdbarch *gdbarch);
+extern void set_gdbarch_double_format (struct gdbarch *gdbarch, const struct floatformat ** double_format);
 #if !defined (GDB_TM_FILE) && defined (TARGET_DOUBLE_FORMAT)
 #error "Non multi-arch definition of TARGET_DOUBLE_FORMAT"
 #endif
@@ -188,8 +190,8 @@ extern void set_gdbarch_long_double_bit
 #define TARGET_LONG_DOUBLE_BIT (gdbarch_long_double_bit (current_gdbarch))
 #endif
 
-extern const struct floatformat * gdbarch_long_double_format (struct gdbarch *gdbarch);
-extern void set_gdbarch_long_double_format (struct gdbarch *gdbarch, const struct floatformat * long_double_format);
+extern const struct floatformat ** gdbarch_long_double_format (struct gdbarch *gdbarch);
+extern void set_gdbarch_long_double_format (struct gdbarch *gdbarch, const struct floatformat ** long_double_format);
 #if !defined (GDB_TM_FILE) && defined (TARGET_LONG_DOUBLE_FORMAT)
 #error "Non multi-arch definition of TARGET_LONG_DOUBLE_FORMAT"
 #endif
Index: src/gdb/gdbarch.sh
===================================================================
--- src.orig/gdb/gdbarch.sh 2007-01-24 11:43:26.000000000 -0500
+++ src/gdb/gdbarch.sh 2007-01-24 13:49:46.000000000 -0500
@@ -391,13 +391,15 @@ v:TARGET_LONG_LONG_BIT:int:long_long_bit
 # The ABI default bit-size and format for "float", "double", and "long
 # double".  These bit/format pairs should eventually be combined into
 # a single object.  For the moment, just initialize them as a pair.
+# Each format describes both the big and little endian layouts (if
+# useful).
 
 v:TARGET_FLOAT_BIT:int:float_bit:::8 * sizeof (float):4*TARGET_CHAR_BIT::0
-v:TARGET_FLOAT_FORMAT:const struct floatformat *:float_format:::::default_float_format (current_gdbarch)::pformat (current_gdbarch->float_format)
+v:TARGET_FLOAT_FORMAT:const struct floatformat **:float_format:::::floatformats_ieee_single::pformat (current_gdbarch->float_format)
 v:TARGET_DOUBLE_BIT:int:double_bit:::8 * sizeof (double):8*TARGET_CHAR_BIT::0
-v:TARGET_DOUBLE_FORMAT:const struct floatformat *:double_format:::::default_double_format (current_gdbarch)::pformat (current_gdbarch->double_format)
+v:TARGET_DOUBLE_FORMAT:const struct floatformat **:double_format:::::floatformats_ieee_double::pformat (current_gdbarch->double_format)
 v:TARGET_LONG_DOUBLE_BIT:int:long_double_bit:::8 * sizeof (long double):8*TARGET_CHAR_BIT::0
-v:TARGET_LONG_DOUBLE_FORMAT:const struct floatformat *:long_double_format:::::default_double_format (current_gdbarch)::pformat (current_gdbarch->long_double_format)
+v:TARGET_LONG_DOUBLE_FORMAT:const struct floatformat **:long_double_format:::::floatformats_ieee_double::pformat (current_gdbarch->long_double_format)
 
 # For most targets, a pointer on the target and its representation as an
 # address in GDB have the same size and "look the same".  For such a
@@ -1204,12 +1206,13 @@ show_gdbarch_debug (struct ui_file *file
 }
 
 static const char *
-pformat (const struct floatformat *format)
+pformat (const struct floatformat **format)
 {
   if (format == NULL)
     return "(null)";
   else
-    return  format->name;
+    /* Just print out one of them - this is only for diagnostics.  */
+    return format[0]->name;
 }
 
 EOF
Index: src/gdb/gdbtypes.c
===================================================================
--- src.orig/gdb/gdbtypes.c 2007-01-24 10:54:00.000000000 -0500
+++ src/gdb/gdbtypes.c 2007-01-24 14:05:55.000000000 -0500
@@ -98,27 +98,57 @@ struct type *builtin_type_v4hi;
 struct type *builtin_type_v2si;
 struct type *builtin_type_vec64;
 struct type *builtin_type_vec128;
-struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN];
-struct type *builtin_type_ieee_single_big;
-struct type *builtin_type_ieee_single_little;
-struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN];
-struct type *builtin_type_ieee_double_big;
-struct type *builtin_type_ieee_double_little;
-struct type *builtin_type_ieee_double_littlebyte_bigword;
+
+/* Floatformat pairs.  */
+const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_ieee_single_big,
+  &floatformat_ieee_single_little
+};
+const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_ieee_double_big,
+  &floatformat_ieee_double_little
+};
+const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_ieee_double_big,
+  &floatformat_ieee_double_littlebyte_bigword
+};
+const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_i387_ext,
+  &floatformat_i387_ext
+};
+const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_m68881_ext,
+  &floatformat_m68881_ext
+};
+const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_arm_ext_big,
+  &floatformat_arm_ext_littlebyte_bigword
+};
+const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_ia64_spill_big,
+  &floatformat_ia64_spill_little
+};
+const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_ia64_quad_big,
+  &floatformat_ia64_quad_little
+};
+const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_vax_f,
+  &floatformat_vax_f
+};
+const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_vax_d,
+  &floatformat_vax_d
+};
+
+struct type *builtin_type_ieee_single;
+struct type *builtin_type_ieee_double;
 struct type *builtin_type_i387_ext;
 struct type *builtin_type_m68881_ext;
-struct type *builtin_type_i960_ext;
-struct type *builtin_type_m88110_ext;
-struct type *builtin_type_m88110_harris_ext;
-struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN];
-struct type *builtin_type_arm_ext_big;
-struct type *builtin_type_arm_ext_littlebyte_bigword;
-struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN];
-struct type *builtin_type_ia64_spill_big;
-struct type *builtin_type_ia64_spill_little;
-struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN];
-struct type *builtin_type_ia64_quad_big;
-struct type *builtin_type_ia64_quad_little;
+struct type *builtin_type_arm_ext;
+struct type *builtin_type_ia64_spill;
+struct type *builtin_type_ia64_quad;
+
 struct type *builtin_type_void_data_ptr;
 struct type *builtin_type_void_func_ptr;
 struct type *builtin_type_CORE_ADDR;
@@ -3148,11 +3178,26 @@ recursive_dump_type (struct type *type,
 
     case TYPE_CODE_FLT:
       printfi_filtered (spaces, "floatformat ");
-      if (TYPE_FLOATFORMAT (type) == NULL
-  || TYPE_FLOATFORMAT (type)->name == NULL)
+      if (TYPE_FLOATFORMAT (type) == NULL)
  puts_filtered ("(null)");
       else
- puts_filtered (TYPE_FLOATFORMAT (type)->name);
+ {
+  puts_filtered ("{ ");
+  if (TYPE_FLOATFORMAT (type)[0] == NULL
+      || TYPE_FLOATFORMAT (type)[0]->name == NULL)
+    puts_filtered ("(null)");
+  else
+    puts_filtered (TYPE_FLOATFORMAT (type)[0]->name);
+
+  puts_filtered (", ");
+  if (TYPE_FLOATFORMAT (type)[1] == NULL
+      || TYPE_FLOATFORMAT (type)[1]->name == NULL)
+    puts_filtered ("(null)");
+  else
+    puts_filtered (TYPE_FLOATFORMAT (type)[1]->name);
+
+  puts_filtered (" }");
+ }
       puts_filtered ("\n");
       break;
 
@@ -3315,6 +3360,22 @@ copy_type_recursive (struct objfile *obj
   return new_type;
 }
 
+static struct type *
+build_flt (int bit, char *name, const struct floatformat **floatformats)
+{
+  struct type *t;
+
+  gdb_assert (floatformats != NULL);
+  gdb_assert (floatformats[0] != NULL && floatformats[1] != NULL);
+  if (bit == -1)
+    bit = floatformats[0]->totalsize;
+  gdb_assert (bit >= 0);
+
+  t = init_type (TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, 0, name, NULL);
+  TYPE_FLOATFORMAT (t) = floatformats;
+  return t;
+}
+
 static void
 build_gdbtypes (void)
 {
@@ -3371,35 +3432,14 @@ build_gdbtypes (void)
     init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
        TYPE_FLAG_UNSIGNED,
        "unsigned long long", (struct objfile *) NULL);
-  builtin_type_float =
-    init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
-       0,
-       "float", (struct objfile *) NULL);
-/* [hidden email] 2002-02-08:
-   The below lines are disabled since they are doing the wrong
-   thing for non-multiarch targets.  They are setting the correct
-   type of floats for the target but while on multiarch targets
-   this is done everytime the architecture changes, it's done on
-   non-multiarch targets only on startup, leaving the wrong values
-   in even if the architecture changes (eg. from big-endian to
-   little-endian).  */
-#if 0
-  TYPE_FLOATFORMAT (builtin_type_float) = TARGET_FLOAT_FORMAT;
-#endif
-  builtin_type_double =
-    init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
-       0,
-       "double", (struct objfile *) NULL);
-#if 0
-  TYPE_FLOATFORMAT (builtin_type_double) = TARGET_DOUBLE_FORMAT;
-#endif
-  builtin_type_long_double =
-    init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
-       0,
-       "long double", (struct objfile *) NULL);
-#if 0
-  TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT;
-#endif
+
+  builtin_type_float = build_flt (TARGET_FLOAT_BIT, "float",
+  TARGET_FLOAT_FORMAT);
+  builtin_type_double = build_flt (TARGET_DOUBLE_BIT, "double",
+   TARGET_DOUBLE_FORMAT);
+  builtin_type_long_double = build_flt (TARGET_LONG_DOUBLE_BIT, "long double",
+ TARGET_LONG_DOUBLE_FORMAT);
+
   builtin_type_complex =
     init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
        0,
@@ -3503,21 +3543,6 @@ builtin_type (struct gdbarch *gdbarch)
 
 
 static struct type *
-build_flt (int bit, char *name, const struct floatformat *floatformat)
-{
-  struct type *t;
-  if (bit <= 0 || floatformat == NULL)
-    {
-      gdb_assert (builtin_type_error != NULL);
-      return builtin_type_error;
-    }
-  t = init_type (TYPE_CODE_FLT, bit / TARGET_CHAR_BIT,
- 0, name, (struct objfile *) NULL);
-  TYPE_FLOATFORMAT (t) = floatformat;
-  return t;
-}
-
-static struct type *
 build_complex (int bit, char *name, struct type *target_type)
 {
   struct type *t;
@@ -3768,110 +3793,20 @@ _initialize_gdbtypes (void)
   /* Note: These types do not need to be swapped - they are target
      neutral.  FIXME: Are you sure?  See the comment above the calls
      to DEPRECATED_REGISTER_GDBARCH_SWAP above.  */
-  builtin_type_ieee_single_big =
-    init_type (TYPE_CODE_FLT, floatformat_ieee_single_big.totalsize / 8,
-       0, "builtin_type_ieee_single_big", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ieee_single_big) = &floatformat_ieee_single_big;
-  builtin_type_ieee_single_little =
-    init_type (TYPE_CODE_FLT, floatformat_ieee_single_little.totalsize / 8,
-       0, "builtin_type_ieee_single_little", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ieee_single_little) = &floatformat_ieee_single_little;
-  builtin_type_ieee_single[BFD_ENDIAN_BIG]
-    = build_flt (floatformat_ieee_single_big.totalsize,
- "builtin_type_ieee_single_big",
- &floatformat_ieee_single_big);
-  builtin_type_ieee_single[BFD_ENDIAN_LITTLE]
-    = build_flt (floatformat_ieee_single_little.totalsize,
- "builtin_type_ieee_single_little",
- &floatformat_ieee_single_little);
-  builtin_type_ieee_double_big =
-    init_type (TYPE_CODE_FLT, floatformat_ieee_double_big.totalsize / 8,
-       0, "builtin_type_ieee_double_big", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ieee_double_big) = &floatformat_ieee_double_big;
-  builtin_type_ieee_double_little =
-    init_type (TYPE_CODE_FLT, floatformat_ieee_double_little.totalsize / 8,
-       0, "builtin_type_ieee_double_little", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ieee_double_little) = &floatformat_ieee_double_little;
-  builtin_type_ieee_double[BFD_ENDIAN_BIG]
-    = build_flt (floatformat_ieee_double_big.totalsize,
- "builtin_type_ieee_double_big",
- &floatformat_ieee_double_big);
-  builtin_type_ieee_double[BFD_ENDIAN_LITTLE]
-    = build_flt (floatformat_ieee_double_little.totalsize,
- "builtin_type_ieee_double_little",
- &floatformat_ieee_double_little);
-  builtin_type_ieee_double_littlebyte_bigword =
-    init_type (TYPE_CODE_FLT, floatformat_ieee_double_littlebyte_bigword.totalsize / 8,
-       0, "builtin_type_ieee_double_littlebyte_bigword", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ieee_double_littlebyte_bigword) = &floatformat_ieee_double_littlebyte_bigword;
-  builtin_type_i387_ext =
-    init_type (TYPE_CODE_FLT, floatformat_i387_ext.totalsize / 8,
-       0, "builtin_type_i387_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_i387_ext) = &floatformat_i387_ext;
-  builtin_type_m68881_ext =
-    init_type (TYPE_CODE_FLT, floatformat_m68881_ext.totalsize / 8,
-       0, "builtin_type_m68881_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_m68881_ext) = &floatformat_m68881_ext;
-  builtin_type_i960_ext =
-    init_type (TYPE_CODE_FLT, floatformat_i960_ext.totalsize / 8,
-       0, "builtin_type_i960_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_i960_ext) = &floatformat_i960_ext;
-  builtin_type_m88110_ext =
-    init_type (TYPE_CODE_FLT, floatformat_m88110_ext.totalsize / 8,
-       0, "builtin_type_m88110_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_m88110_ext) = &floatformat_m88110_ext;
-  builtin_type_m88110_harris_ext =
-    init_type (TYPE_CODE_FLT, floatformat_m88110_harris_ext.totalsize / 8,
-       0, "builtin_type_m88110_harris_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_m88110_harris_ext) = &floatformat_m88110_harris_ext;
-  builtin_type_arm_ext_big =
-    init_type (TYPE_CODE_FLT, floatformat_arm_ext_big.totalsize / 8,
-       0, "builtin_type_arm_ext_big", NULL);
-  TYPE_FLOATFORMAT (builtin_type_arm_ext_big) = &floatformat_arm_ext_big;
-  builtin_type_arm_ext_littlebyte_bigword =
-    init_type (TYPE_CODE_FLT, floatformat_arm_ext_littlebyte_bigword.totalsize / 8,
-       0, "builtin_type_arm_ext_littlebyte_bigword", NULL);
-  TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword) = &floatformat_arm_ext_littlebyte_bigword;
-  builtin_type_arm_ext[BFD_ENDIAN_BIG]
-    = build_flt (floatformat_arm_ext_big.totalsize,
- "builtin_type_arm_ext_big",
- &floatformat_arm_ext_big);
-  builtin_type_arm_ext[BFD_ENDIAN_LITTLE]
-    = build_flt (floatformat_arm_ext_littlebyte_bigword.totalsize,
- "builtin_type_arm_ext_littlebyte_bigword",
- &floatformat_arm_ext_littlebyte_bigword);
-  builtin_type_ia64_spill_big =
-    init_type (TYPE_CODE_FLT, floatformat_ia64_spill_big.totalsize / 8,
-       0, "builtin_type_ia64_spill_big", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_spill_big) = &floatformat_ia64_spill_big;
-  builtin_type_ia64_spill_little =
-    init_type (TYPE_CODE_FLT, floatformat_ia64_spill_little.totalsize / 8,
-       0, "builtin_type_ia64_spill_little", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_spill_little) = &floatformat_ia64_spill_little;
-  builtin_type_ia64_spill[BFD_ENDIAN_BIG]
-    = build_flt (floatformat_ia64_spill_big.totalsize,
- "builtin_type_ia64_spill_big",
- &floatformat_ia64_spill_big);
-  builtin_type_ia64_spill[BFD_ENDIAN_LITTLE]
-    = build_flt (floatformat_ia64_spill_little.totalsize,
- "builtin_type_ia64_spill_little",
- &floatformat_ia64_spill_little);
-  builtin_type_ia64_quad_big =
-    init_type (TYPE_CODE_FLT, floatformat_ia64_quad_big.totalsize / 8,
-       0, "builtin_type_ia64_quad_big", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_quad_big) = &floatformat_ia64_quad_big;
-  builtin_type_ia64_quad_little =
-    init_type (TYPE_CODE_FLT, floatformat_ia64_quad_little.totalsize / 8,
-       0, "builtin_type_ia64_quad_little", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_quad_little) = &floatformat_ia64_quad_little;
-  builtin_type_ia64_quad[BFD_ENDIAN_BIG]
-    = build_flt (floatformat_ia64_quad_big.totalsize,
- "builtin_type_ia64_quad_big",
- &floatformat_ia64_quad_big);
-  builtin_type_ia64_quad[BFD_ENDIAN_LITTLE]
-    = build_flt (floatformat_ia64_quad_little.totalsize,
- "builtin_type_ia64_quad_little",
- &floatformat_ia64_quad_little);
+  builtin_type_ieee_single
+    = build_flt (-1, "builtin_type_ieee_single", floatformats_ieee_single);
+  builtin_type_ieee_double
+    = build_flt (-1, "builtin_type_ieee_double", floatformats_ieee_double);
+  builtin_type_i387_ext
+    = build_flt (-1, "builtin_type_i387_ext", floatformats_i387_ext);
+  builtin_type_m68881_ext
+    = build_flt (-1, "builtin_type_m68881_ext", floatformats_m68881_ext);
+  builtin_type_arm_ext
+    = build_flt (-1, "builtin_type_arm_ext", floatformats_arm_ext);
+  builtin_type_ia64_spill
+    = build_flt (-1, "builtin_type_ia64_spill", floatformats_ia64_spill);
+  builtin_type_ia64_quad
+    = build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
 
   add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
 Set debugging of C++ overloading."), _("\
Index: src/gdb/gdbtypes.h
===================================================================
--- src.orig/gdb/gdbtypes.h 2007-01-24 10:51:48.000000000 -0500
+++ src/gdb/gdbtypes.h 2007-01-24 13:52:10.000000000 -0500
@@ -497,11 +497,12 @@ struct main_type
 
     struct cplus_struct_type *cplus_stuff;
 
-    /* FLOATFORMAT is for TYPE_CODE_FLT.  It is a pointer to the
-       floatformat object that describes the floating-point value
-       that resides within the type.  */
+    /* FLOATFORMAT is for TYPE_CODE_FLT.  It is a pointer to two
+       floatformat objects that describe the floating-point value
+       that resides within the type.  The first is for big endian
+       targets and the second is for little endian targets.  */
 
-    const struct floatformat *floatformat;
+    const struct floatformat **floatformat;
   } type_specific;
 };
 
@@ -1105,27 +1106,24 @@ extern struct type *builtin_type_v16_int
 extern struct type *builtin_type_vec128;
 
 /* Explicit floating-point formats.  See "floatformat.h".  */
-extern struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN];
-extern struct type *builtin_type_ieee_single_big;
-extern struct type *builtin_type_ieee_single_little;
-extern struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN];
-extern struct type *builtin_type_ieee_double_big;
-extern struct type *builtin_type_ieee_double_little;
-extern struct type *builtin_type_ieee_double_littlebyte_bigword;
+extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
+
+extern struct type *builtin_type_ieee_single;
+extern struct type *builtin_type_ieee_double;
 extern struct type *builtin_type_i387_ext;
 extern struct type *builtin_type_m68881_ext;
-extern struct type *builtin_type_i960_ext;
-extern struct type *builtin_type_m88110_ext;
-extern struct type *builtin_type_m88110_harris_ext;
-extern struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN];
-extern struct type *builtin_type_arm_ext_big;
-extern struct type *builtin_type_arm_ext_littlebyte_bigword;
-extern struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN];
-extern struct type *builtin_type_ia64_spill_big;
-extern struct type *builtin_type_ia64_spill_little;
-extern struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN];
-extern struct type *builtin_type_ia64_quad_big;
-extern struct type *builtin_type_ia64_quad_little;
+extern struct type *builtin_type_arm_ext;
+extern struct type *builtin_type_ia64_spill;
+extern struct type *builtin_type_ia64_quad;
 
 /* We use this for the '/c' print format, because builtin_type_char is
    just a one-byte integral type, which languages less laid back than
Index: src/gdb/hppa-tdep.c
===================================================================
--- src.orig/gdb/hppa-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/hppa-tdep.c 2007-01-24 14:13:38.000000000 -0500
@@ -2635,7 +2635,7 @@ hppa32_register_type (struct gdbarch *gd
    if (regnum < HPPA_FP4_REGNUM)
      return builtin_type_uint32;
    else
-     return builtin_type_ieee_single_big;
+     return builtin_type_ieee_single;
 }
 
 static struct type *
@@ -2644,7 +2644,7 @@ hppa64_register_type (struct gdbarch *gd
    if (regnum < HPPA64_FP4_REGNUM)
      return builtin_type_uint64;
    else
-     return builtin_type_ieee_double_big;
+     return builtin_type_ieee_double;
 }
 
 /* Return non-zero if REGNUM is not a register available to the user
@@ -3085,7 +3085,7 @@ hppa_gdbarch_init (struct gdbarch_info i
      and LP64, but might show differences some day.  */
   set_gdbarch_long_long_bit (gdbarch, 64);
   set_gdbarch_long_double_bit (gdbarch, 128);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
 
   /* The following gdbarch vector elements do not depend on the address
      size, or in any other gdbarch element previously set.  */
Index: src/gdb/hppabsd-tdep.c
===================================================================
--- src.orig/gdb/hppabsd-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/hppabsd-tdep.c 2007-01-24 14:03:23.000000000 -0500
@@ -171,7 +171,7 @@ hppabsd_init_abi (struct gdbarch_info in
 
   /* OpenBSD and NetBSD have a 64-bit 'long double'.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
 
   /* Core file support.  */
   set_gdbarch_regset_from_core_section
Index: src/gdb/i386-tdep.c
===================================================================
--- src.orig/gdb/i386-tdep.c 2007-01-24 11:44:23.000000000 -0500
+++ src/gdb/i386-tdep.c 2007-01-24 14:03:20.000000000 -0500
@@ -2333,7 +2333,7 @@ i386_gdbarch_init (struct gdbarch_info i
      the i387 extended floating-point format.  In fact, of all targets
      in the GCC 2.95 tree, only OSF/1 does it different, and insists
      on having a `long double' that's not `long' at all.  */
-  set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
+  set_gdbarch_long_double_format (gdbarch, floatformats_i387_ext);
 
   /* Although the i387 extended floating-point has only 80 significant
      bits, a `long double' actually takes up 96, probably to enforce
Index: src/gdb/ia64-tdep.c
===================================================================
--- src.orig/gdb/ia64-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/ia64-tdep.c 2007-01-24 14:03:18.000000000 -0500
@@ -336,6 +336,12 @@ const struct floatformat floatformat_ia6
   floatformat_intbit_yes, "floatformat_ia64_ext", floatformat_valid
 };
 
+const struct floatformat *floatformats_ia64_ext[2] =
+{
+  &floatformat_ia64_ext,
+  &floatformat_ia64_ext
+};
+
 
 /* Extract ``len'' bits from an instruction bundle starting at
    bit ``from''.  */
@@ -3574,7 +3580,7 @@ ia64_gdbarch_init (struct gdbarch_info i
   builtin_type_ia64_ext =
     init_type (TYPE_CODE_FLT, 128 / 8,
                0, "builtin_type_ia64_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_ext) = &floatformat_ia64_ext;
+  TYPE_FLOATFORMAT (builtin_type_ia64_ext) = &floatformats_ia64_ext;
 
   /* According to the ia64 specs, instructions that store long double
      floats in memory use a long-double format different than that
@@ -3584,7 +3590,7 @@ ia64_gdbarch_init (struct gdbarch_info i
      format for storing long doubles (e.g. HPUX).  In the latter case,
      the setting of the format may be moved/overridden in an
      OS-specific tdep file.  */
-  set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
+  set_gdbarch_long_double_format (gdbarch, floatformats_i387_ext);
 
   set_gdbarch_short_bit (gdbarch, 16);
   set_gdbarch_int_bit (gdbarch, 32);
Index: src/gdb/iq2000-tdep.c
===================================================================
--- src.orig/gdb/iq2000-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/iq2000-tdep.c 2007-01-24 14:03:14.000000000 -0500
@@ -837,9 +837,9 @@ iq2000_gdbarch_init (struct gdbarch_info
   set_gdbarch_float_bit            (gdbarch, 4 * TARGET_CHAR_BIT);
   set_gdbarch_double_bit           (gdbarch, 8 * TARGET_CHAR_BIT);
   set_gdbarch_long_double_bit      (gdbarch, 8 * TARGET_CHAR_BIT);
-  set_gdbarch_float_format         (gdbarch, & floatformat_ieee_single_big);
-  set_gdbarch_double_format        (gdbarch, & floatformat_ieee_double_big);
-  set_gdbarch_long_double_format   (gdbarch, & floatformat_ieee_double_big);
+  set_gdbarch_float_format         (gdbarch, floatformats_ieee_single);
+  set_gdbarch_double_format        (gdbarch, floatformats_ieee_double);
+  set_gdbarch_long_double_format   (gdbarch, floatformats_ieee_double);
   set_gdbarch_return_value   (gdbarch, iq2000_return_value);
   set_gdbarch_breakpoint_from_pc   (gdbarch, iq2000_breakpoint_from_pc);
   set_gdbarch_frame_args_skip      (gdbarch, 0);
Index: src/gdb/m68k-tdep.c
===================================================================
--- src.orig/gdb/m68k-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/m68k-tdep.c 2007-01-24 14:03:08.000000000 -0500
@@ -1157,7 +1157,7 @@ m68k_gdbarch_init (struct gdbarch_info i
   tdep = xmalloc (sizeof (struct gdbarch_tdep));
   gdbarch = gdbarch_alloc (&info, tdep);
 
-  set_gdbarch_long_double_format (gdbarch, &floatformat_m68881_ext);
+  set_gdbarch_long_double_format (gdbarch, floatformats_m68881_ext);
   set_gdbarch_long_double_bit (gdbarch, 96);
 
   set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue);
Index: src/gdb/m88k-tdep.c
===================================================================
--- src.orig/gdb/m88k-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/m88k-tdep.c 2007-01-24 14:03:04.000000000 -0500
@@ -845,7 +845,7 @@ m88k_gdbarch_init (struct gdbarch_info i
 
   /* There is no real `long double'.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
 
   set_gdbarch_num_regs (gdbarch, M88K_NUM_REGS);
   set_gdbarch_register_name (gdbarch, m88k_register_name);
Index: src/gdb/mips-linux-tdep.c
===================================================================
--- src.orig/gdb/mips-linux-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/mips-linux-tdep.c 2007-01-24 14:03:01.000000000 -0500
@@ -1152,10 +1152,7 @@ mips_linux_init_abi (struct gdbarch_info
    the same 128-bit IEEE floating point format that IA-64 uses,
    except that the quiet/signalling NaN bit is reversed (GDB
    does not distinguish between quiet and signalling NaNs).  */
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big);
- else
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_little);
+ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
  tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe);
  break;
       case MIPS_ABI_N64:
@@ -1169,10 +1166,7 @@ mips_linux_init_abi (struct gdbarch_info
    the same 128-bit IEEE floating point format that IA-64 uses,
    except that the quiet/signalling NaN bit is reversed (GDB
    does not distinguish between quiet and signalling NaNs).  */
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big);
- else
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_little);
+ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
  tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe);
  break;
       default:
Index: src/gdb/mips-tdep.c
===================================================================
--- src.orig/gdb/mips-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/mips-tdep.c 2007-01-24 14:12:30.000000000 -0500
@@ -179,10 +179,16 @@ static const struct floatformat floatfor
 {
   floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
   floatformat_intbit_no,
-  "floatformat_ieee_double_big",
+  "floatformat_n32n64_long_double_big",
   n32n64_floatformat_always_valid
 };
 
+static const struct floatformat *floatformats_n32n64_long[BFD_ENDIAN_UNKNOWN] =
+{
+  &floatformat_n32n64_long_double_big,
+  &floatformat_n32n64_long_double_big
+};
+
 const struct mips_regnum *
 mips_regnum (struct gdbarch *gdbarch)
 {
@@ -701,22 +707,10 @@ mips_register_type (struct gdbarch *gdba
     {
       /* The floating-point registers raw, or cooked, always match
          mips_isa_regsize(), and also map 1:1, byte for byte.  */
-      switch (gdbarch_byte_order (gdbarch))
- {
- case BFD_ENDIAN_BIG:
-  if (mips_isa_regsize (gdbarch) == 4)
-    return builtin_type_ieee_single_big;
-  else
-    return builtin_type_ieee_double_big;
- case BFD_ENDIAN_LITTLE:
-  if (mips_isa_regsize (gdbarch) == 4)
-    return builtin_type_ieee_single_little;
-  else
-    return builtin_type_ieee_double_little;
- case BFD_ENDIAN_UNKNOWN:
- default:
-  internal_error (__FILE__, __LINE__, _("bad switch"));
- }
+      if (mips_isa_regsize (gdbarch) == 4)
+ return builtin_type_ieee_single;
+      else
+ return builtin_type_ieee_double;
     }
   else if (regnum < NUM_REGS)
     {
@@ -3867,19 +3861,13 @@ mips_o64_return_value (struct gdbarch *g
 static struct type *
 mips_float_register_type (void)
 {
-  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
-    return builtin_type_ieee_single_big;
-  else
-    return builtin_type_ieee_single_little;
+  return builtin_type_ieee_single;
 }
 
 static struct type *
 mips_double_register_type (void)
 {
-  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
-    return builtin_type_ieee_double_big;
-  else
-    return builtin_type_ieee_double_little;
+  return builtin_type_ieee_double;
 }
 
 /* Copy a 32-bit single-precision value from the current frame
@@ -5077,8 +5065,7 @@ mips_gdbarch_init (struct gdbarch_info i
       set_gdbarch_ptr_bit (gdbarch, 32);
       set_gdbarch_long_long_bit (gdbarch, 64);
       set_gdbarch_long_double_bit (gdbarch, 128);
-      set_gdbarch_long_double_format (gdbarch,
-                                      &floatformat_n32n64_long_double_big);
+      set_gdbarch_long_double_format (gdbarch, floatformats_n32n64_long);
       break;
     case MIPS_ABI_N64:
       set_gdbarch_push_dummy_call (gdbarch, mips_n32n64_push_dummy_call);
@@ -5090,8 +5077,7 @@ mips_gdbarch_init (struct gdbarch_info i
       set_gdbarch_ptr_bit (gdbarch, 64);
       set_gdbarch_long_long_bit (gdbarch, 64);
       set_gdbarch_long_double_bit (gdbarch, 128);
-      set_gdbarch_long_double_format (gdbarch,
-                                      &floatformat_n32n64_long_double_big);
+      set_gdbarch_long_double_format (gdbarch, floatformats_n32n64_long);
       break;
     default:
       internal_error (__FILE__, __LINE__, _("unknown ABI in switch"));
Index: src/gdb/mt-tdep.c
===================================================================
--- src.orig/gdb/mt-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/mt-tdep.c 2007-01-24 14:02:46.000000000 -0500
@@ -1118,23 +1118,9 @@ mt_gdbarch_init (struct gdbarch_info inf
      provided.  */
   gdbarch = gdbarch_alloc (&info, NULL);
 
-  switch (info.byte_order)
-    {
-    case BFD_ENDIAN_BIG:
-      set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_big);
-      set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_big);
-      set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
-      break;
-    case BFD_ENDIAN_LITTLE:
-      set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_little);
-      set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_little);
-      set_gdbarch_long_double_format (gdbarch,
-      &floatformat_ieee_double_little);
-      break;
-    default:
-      internal_error (__FILE__, __LINE__,
-      _("mt_gdbarch_init: bad byte order for float format"));
-    }
+  set_gdbarch_float_format (gdbarch, floatformats_ieee_single_big);
+  set_gdbarch_double_format (gdbarch, floatformats_ieee_double_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double_big);
 
   set_gdbarch_register_name (gdbarch, mt_register_name);
   set_gdbarch_num_regs (gdbarch, MT_NUM_REGS);
Index: src/gdb/ppcobsd-tdep.c
===================================================================
--- src.orig/gdb/ppcobsd-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/ppcobsd-tdep.c 2007-01-24 14:02:40.000000000 -0500
@@ -280,7 +280,7 @@ ppcobsd_init_abi (struct gdbarch_info in
 {
   /* OpenBSD doesn't support the 128-bit `long double' from the psABI.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
 
   /* OpenBSD currently uses a broken GCC.  */
   set_gdbarch_return_value (gdbarch, ppc_sysv_abi_broken_return_value);
Index: src/gdb/sparc-linux-tdep.c
===================================================================
--- src.orig/gdb/sparc-linux-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/sparc-linux-tdep.c 2007-01-24 14:02:37.000000000 -0500
@@ -246,7 +246,7 @@ sparc32_linux_init_abi (struct gdbarch_i
 
   /* GNU/Linux doesn't support the 128-bit `long double' from the psABI.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
 
   /* Enable TLS support.  */
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
Index: src/gdb/sparc-tdep.c
===================================================================
--- src.orig/gdb/sparc-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/sparc-tdep.c 2007-01-24 14:02:31.000000000 -0500
@@ -65,7 +65,7 @@ struct regset;
 
 /* The SPARC Floating-Point Quad-Precision format is similar to
    big-endian IA-64 Quad-recision format.  */
-#define floatformat_sparc_quad floatformat_ia64_quad_big
+#define floatformats_sparc_quad floatformats_ia64_quad
 
 /* The stack pointer is offset from the stack frame by a BIAS of 2047
    (0x7ff) for 64-bit code.  BIAS is likely to be defined on SPARC
@@ -1296,7 +1296,7 @@ sparc32_gdbarch_init (struct gdbarch_inf
   tdep->step_trap = sparc_step_trap;
 
   set_gdbarch_long_double_bit (gdbarch, 128);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_sparc_quad);
+  set_gdbarch_long_double_format (gdbarch, floatformats_sparc_quad);
 
   set_gdbarch_num_regs (gdbarch, SPARC32_NUM_REGS);
   set_gdbarch_register_name (gdbarch, sparc32_register_name);
Index: src/gdb/sparcnbsd-tdep.c
===================================================================
--- src.orig/gdb/sparcnbsd-tdep.c 2007-01-24 11:52:06.000000000 -0500
+++ src/gdb/sparcnbsd-tdep.c 2007-01-24 14:02:27.000000000 -0500
@@ -293,7 +293,7 @@ sparc32nbsd_init_abi (struct gdbarch_inf
 
   /* NetBSD doesn't support the 128-bit `long double' from the psABI.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
 
   tdep->gregset = regset_alloc (gdbarch, sparc32nbsd_supply_gregset, NULL);
   tdep->sizeof_gregset = 20 * 4;
Index: src/gdb/spu-tdep.c
===================================================================
--- src.orig/gdb/spu-tdep.c 2007-01-24 11:51:32.000000000 -0500
+++ src/gdb/spu-tdep.c 2007-01-24 14:02:19.000000000 -0500
@@ -1053,9 +1053,9 @@ spu_gdbarch_init (struct gdbarch_info in
   set_gdbarch_float_bit (gdbarch, 32);
   set_gdbarch_double_bit (gdbarch, 64);
   set_gdbarch_long_double_bit (gdbarch, 64);
-  set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_big);
-  set_gdbarch_double_format (gdbarch, &floatformat_ieee_double_big);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+  set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
+  set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
 
   /* Inferior function calls.  */
   set_gdbarch_push_dummy_call (gdbarch, spu_push_dummy_call);
Index: src/gdb/vax-tdep.c
===================================================================
--- src.orig/gdb/vax-tdep.c 2007-01-24 11:49:05.000000000 -0500
+++ src/gdb/vax-tdep.c 2007-01-24 14:02:13.000000000 -0500
@@ -477,10 +477,10 @@ vax_gdbarch_init (struct gdbarch_info in
 
   gdbarch = gdbarch_alloc (&info, NULL);
 
-  set_gdbarch_float_format (gdbarch, &floatformat_vax_f);
-  set_gdbarch_double_format (gdbarch, &floatformat_vax_d);
-  set_gdbarch_long_double_format (gdbarch, &floatformat_vax_d);
-  set_gdbarch_long_double_bit(gdbarch, 64);
+  set_gdbarch_float_format (gdbarch, floatformats_vax_f);
+  set_gdbarch_double_format (gdbarch, floatformats_vax_d);
+  set_gdbarch_long_double_format (gdbarch, floatformats_vax_d);
+  set_gdbarch_long_double_bit (gdbarch, 64);
 
   /* Register info */
   set_gdbarch_num_regs (gdbarch, VAX_NUM_REGS);
Index: src/gdb/alpha-tdep.c
===================================================================
--- src.orig/gdb/alpha-tdep.c 2007-01-24 14:13:06.000000000 -0500
+++ src/gdb/alpha-tdep.c 2007-01-24 14:13:10.000000000 -0500
@@ -103,7 +103,7 @@ alpha_register_type (struct gdbarch *gdb
   /* Don't need to worry about little vs big endian until
      some jerk tries to port to alpha-unicosmk.  */
   if (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31)
-    return builtin_type_ieee_double_little;
+    return builtin_type_ieee_double;
 
   return builtin_type_int64;
 }
@@ -319,7 +319,7 @@ alpha_push_dummy_call (struct gdbarch *g
   if (accumulate_size < sizeof (arg_reg_buffer)
       && TYPE_LENGTH (arg_type) == 4)
     {
-      arg_type = builtin_type_ieee_double_little;
+      arg_type = builtin_type_ieee_double;
       arg = value_cast (arg_type, arg);
     }
   /* Tru64 5.1 has a 128-bit long double, and passes this by
Index: src/gdb/arch-utils.c
===================================================================
--- src.orig/gdb/arch-utils.c 2007-01-24 13:48:26.000000000 -0500
+++ src/gdb/arch-utils.c 2007-01-24 13:49:00.000000000 -0500
@@ -143,42 +143,6 @@ core_addr_greaterthan (CORE_ADDR lhs, CO
   return (lhs > rhs);
 }
 
-
-/* Helper functions for TARGET_{FLOAT,DOUBLE}_FORMAT */
-
-const struct floatformat *
-default_float_format (struct gdbarch *gdbarch)
-{
-  int byte_order = gdbarch_byte_order (gdbarch);
-  switch (byte_order)
-    {
-    case BFD_ENDIAN_BIG:
-      return &floatformat_ieee_single_big;
-    case BFD_ENDIAN_LITTLE:
-      return &floatformat_ieee_single_little;
-    default:
-      internal_error (__FILE__, __LINE__,
-      _("default_float_format: bad byte order"));
-    }
-}
-
-
-const struct floatformat *
-default_double_format (struct gdbarch *gdbarch)
-{
-  int byte_order = gdbarch_byte_order (gdbarch);
-  switch (byte_order)
-    {
-    case BFD_ENDIAN_BIG:
-      return &floatformat_ieee_double_big;
-    case BFD_ENDIAN_LITTLE:
-      return &floatformat_ieee_double_little;
-    default:
-      internal_error (__FILE__, __LINE__,
-      _("default_double_format: bad byte order"));
-    }
-}
-
 /* Misc helper functions for targets. */
 
 CORE_ADDR
Index: src/gdb/arch-utils.h
===================================================================
--- src.orig/gdb/arch-utils.h 2007-01-24 12:14:58.000000000 -0500
+++ src/gdb/arch-utils.h 2007-01-24 13:49:05.000000000 -0500
@@ -52,10 +52,6 @@ extern gdbarch_remote_translate_xfer_add
 extern int core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs);
 extern int core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs);
 
-/* Floating point values. */
-extern const struct floatformat *default_float_format (struct gdbarch *gdbarch);
-extern const struct floatformat *default_double_format (struct gdbarch *gdbarch);
-
 /* Identity functions on a CORE_ADDR.  Just return the "addr".  */
 
 extern CORE_ADDR core_addr_identity (CORE_ADDR addr);
Index: src/gdb/ppc-sysv-tdep.c
===================================================================
--- src.orig/gdb/ppc-sysv-tdep.c 2007-01-24 14:10:35.000000000 -0500
+++ src/gdb/ppc-sysv-tdep.c 2007-01-24 14:10:58.000000000 -0500
@@ -132,19 +132,8 @@ ppc_sysv_abi_push_dummy_call (struct gdb
   if (write_pass)
     {
       char memval[8];
-      struct type *memtype;
-      switch (TARGET_BYTE_ORDER)
- {
- case BFD_ENDIAN_BIG:
-  memtype = builtin_type_ieee_double_big;
-  break;
- case BFD_ENDIAN_LITTLE:
-  memtype = builtin_type_ieee_double_little;
-  break;
- default:
-  internal_error (__FILE__, __LINE__, _("bad switch"));
- }
-      convert_typed_floating (val, type, memval, memtype);
+      convert_typed_floating (val, type, memval,
+      builtin_type_ieee_double);
       write_memory (sp + argoffset, val, len);
     }
   argoffset += 8;
Reply | Threaded
Open this post in threaded view
|

Re: [rfc] Use two floatformats per type

Joel Brobecker
> Any comments?  Tested x86_64-linux; this modifies a lot of targets,
> but I've proofread it thoroughly.

This sounds like a good idea to me. I only scanned through the patch,
though.  I can test this patch on hppa-hpux, x86-linux, ia64-linux,
mips-irix, sparc-solaris, and alpha-osf if you like.

--
Joel
Reply | Threaded
Open this post in threaded view
|

Re: [rfc] Use two floatformats per type

Daniel Jacobowitz-2
On Thu, Jan 25, 2007 at 07:14:51PM -0500, Joel Brobecker wrote:
> > Any comments?  Tested x86_64-linux; this modifies a lot of targets,
> > but I've proofread it thoroughly.
>
> This sounds like a good idea to me. I only scanned through the patch,
> though.  I can test this patch on hppa-hpux, x86-linux, ia64-linux,
> mips-irix, sparc-solaris, and alpha-osf if you like.

Thanks.  I tested x86_64-linux again - I'm not sure how I did this last
time since it had a foolish assert in it - and checked it in.  If it
shows up a problem anywhere, please, let me know and I'll fix it ASAP!

--
Daniel Jacobowitz
CodeSourcery