LLVM 23.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
20
21namespace llvm {
22
24class MachineInstr;
25class MachineOperand;
26class MCContext;
27class MCSymbolWasm;
31class MachineSDNode;
32class SDLoc;
33class SelectionDAG;
34
35namespace WebAssembly {
36
37bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
38bool mayThrow(const MachineInstr &MI);
39
40// Exception-related function names
41extern const char *const ClangCallTerminateFn;
42extern const char *const CxaBeginCatchFn;
43extern const char *const CxaRethrowFn;
44extern const char *const StdTerminateFn;
45extern const char *const PersonalityWrapperFn;
46
47/// Returns the operand number of a callee, assuming the argument is a call
48/// instruction.
49const MachineOperand &getCalleeOp(const MachineInstr &MI);
50
51/// Returns the __indirect_function_table, for use in call_indirect and in
52/// function bitcasts.
53MCSymbolWasm *
55 const WebAssemblySubtarget *Subtarget);
56
57/// Returns the __funcref_call_table, for use in funcref calls when lowered to
58/// table.set + call_indirect.
59MCSymbolWasm *
61 const WebAssemblySubtarget *Subtarget);
62
63/// Find a catch instruction from an EH pad. Returns null if no catch
64/// instruction found or the catch is in an invalid location.
65MachineInstr *findCatch(MachineBasicBlock *EHPad);
66
67/// Returns the appropriate copy opcode for the given register class.
68unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC);
69
70/// Returns true if multivalue returns of a function can be lowered directly,
71/// i.e., not indirectly via a pointer parameter that points to the value in
72/// memory.
73bool canLowerMultivalueReturn(const WebAssemblySubtarget *Subtarget);
74
75/// Returns true if the function's return value(s) can be lowered directly,
76/// i.e., not indirectly via a pointer parameter that points to the value in
77/// memory.
78bool canLowerReturn(size_t ResultSize, const WebAssemblySubtarget *Subtarget);
79
80// Get the TLS base value for the current target
81// If using libcall thread context, calls
82// __wasm_get_tls_base, otherwise, global.get __tls_base
83MachineSDNode *getTLSBase(SelectionDAG &DAG, const SDLoc &DL,
84 const WebAssemblySubtarget *Subtarget,
85 const SDValue Chain = SDValue());
86
87} // end namespace WebAssembly
88
89} // end namespace llvm
90
91#endif
return SDValue()
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
IRTranslator LLVM IR MI
Context object for machine code objects.
Definition MCContext.h:83
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
An SDNode that represents everything that will be needed to construct a MachineInstr.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
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.
bool canLowerMultivalueReturn(const WebAssemblySubtarget *Subtarget)
Returns true if multivalue returns of a function can be lowered directly, i.e., not indirectly via a ...
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
bool canLowerReturn(size_t ResultSize, const WebAssemblySubtarget *Subtarget)
Returns true if the function's return value(s) can be lowered directly, i.e., not indirectly via a po...
const char *const ClangCallTerminateFn
bool mayThrow(const MachineInstr &MI)
MachineSDNode * getTLSBase(SelectionDAG &DAG, const SDLoc &DL, const WebAssemblySubtarget *Subtarget, const SDValue Chain=SDValue())
This is an optimization pass for GlobalISel generic memory operations.