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
15// The call sequence start/end LLVM-isms isn't useful to WebAssembly since it's
16// a virtual ISA.
17let isCodeGenOnly = 1 in {
18def : I<(outs), (ins i64imm:$amt),
19        [(WebAssemblycallseq_start timm:$amt)]>;
20def : I<(outs), (ins i64imm:$amt1, i64imm:$amt2),
21        [(WebAssemblycallseq_end timm:$amt1, timm:$amt2)]>;
22} // isCodeGenOnly = 1
23
24multiclass CALL<WebAssemblyRegClass vt> {
25  def CALL_#vt : I<(outs vt:$dst), (ins global:$callee, variable_ops),
26                   [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))]>;
27  def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
28                            [(set vt:$dst, (WebAssemblycall1 I32:$callee))]>;
29}
30let Uses = [SP32, SP64], isCall = 1 in {
31  defm : CALL<I32>;
32  defm : CALL<I64>;
33  defm : CALL<F32>;
34  defm : CALL<F64>;
35
36  def CALL_VOID : I<(outs), (ins global:$callee, variable_ops),
37                    [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))]>;
38  def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops),
39                             [(WebAssemblycall0 I32:$callee)]>;
40} // Uses = [SP32,SP64], isCall = 1
41
42/*
43 * TODO(jfb): Add the following.
44 *
45 * addressof: obtain a function pointer value for a given function
46 */
47