Target FP: Remove unused floating-point routines
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 6 Nov 2017 15:02:33 +0000 (16:02 +0100)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 6 Nov 2017 15:02:33 +0000 (16:02 +0100)
This patch removes the following routines, which now have no remaining
users in GDB:
 - extract_typed_floating
 - store_typed_floating
 - convert_typed_floating
 - decimal_from_doublest
 - decimal_to_doublest
 - value_as_double
 - unpack_double
 - value_from_double
 - value_from_decfloat

This completes removal of DOUBLEST from all files except doublest.{c,h}
and target-float.c.

gdb/ChangeLog:
2017-11-06  Ulrich Weigand  <uweigand@de.ibm.com>

* doublest.c: Do not include "gdbtypes.h".
(extract_typed_floating): Remove.
(store_typed_floating): Remove.
(convert_typed_floating): Remove.
* doublest.h (struct type): Remove.
(DOUBLEST_PRINT_FORMAT): Remove.
(DOUBLEST_SCAN_FORMAT): Remove.
(extract_typed_floating): Remove.
(store_typed_floating): Remove.
(convert_typed_floating): Remove.

* dfp.c (decimal_from_doublest): Remove.
(decimal_to_doublest): Remove.
* dfp.h: Do not include "doublest.h".
(decimal_from_doublest): Remove.
(decimal_to_doublest): Remove.

* value.c: Do not include "doublest.h" and "dfp.h".
(value_as_double): Remove.
(unpack_double): Remove.
(value_from_double): Remove.
(value_from_decfloat): Remove.
* value.h: Do not include "doublest.h".
(value_as_double): Remove.
(unpack_double): Remove.
(value_from_double): Remove.
(value_from_decfloat): Remove.

gdb/ChangeLog
gdb/dfp.c
gdb/dfp.h
gdb/doublest.c
gdb/doublest.h
gdb/value.c
gdb/value.h

index 617caaea7980c0d0504c62c2478c9f8707d358e9..2691367ac3090d7a39cde6289776fcd7f316ed6f 100644 (file)
@@ -1,3 +1,33 @@
+2017-11-06  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * doublest.c: Do not include "gdbtypes.h".
+       (extract_typed_floating): Remove.
+       (store_typed_floating): Remove.
+       (convert_typed_floating): Remove.
+       * doublest.h (struct type): Remove.
+       (DOUBLEST_PRINT_FORMAT): Remove.
+       (DOUBLEST_SCAN_FORMAT): Remove.
+       (extract_typed_floating): Remove.
+       (store_typed_floating): Remove.
+       (convert_typed_floating): Remove.
+
+       * dfp.c (decimal_from_doublest): Remove.
+       (decimal_to_doublest): Remove.
+       * dfp.h: Do not include "doublest.h".
+       (decimal_from_doublest): Remove.
+       (decimal_to_doublest): Remove.
+
+       * value.c: Do not include "doublest.h" and "dfp.h".
+       (value_as_double): Remove.
+       (unpack_double): Remove.
+       (value_from_double): Remove.
+       (value_from_decfloat): Remove.
+       * value.h: Do not include "doublest.h".
+       (value_as_double): Remove.
+       (unpack_double): Remove.
+       (value_from_double): Remove.
+       (value_from_decfloat): Remove.
+
 2017-11-06  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * i386-tdep.c: Include "target-float.h".  Do not include "doublest.h".
index d47026855f0a4064f53eb86d43d2351b4acb3ff5..ec051342c759808b9ac2fd01e9c5551c5049f399 100644 (file)
--- a/gdb/dfp.c
+++ b/gdb/dfp.c
@@ -268,29 +268,6 @@ decimal_to_longest (const gdb_byte *from, int len, enum bfd_endian byte_order)
   return strtoll (str.c_str (), NULL, 10);
 }
 
