Eliminate IEEE_FLOAT.
authorAndrew Cagney <cagney@redhat.com>
Sun, 20 Jan 2002 18:05:54 +0000 (18:05 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sun, 20 Jan 2002 18:05:54 +0000 (18:05 +0000)
29 files changed:
gdb/ChangeLog
gdb/config/alpha/tm-alpha.h
gdb/config/arc/tm-arc.h
gdb/config/arm/tm-arm.h
gdb/config/fr30/tm-fr30.h
gdb/config/h8300/tm-h8300.h
gdb/config/h8500/tm-h8500.h
gdb/config/i386/tm-i386.h
gdb/config/i960/tm-i960.h
gdb/config/m68k/tm-m68k.h
gdb/config/m88k/tm-m88k.h
gdb/config/pa/tm-hppa.h
gdb/config/sparc/tm-sparc.h
gdb/config/z8k/tm-z8k.h
gdb/cris-tdep.c
gdb/doc/ChangeLog
gdb/doc/gdbint.texinfo
gdb/doublest.c
gdb/doublest.h
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/m68hc11-tdep.c
gdb/mips-tdep.c
gdb/s390-tdep.c
gdb/sh-tdep.c
gdb/sparc-tdep.c
gdb/valprint.c
gdb/x86-64-tdep.c

index e247174..11ec997 100644 (file)
@@ -1,3 +1,36 @@
+2002-01-20  Andrew Cagney  <ac131313@redhat.com>
+
+       * doublest.h (floatformat_from_type): Declare.
+       * doublest.c (floatformat_from_type): New function.
+       (convert_typed_floating): Use.
+
+       * valprint.c (print_floating): Replace checks for IEEE_FLOAT with
+       call to function floatformat_from_type.
+
+       * gdbarch.sh (IEEE_FLOAT): Delete.
+       * gdbarch.h, gdbarch.c: Re-generate.
+       * config/i960/tm-i960.h (IEEE_FLOAT): Delete macro.
+       * config/i386/tm-i386.h (IEEE_FLOAT): Ditto.
+       * config/z8k/tm-z8k.h (IEEE_FLOAT): Ditto.
+       * config/sparc/tm-sparc.h (IEEE_FLOAT): Ditto.
+       * config/pa/tm-hppa.h (IEEE_FLOAT): Ditto.
+       * config/m88k/tm-m88k.h (IEEE_FLOAT): Ditto.
+       * config/m68k/tm-m68k.h (IEEE_FLOAT): Ditto.
+       * config/h8500/tm-h8500.h (IEEE_FLOAT): Ditto.
+       * config/h8300/tm-h8300.h (IEEE_FLOAT): Ditto.
+       * config/fr30/tm-fr30.h (IEEE_FLOAT): Ditto.
+       * config/arm/tm-arm.h (IEEE_FLOAT): Ditto.
+       * config/arc/tm-arc.h (IEEE_FLOAT): Ditto.
+       * config/alpha/tm-alpha.h (IEEE_FLOAT): Ditto.
+
+       * s390-tdep.c (s390_gdbarch_init): Do not set ieee_float.
+       * x86-64-tdep.c (i386_gdbarch_init): Ditto.
+       * sparc-tdep.c (sparc_gdbarch_init): Ditto.
+       * sh-tdep.c (sh_gdbarch_init): Ditto.
+       * mips-tdep.c (mips_gdbarch_init): Ditto.
+       * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto.
+       * cris-tdep.c (cris_gdbarch_init): Ditto.
+
 2002-01-20  Jiri Smid  <smid@suse.cz>
 
        * configure.host, configure.tgt: Support x86-64.
index cc29e77..a508354 100644 (file)
@@ -43,9 +43,6 @@ struct symbol;
 #define TARGET_LONG_LONG_BIT 64
 #define TARGET_PTR_BIT 64
 
-/* Floating point is IEEE compliant */
-#define IEEE_FLOAT (1)
-
 /* Number of traps that happen between exec'ing the shell 
  * to run an inferior, and when we finally get to 
  * the inferior code.  This is 2 on most implementations.
index 7521296..a015843 100644 (file)
@@ -27,9 +27,6 @@
 /* Byte order is selectable.  */
 #define        TARGET_BYTE_ORDER_SELECTABLE
 
-/* We have IEEE floating point, if we have any float at all.  */
-#define IEEE_FLOAT (1)
-
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
 #define FUNCTION_START_OFFSET 0
index 377b2d8..80fc1f6 100644 (file)
@@ -35,7 +35,6 @@ struct value;
 #define TARGET_BYTE_ORDER_DEFAULT BFD_ENDIAN_LITTLE
 
 /* IEEE format floating point.  */
-#define IEEE_FLOAT (1)
 #define TARGET_DOUBLE_FORMAT  (target_byte_order == BFD_ENDIAN_BIG \
                               ? &floatformat_ieee_double_big    \
                               : &floatformat_ieee_double_littlebyte_bigword)
