[ARM][gas] Fix warnings about uninitialised uses and unused const variables
[deliverable/binutils-gdb.git] / gas / config / atof-ieee.c
index fbf0ffb62c9e02043a6e2c5f2b37b98a3a534b8c..443d28c2c4f8b0fbce4e0858b715593c1cbf3975 100644 (file)
@@ -1,12 +1,11 @@
 /* atof_ieee.c - turn a Flonum into an IEEE floating point number
 /* atof_ieee.c - turn a Flonum into an IEEE floating point number
-   Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 1998
-   Free Software Foundation, Inc.
+   Copyright (C) 1987-2016 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This file is part of GAS, the GNU Assembler.
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
    any later version.
 
    GAS is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 #include "as.h"
 
 /* Flonums returned here.  */
 extern FLONUM_TYPE generic_floating_point_number;
 
 
 #include "as.h"
 
 /* Flonums returned here.  */
 extern FLONUM_TYPE generic_floating_point_number;
 
-static int next_bits PARAMS ((int));
-static void unget_bits PARAMS ((int));
-static void make_invalid_floating_point_number PARAMS ((LITTLENUM_TYPE *));
-
-extern const char EXP_CHARS[];
-/* Precision in LittleNums. */
+/* Precision in LittleNums.  */
 /* Don't count the gap in the m68k extended precision format.  */
 /* Don't count the gap in the m68k extended precision format.  */
-#define MAX_PRECISION (5)
-#define F_PRECISION (2)
-#define D_PRECISION (4)
-#define X_PRECISION (5)
-#define P_PRECISION (5)
+#define MAX_PRECISION  5
+#define F_PRECISION    2
+#define D_PRECISION    4
+#define X_PRECISION    5
+#define P_PRECISION    5
+
+/* Length in LittleNums of guard bits.  */
+#define GUARD          2
 
 
-/* Length in LittleNums of guard bits. */
-#define GUARD (2)
+#ifndef TC_LARGEST_EXPONENT_IS_NORMAL
+#define TC_LARGEST_EXPONENT_IS_NORMAL(PRECISION) 0
+#endif
 
 static const unsigned long mask[] =
 {
 
 static const unsigned long mask[] =
 {
@@ -77,19 +75,18 @@ static const unsigned long mask[] =
   0xffffffff,
 };
 \f
   0xffffffff,
 };
 \f
-
 static int bits_left_in_littlenum;
 static int littlenums_left;
 static LITTLENUM_TYPE *littlenum_pointer;
 
 static int
 static int bits_left_in_littlenum;
 static int littlenums_left;
 static LITTLENUM_TYPE *littlenum_pointer;
 
 static int
-next_bits (number_of_bits)
-     int number_of_bits;
+next_bits (int number_of_bits)
 {
   int return_value;
 
   if (!littlenums_left)
 {
   int return_value;
 
   if (!littlenums_left)
-    return (0);
+    return 0;
+
   if (number_of_bits >= bits_left_in_littlenum)
     {
       return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
   if (number_of_bits >= bits_left_in_littlenum)
     {
       return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
@@ -100,21 +97,24 @@ next_bits (number_of_bits)
        {
          bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
          --littlenum_pointer;
        {
          bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
          --littlenum_pointer;
-         return_value |= (*littlenum_pointer >> bits_left_in_littlenum) & mask[number_of_bits];
+         return_value |=
+           (*littlenum_pointer >> bits_left_in_littlenum)
+           & mask[number_of_bits];
        }
     }
   else
     {
       bits_left_in_littlenum -= number_of_bits;
        }
     }
   else
     {
       bits_left_in_littlenum -= number_of_bits;
-      return_value = mask[number_of_bits] & (*littlenum_pointer >> bits_left_in_littlenum);
+      return_value =
+       mask[number_of_bits] & (*littlenum_pointer >> bits_left_in_littlenum);
     }
     }
-  return (return_value);
+  return return_value;
 }
 
 }
 
