blob: aec614e9ea3189a3b7e76d3f0fa5dadfe9bd3501 [file] [log] [blame]
JF Bastien5ca0bac2015-07-10 18:23:10 +00001//===- 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
JF Bastienaf111db2015-08-24 22:16:48 +000015// 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> {
Dan Gohman05a17aa2015-09-28 16:22:39 +000025 def CALL_#vt : I<(outs vt:$dst), (ins global:$callee, variable_ops),
Dan Gohmancf4748f2015-11-12 17:04:33 +000026 [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))],
Dan Gohman94ef41f2015-11-18 17:05:35 +000027 "call \t$callee, $dst">;
Dan Gohman05a17aa2015-09-28 16:22:39 +000028 def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
Dan Gohmancf4748f2015-11-12 17:04:33 +000029 [(set vt:$dst, (WebAssemblycall1 I32:$callee))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000030 "call_indirect\t$callee, $dst">;
JF Bastienaf111db2015-08-24 22:16:48 +000031}
32let Uses = [SP32, SP64], isCall = 1 in {
Dan Gohmand0bf9812015-09-26 01:09:44 +000033 defm : CALL<I32>;
34 defm : CALL<I64>;
35 defm : CALL<F32>;
36 defm : CALL<F64>;
Dan Gohmanf71abef2015-09-09 16:13:47 +000037
Dan Gohman05a17aa2015-09-28 16:22:39 +000038 def CALL_VOID : I<(outs), (ins global:$callee, variable_ops),
Dan Gohmancf4748f2015-11-12 17:04:33 +000039 [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))],
Dan Gohman94ef41f2015-11-18 17:05:35 +000040 "call \t$callee">;
Dan Gohman05a17aa2015-09-28 16:22:39 +000041 def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops),
Dan Gohmancf4748f2015-11-12 17:04:33 +000042 [(WebAssemblycall0 I32:$callee)],
Dan Gohman1031d4a2015-11-15 15:34:19 +000043 "call_indirect\t$callee">;
JF Bastienaf111db2015-08-24 22:16:48 +000044} // Uses = [SP32,SP64], isCall = 1