This is an archive of the discontinued LLVM Phabricator instance.

WebAssembly: print immediates
ClosedPublic

Authored by jfb on Aug 10 2015, 11:29 AM.

Details

Summary

For now output using C99's hexadecimal floating-point representation.

This patch also cleans up how machine operands are printed: instead of special-casing per type of machine instruction, the code now handles operands generically.

Diff Detail

Repository
rL LLVM

Event Timeline

jfb updated this revision to Diff 31704.Aug 10 2015, 11:29 AM
jfb retitled this revision from to WebAssembly: print immediates.
jfb updated this object.
jfb added a reviewer: sunfish.
jfb added a subscriber: llvm-commits.
sunfish accepted this revision.Aug 10 2015, 2:55 PM
sunfish edited edge metadata.
sunfish added inline comments.
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
122 ↗(On Diff #31704)

It looks like APFloat's NaN printing doesn't include the significand (the "(n-char-sequence)"). I don't want to bikeshed on the format here, but we'll need to do *something* to preserve all the information in any case. Can you add asserts, or perhaps just highly-visible comments, indicating that we're missing functionality here?

This revision is now accepted and ready to land.Aug 10 2015, 2:55 PM
jfb updated this revision to Diff 31738.Aug 10 2015, 3:36 PM
jfb edited edge metadata.
  • Canonicalize NaNs.
This revision was automatically updated to reflect the committed changes.
jfb added inline comments.Aug 10 2015, 3:38 PM
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
122 ↗(On Diff #31704)

I changed it to canonicalize by default. The code looks a bit weird, so that all the bits are in place to do something else if we want to.

sunfish added inline comments.Aug 10 2015, 3:48 PM
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
123

WebAssembly does have NaNs that have sign bits and payloads, so the comment here is incorrect.

Canonicalization here isn't useful since APFloat currently ignores NaN payloads. Could you change this canonicalization code to assert if a NaN is non-canonical? That won't happen in any code we write for a while, and when it does, the assert will fail and remind us that we need to fix this.

jfb added inline comments.Aug 10 2015, 5:49 PM
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
123

Done in D11925.