-/* Num had better be less than LITTLENUM_NUMBER_OF_BITS */
+/* Num had better be less than LITTLENUM_NUMBER_OF_BITS.  */
+
 static void
 static void
-unget_bits (num)
-     int num;
+unget_bits (int num)
 {
   if (!littlenums_left)
     {
 {
   if (!littlenums_left)
     {
@@ -124,7 +124,8 @@ unget_bits (num)
     }
   else if (bits_left_in_littlenum + num > LITTLENUM_NUMBER_OF_BITS)
     {
     }
   else if (bits_left_in_littlenum + num > LITTLENUM_NUMBER_OF_BITS)
     {
-      bits_left_in_littlenum = num - (LITTLENUM_NUMBER_OF_BITS - bits_left_in_littlenum);
+      bits_left_in_littlenum =
+       num - (LITTLENUM_NUMBER_OF_BITS - bits_left_in_littlenum);
       ++littlenum_pointer;
       ++littlenums_left;
     }
       ++littlenum_pointer;
       ++littlenums_left;
     }
@@ -133,11 +134,11 @@ unget_bits (num)
 }
 
 static void
 }
 
 static void
-make_invalid_floating_point_number (words)
-     LITTLENUM_TYPE *words;
+make_invalid_floating_point_number (LITTLENUM_TYPE *words)
 {
   as_bad (_("cannot create floating-point number"));
 {
   as_bad (_("cannot create floating-point number"));
-  words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1; /* Zero the leftmost bit */
+  /* Zero the leftmost bit.  */
+  words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1;
   words[1] = (LITTLENUM_TYPE) -1;
   words[2] = (LITTLENUM_TYPE) -1;
   words[3] = (LITTLENUM_TYPE) -1;
   words[1] = (LITTLENUM_TYPE) -1;
   words[2] = (LITTLENUM_TYPE) -1;
   words[3] = (LITTLENUM_TYPE) -1;
@@ -145,29 +146,26 @@ make_invalid_floating_point_number (words)
   words[5] = (LITTLENUM_TYPE) -1;
 }
 \f
   words[5] = (LITTLENUM_TYPE) -1;
 }
 \f
-/************************************************************************\
- *     Warning: this returns 16-bit LITTLENUMs. It is up to the caller *
- *     to figure out any alignment problems and to conspire for the    *
- *     bytes/word to be emitted in the right order. Bigendians beware! *
- *                                                                     *
-\************************************************************************/
+/* Warning: This returns 16-bit LITTLENUMs.  It is up to the caller to
+   figure out any alignment problems and to conspire for the
+   bytes/word to be emitted in the right order.  Bigendians beware!  */
 
 /* Note that atof-ieee always has X and P precisions enabled.  it is up
    to md_atof to filter them out if the target machine does not support
    them.  */
 
 
 /* Note that atof-ieee always has X and P precisions enabled.  it is up
    to md_atof to filter them out if the target machine does not support
    them.  */
 
-/* Returns pointer past text consumed. */
+/* Returns pointer past text consumed.  */
+
 char *
 char *
-atof_ieee (str, what_kind, words)
-     char *str;                        /* Text to convert to binary. */
-     char what_kind;           /* 'd', 'f', 'g', 'h' */
-     LITTLENUM_TYPE *words;    /* Build the binary here. */
+atof_ieee (char *str,                  /* Text to convert to binary.  */
+          int what_kind,               /* 'd', 'f', 'x', 'p'.  */
+          LITTLENUM_TYPE *words)       /* Build the binary here.  */
 {
 {
-  /* Extra bits for zeroed low-order bits.  The 1st MAX_PRECISION are
-     zeroed, the last contain flonum bits. */
+  /* Extra bits for zeroed low-order bits.
+     The 1st MAX_PRECISION are zeroed, the last contain flonum bits.  */
   static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
   char *return_value;
   static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
   char *return_value;
-  /* Number of 16-bit words in the format. */
+  /* Number of 16-bit words in the format.  */
   int precision;
   long exponent_bits;
   FLONUM_TYPE save_gen_flonum;
   int precision;
   long exponent_bits;
   FLONUM_TYPE save_gen_flonum;
@@ -186,7 +184,7 @@ atof_ieee (str, what_kind, words)
   generic_floating_point_number.sign = '\0';
 
   /* Use more LittleNums than seems necessary: the highest flonum may
   generic_floating_point_number.sign = '\0';
 
   /* Use more LittleNums than seems necessary: the highest flonum may
-     have 15 leading 0 bits, so could be useless. */
+     have 15 leading 0 bits, so could be useless.  */
 
   memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION);
 
 
   memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION);
 
