This is an archive of the discontinued LLVM Phabricator instance.

WebAssembly: add basic int/fp instruction codegen.
ClosedPublic

Authored by jfb on Jul 14 2015, 12:51 PM.

Details

Summary

This patch has the most basic instruction codegen for 32 and 64 bit int/fp.

Diff Detail

Repository
rL LLVM

Event Timeline

jfb updated this revision to Diff 29702.Jul 14 2015, 12:51 PM
jfb retitled this revision from to WebAssembly: add basic int/fp instruction codegen..
jfb updated this object.
jfb added a reviewer: sunfish.
jfb added a subscriber: llvm-commits.
sunfish accepted this revision.Jul 14 2015, 1:28 PM
sunfish edited edge metadata.

lgtm, with a few comments:

lib/Target/WebAssembly/WebAssemblyInstrFloat.td
24 ↗(On Diff #29702)

This should use ftrunc, rather than frint.

Since WebAssembly doesn't expose floating-point exceptions, frint should map to the nearestint operator, similar to fnearbyint.

39 ↗(On Diff #29702)

WebAssembly's current min and max operators return NaN if either operand is NaN, so they aren't the same as LLVM's fminnum and fmaxnum. (Actual minNum and maxNum operators are being considered as possible future features.)

It's fine to just defer defining these for now. The NEON backends have similar instructions and will serve as examples of how to utilize them, when we're ready.

lib/Target/WebAssembly/WebAssemblyInstrFormats.td
33 ↗(On Diff #29702)

It's common and nice to prefix multiclass def names with an underscore, since they are concatenated onto the end of the instruction names they expand into. ADD_I32 will be nicer than ADDI32, especially as we add more opcodes where the concatenation can lead to ambiguous-looking names.

This revision is now accepted and ready to land.Jul 14 2015, 1:28 PM
jfb updated this revision to Diff 29710.Jul 14 2015, 2:10 PM
jfb marked 3 inline comments as done.
jfb edited edge metadata.
  • Address sunfish's comments.
jfb added a comment.Jul 14 2015, 2:13 PM

Comments addressed.

This revision was automatically updated to reflect the committed changes.