JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 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 | |
Dan Gohman | fb3e059 | 2015-11-25 19:36:19 +0000 | [diff] [blame^] | 15 | let Defs = [ARGUMENTS] in { |
| 16 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 17 | // The call sequence start/end LLVM-isms isn't useful to WebAssembly since it's |
| 18 | // a virtual ISA. |
| 19 | let isCodeGenOnly = 1 in { |
| 20 | def : I<(outs), (ins i64imm:$amt), |
| 21 | [(WebAssemblycallseq_start timm:$amt)]>; |
| 22 | def : I<(outs), (ins i64imm:$amt1, i64imm:$amt2), |
| 23 | [(WebAssemblycallseq_end timm:$amt1, timm:$amt2)]>; |
| 24 | } // isCodeGenOnly = 1 |
| 25 | |
| 26 | multiclass CALL<WebAssemblyRegClass vt> { |
Dan Gohman | 05a17aa | 2015-09-28 16:22:39 +0000 | [diff] [blame] | 27 | def CALL_#vt : I<(outs vt:$dst), (ins global:$callee, variable_ops), |
Dan Gohman | cf4748f | 2015-11-12 17:04:33 +0000 | [diff] [blame] | 28 | [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))], |
Dan Gohman | 2f16f25 | 2015-11-23 22:04:06 +0000 | [diff] [blame] | 29 | "call \t$dst, $callee">; |
Dan Gohman | 05a17aa | 2015-09-28 16:22:39 +0000 | [diff] [blame] | 30 | def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops), |
Dan Gohman | cf4748f | 2015-11-12 17:04:33 +0000 | [diff] [blame] | 31 | [(set vt:$dst, (WebAssemblycall1 I32:$callee))], |
Dan Gohman | 2f16f25 | 2015-11-23 22:04:06 +0000 | [diff] [blame] | 32 | "call_indirect\t$dst, $callee">; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 33 | } |
| 34 | let Uses = [SP32, SP64], isCall = 1 in { |
Dan Gohman | d0bf981 | 2015-09-26 01:09:44 +0000 | [diff] [blame] | 35 | defm : CALL<I32>; |
| 36 | defm : CALL<I64>; |
| 37 | defm : CALL<F32>; |
| 38 | defm : CALL<F64>; |
Dan Gohman | f71abef | 2015-09-09 16:13:47 +0000 | [diff] [blame] | 39 | |
Dan Gohman | 05a17aa | 2015-09-28 16:22:39 +0000 | [diff] [blame] | 40 | def CALL_VOID : I<(outs), (ins global:$callee, variable_ops), |
Dan Gohman | cf4748f | 2015-11-12 17:04:33 +0000 | [diff] [blame] | 41 | [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))], |
Dan Gohman | 94ef41f | 2015-11-18 17:05:35 +0000 | [diff] [blame] | 42 | "call \t$callee">; |
Dan Gohman | 05a17aa | 2015-09-28 16:22:39 +0000 | [diff] [blame] | 43 | def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops), |
Dan Gohman | cf4748f | 2015-11-12 17:04:33 +0000 | [diff] [blame] | 44 | [(WebAssemblycall0 I32:$callee)], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 45 | "call_indirect\t$callee">; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 46 | } // Uses = [SP32,SP64], isCall = 1 |
Dan Gohman | fb3e059 | 2015-11-25 19:36:19 +0000 | [diff] [blame^] | 47 | |
| 48 | } // Defs = [ARGUMENTS] |