-/* Converts a value of a float type to a decimal float of
-   specified LEN bytes.
-
-   This is an ugly way to do the conversion, but libdecnumber does
-   not offer a direct way to do it.  */
-void
-decimal_from_doublest (DOUBLEST from,
-                      gdb_byte *to, int len, enum bfd_endian byte_order)
-{
-  std::string str = string_printf ("%.30" DOUBLEST_PRINT_FORMAT, from);
-  decimal_from_string (to, len, byte_order, str);
-}
-
-/* Converts a decimal float of LEN bytes to a double value.  */
-DOUBLEST
-decimal_to_doublest (const gdb_byte *from, int len, enum bfd_endian byte_order)
-{
-  /* This is an ugly way to do the conversion, but libdecnumber does
-     not offer a direct way to do it.  */
-  std::string str = decimal_to_string (from, len, byte_order);
-  return strtod (str.c_str (), NULL);
-}
-
 /* Perform operation OP with operands X and Y with sizes LEN_X and LEN_Y
    and byte orders BYTE_ORDER_X and BYTE_ORDER_Y, and store value in
    RESULT with size LEN_RESULT and byte order BYTE_ORDER_RESULT.  */
index e17f1ce10c4206fe2aecca3421f23b9598f392dc..af52fa2a3bcb63c53938fa2ca661bc4818674e3a 100644 (file)
--- a/gdb/dfp.h
+++ b/gdb/dfp.h
@@ -25,7 +25,6 @@
 #ifndef DFP_H
 #define DFP_H
 
