LLVM  9.0.0svn
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"
19 #include "llvm/IR/BasicBlock.h"
20 
21 namespace llvm {
22 
23 enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
24 
26 
28  // When there is an entry <A, B>, if an exception is not caught by A, it
29  // should next unwind to the EH pad B.
31 
32  // Helper functions
33  const BasicBlock *getEHPadUnwindDest(const BasicBlock *BB) const {
34  return EHPadUnwindMap.lookup(BB).get<const BasicBlock *>();
35  }
36  void setEHPadUnwindDest(const BasicBlock *BB, const BasicBlock *Dest) {
37  EHPadUnwindMap[BB] = Dest;
38  }
39  bool hasEHPadUnwindDest(const BasicBlock *BB) const {
40  return EHPadUnwindMap.count(BB);
41  }
42 
44  return EHPadUnwindMap.lookup(MBB).get<MachineBasicBlock *>();
45  }
47  EHPadUnwindMap[MBB] = Dest;
48  }
50  return EHPadUnwindMap.count(MBB);
51  }
52 };
53 
54 // Analyze the IR in the given function to build WasmEHFuncInfo.
55 void calculateWasmEHInfo(const Function *F, WasmEHFuncInfo &EHInfo);
56 
57 } // namespace llvm
58 
59 #endif // LLVM_CODEGEN_WASMEHFUNCINFO_H
bool hasEHPadUnwindDest(const BasicBlock *BB) const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
F(f)
void setEHPadUnwindDest(MachineBasicBlock *MBB, MachineBasicBlock *Dest)
DenseMap< BBOrMBB, BBOrMBB > EHPadUnwindMap
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
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:171
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:211
MachineBasicBlock * getEHPadUnwindDest(MachineBasicBlock *MBB) const
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
Definition: PointerUnion.h:86