From: Dan Gohman Date: Wed, 9 Sep 2015 16:13:47 +0000 (+0000) Subject: [WebAssembly] Implement calls with void return types. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=85ef3e393dc3293d0df99d7a896152a5cd2d8fab [WebAssembly] Implement calls with void return types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247158 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/WebAssembly/WebAssemblyISD.def b/lib/Target/WebAssembly/WebAssemblyISD.def index 0bc9b2f55b1..24e613e7711 100644 --- a/lib/Target/WebAssembly/WebAssemblyISD.def +++ b/lib/Target/WebAssembly/WebAssemblyISD.def @@ -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) diff --git a/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 7e9e1b0e016..12dce113c3e 100644 --- a/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -261,7 +261,9 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI, 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 { diff --git a/lib/Target/WebAssembly/WebAssemblyInstrCall.td b/lib/Target/WebAssembly/WebAssemblyInstrCall.td index abb7f21512a..d3430f225ee 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrCall.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrCall.td @@ -23,14 +23,16 @@ def : I<(outs), (ins i64imm:$amt1, i64imm:$amt2), multiclass CALL { 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; defm : CALL; defm : CALL; defm : CALL; - // FIXME: void. + + def CALL_VOID : I<(outs), (ins Int32:$callee, variable_ops), + [(WebAssemblycall0 Int32:$callee)]>; } // Uses = [SP32,SP64], isCall = 1 /* diff --git a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td index d73e66ea985..409c8525f93 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -28,7 +28,8 @@ def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">, 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", diff --git a/test/CodeGen/WebAssembly/call.ll b/test/CodeGen/WebAssembly/call.ll index d628ec09630..14a41b0feb5 100644 --- a/test/CodeGen/WebAssembly/call.ll +++ b/test/CodeGen/WebAssembly/call.ll @@ -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))