LLVM 19.0.0git
WebAssemblyUtilities.h
Go to the documentation of this file.
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
19
20namespace llvm {
21
22class MachineBasicBlock;
23class MachineInstr;
24class MachineOperand;
25class MCContext;
26class MCSymbolWasm;
27class TargetRegisterClass;
28class WebAssemblyFunctionInfo;
29class WebAssemblySubtarget;
30
31namespace WebAssembly {
32
33bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
34bool mayThrow(const MachineInstr &MI);
35
36// Exception-related function names
37extern const char *const ClangCallTerminateFn;
38extern const char *const CxaBeginCatchFn;
39extern const char *const CxaRethrowFn;
40extern const char *const StdTerminateFn;
41extern const char *const PersonalityWrapperFn;
42
43/// Returns the operand number of a callee, assuming the argument is a call
44/// instruction.
45const MachineOperand &getCalleeOp(const MachineInstr &MI);
46
47/// Returns the __indirect_function_table, for use in call_indirect and in
48/// function bitcasts.
49MCSymbolWasm *
51 const WebAssemblySubtarget *Subtarget);
52
53/// Returns the __funcref_call_table, for use in funcref calls when lowered to
54/// table.set + call_indirect.
55MCSymbolWasm *
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.
61MachineInstr *findCatch(MachineBasicBlock *EHPad);
62
63/// Returns the appropriate copy opcode for the given register class.
64unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC);
65
66} // end namespace WebAssembly
67
68} // end namespace llvm
69
70#endif
IRTranslator LLVM IR MI
const char *const StdTerminateFn
const char *const CxaBeginCatchFn
bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI)
Test whether MI is a child of some other node in an expression tree.
const char *const CxaRethrowFn
MCSymbolWasm * getOrCreateFunctionTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)
Returns the __indirect_function_table, for use in call_indirect and in function bitcasts.
unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC)
Returns the appropriate copy opcode for the given register class.
const MachineOperand & getCalleeOp(const MachineInstr &MI)
Returns the operand number of a callee, assuming the argument is a call instruction.
MachineInstr * findCatch(MachineBasicBlock *EHPad)
Find a catch instruction from an EH pad.
MCSymbolWasm * getOrCreateFuncrefCallTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)
Returns the __funcref_call_table, for use in funcref calls when lowered to table.set + call_indirect.
const char *const PersonalityWrapperFn
const char *const ClangCallTerminateFn
bool mayThrow(const MachineInstr &MI)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18