14#ifndef CLANG_LIB_CIR_CODEGEN_CIRGENCLEANUP_H
15#define CLANG_LIB_CIR_CODEGEN_CIRGENCLEANUP_H
20#include "mlir/IR/Value.h"
37 class CommonBitFields {
41 enum { NumCommonBits = 3 };
51 unsigned isNormalCleanup : 1;
54 unsigned isEHCleanup : 1;
57 unsigned isActive : 1;
60 unsigned isLifetimeMarker : 1;
63 unsigned testFlagInNormalCleanup : 1;
66 unsigned testFlagInEHCleanup : 1;
70 unsigned cleanupSize : 12;
82 : enclosingEHScope(enclosingEHScope) {
98 return enclosingEHScope;
110 mlir::Block *normalBlock =
nullptr;
117 cir::CleanupScopeOp cleanupScopeOp;
131 cir::CleanupScopeOp cleanupScopeOp,
135 enclosingNormal(enclosingNormal), cleanupScopeOp(cleanupScopeOp) {
144 assert(
cleanupBits.cleanupSize == cleanupSize &&
"cleanup size overflow");
182 return enclosingNormal;
206 explicit iterator(
char *ptr) : ptr(ptr) {}
220 llvm_unreachable(
"EHScopeStack::iterator Filter");
228 llvm_unreachable(
"EHScopeStack::iterator Terminate");
235 bool operator==(iterator other)
const {
return ptr == other.ptr; }
236 bool operator!=(iterator other)
const {
return ptr != other.ptr; }
249 assert(savePoint.
isValid() &&
"finding invalid savepoint");
251 "finding savepoint after pop");
252 return iterator(endOfBuffer - savePoint.size);
static Decl::Kind getKind(const Decl *D)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
This class organizes the cross-function state that is used while generating CIR code.
A cleanup scope which generates the cleanup blocks lazily.
size_t getAllocatedSize() const
mlir::Block * getNormalBlock() const
EHScopeStack::Cleanup * getCleanup()
EHCleanupScope(bool isNormal, bool isEH, unsigned cleanupSize, cir::CleanupScopeOp cleanupScopeOp, EHScopeStack::stable_iterator enclosingNormal, EHScopeStack::stable_iterator enclosingEH)
void setTestFlagInEHCleanup(bool value)
void setTestFlagInNormalCleanup(bool value)
Address getActiveFlag() const
bool isLifetimeMarker() const
size_t getCleanupSize() const
cir::CleanupScopeOp getCleanupScopeOp()
bool shouldTestFlagInEHCleanup() const
static bool classof(const EHScope *scope)
static size_t getSizeForCleanupSize(size_t size)
Gets the size required for a lazy cleanup scope with the given cleanup-data requirements.
bool isNormalCleanup() const
bool hasActiveFlag() const
void setActiveFlag(Address var)
EHScopeStack::stable_iterator getEnclosingNormalCleanup() const
void * getCleanupBuffer()
bool shouldTestFlagInNormalCleanup() const
void setNormalBlock(mlir::Block *bb)
void setActive(bool isActive)
Information for lazily generating a cleanup.
A non-stable pointer into the scope stack.
friend class EHScopeStack
bool operator!=(iterator other) const
EHScope & operator*() const
EHScope * operator->() const
bool operator==(iterator other) const
A saved depth on the scope stack.
iterator find(stable_iterator savePoint) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
iterator end() const
Returns an iterator pointing to the outermost EH scope.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
friend class EHCleanupScope
A protected scope for zero-cost EH handling.
CleanupBitFields cleanupBits
void setMayThrow(bool mayThrow)
EHScopeStack::stable_iterator getEnclosingEHScope() const
CommonBitFields commonBits
EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope)
Represents a function declaration or definition.
const EHPersonality & getEHPersonality(CIRGenModule &cgm, const clang::FunctionDecl *fd)
Selects the personality function to use for fd, or for the translation unit as a whole when fd is nul...
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
The exceptions personality for a function.