LLVM  12.0.0git
WasmEHFuncInfo.h
Go to the documentation of this file.
1 //===--- llvm/CodeGen/WasmEHFuncInfo.h --------------------------*- 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 // Data structures for Wasm exception handling schemes.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_WASMEHFUNCINFO_H
14 #define LLVM_CODEGEN_WASMEHFUNCINFO_H
15 
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/PointerUnion.h"
18 
19 namespace llvm {
20 
21 class BasicBlock;
22 class Function;
23 class MachineBasicBlock;
24 
25 enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
26 
28 
30  // When there is an entry <A, B>, if an exception is not caught by A, it
31  // should next unwind to the EH pad B.
33 
34  // Helper functions
35  const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const {
36  return EHPadUnwindMap.lookup(BB).get<const BasicBlock *>();
37  }
38  void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
39  EHPadUnwindMap[BB] = Dest;
40  }
41  bool hasEHPadUnwindDest(const BasicBlock *BB) const {
42  return EHPadUnwindMap.count(BB);
43  }
44 
46  return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
47  }
49  EHPadUnwindMap[MBB] = Dest;
50  }
52  return EHPadUnwindMap.count(MBB);
53  }
54 };
55 
56 // Analyze the IR in the given function to build WasmEHFuncInfo.
57 void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo);
58 
59 } // namespace llvm
60 
61 #endif // LLVM_CODEGEN_WASMEHFUNCINFO_H
bool hasEHPadUnwindDest(const BasicBlock *BB) const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Various leaf nodes.
Definition: ISDOpcodes.h:64
F(f)
MachineBasicBlock & MBB
void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest)
DenseMap< BBOrMBB, BBOrMBB > EHPadUnwindMap
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest)
const BasicBlock * getEHPadUnwindDest(const BasicBlock *BB) const
bool hasEHPadUnwindDest(MachineBasicBlock *MBB) const
void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:145
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:197
MachineBasicBlock * getEHPadUnwindDest(MachineBasicBlock *MBB) const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:149