1*5f757f3fSDimitry Andric //===-- WebAssemblyUtilities - WebAssembly Utility Functions ---*- C++ -*-====// 2*5f757f3fSDimitry Andric // 3*5f757f3fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*5f757f3fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*5f757f3fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*5f757f3fSDimitry Andric // 7*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===// 8*5f757f3fSDimitry Andric /// 9*5f757f3fSDimitry Andric /// \file 10*5f757f3fSDimitry Andric /// This file contains the declaration of the WebAssembly-specific 11*5f757f3fSDimitry Andric /// utility functions. 12*5f757f3fSDimitry Andric /// 13*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===// 14*5f757f3fSDimitry Andric 15*5f757f3fSDimitry Andric #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYUTILITIES_H 16*5f757f3fSDimitry Andric #define LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYUTILITIES_H 17*5f757f3fSDimitry Andric 18*5f757f3fSDimitry Andric #include "llvm/Support/CommandLine.h" 19*5f757f3fSDimitry Andric 20*5f757f3fSDimitry Andric namespace llvm { 21*5f757f3fSDimitry Andric 22*5f757f3fSDimitry Andric class MachineBasicBlock; 23*5f757f3fSDimitry Andric class MachineInstr; 24*5f757f3fSDimitry Andric class MachineOperand; 25*5f757f3fSDimitry Andric class MCContext; 26*5f757f3fSDimitry Andric class MCSymbolWasm; 27*5f757f3fSDimitry Andric class TargetRegisterClass; 28*5f757f3fSDimitry Andric class WebAssemblyFunctionInfo; 29*5f757f3fSDimitry Andric class WebAssemblySubtarget; 30*5f757f3fSDimitry Andric 31*5f757f3fSDimitry Andric namespace WebAssembly { 32*5f757f3fSDimitry Andric 33*5f757f3fSDimitry Andric bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI); 34*5f757f3fSDimitry Andric bool mayThrow(const MachineInstr &MI); 35*5f757f3fSDimitry Andric 36*5f757f3fSDimitry Andric // Exception-related function names 37*5f757f3fSDimitry Andric extern const char *const ClangCallTerminateFn; 38*5f757f3fSDimitry Andric extern const char *const CxaBeginCatchFn; 39*5f757f3fSDimitry Andric extern const char *const CxaRethrowFn; 40*5f757f3fSDimitry Andric extern const char *const StdTerminateFn; 41*5f757f3fSDimitry Andric extern const char *const PersonalityWrapperFn; 42*5f757f3fSDimitry Andric 43*5f757f3fSDimitry Andric /// Returns the operand number of a callee, assuming the argument is a call 44*5f757f3fSDimitry Andric /// instruction. 45*5f757f3fSDimitry Andric const MachineOperand &getCalleeOp(const MachineInstr &MI); 46*5f757f3fSDimitry Andric 47*5f757f3fSDimitry Andric /// Returns the __indirect_function_table, for use in call_indirect and in 48*5f757f3fSDimitry Andric /// function bitcasts. 49*5f757f3fSDimitry Andric MCSymbolWasm * 50*5f757f3fSDimitry Andric getOrCreateFunctionTableSymbol(MCContext &Ctx, 51*5f757f3fSDimitry Andric const WebAssemblySubtarget *Subtarget); 52*5f757f3fSDimitry Andric 53*5f757f3fSDimitry Andric /// Returns the __funcref_call_table, for use in funcref calls when lowered to 54*5f757f3fSDimitry Andric /// table.set + call_indirect. 55*5f757f3fSDimitry Andric MCSymbolWasm * 56*5f757f3fSDimitry Andric getOrCreateFuncrefCallTableSymbol(MCContext &Ctx, 57*5f757f3fSDimitry Andric const WebAssemblySubtarget *Subtarget); 58*5f757f3fSDimitry Andric 59*5f757f3fSDimitry Andric /// Find a catch instruction from an EH pad. Returns null if no catch 60*5f757f3fSDimitry Andric /// instruction found or the catch is in an invalid location. 61*5f757f3fSDimitry Andric MachineInstr *findCatch(MachineBasicBlock *EHPad); 62*5f757f3fSDimitry Andric 63*5f757f3fSDimitry Andric /// Returns the appropriate copy opcode for the given register class. 64*5f757f3fSDimitry Andric unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC); 65*5f757f3fSDimitry Andric 66*5f757f3fSDimitry Andric } // end namespace WebAssembly 67*5f757f3fSDimitry Andric 68*5f757f3fSDimitry Andric } // end namespace llvm 69*5f757f3fSDimitry Andric 70*5f757f3fSDimitry Andric #endif 71