index 5a415c9..4d55092 100644 (file)
@@ -187,9 +187,6 @@ extern void fr30_store_return_value (struct type *type, char *valbuf);
 /* Define this for Wingdb */
 #define TARGET_FR30
 
-/* IEEE format floating point */
-#define IEEE_FLOAT (1)
-
 /* Define other aspects of the stack frame.  */
 
 /* An expression that tells us whether the function invocation represented
index ad6e7a4..79f52dc 100644 (file)
@@ -58,7 +58,6 @@ extern int h8300smode;
 
 extern void h8300_init_extra_frame_info ();
 
-#define IEEE_FLOAT (1)
 /* Define the bit, byte, and word ordering of the machine.  */
 #define TARGET_BYTE_ORDER BFD_ENDIAN_BIG
 #undef TARGET_INT_BIT
index 5d00148..2beec07 100644 (file)
@@ -25,8 +25,6 @@
 
 #define GDB_TARGET_IS_H8500
 
-#define IEEE_FLOAT (1)
-
 /* Define the bit, byte, and word ordering of the machine.  */
 
 #define TARGET_BYTE_ORDER BFD_ENDIAN_BIG
index 0e3f9b0..9888ca4 100644 (file)
@@ -47,11 +47,6 @@ struct type;
 
 #define TARGET_LONG_DOUBLE_BIT 96
 
-/* Used for example in valprint.c:print_floating() to enable checking
-   for NaN's */
-
-#define IEEE_FLOAT (1)
-
 /* Number of traps that happen between exec'ing the shell to run an
    inferior, and when we finally get to the inferior code.  This is 2
    on most implementations. */
index b6ed313..da0766d 100644 (file)
 /* Byte order is configurable, but this machine runs little-endian.  */
 #define        TARGET_BYTE_ORDER BFD_ENDIAN_LITTLE
 
-/* We have IEEE floating point, if we have any float at all.  */
-
-#define IEEE_FLOAT (1)
-
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
 
index d993da5..888089b 100644 (file)
@@ -23,8 +23,6 @@
 
 /* Generic 68000 stuff, to be included by other tm-*.h files.  */
 
-#define IEEE_FLOAT (1)
-
 /* Define the bit, byte, and word ordering of the machine.  */
 #define TARGET_BYTE_ORDER BFD_ENDIAN_BIG
 
index 0f509ff..34762b9 100644 (file)
@@ -47,8 +47,6 @@
        init_extra_frame_info (fromleaf, fi)
 extern void init_extra_frame_info ();
 
-#define IEEE_FLOAT (1)
-
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
 
index ed74844..14dc304 100644 (file)
@@ -54,10 +54,6 @@ struct inferior_status;
   ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
 #endif
 
-/* Watch out for NaNs */
-
-#define IEEE_FLOAT (1)
-
 /* On the PA, any pass-by-value structure > 8 bytes is actually
    passed via a pointer regardless of its type or the compiler
    used.  */
index cf98201..4885cd0 100644 (file)
@@ -298,9 +298,6 @@ extern CORE_ADDR sparc_extract_struct_value_address (char *);
 #define STACK_ALIGN(ADDR) sparc32_stack_align (ADDR)
 extern CORE_ADDR sparc32_stack_align (CORE_ADDR addr);
 
-/* Floating point is IEEE compatible.  */
-#define IEEE_FLOAT (1)
-
 /* The Sparc returns long doubles on the stack.  */
 
 #define RETURN_VALUE_ON_STACK(TYPE) \
index 339eb8f..c0dbcd4 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#define IEEE_FLOAT (1)
-
 #undef TARGET_INT_BIT
 #undef TARGET_LONG_BIT
 #undef TARGET_SHORT_BIT
