MIPS/GAS: Don't convert RELA JALR relocations on R6
[deliverable/binutils-gdb.git] / gas / config / atof-ieee.c
index bf842e1717dbba131b81971cb1d1f4e3f26d3765..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 1987, 1992, 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2005
-   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,
@@ -24,7 +23,6 @@
 /* Flonums returned here.  */
 extern FLONUM_TYPE generic_floating_point_number;
 
 /* Flonums returned here.  */
 extern FLONUM_TYPE generic_floating_point_number;
 
-extern const char EXP_CHARS[];
 /* Precision in LittleNums.  */
 /* Don't count the gap in the m68k extended precision format.  */
 #define MAX_PRECISION  5
 /* Precision in LittleNums.  */
 /* Don't count the gap in the m68k extended precision format.  */
 #define MAX_PRECISION  5
@@ -160,7 +158,7 @@ make_invalid_floating_point_number (LITTLENUM_TYPE *words)
 
 char *
 atof_ieee (char *str,                  /* Text to convert to binary.  */
 
 char *
 atof_ieee (char *str,                  /* Text to convert to binary.  */
-          int what_kind,               /* 'd', 'f', 'g', 'h'.  */
+          int what_kind,               /* 'd', 'f', 'x', 'p'.  */
           LITTLENUM_TYPE *words)       /* Build the binary here.  */
 {
   /* Extra bits for zeroed low-order bits.
           LITTLENUM_TYPE *words)       /* Build the binary here.  */
 {
   /* Extra bits for zeroed low-order bits.
@@ -218,7 +216,6 @@ atof_ieee (char *str,                       /* Text to convert to binary.  */
 
     case 'p':
     case 'P':
 
     case 'p':
     case 'P':
-
       precision = P_PRECISION;
       exponent_bits = -1;
       break;
       precision = P_PRECISION;
       exponent_bits = -1;
       break;
@@ -286,7 +283,7 @@ gen_to_words (LITTLENUM_TYPE *words, int precision, long exponent_bits)
   if (generic_floating_point_number.sign == 0)
     {
       if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
   if (generic_floating_point_number.sign == 0)
     {
       if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
-       as_warn ("NaNs are not supported by this target\n");
+       as_warn (_("NaNs are not supported by this target\n"));
       if (precision == F_PRECISION)
        {
          words[0] = 0x7fff;
       if (precision == F_PRECISION)
        {
          words[0] = 0x7fff;
@@ -325,7 +322,7 @@ gen_to_words (LITTLENUM_TYPE *words, int precision, long exponent_bits)
   else if (generic_floating_point_number.sign == 'P')
     {
       if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
   else if (generic_floating_point_number.sign == 'P')
     {
       if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
-       as_warn ("Infinities are not supported by this target\n");
+       as_warn (_("Infinities are not supported by this target\n"));
 
       /* +INF:  Do the right thing.  */
       if (precision == F_PRECISION)
 
       /* +INF:  Do the right thing.  */
       if (precision == F_PRECISION)
@@ -366,7 +363,7 @@ gen_to_words (LITTLENUM_TYPE *words, int precision, long exponent_bits)
   else if (generic_floating_point_number.sign == 'N')
     {
       if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
   else if (generic_floating_point_number.sign == 'N')
     {
       if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
-       as_warn ("Infinities are not supported by this target\n");
+       as_warn (_("Infinities are not supported by this target\n"));
 
       /* Negative INF.  */
       if (precision == F_PRECISION)
 
       /* Negative INF.  */
       if (precision == F_PRECISION)
@@ -420,7 +417,7 @@ gen_to_words (LITTLENUM_TYPE *words, int precision, long exponent_bits)
                     - generic_floating_point_number.low);
 
   /* Seek (and forget) 1st significant bit.  */
                     - generic_floating_point_number.low);
 
   /* Seek (and forget) 1st significant bit.  */
-  for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage);;
+  for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage);
   exponent_1 = (generic_floating_point_number.exponent
                + generic_floating_point_number.leader
                + 1
   exponent_1 = (generic_floating_point_number.exponent
                + generic_floating_point_number.leader
                + 1
@@ -696,5 +693,118 @@ print_gen (gen)
 
   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;
+
+       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.036247 seconds and 4 git commands to generate.