LLVM  8.0.1
WebAssemblyUtilities.h
Go to the documentation of this file.
1 //===-- WebAssemblyUtilities - WebAssembly Utility Functions ---*- C++ -*-====//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file contains the declaration of the WebAssembly-specific
12 /// utility functions.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
17 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
18 
20 
21 namespace llvm {
22 
23 class WebAssemblyFunctionInfo;
24 
25 namespace WebAssembly {
26 
27 bool isArgument(const MachineInstr &MI);
28 bool isCopy(const MachineInstr &MI);
29 bool isTee(const MachineInstr &MI);
30 bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
31 bool isCallDirect(const MachineInstr &MI);
32 bool isCallIndirect(const MachineInstr &MI);
33 bool isMarker(const MachineInstr &MI);
34 bool isThrow(const MachineInstr &MI);
35 bool isRethrow(const MachineInstr &MI);
36 bool isCatch(const MachineInstr &MI);
37 bool mayThrow(const MachineInstr &MI);
38 
39 /// Returns the operand number of a callee, assuming the argument is a call
40 /// instruction.
41 unsigned getCalleeOpNo(const MachineInstr &MI);
42 
43 /// Returns if the given BB is a single BB terminate pad which starts with a
44 /// 'catch' instruction.
45 bool isCatchTerminatePad(const MachineBasicBlock &MBB);
46 /// Returns if the given BB is a single BB terminate pad which starts with a
47 /// 'catch_all' insrtruction.
48 bool isCatchAllTerminatePad(const MachineBasicBlock &MBB);
49 
50 // Exception-related function names
51 extern const char *const ClangCallTerminateFn;
52 extern const char *const CxaBeginCatchFn;
53 extern const char *const CxaRethrowFn;
54 extern const char *const StdTerminateFn;
55 extern const char *const PersonalityWrapperFn;
56 
57 /// Return the "bottom" block of an entity, which can be either a MachineLoop or
58 /// WebAssemblyException. This differs from MachineLoop::getBottomBlock in that
59 /// it works even if the entity is discontiguous.
60 template <typename T> MachineBasicBlock *getBottom(const T *Unit) {
61  MachineBasicBlock *Bottom = Unit->getHeader();
62  for (MachineBasicBlock *MBB : Unit->blocks())
63  if (MBB->getNumber() > Bottom->getNumber())
64  Bottom = MBB;
65  return Bottom;
66 }
67 
68 } // end namespace WebAssembly
69 
70 } // end namespace llvm
71 
72 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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 isThrow(const MachineInstr &MI)
bool isCopy(const MachineInstr &MI)
bool isCallDirect(const MachineInstr &MI)
struct UnitT Unit
const char *const CxaRethrowFn
bool isRethrow(const MachineInstr &MI)
bool isTee(const MachineInstr &MI)
const char *const ClangCallTerminateFn
bool isArgument(const MachineInstr &MI)
bool isCatchTerminatePad(const MachineBasicBlock &MBB)
Returns if the given BB is a single BB terminate pad which starts with a &#39;catch&#39; instruction.
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)
bool isCatch(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.
bool isCatchAllTerminatePad(const MachineBasicBlock &MBB)
Returns if the given BB is a single BB terminate pad which starts with a &#39;catch_all&#39; insrtruction...