index a134430..8f22ed6 100644 (file)
@@ -4154,9 +4154,6 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      which means we have to set this explicitly.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
     
-  /* Floating point is IEEE compatible.  */
-  set_gdbarch_ieee_float (gdbarch, 1);
-
   /* There are 32 registers (some of which may not be implemented).  */
   set_gdbarch_num_regs (gdbarch, 32);
   set_gdbarch_sp_regnum (gdbarch, 14);
index c6dee70..fe7cf21 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-20  Andrew Cagney  <ac131313@redhat.com>
+
+       * gdbint.texinfo (Target Architecture Definition): Remove
+       definition of IEEE_FLOAT.
+
 2002-01-20  Eli Zaretskii  <eliz@is.elta.co.il>
 
        * gdb.texinfo: Beautify copyright years; fix a typo.
index 51e21db..515b30b 100644 (file)
@@ -3071,10 +3071,6 @@ On HP-UX, certain system routines (millicode) have names beginning with
 @samp{$} or @samp{$$}.  For example, @code{$$dyncall} is a millicode
 routine that handles inter-space procedure calls on PA-RISC.
 
-@item IEEE_FLOAT
-@findex IEEE_FLOAT
-Define this if the target system uses IEEE-format floating point numbers.
-
 @item INIT_EXTRA_FRAME_INFO (@var{fromleaf}, @var{frame})
 @findex INIT_EXTRA_FRAME_INFO
 If additional information about the frame is required this should be
