[PATCH] [WebAssembly] Disassembler support

Pip Cet pipcet@gmail.com
Mon Apr 10 00:11:00 GMT 2017


On Sun, Apr 9, 2017 at 11:39 PM, Alan Modra <amodra@gmail.com> wrote:
> Yeah, I'm fine with your DECIMAL_DIG_IEEE754 patch, except to query
> whether you really want a precision of 17 for wasm_constant_f32,
> in which case forget the #define and use a hardcoded %.9g there and
> %.17g for wasm_constant_f64.  Patch to do that preapproved.


Thank you. I've attached a patch to do that (I don't have
write-after-approval privileges, so I'd be grateful if someone could
apply it).
-------------- next part --------------
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 73a0071a93..1e8763e307 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-09  Pip Cet  <pipcet@gmail.com>
+
+	* wasm32-dis.c (print_insn_wasm32): Avoid DECIMAL_DIG, specify
+	appropriate floating-point precision directly.
+
 2017-04-07  Alan Modra  <amodra@gmail.com>
 
 	* ppc-opc.c (powerpc_opcodes <mviwsplt, mvidsplt, lvexbx, lvepxl,
diff --git a/opcodes/wasm32-dis.c b/opcodes/wasm32-dis.c
index 80e4ffe81a..18295d08e1 100644
--- a/opcodes/wasm32-dis.c
+++ b/opcodes/wasm32-dis.c
@@ -23,7 +23,6 @@
 #include "opintl.h"
 #include "safe-ctype.h"
 #include "floatformat.h"
-#include <float.h>
 #include "libiberty.h"
 #include "elf-bfd.h"
 #include "elf/internal.h"
@@ -405,7 +404,7 @@ print_insn_wasm32 (bfd_vma pc, struct disassemble_info *info)
           if (ret < 0)
             return -1;
           len += ret;
-          prin (stream, " %.*g", DECIMAL_DIG, fconstant);
+          prin (stream, " %.9g", fconstant);
           break;
 
         case wasm_constant_f64:
@@ -413,7 +412,7 @@ print_insn_wasm32 (bfd_vma pc, struct disassemble_info *info)
           if (ret < 0)
             return -1;
           len += ret;
-          prin (stream, " %.*g", DECIMAL_DIG, fconstant);
+          prin (stream, " %.17g", fconstant);
           break;
 
         case wasm_call:


More information about the Binutils mailing list