]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Float16: Fix test failures for non ELF targets
authorBarnaby Wilks <Barnaby.Wilks@arm.com>
Thu, 15 Aug 2019 16:21:59 +0000 (16:21 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 19 Aug 2019 00:23:22 +0000 (09:53 +0930)
The tests were failing due to md_atof trying to do word-wise endian
switching on the float16 (for little-endian targets sometimes
multi word values have their word order changed).
However since a float16 is only 1 word wide, it would end up writing
incorrect data, as you cannot switch the word order of just one word.

* config/tc-arm.c (md_atof): Add precision check.  Formatting.

gas/ChangeLog
gas/config/tc-arm.c

index 3ac707ce62644433d5d3aaebab28cf52b1e26234..51c6c87e4086f9df2c058503b0165125c6e2fa7e 100644 (file)
@@ -1,3 +1,7 @@
+2019-08-19  Barnaby Wilks  <Barnaby.Wilks@arm.com>
+
+       * config/tc-arm.c (md_atof): Add precision check.  Formatting.
+
 2019-08-15  Nick Clifton  <nickc@redhat.com>
 
        * po/sv.po: Updated Swedish translation.
index e2b21ed915f4ede69ef926d6144d7a87e2dacdf4..c58748dfaa1b83dbb65b44ab40e1cdfc591e4ac4 100644 (file)
@@ -1237,34 +1237,29 @@ md_atof (int type, char * litP, int * sizeP)
     input_line_pointer = t;
   *sizeP = prec * sizeof (LITTLENUM_TYPE);
 
-  if (target_big_endian)
-    {
-      for (i = 0; i < prec; i++)
-       {
-         md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
-         litP += sizeof (LITTLENUM_TYPE);
-       }
-    }
+  if (target_big_endian || prec == 1)
+    for (i = 0; i < prec; i++)
+      {
+       md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
+       litP += sizeof (LITTLENUM_TYPE);
+      }
+  else if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_endian_pure))
+    for (i = prec - 1; i >= 0; i--)
+      {
+       md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
+       litP += sizeof (LITTLENUM_TYPE);
+      }
   else
-    {
-      if (ARM_CPU_HAS_FEATURE (cpu_variant, fpu_endian_pure))
-       for (i = prec - 1; i >= 0; i--)
-         {
-           md_number_to_chars (litP, (valueT) words[i], sizeof (LITTLENUM_TYPE));
-           litP += sizeof (LITTLENUM_TYPE);
-         }
-      else
-       /* For a 4 byte float the order of elements in `words' is 1 0.
-          For an 8 byte float the order is 1 0 3 2.  */
-       for (i = 0; i < prec; i += 2)
-         {
-           md_number_to_chars (litP, (valueT) words[i + 1],
-                               sizeof (LITTLENUM_TYPE));
-           md_number_to_chars (litP + sizeof (LITTLENUM_TYPE),
-                               (valueT) words[i], sizeof (LITTLENUM_TYPE));
-           litP += 2 * sizeof (LITTLENUM_TYPE);
-         }
-    }
+    /* For a 4 byte float the order of elements in `words' is 1 0.
+       For an 8 byte float the order is 1 0 3 2.  */
+    for (i = 0; i < prec; i += 2)
+      {
+       md_number_to_chars (litP, (valueT) words[i + 1],
+                           sizeof (LITTLENUM_TYPE));
+       md_number_to_chars (litP + sizeof (LITTLENUM_TYPE),
+                           (valueT) words[i], sizeof (LITTLENUM_TYPE));
+       litP += 2 * sizeof (LITTLENUM_TYPE);
+      }
 
   return NULL;
 }