Path: blob/main/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/WinException.h
35271 views
//===-- WinException.h - Windows Exception Handling ----------*- C++ -*--===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file contains support for writing windows exception info into asm files.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WIN64EXCEPTION_H13#define LLVM_LIB_CODEGEN_ASMPRINTER_WIN64EXCEPTION_H1415#include "EHStreamer.h"16#include <vector>1718namespace llvm {19class GlobalValue;20class MachineFunction;21class MCExpr;22class MCSection;23struct WinEHFuncInfo;2425class LLVM_LIBRARY_VISIBILITY WinException : public EHStreamer {26/// Per-function flag to indicate if personality info should be emitted.27bool shouldEmitPersonality = false;2829/// Per-function flag to indicate if the LSDA should be emitted.30bool shouldEmitLSDA = false;3132/// Per-function flag to indicate if frame moves info should be emitted.33bool shouldEmitMoves = false;3435/// True if this is a 64-bit target and we should use image relative offsets.36bool useImageRel32 = false;3738/// True if we are generating exception handling on Windows for ARM64.39bool isAArch64 = false;4041/// True if we are generating exception handling on Windows for ARM (Thumb).42bool isThumb = false;4344/// Pointer to the current funclet entry BB.45const MachineBasicBlock *CurrentFuncletEntry = nullptr;4647/// The section of the last funclet start.48MCSection *CurrentFuncletTextSection = nullptr;4950/// The list of symbols to add to the ehcont section51std::vector<const MCSymbol *> EHContTargets;5253void emitCSpecificHandlerTable(const MachineFunction *MF);5455void emitSEHActionsForRange(const WinEHFuncInfo &FuncInfo,56const MCSymbol *BeginLabel,57const MCSymbol *EndLabel, int State);5859/// Emit the EH table data for 32-bit and 64-bit functions using60/// the __CxxFrameHandler3 personality.61void emitCXXFrameHandler3Table(const MachineFunction *MF);6263/// Emit the EH table data for _except_handler3 and _except_handler464/// personality functions. These are only used on 32-bit and do not use CFI65/// tables.66void emitExceptHandlerTable(const MachineFunction *MF);6768void emitCLRExceptionTable(const MachineFunction *MF);6970void computeIP2StateTable(71const MachineFunction *MF, const WinEHFuncInfo &FuncInfo,72SmallVectorImpl<std::pair<const MCExpr *, int>> &IPToStateTable);7374/// Emits the label used with llvm.eh.recoverfp, which is used by75/// outlined funclets.76void emitEHRegistrationOffsetLabel(const WinEHFuncInfo &FuncInfo,77StringRef FLinkageName);7879const MCExpr *create32bitRef(const MCSymbol *Value);80const MCExpr *create32bitRef(const GlobalValue *GV);81const MCExpr *getLabel(const MCSymbol *Label);82const MCExpr *getLabelPlusOne(const MCSymbol *Label);83const MCExpr *getOffset(const MCSymbol *OffsetOf, const MCSymbol *OffsetFrom);84const MCExpr *getOffsetPlusOne(const MCSymbol *OffsetOf,85const MCSymbol *OffsetFrom);8687/// Gets the offset that we should use in a table for a stack object with the88/// given index. For targets using CFI (Win64, etc), this is relative to the89/// established SP at the end of the prologue. For targets without CFI (Win3290/// only), it is relative to the frame pointer.91int getFrameIndexOffset(int FrameIndex, const WinEHFuncInfo &FuncInfo);9293void endFuncletImpl();94public:95//===--------------------------------------------------------------------===//96// Main entry points.97//98WinException(AsmPrinter *A);99~WinException() override;100101/// Emit all exception information that should come after the content.102void endModule() override;103104/// Gather pre-function exception information. Assumes being emitted105/// immediately after the function entry point.106void beginFunction(const MachineFunction *MF) override;107108void markFunctionEnd() override;109110/// Gather and emit post-function exception information.111void endFunction(const MachineFunction *) override;112113/// Emit target-specific EH funclet machinery.114void beginFunclet(const MachineBasicBlock &MBB, MCSymbol *Sym) override;115void endFunclet() override;116};117}118119#endif120121122123