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 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 26 | bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI); |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 27 | bool mayThrow(const MachineInstr &MI); |
| 28 | |
Heejin Ahn | 817811ca | 2018-06-19 00:32:03 +0000 | [diff] [blame] | 29 | // Exception-related function names |
| 30 | extern const char *const ClangCallTerminateFn; |
| 31 | extern const char *const CxaBeginCatchFn; |
| 32 | extern const char *const CxaRethrowFn; |
| 33 | extern const char *const StdTerminateFn; |
| 34 | extern const char *const PersonalityWrapperFn; |
| 35 | |
| 36 | /// Return the "bottom" block of an entity, which can be either a MachineLoop or |
| 37 | /// WebAssemblyException. This differs from MachineLoop::getBottomBlock in that |
| 38 | /// it works even if the entity is discontiguous. |
| 39 | template <typename T> MachineBasicBlock *getBottom(const T *Unit) { |
| 40 | MachineBasicBlock *Bottom = Unit->getHeader(); |
| 41 | for (MachineBasicBlock *MBB : Unit->blocks()) |
| 42 | if (MBB->getNumber() > Bottom->getNumber()) |
| 43 | Bottom = MBB; |
| 44 | return Bottom; |
| 45 | } |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 46 | |
| 47 | } // end namespace WebAssembly |
Dan Gohman | f52ee17 | 2017-02-27 22:38:58 +0000 | [diff] [blame] | 48 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 49 | } // end namespace llvm |
| 50 | |
| 51 | #endif |