LLVM 17.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 handling / setjmp-longjmp handling command-line options
37extern cl::opt<bool> WasmEnableEmEH; // asm.js-style EH
38extern cl::opt<bool> WasmEnableEmSjLj; // asm.js-style SjLJ
39extern cl::opt<bool> WasmEnableEH; // EH using Wasm EH instructions
40extern cl::opt<bool> WasmEnableSjLj; // SjLj using Wasm EH instructions
41
42// Exception-related function names
43extern const char *const ClangCallTerminateFn;
44extern const char *const CxaBeginCatchFn;
45extern const char *const CxaRethrowFn;
46extern const char *const StdTerminateFn;
47extern const char *const PersonalityWrapperFn;
48
49/// Returns the operand number of a callee, assuming the argument is a call
50/// instruction.
51const MachineOperand &getCalleeOp(const MachineInstr &MI);
52
53/// Returns the __indirect_function_table, for use in call_indirect and in
54/// function bitcasts.
55MCSymbolWasm *
57 const WebAssemblySubtarget *Subtarget);
58
59/// Returns the __funcref_call_table, for use in funcref calls when lowered to
60/// table.set + call_indirect.
61MCSymbolWasm *
63 const WebAssemblySubtarget *Subtarget);
64
65/// Find a catch instruction from an EH pad. Returns null if no catch
66/// instruction found or the catch is in an invalid location.
67MachineInstr *findCatch(MachineBasicBlock *EHPad);
68
69/// Returns the appropriate copy opcode for the given register class.
70unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC);
71
72} // end namespace WebAssembly
73
74} // end namespace llvm
75
76#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.
cl::opt< bool > WasmEnableEH
cl::opt< bool > WasmEnableSjLj
const char *const PersonalityWrapperFn
const char *const ClangCallTerminateFn
cl::opt< bool > WasmEnableEmEH
cl::opt< bool > WasmEnableEmSjLj
bool mayThrow(const MachineInstr &MI)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18