LLVM  9.0.0svn
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_WEBASSEMBLYUTILITIES_H
16 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
17 
19 
20 namespace llvm {
21 
22 class WebAssemblyFunctionInfo;
23 
24 namespace WebAssembly {
25 
26 bool isArgument(const MachineInstr &MI);
27 bool isCopy(const MachineInstr &MI);
28 bool isTee(const MachineInstr &MI);
29 bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
30 bool isCallDirect(const MachineInstr &MI);
31 bool isCallIndirect(const MachineInstr &MI);
32 bool isMarker(const MachineInstr &MI);
33 bool mayThrow(const MachineInstr &MI);
34 
35 /// Returns the operand number of a callee, assuming the argument is a call
36 /// instruction.
37 unsigned getCalleeOpNo(const MachineInstr &MI);
38 
39 // Exception-related function names
40 extern const char *const ClangCallTerminateFn;
41 extern const char *const CxaBeginCatchFn;
42 extern const char *const CxaRethrowFn;
43 extern const char *const StdTerminateFn;
44 extern const char *const PersonalityWrapperFn;
45 
46 /// Return the "bottom" block of an entity, which can be either a MachineLoop or
47 /// WebAssemblyException. This differs from MachineLoop::getBottomBlock in that
48 /// it works even if the entity is discontiguous.
49 template <typename T> MachineBasicBlock *getBottom(const T *Unit) {
50  MachineBasicBlock *Bottom = Unit->getHeader();
51  for (MachineBasicBlock *MBB : Unit->blocks())
52  if (MBB->getNumber() > Bottom->getNumber())
53  Bottom = MBB;
54  return Bottom;
55 }
56 
57 } // end namespace WebAssembly
58 
59 } // end namespace llvm
60 
61 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool mayThrow(const MachineInstr &MI)
const char *const CxaBeginCatchFn
const char *const StdTerminateFn
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they&#39;re not in a MachineFuncti...
bool isCopy(const MachineInstr &MI)
bool isCallDirect(const MachineInstr &MI)
const char *const CxaRethrowFn
bool isTee(const MachineInstr &MI)
const char *const ClangCallTerminateFn
bool isArgument(const MachineInstr &MI)
const char *const PersonalityWrapperFn
unsigned getCalleeOpNo(const MachineInstr &MI)
Returns the operand number of a callee, assuming the argument is a call instruction.
bool isMarker(const MachineInstr &MI)
MachineBasicBlock * getBottom(const T *Unit)
Return the "bottom" block of an entity, which can be either a MachineLoop or WebAssemblyException.
IRTranslator LLVM IR MI
bool isCallIndirect(const MachineInstr &MI)
bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI)
Test whether MI is a child of some other node in an expression tree.