15ca0bacaSJF Bastien//===- WebAssemblyInstrCall.td-WebAssembly Call codegen support -*- tablegen -*-
25ca0bacaSJF Bastien//
35ca0bacaSJF Bastien//                     The LLVM Compiler Infrastructure
45ca0bacaSJF Bastien//
55ca0bacaSJF Bastien// This file is distributed under the University of Illinois Open Source
65ca0bacaSJF Bastien// License. See LICENSE.TXT for details.
75ca0bacaSJF Bastien//
85ca0bacaSJF Bastien//===----------------------------------------------------------------------===//
95ca0bacaSJF Bastien///
105ca0bacaSJF Bastien/// \file
115ca0bacaSJF Bastien/// \brief WebAssembly Call operand code-gen constructs.
125ca0bacaSJF Bastien///
135ca0bacaSJF Bastien//===----------------------------------------------------------------------===//
145ca0bacaSJF Bastien
15fb3e0594SDan Gohmanlet Defs = [ARGUMENTS] in {
16fb3e0594SDan Gohman
17af111db8SJF Bastien// The call sequence start/end LLVM-isms isn't useful to WebAssembly since it's
18af111db8SJF Bastien// a virtual ISA.
19af111db8SJF Bastienlet isCodeGenOnly = 1 in {
20*541841e3SDan Gohmandef ADJCALLSTACKDOWN : I<(outs), (ins i64imm:$amt),
21af111db8SJF Bastien                         [(WebAssemblycallseq_start timm:$amt)]>;
22*541841e3SDan Gohmandef ADJCALLSTACKUP : I<(outs), (ins i64imm:$amt1, i64imm:$amt2),
23af111db8SJF Bastien                       [(WebAssemblycallseq_end timm:$amt1, timm:$amt2)]>;
24af111db8SJF Bastien} // isCodeGenOnly = 1
25af111db8SJF Bastien
26af111db8SJF Bastienmulticlass CALL<WebAssemblyRegClass vt> {
2705a17aa8SDan Gohman  def CALL_#vt : I<(outs vt:$dst), (ins global:$callee, variable_ops),
28cf4748f1SDan Gohman                   [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))],
292f16f253SDan Gohman                   "call    \t$dst, $callee">;
3005a17aa8SDan Gohman  def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
31cf4748f1SDan Gohman                            [(set vt:$dst, (WebAssemblycall1 I32:$callee))],
322f16f253SDan Gohman                            "call_indirect\t$dst, $callee">;
33af111db8SJF Bastien}
34af111db8SJF Bastienlet Uses = [SP32, SP64], isCall = 1 in {
35d0bf9812SDan Gohman  defm : CALL<I32>;
36d0bf9812SDan Gohman  defm : CALL<I64>;
37d0bf9812SDan Gohman  defm : CALL<F32>;
38d0bf9812SDan Gohman  defm : CALL<F64>;
39f71abef7SDan Gohman
4005a17aa8SDan Gohman  def CALL_VOID : I<(outs), (ins global:$callee, variable_ops),
41cf4748f1SDan Gohman                    [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))],
421031d4a8SDan Gohman                    "call    \t$callee">;
4305a17aa8SDan Gohman  def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops),
44cf4748f1SDan Gohman                             [(WebAssemblycall0 I32:$callee)],
451031d4a8SDan Gohman                             "call_indirect\t$callee">;
46af111db8SJF Bastien} // Uses = [SP32,SP64], isCall = 1
47fb3e0594SDan Gohman
48fb3e0594SDan Gohman} // Defs = [ARGUMENTS]
49