[llvm] r247158 - [WebAssembly] Implement calls with void return types.

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 09:13:47 PDT 2015


Author: djg
Date: Wed Sep  9 11:13:47 2015
New Revision: 247158

URL: http://llvm.org/viewvc/llvm-project?rev=247158&view=rev
Log:
[WebAssembly] Implement calls with void return types.

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyISD.def
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
    llvm/trunk/test/CodeGen/WebAssembly/call.ll

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISD.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISD.def?rev=247158&r1=247157&r2=247158&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISD.def (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISD.def Wed Sep  9 11:13:47 2015
@@ -14,7 +14,8 @@
 
 // NOTE: NO INCLUDE GUARD DESIRED!
 
-HANDLE_NODETYPE(CALL)
+HANDLE_NODETYPE(CALL1)
+HANDLE_NODETYPE(CALL0)
 HANDLE_NODETYPE(RETURN)
 HANDLE_NODETYPE(ARGUMENT)
 HANDLE_NODETYPE(Wrapper)

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=247158&r1=247157&r2=247158&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Wed Sep  9 11:13:47 2015
@@ -261,7 +261,9 @@ WebAssemblyTargetLowering::LowerCall(Cal
     Tys.push_back(In.VT);
   Tys.push_back(MVT::Other);
   SDVTList TyList = DAG.getVTList(Tys);
-  SDValue Res = DAG.getNode(WebAssemblyISD::CALL, DL, TyList, Ops);
+  SDValue Res =
+      DAG.getNode(Ins.empty() ? WebAssemblyISD::CALL0 : WebAssemblyISD::CALL1,
+                  DL, TyList, Ops);
   if (Ins.empty()) {
     Chain = Res;
   } else {

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td?rev=247158&r1=247157&r2=247158&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td Wed Sep  9 11:13:47 2015
@@ -23,14 +23,16 @@ def : I<(outs), (ins i64imm:$amt1, i64im
 
 multiclass CALL<WebAssemblyRegClass vt> {
   def CALL_#vt : I<(outs vt:$dst), (ins Int32:$callee, variable_ops),
-                   [(set vt:$dst, (WebAssemblycall Int32:$callee))]>;
+                   [(set vt:$dst, (WebAssemblycall1 Int32:$callee))]>;
 }
 let Uses = [SP32, SP64], isCall = 1 in {
   defm : CALL<Int32>;
   defm : CALL<Int64>;
   defm : CALL<Float32>;
   defm : CALL<Float64>;
-  // FIXME: void.
+
+  def CALL_VOID : I<(outs), (ins Int32:$callee, variable_ops),
+                    [(WebAssemblycall0 Int32:$callee)]>;
 } // Uses = [SP32,SP64], isCall = 1
 
 /*

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td?rev=247158&r1=247157&r2=247158&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td Wed Sep  9 11:13:47 2015
@@ -28,7 +28,8 @@ def HasSIMD128 : Predicate<"Subtarget->h
 def SDT_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>]>;
 def SDT_WebAssemblyCallSeqEnd :
     SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
-def SDT_WebAssemblyCall     : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>;
+def SDT_WebAssemblyCall0    : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
+def SDT_WebAssemblyCall1    : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>;
 def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>;
 def SDT_WebAssemblyReturn   : SDTypeProfile<0, -1, []>;
 def SDT_WebAssemblyWrapper  : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
@@ -44,9 +45,12 @@ def WebAssemblycallseq_start :
 def WebAssemblycallseq_end :
     SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd,
            [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
-def WebAssemblycall      : SDNode<"WebAssemblyISD::CALL",
-                                  SDT_WebAssemblyCall,
-                                  [SDNPHasChain, SDNPVariadic]>;
+def WebAssemblycall0 : SDNode<"WebAssemblyISD::CALL0",
+                              SDT_WebAssemblyCall0,
+                              [SDNPHasChain, SDNPVariadic]>;
+def WebAssemblycall1 : SDNode<"WebAssemblyISD::CALL1",
+                              SDT_WebAssemblyCall1,
+                              [SDNPHasChain, SDNPVariadic]>;
 def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT",
                                  SDT_WebAssemblyArgument>;
 def WebAssemblyreturn   : SDNode<"WebAssemblyISD::RETURN",

Modified: llvm/trunk/test/CodeGen/WebAssembly/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call.ll?rev=247158&r1=247157&r2=247158&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call.ll Wed Sep  9 11:13:47 2015
@@ -11,6 +11,7 @@ declare i32 @i32_binary(i32, i32)
 declare i64 @i64_nullary()
 declare float @float_nullary()
 declare double @double_nullary()
+declare void @void_nullary()
 
 ; CHECK-LABEL: (func $call_i32_nullary
 ; CHECK-NEXT: (result i32)
@@ -52,6 +53,15 @@ define double @call_double_nullary() {
   ret double %r
 }
 
+; CHECK-LABEL: (func $call_void_nullary
+; CHECK-NEXT: (setlocal @0 (global $void_nullary))
+; CHECK-NEXT: (call @0)
+; CHECK-NEXT: (return)
+define void @call_void_nullary() {
+  call void @void_nullary()
+  ret void
+}
+
 ; CHECK-LABEL: (func $call_i32_unary
 ; CHECK-NEXT: (param i32) (result i32)
 ; CHECK-NEXT: (setlocal @0 (argument 0))




More information about the llvm-commits mailing list