summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJF Bastien <jfb@google.com>2015-08-03 00:00:11 +0000
committerJF Bastien <jfb@google.com>2015-08-03 00:00:11 +0000
commitfda53373f2360494d38bf705f776d32d1153be69 (patch)
tree6bc234f95bacb463d1041cdbe2992601c695aca9
parent1cd693c9e976b60ee8a2114e4644d4e83478ae77 (diff)
downloadbcm5719-llvm-fda53373f2360494d38bf705f776d32d1153be69.tar.gz
bcm5719-llvm-fda53373f2360494d38bf705f776d32d1153be69.zip
WebAssembly: implement getScalarShiftAmountTy so we can shift by amount, with type
Summary: This currently sets the shift amount RHS to the same type as the LHS, and assumes that the LHS is a simple type. This isn't currently the case e.g. with weird integers sizes, but will eventually be true and will assert if not. That's what you get for having an experimental backend: break it and you get to keep both pieces. Most backends either set the RHS to MVT::i32 or MVT::i64, but WebAssembly is a virtual ISA and tries to have regular-looking binary operations where both operands are the same type (even if a 64-bit RHS shifter is slightly silly, hey it's free!). Subscribers: llvm-commits, sunfish, jfb Differential Revision: http://reviews.llvm.org/D11715 llvm-svn: 243860
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp5
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h2
-rw-r--r--llvm/test/CodeGen/WebAssembly/integer64.ll62
3 files changed, 36 insertions, 33 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index f8b4fbd3bde..4360116a7f1 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -111,6 +111,11 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
// FIXME: setOperationAction...
}
+MVT WebAssemblyTargetLowering::getScalarShiftAmountTy(const DataLayout &DL,
+ EVT VT) const {
+ return VT.getSimpleVT();
+}
+
//===----------------------------------------------------------------------===//
// WebAssembly Lowering private implementation.
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
index 3e8252604d6..12b4fe62864 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
@@ -45,6 +45,8 @@ private:
/// right decision when generating code for different targets.
const WebAssemblySubtarget *Subtarget;
+ MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
+
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
bool isVarArg,
const SmallVectorImpl<ISD::OutputArg> &Outs,
diff --git a/llvm/test/CodeGen/WebAssembly/integer64.ll b/llvm/test/CodeGen/WebAssembly/integer64.ll
index 4ac2846754c..540646cc388 100644
--- a/llvm/test/CodeGen/WebAssembly/integer64.ll
+++ b/llvm/test/CodeGen/WebAssembly/integer64.ll
@@ -109,39 +109,35 @@ define i64 @xor64(i64 %x, i64 %y) {
ret i64 %a
}
-; FIXME: 64-bit shifts have an extra truncate of the input shift value, which
-; WebAssembly hasn't taught isel to match yet. Fix with
-; getScalarShiftAmountTy.
-
-; C;HECK-LABEL: shl64:
-; C;HECK-NEXT: (setlocal @0 (argument 1))
-; C;HECK-NEXT: (setlocal @1 (argument 0))
-; C;HECK-NEXT: (setlocal @2 (SHL_I64 @1 @0))
-; C;HECK-NEXT: (return @2)
-;define i64 @shl64(i64 %x, i64 %y) {
-; %a = shl i64 %x, %y
-; ret i64 %a
-;}
-
-; C;HECK-LABEL: shr64:
-; C;HECK-NEXT: (setlocal @0 (argument 1))
-; C;HECK-NEXT: (setlocal @1 (argument 0))
-; C;HECK-NEXT: (setlocal @2 (SHR_I64 @1 @0))
-; C;HECK-NEXT: (return @2)
-;define i64 @shr64(i64 %x, i64 %y) {
-; %a = lshr i64 %x, %y
-; ret i64 %a
-;}
-
-; C;HECK-LABEL: sar64:
-; C;HECK-NEXT: (setlocal @0 (argument 1))
-; C;HECK-NEXT: (setlocal @1 (argument 0))
-; C;HECK-NEXT: (setlocal @2 (SAR_I64 @1 @0))
-; C;HECK-NEXT: (return @2)
-;define i64 @sar64(i64 %x, i64 %y) {
-; %a = ashr i64 %x, %y
-; ret i64 %a
-;}
+; CHECK-LABEL: shl64:
+; CHECK-NEXT: (setlocal @0 (argument 1))
+; CHECK-NEXT: (setlocal @1 (argument 0))
+; CHECK-NEXT: (setlocal @2 (SHL_I64 @1 @0))
+; CHECK-NEXT: (return @2)
+define i64 @shl64(i64 %x, i64 %y) {
+ %a = shl i64 %x, %y
+ ret i64 %a
+}
+
+; CHECK-LABEL: shr64:
+; CHECK-NEXT: (setlocal @0 (argument 1))
+; CHECK-NEXT: (setlocal @1 (argument 0))
+; CHECK-NEXT: (setlocal @2 (SHR_I64 @1 @0))
+; CHECK-NEXT: (return @2)
+define i64 @shr64(i64 %x, i64 %y) {
+ %a = lshr i64 %x, %y
+ ret i64 %a
+}
+
+; CHECK-LABEL: sar64:
+; CHECK-NEXT: (setlocal @0 (argument 1))
+; CHECK-NEXT: (setlocal @1 (argument 0))
+; CHECK-NEXT: (setlocal @2 (SAR_I64 @1 @0))
+; CHECK-NEXT: (return @2)
+define i64 @sar64(i64 %x, i64 %y) {
+ %a = ashr i64 %x, %y
+ ret i64 %a
+}
; CHECK-LABEL: clz64:
; CHECK-NEXT: (setlocal @0 (argument 0))
OpenPOWER on IntegriCloud