-#include "doublest.h"    /* For DOUBLEST.  */
 #include "expression.h"  /* For enum exp_opcode.  */
 
 extern std::string decimal_to_string (const gdb_byte *, int, enum bfd_endian,
@@ -38,10 +37,6 @@ extern void decimal_from_ulongest (ULONGEST from, gdb_byte *to,
                                   int len, enum bfd_endian byte_order);
 extern LONGEST decimal_to_longest (const gdb_byte *from, int len,
                                   enum bfd_endian byte_order);
-extern void decimal_from_doublest (DOUBLEST from, gdb_byte *to,
-                                  int len, enum bfd_endian byte_order);
-extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len,
-                                    enum bfd_endian byte_order);
 extern void decimal_binop (enum exp_opcode,
                           const gdb_byte *, int, enum bfd_endian,
                           const gdb_byte *, int, enum bfd_endian,
index 79c15feb069cfe9570037cb54fe37f8495cb20a7..87d3b1fcb73ca7268ed167aa90aca63d3febb0e5 100644 (file)
@@ -26,7 +26,6 @@
 #include "defs.h"
 #include "doublest.h"
 #include "floatformat.h"
-#include "gdbtypes.h"
 #include <math.h>              /* ldexp */
 #include <algorithm>
 
@@ -897,95 +896,3 @@ floatformat_from_string (const struct floatformat *fmt, gdb_byte *out,
   floatformat_from_doublest (fmt, &doub, out);
   return true;
 }
-\f
-/* Extract a floating-point number of type TYPE from a target-order
-   byte-stream at ADDR.  Returns the value as type DOUBLEST.  */
-
-DOUBLEST
-extract_typed_floating (const void *addr, const struct type *type)
-{
-  const struct floatformat *fmt = floatformat_from_type (type);
-  DOUBLEST retval;
-
-  floatformat_to_doublest (fmt, addr, &retval);
-  return retval;
-}
-
-/* Store VAL as a floating-point number of type TYPE to a target-order
-   byte-stream at ADDR.  */
-
-void
-store_typed_floating (void *addr, const struct type *type, DOUBLEST val)
-{
-  const struct floatformat *fmt = floatformat_from_type (type);
-
-  /* FIXME: kettenis/2001-10-28: It is debatable whether we should
-     zero out any remaining bytes in the target buffer when TYPE is
-     longer than the actual underlying floating-point format.  Perhaps
-     we should store a fixed bitpattern in those remaining bytes,
-     instead of zero, or perhaps we shouldn't touch those remaining
-     bytes at all.
-
-     NOTE: cagney/2001-10-28: With the way things currently work, it
-     isn't a good idea to leave the end bits undefined.  This is
-     because GDB writes out the entire sizeof(<floating>) bits of the
-     floating-point type even though the value might only be stored
-     in, and the target processor may only refer to, the first N <
-     TYPE_LENGTH (type) bits.  If the end of the buffer wasn't
-     initialized, GDB would write undefined data to the target.  An
-     errant program, refering to that undefined data, would then
-     become non-deterministic.
-
-     See also the function convert_typed_floating below.  */
-  memset (addr, 0, TYPE_LENGTH (type));
-
-  floatformat_from_doublest (fmt, &val, addr);
-}
-
-/* Convert a floating-point number of type FROM_TYPE from a
-   target-order byte-stream at FROM to a floating-point number of type
-   TO_TYPE, and store it to a target-order byte-stream at TO.  */
-
-void
-convert_typed_floating (const void *from, const struct type *from_type,
-                        void *to, const struct type *to_type)
-{
-  const struct floatformat *from_fmt = floatformat_from_type (from_type);
-  const struct floatformat *to_fmt = floatformat_from_type (to_type);
-
-  if (from_fmt == NULL || to_fmt == NULL)
-    {
-      /* If we don't know the floating-point format of FROM_TYPE or
-         TO_TYPE, there's not much we can do.  We might make the
-         assumption that if the length of FROM_TYPE and TO_TYPE match,
-         their floating-point format would match too, but that
-         assumption might be wrong on targets that support
-         floating-point types that only differ in endianness for
-         example.  So we warn instead, and zero out the target buffer.  */
-      warning (_("Can't convert floating-point number to desired type."));
-      memset (to, 0, TYPE_LENGTH (to_type));
-    }
-  else if (from_fmt == to_fmt)
-    {
-      /* We're in business.  The floating-point format of FROM_TYPE
-         and TO_TYPE match.  However, even though the floating-point
-         format matches, the length of the type might still be
-         different.  Make sure we don't overrun any buffers.  See
-         comment in store_typed_floating for a discussion about
-         zeroing out remaining bytes in the target buffer.  */
-      memset (to, 0, TYPE_LENGTH (to_type));
-      memcpy (to, from, std::min (TYPE_LENGTH (from_type),
-                                 TYPE_LENGTH (to_type)));
-    }
-  else
-    {
-      /* The floating-point types don't match.  The best we can do
-         (apart from simulating the target FPU) is converting to the
-         widest floating-point type supported by the host, and then
-         again to the desired type.  */
-      DOUBLEST d;
-
-      floatformat_to_doublest (from_fmt, from, &d);
-      floatformat_from_doublest (to_fmt, &d, to);
-    }
-}
index 4b9d6bcbc916589526172ff2338dc900c0698de8..fe3f897622ffea9441cc75cfc7b432b9b59c26ec 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef DOUBLEST_H
 #define DOUBLEST_H
 
-struct type;
 struct floatformat;
 
 /* Use `long double' if the host compiler supports it.  (Note that this is not
@@ -35,12 +34,8 @@ struct floatformat;
 #if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
      && defined SCANF_HAS_LONG_DOUBLE)
 typedef long double DOUBLEST;
-# define DOUBLEST_PRINT_FORMAT "Lg"
-# define DOUBLEST_SCAN_FORMAT "Lg"
 #else
 typedef double DOUBLEST;
-# define DOUBLEST_PRINT_FORMAT "g"
-# define DOUBLEST_SCAN_FORMAT "lg"
 /* If we can't scan or print long double, we don't want to use it
    anywhere.  */
 # undef HAVE_LONG_DOUBLE
@@ -81,12 +76,4 @@ extern bool floatformat_from_string (const struct floatformat *fmt,
 
 extern size_t floatformat_totalsize_bytes (const struct floatformat *fmt);
 
-extern DOUBLEST extract_typed_floating (const void *addr,
-                                       const struct type *type);
-extern void store_typed_floating (void *addr, const struct type *type,
-                                 DOUBLEST val);
-extern void convert_typed_floating (const void *from,
-                                   const struct type *from_type,
-                                    void *to, const struct type *to_type);
-
 #endif
index bc211139f77588d31d9f58761fee79f20982251b..8fd391e637d0430ef90ae1eb12a7bb7df812ff25 100644 (file)
 #include "target.h"
 #include "language.h"
 #include "demangle.h"
-#include "doublest.h"
 #include "regcache.h"
 #include "block.h"
-#include "dfp.h"
 #include "target-float.h"
 #include "objfiles.h"
 #include "valprint.h"
@@ -2764,18 +2762,6 @@ value_as_long (struct value *val)
   return unpack_long (value_type (val), value_contents (val));
 }
 
-DOUBLEST
-value_as_double (struct value *val)
-{
-  DOUBLEST foo;
-  int inv;
-
-  foo = unpack_double (value_type (val), value_contents (val), &inv);
-  if (inv)
-    error (_("Invalid floating value found in program."));
-  return foo;
-}
-
 /* Extract a value as a C pointer.  Does not deallocate the value.
    Note that val's type may not actually be a pointer; value_as_long
    handles all the cases.  */
@@ -2938,49 +2924,6 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
   return 0;                    /* Placate lint.  */
 }
 