@@ -218,7 +216,6 @@ atof_ieee (str, what_kind, words)
 
     case 'p':
     case 'P':
 
     case 'p':
     case 'P':
-
       precision = P_PRECISION;
       exponent_bits = -1;
       break;
       precision = P_PRECISION;
       exponent_bits = -1;
       break;
@@ -235,7 +232,7 @@ atof_ieee (str, what_kind, words)
                    &generic_floating_point_number))
     {
       make_invalid_floating_point_number (words);
                    &generic_floating_point_number))
     {
       make_invalid_floating_point_number (words);
-      return (NULL);
+      return NULL;
     }
   gen_to_words (words, precision, exponent_bits);
 
     }
   gen_to_words (words, precision, exponent_bits);
 
@@ -247,11 +244,9 @@ atof_ieee (str, what_kind, words)
 }
 
 /* Turn generic_floating_point_number into a real float/double/extended.  */
 }
 
 /* Turn generic_floating_point_number into a real float/double/extended.  */
+
 int
 int
-gen_to_words (words, precision, exponent_bits)
-     LITTLENUM_TYPE *words;
-     int precision;
-     long exponent_bits;
+gen_to_words (LITTLENUM_TYPE *words, int precision, long exponent_bits)
 {
   int return_value = 0;
 
 {
   int return_value = 0;
 
@@ -274,19 +269,21 @@ gen_to_words (words, precision, exponent_bits)
 
   if (generic_floating_point_number.low > generic_floating_point_number.leader)
     {
 
   if (generic_floating_point_number.low > generic_floating_point_number.leader)
     {
-      /* 0.0e0 seen. */
+      /* 0.0e0 seen.  */
       if (generic_floating_point_number.sign == '+')
        words[0] = 0x0000;
       else
        words[0] = 0x8000;
       memset (&words[1], '\0',
              (words_end - words - 1) * sizeof (LITTLENUM_TYPE));
       if (generic_floating_point_number.sign == '+')
        words[0] = 0x0000;
       else
        words[0] = 0x8000;
       memset (&words[1], '\0',
              (words_end - words - 1) * sizeof (LITTLENUM_TYPE));
-      return (return_value);
+      return return_value;
     }
 
     }
 
-  /* NaN:  Do the right thing */
+  /* NaN:  Do the right thing */
   if (generic_floating_point_number.sign == 0)
     {
   if (generic_floating_point_number.sign == 0)
     {
+      if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
+       as_warn (_("NaNs are not supported by this target\n"));
       if (precision == F_PRECISION)
        {
          words[0] = 0x7fff;
       if (precision == F_PRECISION)
        {
          words[0] = 0x7fff;
@@ -301,17 +298,17 @@ gen_to_words (words, precision, exponent_bits)
          words[3] = 0xffff;
          words[4] = 0xffff;
          words[5] = 0xffff;
          words[3] = 0xffff;
          words[4] = 0xffff;
          words[5] = 0xffff;
-#else /* ! TC_M68K */
+#else /* ! TC_M68K  */
 #ifdef TC_I386
          words[0] = 0xffff;
          words[1] = 0xc000;
          words[2] = 0;
          words[3] = 0;
          words[4] = 0;
 #ifdef TC_I386
          words[0] = 0xffff;
          words[1] = 0xc000;
          words[2] = 0;
          words[3] = 0;
          words[4] = 0;
-#else /* ! TC_I386 */
+#else /* ! TC_I386  */
          abort ();
          abort ();
-#endif /* ! TC_I386 */
-#endif /* ! TC_M68K */
+#endif /* ! TC_I386  */
+#endif /* ! TC_M68K  */
        }
       else
        {
        }
       else
        {
@@ -324,7 +321,10 @@ gen_to_words (words, precision, exponent_bits)
     }
   else if (generic_floating_point_number.sign == 'P')
     {
     }
   else if (generic_floating_point_number.sign == 'P')
     {
-      /* +INF:  Do the right thing */
+      if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
+       as_warn (_("Infinities are not supported by this target\n"));
+
+      /* +INF:  Do the right thing.  */
       if (precision == F_PRECISION)
        {
          words[0] = 0x7f80;
       if (precision == F_PRECISION)
        {
          words[0] = 0x7f80;
@@ -339,17 +339,17 @@ gen_to_words (words, precision, exponent_bits)
          words[3] = 0;
          words[4] = 0;
          words[5] = 0;
          words[3] = 0;
          words[4] = 0;
          words[5] = 0;
-#else /* ! TC_M68K */
+#else /* ! TC_M68K  */
 #ifdef TC_I386
          words[0] = 0x7fff;
          words[1] = 0x8000;
          words[2] = 0;
          words[3] = 0;
          words[4] = 0;
 #ifdef TC_I386
          words[0] = 0x7fff;
          words[1] = 0x8000;
          words[2] = 0;
          words[3] = 0;
          words[4] = 0;
-#else /* ! TC_I386 */
+#else /* ! TC_I386  */
          abort ();
          abort ();
-#endif /* ! TC_I386 */
-#endif /* ! TC_M68K */
+#endif /* ! TC_I386  */
+#endif /* ! TC_M68K  */
        }
       else
        {
        }
       else
        {
@@ -358,11 +358,14 @@ gen_to_words (words, precision, exponent_bits)
          words[2] = 0;
          words[3] = 0;
        }
          words[2] = 0;
          words[3] = 0;
        }
-      return (return_value);
+      return return_value;
     }
   else if (generic_floating_point_number.sign == 'N')
     {
     }
   else if (generic_floating_point_number.sign == 'N')
     {
-      /* Negative INF */
+      if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
+       as_warn (_("Infinities are not supported by this target\n"));
+
+      /* Negative INF.  */
       if (precision == F_PRECISION)
        {
          words[0] = 0xff80;
       if (precision == F_PRECISION)
        {
          words[0] = 0xff80;
@@ -377,17 +380,17 @@ gen_to_words (words, precision, exponent_bits)
          words[3] = 0;
          words[4] = 0;
          words[5] = 0;
          words[3] = 0;
          words[4] = 0;
          words[5] = 0;
-#else /* ! TC_M68K */
+#else /* ! TC_M68K  */
 #ifdef TC_I386
          words[0] = 0xffff;
          words[1] = 0x8000;
          words[2] = 0;
          words[3] = 0;
          words[4] = 0;
 #ifdef TC_I386
          words[0] = 0xffff;
          words[1] = 0x8000;
          words[2] = 0;
          words[3] = 0;
          words[4] = 0;
-#else /* ! TC_I386 */
+#else /* ! TC_I386  */
          abort ();
          abort ();
-#endif /* ! TC_I386 */
-#endif /* ! TC_M68K */
+#endif /* ! TC_I386  */
+#endif /* ! TC_M68K  */
        }
       else
        {
        }
       else
        {
@@ -396,46 +399,49 @@ gen_to_words (words, precision, exponent_bits)
          words[2] = 0x0;
          words[3] = 0x0;
        }
          words[2] = 0x0;
          words[3] = 0x0;
        }
-      return (return_value);
+      return return_value;
     }
     }
-  /*
-   * The floating point formats we support have:
-   * Bit 15 is sign bit.
-   * Bits 14:n are excess-whatever exponent.
-   * Bits n-1:0 (if any) are most significant bits of fraction.
-   * Bits 15:0 of the next word(s) are the next most significant bits.
-   *
-   * So we need: number of bits of exponent, number of bits of
-   * mantissa.
-   */
+
+  /* The floating point formats we support have:
+     Bit 15 is sign bit.
+     Bits 14:n are excess-whatever exponent.
+     Bits n-1:0 (if any) are most significant bits of fraction.
+     Bits 15:0 of the next word(s) are the next most significant bits.
+
+     So we need: number of bits of exponent, number of bits of
+     mantissa.  */
   bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
   littlenum_pointer = generic_floating_point_number.leader;
   littlenums_left = (1
                     + generic_floating_point_number.leader
                     - generic_floating_point_number.low);
   bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
   littlenum_pointer = generic_floating_point_number.leader;
   littlenums_left = (1
                     + generic_floating_point_number.leader
                     - generic_floating_point_number.low);
-  /* Seek (and forget) 1st significant bit */
-  for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage);;
+
+  /* Seek (and forget) 1st significant bit.  */
+  for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage);
   exponent_1 = (generic_floating_point_number.exponent
                + generic_floating_point_number.leader
                + 1
                - generic_floating_point_number.low);
   exponent_1 = (generic_floating_point_number.exponent
                + generic_floating_point_number.leader
                + 1
                - generic_floating_point_number.low);
+
   /* Radix LITTLENUM_RADIX, point just higher than
   /* Radix LITTLENUM_RADIX, point just higher than
-     generic_floating_point_number.leader. */
+     generic_floating_point_number.leader.  */
   exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
   exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
-  /* Radix 2. */
+
+  /* Radix 2.  */
   exponent_3 = exponent_2 - exponent_skippage;
   exponent_3 = exponent_2 - exponent_skippage;
-  /* Forget leading zeros, forget 1st bit. */
+
+  /* Forget leading zeros, forget 1st bit.  */
   exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
   exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
-  /* Offset exponent. */
 
 
+  /* Offset exponent.  */
   lp = words;
 
   lp = words;
 
-  /* Word 1. Sign, exponent and perhaps high bits. */
+  /* Word 1.  Sign, exponent and perhaps high bits.  */
   word1 = ((generic_floating_point_number.sign == '+')
           ? 0
           : (1 << (LITTLENUM_NUMBER_OF_BITS - 1)));
 
   word1 = ((generic_floating_point_number.sign == '+')
           ? 0
           : (1 << (LITTLENUM_NUMBER_OF_BITS - 1)));
 
-  /* Assume 2's complement integers. */
+  /* Assume 2's complement integers.  */
   if (exponent_4 <= 0)
     {
       int prec_bits;
   if (exponent_4 <= 0)
     {
       int prec_bits;
@@ -443,7 +449,8 @@ gen_to_words (words, precision, exponent_bits)
 
       unget_bits (1);
       num_bits = -exponent_4;
 
       unget_bits (1);
       num_bits = -exponent_4;
-      prec_bits = LITTLENUM_NUMBER_OF_BITS * precision - (exponent_bits + 1 + num_bits);
+      prec_bits =
+       LITTLENUM_NUMBER_OF_BITS * precision - (exponent_bits + 1 + num_bits);
 #ifdef TC_I386
       if (precision == X_PRECISION && exponent_bits == 15)
        {
 #ifdef TC_I386
       if (precision == X_PRECISION && exponent_bits == 15)
        {
@@ -457,14 +464,15 @@ gen_to_words (words, precision, exponent_bits)
 
       if (num_bits >= LITTLENUM_NUMBER_OF_BITS - exponent_bits)
        {
 
       if (num_bits >= LITTLENUM_NUMBER_OF_BITS - exponent_bits)
        {
-         /* Bigger than one littlenum */
+         /* Bigger than one littlenum */
          num_bits -= (LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits;
          *lp++ = word1;
          num_bits -= (LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits;
          *lp++ = word1;
-         if (num_bits + exponent_bits + 1 > precision * LITTLENUM_NUMBER_OF_BITS)
+         if (num_bits + exponent_bits + 1
+             > precision * LITTLENUM_NUMBER_OF_BITS)
            {
            {
-             /* Exponent overflow */
+             /* Exponent overflow */
              make_invalid_floating_point_number (words);
              make_invalid_floating_point_number (words);
-             return (return_value);
+             return return_value;
            }
 #ifdef TC_M68K
          if (precision == X_PRECISION && exponent_bits == 15)
            }
 #ifdef TC_M68K
          if (precision == X_PRECISION && exponent_bits == 15)
@@ -490,14 +498,15 @@ gen_to_words (words, precision, exponent_bits)
            }
          else
            {
            }
          else
            {
-             word1 |= next_bits ((LITTLENUM_NUMBER_OF_BITS - 1) - (exponent_bits + num_bits));
+             word1 |= next_bits ((LITTLENUM_NUMBER_OF_BITS - 1)
+                                 - (exponent_bits + num_bits));
              *lp++ = word1;
            }
        }
       while (lp < words_end)
        *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
 
              *lp++ = word1;
            }
        }
       while (lp < words_end)
        *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
 
-      /* Round the mantissa up, but don't change the number */
+      /* Round the mantissa up, but don't change the number */
       if (next_bits (1))
        {
          --lp;
       if (next_bits (1))
        {
          --lp;
@@ -568,17 +577,15 @@ gen_to_words (words, precision, exponent_bits)
 
       return return_value;
     }
 
       return return_value;
     }
-  else if ((unsigned long) exponent_4 >= mask[exponent_bits])
+  else if ((unsigned long) exponent_4 > mask[exponent_bits]
+          || (! TC_LARGEST_EXPONENT_IS_NORMAL (precision)
+              && (unsigned long) exponent_4 == mask[exponent_bits]))
     {
     {
-      /*
-       * Exponent overflow. Lose immediately.
-       */
-
-      /*
-       * We leave return_value alone: admit we read the
-       * number, but return a floating exception
-       * because we can't encode the number.
-       */
+      /* Exponent overflow.  Lose immediately.  */
+
+      /* We leave return_value alone: admit we read the
+        number, but return a floating exception
+        because we can't encode the number.  */
       make_invalid_floating_point_number (words);
       return return_value;
     }
       make_invalid_floating_point_number (words);
       return return_value;
     }
@@ -591,7 +598,7 @@ gen_to_words (words, precision, exponent_bits)
   *lp++ = word1;
 
   /* X_PRECISION is special: on the 68k, it has 16 bits of zero in the
   *lp++ = word1;
 
   /* X_PRECISION is special: on the 68k, it has 16 bits of zero in the
-     middle.  Either way, it is then followed by a 1 bit. */
+     middle.  Either way, it is then followed by a 1 bit.  */
   if (exponent_bits == 15 && precision == X_PRECISION)
     {
 #ifdef TC_M68K
   if (exponent_bits == 15 && precision == X_PRECISION)
     {
 #ifdef TC_M68K
@@ -601,21 +608,19 @@ gen_to_words (words, precision, exponent_bits)
               | next_bits (LITTLENUM_NUMBER_OF_BITS - 1));
     }
 
               | next_bits (LITTLENUM_NUMBER_OF_BITS - 1));
     }
 
-  /* The rest of the words are just mantissa bits. */
+  /* The rest of the words are just mantissa bits.  */
   while (lp < words_end)
     *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
 
   if (next_bits (1))
     {
       unsigned long carry;
   while (lp < words_end)
     *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
 
   if (next_bits (1))
     {
       unsigned long carry;
-      /*
-       * Since the NEXT bit is a 1, round UP the mantissa.
-       * The cunning design of these hidden-1 floats permits
-       * us to let the mantissa overflow into the exponent, and
-       * it 'does the right thing'. However, we lose if the
-       * highest-order bit of the lowest-order word flips.
-       * Is that clear?
-       */
+      /* Since the NEXT bit is a 1, round UP the mantissa.
+        The cunning design of these hidden-1 floats permits
+        us to let the mantissa overflow into the exponent, and
+        it 'does the right thing'. However, we lose if the
+        highest-order bit of the lowest-order word flips.
+        Is that clear?  */
 
       /* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
         Please allow at least 1 more bit in carry than is in a LITTLENUM.
 
       /* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
         Please allow at least 1 more bit in carry than is in a LITTLENUM.
@@ -624,11 +629,13 @@ gen_to_words (words, precision, exponent_bits)
         don't get a sticky sign bit after shifting right, and that
         permits us to propagate the carry without any masking of bits.
         #endif */
         don't get a sticky sign bit after shifting right, and that
         permits us to propagate the carry without any masking of bits.
         #endif */
-      for (carry = 1, lp--; carry && (lp >= words); lp--)
+      for (carry = 1, lp--; carry; lp--)
        {
          carry = *lp + carry;
          *lp = carry;
          carry >>= LITTLENUM_NUMBER_OF_BITS;
        {
          carry = *lp + carry;
          *lp = carry;
          carry >>= LITTLENUM_NUMBER_OF_BITS;
+         if (lp == words)
+           break;
        }
       if (precision == X_PRECISION && exponent_bits == 15)
        {
        }
       if (precision == X_PRECISION && exponent_bits == 15)
        {
@@ -638,46 +645,25 @@ gen_to_words (words, precision, exponent_bits)
            {
 #ifdef TC_M68K
              /* On the m68k there is a gap of 16 bits.  We must
            {
 #ifdef TC_M68K
              /* On the m68k there is a gap of 16 bits.  We must
-                explicitly propagate the carry into the exponent. */
+                explicitly propagate the carry into the exponent.  */
              words[0] += words[1];
              words[1] = 0;
              lp++;
 #endif
              words[0] += words[1];
              words[1] = 0;
              lp++;
 #endif
-             /* Put back the integer bit.  */ 
+             /* Put back the integer bit.  */
              lp[1] |= 1 << (LITTLENUM_NUMBER_OF_BITS - 1);
            }
              lp[1] |= 1 << (LITTLENUM_NUMBER_OF_BITS - 1);
            }
-       }
+       }
       if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)))
        {
       if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)))
        {
-         /* We leave return_value alone: admit we read the
-          * number, but return a floating exception
-          * because we can't encode the number.
-          */
+         /* We leave return_value alone: admit we read the number,
+            but return a floating exception because we can't encode
+            the number.  */
          *words &= ~(1 << (LITTLENUM_NUMBER_OF_BITS - 1));
          *words &= ~(1 << (LITTLENUM_NUMBER_OF_BITS - 1));
-         /* make_invalid_floating_point_number (words); */
-         /* return return_value; */
        }
     }
        }
     }
