1//===- WebAssemblyInstrCall.td-WebAssembly Call codegen support -*- tablegen -*-
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief WebAssembly Call operand code-gen constructs.
12///
13//===----------------------------------------------------------------------===//
14
15let Defs = [ARGUMENTS] in {
16
17// The call sequence start/end LLVM-isms isn't useful to WebAssembly since it's
18// a virtual ISA.
19let isCodeGenOnly = 1 in {
20def ADJCALLSTACKDOWN : I<(outs), (ins i64imm:$amt),
21                         [(WebAssemblycallseq_start timm:$amt)]>;
22def ADJCALLSTACKUP : I<(outs), (ins i64imm:$amt),
23                       [(WebAssemblycallseq_end timm:$amt, undef)]>;
24} // isCodeGenOnly = 1
25
26multiclass CALL<WebAssemblyRegClass vt> {
27  def CALL_#vt : I<(outs vt:$dst), (ins global:$callee, variable_ops),
28                   [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))],
29                   "call    \t$dst, $callee">;
30  def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
31                            [(set vt:$dst, (WebAssemblycall1 I32:$callee))],
32                            "call_indirect\t$dst, $callee">;
33}
34let Uses = [SP32, SP64], isCall = 1 in {
35  defm : CALL<I32>;
36  defm : CALL<I64>;
37  defm : CALL<F32>;
38  defm : CALL<F64>;
39
40  def CALL_VOID : I<(outs), (ins global:$callee, variable_ops),
41                    [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))],
42                    "call    \t$callee">;
43  def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops),
44                             [(WebAssemblycall0 I32:$callee)],
45                             "call_indirect\t$callee">;
46} // Uses = [SP32,SP64], isCall = 1
47
48} // Defs = [ARGUMENTS]
49