[PATCH] D11193: WebAssembly: add basic int/fp instruction codegen.

Dan Gohman dan433584 at gmail.com
Tue Jul 14 13:28:52 PDT 2015


sunfish accepted this revision.
sunfish added a comment.
This revision is now accepted and ready to land.

lgtm, with a few comments:


================
Comment at: lib/Target/WebAssembly/WebAssemblyInstrFloat.td:24
@@ +23,3 @@
+defm FLOOR : UnaryFP<ffloor>;
+defm TRUNC : UnaryFP<frint>;
+defm NEARESTINT : UnaryFP<fnearbyint>;
----------------
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.

================
Comment at: lib/Target/WebAssembly/WebAssemblyInstrFloat.td:39
@@ +38,2 @@
+defm MIN : BinaryFP<fminnum>;
+defm MAX : BinaryFP<fmaxnum>;
----------------
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.

================
Comment at: lib/Target/WebAssembly/WebAssemblyInstrFormats.td:33
@@ +32,3 @@
+multiclass UnaryInt<SDNode node> {
+  def I32 : I<(outs Int32:$dst), (ins Int32:$src),
+              [(set Int32:$dst, (node Int32:$src))]>;
----------------
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.


http://reviews.llvm.org/D11193







More information about the llvm-commits mailing list