index 083a50a..2b60657 100644 (file)
@@ -619,7 +619,7 @@ floatformat_from_doublest (const struct floatformat *fmt,
    target-dependent code, the format of floating-point types is known,
    but not passed on by GDB.  This should be fixed.  */
 
-static const struct floatformat *
+const struct floatformat *
 floatformat_from_length (int len)
 {
   if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
@@ -632,6 +632,16 @@ floatformat_from_length (int len)
   return NULL;
 }
 
+const struct floatformat *
+floatformat_from_type (const struct type *type)
+{
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
+  if (TYPE_FLOATFORMAT (type) != NULL)
+    return TYPE_FLOATFORMAT (type);
+  else
+    return floatformat_from_length (TYPE_LENGTH (type));
+}
+
 /* If the host doesn't define NAN, use zero instead.  */
 #ifndef NAN
 #define NAN 0.0
@@ -732,19 +742,12 @@ void
 convert_typed_floating (const void *from, const struct type *from_type,
                         void *to, const struct type *to_type)
 {
-  const struct floatformat *from_fmt = TYPE_FLOATFORMAT (from_type);
-  const struct floatformat *to_fmt = TYPE_FLOATFORMAT (to_type);
+  const struct floatformat *from_fmt = floatformat_from_type (from_type);
+  const struct floatformat *to_fmt = floatformat_from_type (to_type);
 
   gdb_assert (TYPE_CODE (from_type) == TYPE_CODE_FLT);
   gdb_assert (TYPE_CODE (to_type) == TYPE_CODE_FLT);
 
-  /* If the floating-point format of FROM_TYPE or TO_TYPE isn't known,
-     try to guess it from the type's length.  */
-  if (from_fmt == NULL)
-    from_fmt = floatformat_from_length (TYPE_LENGTH (from_type));
-  if (to_fmt == NULL)
-    to_fmt = floatformat_from_length (TYPE_LENGTH (to_type));
-
   if (from_fmt == NULL || to_fmt == NULL)
     {
       /* If we don't know the floating-point format of FROM_TYPE or
index ccd9233..0beeb9b 100644 (file)
@@ -68,6 +68,12 @@ extern char *floatformat_mantissa (const struct floatformat *, char *);
 extern DOUBLEST extract_floating (const void *addr, int len);
 extern void store_floating (void *addr, int len, DOUBLEST val);
 
+/* Given TYPE, return its floatformat.  TYPE_FLOATFORMAT() may return
+   NULL.  type_floatformat() detects that and returns a floatformat
+   based on the type size when FLOATFORMAT is NULL.  */
+
+const struct floatformat *floatformat_from_type (const struct type *type);
+
 extern DOUBLEST extract_typed_floating (const void *addr,
                                        const struct type *type);
 extern void store_typed_floating (void *addr, const struct type *type,
index e53c521..0cc5a36 100644 (file)
@@ -145,7 +145,6 @@ struct gdbarch
   int addr_bit;
   int bfd_vma_bit;
   int char_signed;
-  int ieee_float;
   gdbarch_read_pc_ftype *read_pc;
   gdbarch_write_pc_ftype *write_pc;
   gdbarch_read_fp_ftype *read_fp;
@@ -313,7 +312,6 @@ struct gdbarch startup_gdbarch =
   0,
   0,
   0,
-  0,
   generic_register_raw_size,
   0,
   generic_register_virtual_size,
@@ -566,7 +564,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of bfd_vma_bit, invalid_p == 0 */
   if (gdbarch->char_signed == -1)
     gdbarch->char_signed = 1;
-  /* Skip verify of ieee_float, invalid_p == 0 */
   /* Skip verify of read_pc, invalid_p == 0 */
   /* Skip verify of write_pc, invalid_p == 0 */
   /* Skip verify of read_fp, invalid_p == 0 */
@@ -1256,14 +1253,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                         (long) current_gdbarch->get_saved_register
                         /*GET_SAVED_REGISTER ()*/);
 #endif
-#ifdef IEEE_FLOAT
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: IEEE_FLOAT # %s\n",
-                      XSTRING (IEEE_FLOAT));
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: IEEE_FLOAT = %d\n",
-                      IEEE_FLOAT);
-#endif
 #ifdef INIT_EXTRA_FRAME_INFO
 #if GDB_MULTI_ARCH
   /* Macro might contain `[{}]' when not multi-arch */
@@ -2296,22 +2285,6 @@ set_gdbarch_char_signed (struct gdbarch *gdbarch,
   gdbarch->char_signed = char_signed;
 }
 
-int
-gdbarch_ieee_float (struct gdbarch *gdbarch)
-{
-  /* Skip verify of ieee_float, invalid_p == 0 */
-  if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_ieee_float called\n");
-  return gdbarch->ieee_float;
-}
-
-void
-set_gdbarch_ieee_float (struct gdbarch *gdbarch,
-                        int ieee_float)
-{
-  gdbarch->ieee_float = ieee_float;
-}
-
 CORE_ADDR
 gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid)
 {
index 8cac8cb..1c09fac 100644 (file)
@@ -305,22 +305,6 @@ extern void set_gdbarch_char_signed (struct gdbarch *gdbarch, int char_signed);
 #endif
 #endif
 
-/* Default (value) for non- multi-arch platforms. */
-#if (!GDB_MULTI_ARCH) && !defined (IEEE_FLOAT)
-#define IEEE_FLOAT (0)
-#endif
-
-extern int gdbarch_ieee_float (struct gdbarch *gdbarch);
-extern void set_gdbarch_ieee_float (struct gdbarch *gdbarch, int ieee_float);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (IEEE_FLOAT)
-#error "Non multi-arch definition of IEEE_FLOAT"
-#endif
-#if GDB_MULTI_ARCH
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (IEEE_FLOAT)
-#define IEEE_FLOAT (gdbarch_ieee_float (current_gdbarch))
-#endif
-#endif
-
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (TARGET_READ_PC)
 #define TARGET_READ_PC(ptid) (generic_target_read_pc (ptid))
index 9bd0e51..d6046ec 100755 (executable)
@@ -403,8 +403,6 @@ v::TARGET_BFD_VMA_BIT:int:bfd_vma_bit::::8 * sizeof (void*):TARGET_ARCHITECTURE-
 # One if \`char' acts like \`signed char', zero if \`unsigned char'.
 v::TARGET_CHAR_SIGNED:int:char_signed::::1:-1:1::::
 #
-v::IEEE_FLOAT:int:ieee_float::::0:0::0:::
-#
 f::TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid::0:generic_target_read_pc::0
 f::TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid::0:generic_target_write_pc::0
 f::TARGET_READ_FP:CORE_ADDR:read_fp:void:::0:generic_target_read_fp::0
index 14ae8b1..77d7ebf 100644 (file)
@@ -1157,7 +1157,6 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_stack_align (gdbarch, m68hc11_stack_align);
 
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
-  set_gdbarch_ieee_float (gdbarch, 1);
 
   return gdbarch;
 }
