blob: 26cf84de89b92766bd76d83f72e0d9b8ea57d17d [file] [log] [blame]
Dan Gohman4fc4e422016-10-24 19:49:43 +00001//===-- WebAssemblyUtilities - WebAssembly Utility Functions ---*- C++ -*-====//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Gohman4fc4e422016-10-24 19:49:43 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file contains the declaration of the WebAssembly-specific
Dan Gohman4fc4e422016-10-24 19:49:43 +000011/// utility functions.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
17
Heejin Ahn817811ca2018-06-19 00:32:03 +000018#include "llvm/CodeGen/MachineBasicBlock.h"
19
Dan Gohman4fc4e422016-10-24 19:49:43 +000020namespace llvm {
21
Dan Gohman4fc4e422016-10-24 19:49:43 +000022class WebAssemblyFunctionInfo;
23
24namespace WebAssembly {
25
Dan Gohman4fc4e422016-10-24 19:49:43 +000026bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
Heejin Ahn817811ca2018-06-19 00:32:03 +000027bool mayThrow(const MachineInstr &MI);
28
Heejin Ahn817811ca2018-06-19 00:32:03 +000029// Exception-related function names
30extern const char *const ClangCallTerminateFn;
31extern const char *const CxaBeginCatchFn;
32extern const char *const CxaRethrowFn;
33extern const char *const StdTerminateFn;
34extern 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.
39template <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 Gohman4fc4e422016-10-24 19:49:43 +000046
47} // end namespace WebAssembly
Dan Gohmanf52ee172017-02-27 22:38:58 +000048
Dan Gohman4fc4e422016-10-24 19:49:43 +000049} // end namespace llvm
50
51#endif