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 | #include "llvm/Support/CommandLine.h" |
19 | |
20 | namespace llvm { |
21 | |
22 | class MachineBasicBlock; |
23 | class MachineInstr; |
24 | class MachineOperand; |
25 | class MCContext; |
26 | class MCSymbolWasm; |
27 | class TargetRegisterClass; |
28 | class WebAssemblyFunctionInfo; |
29 | class WebAssemblySubtarget; |
30 | |
31 | namespace WebAssembly { |
32 | |
33 | bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI); |
34 | bool mayThrow(const MachineInstr &MI); |
35 | |
36 | // Exception-related function names |
37 | extern const char *const ClangCallTerminateFn; |
38 | extern const char *const CxaBeginCatchFn; |
39 | extern const char *const CxaRethrowFn; |
40 | extern const char *const StdTerminateFn; |
41 | extern const char *const PersonalityWrapperFn; |
42 | |
43 | /// Returns the operand number of a callee, assuming the argument is a call |
44 | /// instruction. |
45 | const MachineOperand &getCalleeOp(const MachineInstr &MI); |
46 | |
47 | /// Returns the __indirect_function_table, for use in call_indirect and in |
48 | /// function bitcasts. |
49 | MCSymbolWasm * |
50 | getOrCreateFunctionTableSymbol(MCContext &Ctx, |
51 | const WebAssemblySubtarget *Subtarget); |
52 | |
53 | /// Returns the __funcref_call_table, for use in funcref calls when lowered to |
54 | /// table.set + call_indirect. |
55 | MCSymbolWasm * |
56 | getOrCreateFuncrefCallTableSymbol(MCContext &Ctx, |
57 | const WebAssemblySubtarget *Subtarget); |
58 | |
59 | /// Find a catch instruction from an EH pad. Returns null if no catch |
60 | /// instruction found or the catch is in an invalid location. |
61 | MachineInstr *findCatch(MachineBasicBlock *EHPad); |
62 | |
63 | /// Returns the appropriate copy opcode for the given register class. |
64 | unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC); |
65 | |
66 | /// Returns true if multivalue returns of a function can be lowered directly, |
67 | /// i.e., not indirectly via a pointer parameter that points to the value in |
68 | /// memory. |
69 | bool canLowerMultivalueReturn(const WebAssemblySubtarget *Subtarget); |
70 | |
71 | /// Returns true if the function's return value(s) can be lowered directly, |
72 | /// i.e., not indirectly via a pointer parameter that points to the value in |
73 | /// memory. |
74 | bool canLowerReturn(size_t ResultSize, const WebAssemblySubtarget *Subtarget); |
75 | |
76 | } // end namespace WebAssembly |
77 | |
78 | } // end namespace llvm |
79 | |
80 | #endif |
81 | |