Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 1 | //===-- WebAssemblyUtilities - WebAssembly Utility Functions ---*- C++ -*-====// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// This file contains the declaration of the WebAssembly-specific |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 11 | /// utility functions. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H |
| 16 | #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H |
| 17 | |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/MachineBasicBlock.h" |
| 19 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 20 | namespace llvm { |
| 21 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 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); |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 30 | bool isCallDirect(const MachineInstr &MI); |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 31 | bool isCallIndirect(const MachineInstr &MI); |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 32 | bool isMarker(const MachineInstr &MI); |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 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 | |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 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 | } |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 56 | |
| 57 | } // end namespace WebAssembly |
Dan Gohman | f52ee17 | 2017-02-27 22:38:58 +0000 | [diff] [blame] | 58 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 59 | } // end namespace llvm |
| 60 | |
| 61 | #endif |