-/* Return a double value from the specified type and address.
-   INVP points to an int which is set to 0 for valid value,
-   1 for invalid value (bad float format).  In either case,
-   the returned double is OK to use.  Argument is in target
-   format, result is in host format.  */
-
-DOUBLEST
-unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
-{
-  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
-  enum type_code code;
-  int len;
-  int nosign;
-
-  *invp = 0;                   /* Assume valid.  */
-  type = check_typedef (type);
-  code = TYPE_CODE (type);
-  len = TYPE_LENGTH (type);
-  nosign = TYPE_UNSIGNED (type);
-  if (code == TYPE_CODE_FLT)
-    {
-      if (!target_float_is_valid (valaddr, type))
-       {
-         *invp = 1;
-         return 0.0;
-       }
-
-      return extract_typed_floating (valaddr, type);
-    }
-  else if (code == TYPE_CODE_DECFLOAT)
-    return decimal_to_doublest (valaddr, len, byte_order);
-  else if (nosign)
-    {
-      /* Unsigned -- be sure we compensate for signed LONGEST.  */
-      return (ULONGEST) unpack_long (type, valaddr);
-    }
-  else
-    {
-      /* Signed -- we are OK with unpack_long.  */
-      return unpack_long (type, valaddr);
-    }
-}
-
 /* Unpack raw data (copied from debugee, target byte order) at VALADDR
    as a CORE_ADDR, assuming the raw data is described by type TYPE.
    We don't assume any alignment for the raw data.  Return value is in
@@ -3693,32 +3636,6 @@ value_from_contents (struct type *type, const gdb_byte *contents)
   return result;
 }
 
-struct value *
-value_from_double (struct type *type, DOUBLEST num)
-{
-  struct value *val = allocate_value (type);
-  struct type *base_type = check_typedef (type);
-  enum type_code code = TYPE_CODE (base_type);
-
-  if (code == TYPE_CODE_FLT)
-    {
-      store_typed_floating (value_contents_raw (val), base_type, num);
-    }
-  else
-    error (_("Unexpected type encountered for floating constant."));
-
-  return val;
-}
-
-struct value *
-value_from_decfloat (struct type *type, const gdb_byte *dec)
-{
-  struct value *val = allocate_value (type);
-
-  memcpy (value_contents_raw (val), dec, TYPE_LENGTH (type));
-  return val;
-}
-
 /* Extract a value from the history file.  Input will be of the form
    $digits or $$digits.  See block comment above 'write_dollar_variable'
    for details.  */
index 237d5dbde16bf6d3d099af5bb07f0eff599bc287..b1b8c6ded6263f6f3d8e601b6c3addf346026b61 100644 (file)
@@ -20,7 +20,6 @@
 #if !defined (VALUE_H)
 #define VALUE_H 1
 
-#include "doublest.h"
 #include "frame.h"             /* For struct frame_id.  */
 
 struct block;
@@ -613,12 +612,9 @@ extern int print_address_demangle (const struct value_print_options *,
 extern bool is_floating_value (struct value *val);
 
 extern LONGEST value_as_long (struct value *val);
-extern DOUBLEST value_as_double (struct value *val);
 extern CORE_ADDR value_as_address (struct value *val);
 
 extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr);
-extern DOUBLEST unpack_double (struct type *type, const gdb_byte *valaddr,
-                              int *invp);
 extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);
 
 extern LONGEST unpack_field_as_long (struct type *type,
@@ -644,9 +640,6 @@ extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
 extern struct value *value_from_longest (struct type *type, LONGEST num);
 extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
 extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
-extern struct value *value_from_double (struct type *type, DOUBLEST num);
-extern struct value *value_from_decfloat (struct type *type,
-                                         const gdb_byte *decbytes);
 extern struct value *value_from_history_ref (const char *, const char **);
 extern struct value *value_from_component (struct value *, struct type *,
                                           LONGEST);
This page took 0.037411 seconds and 4 git commands to generate.