index 9b5a535..30079b5 100644 (file)
@@ -4283,7 +4283,6 @@ mips_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   set_gdbarch_breakpoint_from_pc (gdbarch, mips_breakpoint_from_pc);
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
-  set_gdbarch_ieee_float (gdbarch, 1);
 
   set_gdbarch_skip_prologue (gdbarch, mips_skip_prologue);
   set_gdbarch_saved_pc_after_call (gdbarch, mips_saved_pc_after_call);
index 7b4972b..239b17a 100644 (file)
@@ -1785,7 +1785,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      but not always.  */
   set_gdbarch_decr_pc_after_break (gdbarch, 2);
   set_gdbarch_pop_frame (gdbarch, s390_pop_frame);
-  set_gdbarch_ieee_float (gdbarch, 1);
   /* Stack grows downward.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   /* Offset from address of function to start of its code.
index ccb060b..04720fe 100644 (file)
@@ -2123,7 +2123,6 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_saved_pc_after_call (gdbarch, sh_saved_pc_after_call);
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
-  set_gdbarch_ieee_float (gdbarch, 1);
 
   return gdbarch;
 }
index 02ebaa4..a32841c 100644 (file)
@@ -2963,7 +2963,6 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frameless_function_invocation (gdbarch, 
                                             frameless_look_for_prologue);
   set_gdbarch_get_saved_register (gdbarch, sparc_get_saved_register);
-  set_gdbarch_ieee_float (gdbarch, 1);
   set_gdbarch_init_extra_frame_info (gdbarch, sparc_init_extra_frame_info);
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
index 45acdc7..84cd272 100644 (file)
@@ -548,21 +548,9 @@ print_floating (char *valaddr, struct type *type, struct ui_file *stream)
 {
   DOUBLEST doub;
   int inv;
-  const struct floatformat *fmt = &floatformat_unknown;
+  const struct floatformat *fmt = floatformat_from_type (type);
   unsigned len = TYPE_LENGTH (type);
 
-  /* FIXME: kettenis/2001-01-20: The check for IEEE_FLOAT is probably
-     still necessary since GDB by default assumes that the target uses
-     the IEEE 754 representation for its floats and doubles.  Of
-     course this is all crock and should be cleaned up.  */
-
-  if (len == TARGET_FLOAT_BIT / TARGET_CHAR_BIT && IEEE_FLOAT)
-    fmt = TARGET_FLOAT_FORMAT;
-  else if (len == TARGET_DOUBLE_BIT / TARGET_CHAR_BIT && IEEE_FLOAT)
-    fmt = TARGET_DOUBLE_FORMAT;
-  else if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT)
-    fmt = TARGET_LONG_DOUBLE_FORMAT;
-
   if (floatformat_is_nan (fmt, valaddr))
     {
       if (floatformat_is_negative (fmt, valaddr))
@@ -575,6 +563,13 @@ print_floating (char *valaddr, struct type *type, struct ui_file *stream)
       return;
     }
 
+  /* FIXME: cagney/2002-01-15: The simpler extract_typed_floating()
+     routine could be used here only that routine has no way of
+     indicating that the floating point it extracted was invalid (As
+     indicated by INVALID_FLOAT).  Instead, this code here could call
+     something like floating_invalid() to check for an invalid
+     floating point.  */
+
   doub = unpack_double (type, valaddr, &inv);
   if (inv)
     {
@@ -585,6 +580,10 @@ print_floating (char *valaddr, struct type *type, struct ui_file *stream)
   /* FIXME: kettenis/2001-01-20: The following code makes too much
      assumptions about the host and target floating point format.  */
 
+  /* FIXME: cagney/2002-01-15: The floatformat pointed to by FMT
+     should contain all the information needed to print the
+     floating-point value without host dependencies.  */
+
   if (len < sizeof (double))
       fprintf_filtered (stream, "%.9g", (double) doub);
   else if (len == sizeof (double))
index ce689dd..f02f2b6 100644 (file)
@@ -834,8 +834,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_ptr_bit (gdbarch, 64);
 
   set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
-  set_gdbarch_ieee_float (gdbarch, 1);
-
 
   set_gdbarch_num_regs (gdbarch, X86_64_NUM_REGS);
   set_gdbarch_register_name (gdbarch, x86_64_register_name);