-  return (return_value);
-}
-
-#if 0 /* unused */
-/* This routine is a real kludge.  Someone really should do it better,
-   but I'm too lazy, and I don't understand this stuff all too well
-   anyway. (JF)  */
-static void
-int_to_gen (x)
-     long x;
-{
-  char buf[20];
-  char *bufp;
-
-  sprintf (buf, "%ld", x);
-  bufp = &buf[0];
-  if (atof_generic (&bufp, ".", EXP_CHARS, &generic_floating_point_number))
-    as_bad (_("Error converting number to floating point (Exponent overflow?)"));
+  return return_value;
 }
 }
-#endif
 
 #ifdef TEST
 char *
 
 #ifdef TEST
 char *
@@ -703,13 +689,122 @@ print_gen (gen)
   sprintf (sbuf + strlen (sbuf), "%x %x %.12g\n", arr[0], arr[1], fv);
 
   if (gen)
   sprintf (sbuf + strlen (sbuf), "%x %x %.12g\n", arr[0], arr[1], fv);
 
   if (gen)
-    {
-      generic_floating_point_number = f;
-    }
+    generic_floating_point_number = f;
 
   return (sbuf);
 }
 
   return (sbuf);
 }
+#endif
+
+#define MAX_LITTLENUMS 6
+
+/* This is a utility function called from various tc-*.c files.  It
+   is here in order to reduce code duplication.
+
+   Turn a string at input_line_pointer into a floating point constant
+   of type TYPE (a character found in the FLT_CHARS macro), and store
+   it as LITTLENUMS in the bytes buffer LITP.  The number of chars
+   emitted is stored in *SIZEP.  BIG_WORDIAN is TRUE if the littlenums
+   should be emitted most significant littlenum first.
+
+   An error message is returned, or a NULL pointer if everything went OK.  */
+
+const char *
+ieee_md_atof (int type,
+             char *litP,
+             int *sizeP,
+             bfd_boolean big_wordian)
+{
+  LITTLENUM_TYPE words[MAX_LITTLENUMS];
+  LITTLENUM_TYPE *wordP;
+  char *t;
+  int prec = 0;
 
 
+  if (strchr (FLT_CHARS, type) != NULL)
+    {
+      switch (type)
+       {
+       case 'f':
+       case 'F':
+       case 's':
+       case 'S':
+         prec = F_PRECISION;
+         break;
+
+       case 'd':
+       case 'D':
+       case 'r':
+       case 'R':
+         prec = D_PRECISION;
+         break;
+
+       case 't':
+       case 'T':
+         prec = X_PRECISION;
+         type = 'x';           /* This is what atof_ieee() understands.  */
+         break;
+
+       case 'x':
+       case 'X':
+       case 'p':
+       case 'P':
+#ifdef TC_M68K
+         /* Note: on the m68k there is a gap of 16 bits (one littlenum)
+            between the exponent and mantissa.  Hence the precision is
+            6 and not 5.  */
+         prec = P_PRECISION + 1;
+#else
+         prec = P_PRECISION;
 #endif
 #endif
+         break;
 
 
-/* end of atof-ieee.c */
+       default:
+         break;
+       }
+    }
+  /* The 'f' and 'd' types are always recognised, even if the target has
+     not put them into the FLT_CHARS macro.  This is because the 'f' type
+     can come from the .dc.s, .dcb.s, .float or .single pseudo-ops and the
+     'd' type from the .dc.d, .dbc.d or .double pseudo-ops.
+
+     The 'x' type is not implicitly recongised however, even though it can
+     be generated by the .dc.x and .dbc.x pseudo-ops because not all targets
+     can support floating point values that big.  ie the target has to
+     explicitly allow them by putting them into FLT_CHARS.  */
+  else if (type == 'f')
+    prec = F_PRECISION;
+  else if (type == 'd')
+    prec = D_PRECISION;
+
+  if (prec == 0)
+    {
+      *sizeP = 0;
+      return _("Unrecognized or unsupported floating point constant");
+    }
+
+  gas_assert (prec <= MAX_LITTLENUMS);
+
+  t = atof_ieee (input_line_pointer, type, words);
+  if (t)
+    input_line_pointer = t;
+
+  *sizeP = prec * sizeof (LITTLENUM_TYPE);
+
+  if (big_wordian)
+    {
+      for (wordP = words; prec --;)
+       {
+         md_number_to_chars (litP, (valueT) (* wordP ++), sizeof (LITTLENUM_TYPE));
+         litP += sizeof (LITTLENUM_TYPE);
+       }
+    }
+  else
+    {
+      for (wordP = words + prec; prec --;)
+       {
+         md_number_to_chars (litP, (valueT) (* -- wordP), sizeof (LITTLENUM_TYPE));
+         litP += sizeof (LITTLENUM_TYPE);
+       }
+    }
+
+  return NULL;
+}
This page took 0.035633 seconds and 4 git commands to generate.