[llvm] r247649 - [WebAssembly] Implement int64-to-int32 conversion.

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 17:55:20 PDT 2015


Author: djg
Date: Mon Sep 14 19:55:19 2015
New Revision: 247649

URL: http://llvm.org/viewvc/llvm-project?rev=247649&view=rev
Log:
[WebAssembly] Implement int64-to-int32 conversion.

Added:
    llvm/trunk/test/CodeGen/WebAssembly/conv.ll
Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrConv.td

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrConv.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrConv.td?rev=247649&r1=247648&r2=247649&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrConv.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrConv.td Mon Sep 14 19:55:19 2015
@@ -42,3 +42,6 @@
  * float64.cvt_unsigned[int64]: convert an unsigned 64-bit integer to a 64-bit float
  * float64.reinterpret[int64]: reinterpret the bits of a 64-bit integer as a 64-bit float
  */
+
+def WRAP_I64_I32 : I<(outs Int32:$dst), (ins Int64:$src),
+                     [(set Int32:$dst, (trunc Int64:$src))]>;

Added: llvm/trunk/test/CodeGen/WebAssembly/conv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/conv.ll?rev=247649&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/conv.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/conv.ll Mon Sep 14 19:55:19 2015
@@ -0,0 +1,16 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that basic conversion operations assemble as expected.
+
+target datalayout = "e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; CHECK-LABEL: $wrap_i64_i32
+; CHECK-NEXT: (param i64) (result i32)
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (wrap_i64 @0))
+; CHECK-NEXT: (return @1)
+define i32 @wrap_i64_i32(i64 %x) {
+  %a = trunc i64 %x to i32
+  ret i32 %a
+}




More information about the llvm-commits mailing list