This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [WebAssembly] Disassembler support

On Sun, Apr 09, 2017 at 01:20:16PM +0000, Pip Cet wrote:
> On Sun, Apr 9, 2017 at 10:35 AM, Alan Modra <> wrote:
> > I think what I'd be inclined to do is print your WebAssembly floats
> > and doubles in %a format.
> Wouldn't that also be a C99 thing? I know I looked into using %a and
> decided it wasn't a good idea, probably for that reason. (Possibly,
> also, because I personally find it hard to read, but that's less of a
> concern).
> > You can probably do that without converting
> > to host doubles.
> Well, I certainly would have to convert 32-bit floats to doubles
> before calling printf...

What I meant by %a format and not converting to host double is:
- read 4-byte or 8-byte value
- convert to host endian with bfd_get_32 or bfd_get_64
- extract sign, mantissa and exponent
- decode special cases, nan, inf
- print sign if negative, mantissa as hex, exponent as decimal to give
  [-]0xL.MMMMMMMMMMMMMp[+-]EEE (L being the leading implicit 1 or 0 if
  denormal, M mantissa, E exponent).
See glibc/stdio_common/printf_fphex.c

> > If that idea doesn't fly, just use a constant
> > specific to your target floats and doubles, hoping the host is
> > reasonably compatible.
> I think that's what my patch does, and I think it's the best thing to
> do for now; should non-IEEE floats become significant again,
> floatformat should probably provide its own printing functions.

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.

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]