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