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 15*e2a7a827SDan Gohman// TODO: addr64: These currently assume the callee address is 32-bit. 16*e2a7a827SDan Gohman 17fb3e0594SDan Gohmanlet Defs = [ARGUMENTS] in { 18fb3e0594SDan Gohman 19905bef5cSDan Gohman// Call sequence markers. These have an immediate which represents the amount of 20905bef5cSDan Gohman// stack space to allocate or free, which is used for varargs lowering. 21af111db8SJF Bastienlet isCodeGenOnly = 1 in { 22*e2a7a827SDan Gohmandef ADJCALLSTACKDOWN : I<(outs), (ins i32imm:$amt), 23af111db8SJF Bastien [(WebAssemblycallseq_start timm:$amt)]>; 24*e2a7a827SDan Gohmandef ADJCALLSTACKUP : I<(outs), (ins i32imm:$amt), 2535bfb24cSDan Gohman [(WebAssemblycallseq_end timm:$amt, undef)]>; 26af111db8SJF Bastien} // isCodeGenOnly = 1 27af111db8SJF Bastien 28af111db8SJF Bastienmulticlass CALL<WebAssemblyRegClass vt> { 29*e2a7a827SDan Gohman def CALL_#vt : I<(outs vt:$dst), (ins i32imm:$callee, variable_ops), 30*e2a7a827SDan Gohman [(set vt:$dst, (WebAssemblycall1 (i32 imm:$callee)))], 312f16f253SDan Gohman "call \t$dst, $callee">; 3205a17aa8SDan Gohman def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops), 33cf4748f1SDan Gohman [(set vt:$dst, (WebAssemblycall1 I32:$callee))], 342f16f253SDan Gohman "call_indirect\t$dst, $callee">; 35af111db8SJF Bastien} 36af111db8SJF Bastienlet Uses = [SP32, SP64], isCall = 1 in { 37d0bf9812SDan Gohman defm : CALL<I32>; 38d0bf9812SDan Gohman defm : CALL<I64>; 39d0bf9812SDan Gohman defm : CALL<F32>; 40d0bf9812SDan Gohman defm : CALL<F64>; 41f71abef7SDan Gohman 42*e2a7a827SDan Gohman def CALL_VOID : I<(outs), (ins i32imm:$callee, variable_ops), 43*e2a7a827SDan Gohman [(WebAssemblycall0 (i32 imm:$callee))], 441031d4a8SDan Gohman "call \t$callee">; 4505a17aa8SDan Gohman def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops), 46cf4748f1SDan Gohman [(WebAssemblycall0 I32:$callee)], 471031d4a8SDan Gohman "call_indirect\t$callee">; 48af111db8SJF Bastien} // Uses = [SP32,SP64], isCall = 1 49fb3e0594SDan Gohman 50fb3e0594SDan Gohman} // Defs = [ARGUMENTS] 51*e2a7a827SDan Gohman 52*e2a7a827SDan Gohman// Patterns for matching a direct call to a global address. 53*e2a7a827SDan Gohmandef : Pat<(i32 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), 54*e2a7a827SDan Gohman (CALL_I32 tglobaladdr:$callee)>; 55*e2a7a827SDan Gohmandef : Pat<(i64 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), 56*e2a7a827SDan Gohman (CALL_I64 tglobaladdr:$callee)>; 57*e2a7a827SDan Gohmandef : Pat<(f32 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), 58*e2a7a827SDan Gohman (CALL_F32 tglobaladdr:$callee)>; 59*e2a7a827SDan Gohmandef : Pat<(f64 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), 60*e2a7a827SDan Gohman (CALL_F64 tglobaladdr:$callee)>; 61*e2a7a827SDan Gohmandef : Pat<(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee)), 62*e2a7a827SDan Gohman (CALL_VOID tglobaladdr:$callee)>; 63*e2a7a827SDan Gohman 64*e2a7a827SDan Gohman// Patterns for matching a direct call to an external symbol. 65*e2a7a827SDan Gohmandef : Pat<(i32 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), 66*e2a7a827SDan Gohman (CALL_I32 texternalsym:$callee)>; 67*e2a7a827SDan Gohmandef : Pat<(i64 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), 68*e2a7a827SDan Gohman (CALL_I64 texternalsym:$callee)>; 69*e2a7a827SDan Gohmandef : Pat<(f32 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), 70*e2a7a827SDan Gohman (CALL_F32 texternalsym:$callee)>; 71*e2a7a827SDan Gohmandef : Pat<(f64 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), 72*e2a7a827SDan Gohman (CALL_F64 texternalsym:$callee)>; 73*e2a7a827SDan Gohmandef : Pat<(WebAssemblycall0 (WebAssemblywrapper texternalsym:$callee)), 74*e2a7a827SDan Gohman (CALL_VOID texternalsym:$callee)>; 75