xref: /freebsd/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.h (revision bc5304a006238115291e7568583632889dffbab9)
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_WEBASSEMBLYUTILITIES_H
16 #define LLVM_LIB_TARGET_WEBASSEMBLY_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 
28 namespace WebAssembly {
29 
30 bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
31 bool mayThrow(const MachineInstr &MI);
32 
33 // Exception-related function names
34 extern const char *const ClangCallTerminateFn;
35 extern const char *const CxaBeginCatchFn;
36 extern const char *const CxaRethrowFn;
37 extern const char *const StdTerminateFn;
38 extern const char *const PersonalityWrapperFn;
39 
40 /// Returns the operand number of a callee, assuming the argument is a call
41 /// instruction.
42 const MachineOperand &getCalleeOp(const MachineInstr &MI);
43 
44 /// Returns the operand number of a callee, assuming the argument is a call
45 /// instruction.
46 MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx,
47                                              const StringRef &Name);
48 
49 /// Find a catch instruction from an EH pad. Returns null if no catch
50 /// instruction found or the catch is in an invalid location.
51 MachineInstr *findCatch(MachineBasicBlock *EHPad);
52 
53 } // end namespace WebAssembly
54 
55 } // end namespace llvm
56 
57 #endif
58