[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / CodeGen / AsmPrinter / WinException.h
blob638589adf0ddcbadee899b3700a06dde07915492
1 //===-- WinException.h - Windows Exception Handling ----------*- 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 // This file contains support for writing windows exception info into asm files.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WIN64EXCEPTION_H
14 #define LLVM_LIB_CODEGEN_ASMPRINTER_WIN64EXCEPTION_H
16 #include "EHStreamer.h"
17 #include <vector>
19 namespace llvm {
20 class GlobalValue;
21 class MachineFunction;
22 class MCExpr;
23 class MCSection;
24 struct WinEHFuncInfo;
26 class LLVM_LIBRARY_VISIBILITY WinException : public EHStreamer {
27 /// Per-function flag to indicate if personality info should be emitted.
28 bool shouldEmitPersonality = false;
30 /// Per-function flag to indicate if the LSDA should be emitted.
31 bool shouldEmitLSDA = false;
33 /// Per-function flag to indicate if frame moves info should be emitted.
34 bool shouldEmitMoves = false;
36 /// True if this is a 64-bit target and we should use image relative offsets.
37 bool useImageRel32 = false;
39 /// True if we are generating exception handling on Windows for ARM64.
40 bool isAArch64 = false;
42 /// True if we are generating exception handling on Windows for ARM (Thumb).
43 bool isThumb = false;
45 /// Pointer to the current funclet entry BB.
46 const MachineBasicBlock *CurrentFuncletEntry = nullptr;
48 /// The section of the last funclet start.
49 MCSection *CurrentFuncletTextSection = nullptr;
51 /// The list of symbols to add to the ehcont section
52 std::vector<const MCSymbol *> EHContTargets;
54 void emitCSpecificHandlerTable(const MachineFunction *MF);
56 void emitSEHActionsForRange(const WinEHFuncInfo &FuncInfo,
57 const MCSymbol *BeginLabel,
58 const MCSymbol *EndLabel, int State);
60 /// Emit the EH table data for 32-bit and 64-bit functions using
61 /// the __CxxFrameHandler3 personality.
62 void emitCXXFrameHandler3Table(const MachineFunction *MF);
64 /// Emit the EH table data for _except_handler3 and _except_handler4
65 /// personality functions. These are only used on 32-bit and do not use CFI
66 /// tables.
67 void emitExceptHandlerTable(const MachineFunction *MF);
69 void emitCLRExceptionTable(const MachineFunction *MF);
71 void computeIP2StateTable(
72 const MachineFunction *MF, const WinEHFuncInfo &FuncInfo,
73 SmallVectorImpl<std::pair<const MCExpr *, int>> &IPToStateTable);
75 /// Emits the label used with llvm.eh.recoverfp, which is used by
76 /// outlined funclets.
77 void emitEHRegistrationOffsetLabel(const WinEHFuncInfo &FuncInfo,
78 StringRef FLinkageName);
80 const MCExpr *create32bitRef(const MCSymbol *Value);
81 const MCExpr *create32bitRef(const GlobalValue *GV);
82 const MCExpr *getLabel(const MCSymbol *Label);
83 const MCExpr *getLabelPlusOne(const MCSymbol *Label);
84 const MCExpr *getOffset(const MCSymbol *OffsetOf, const MCSymbol *OffsetFrom);
85 const MCExpr *getOffsetPlusOne(const MCSymbol *OffsetOf,
86 const MCSymbol *OffsetFrom);
88 /// Gets the offset that we should use in a table for a stack object with the
89 /// given index. For targets using CFI (Win64, etc), this is relative to the
90 /// established SP at the end of the prologue. For targets without CFI (Win32
91 /// only), it is relative to the frame pointer.
92 int getFrameIndexOffset(int FrameIndex, const WinEHFuncInfo &FuncInfo);
94 void endFuncletImpl();
95 public:
96 //===--------------------------------------------------------------------===//
97 // Main entry points.
99 WinException(AsmPrinter *A);
100 ~WinException() override;
102 /// Emit all exception information that should come after the content.
103 void endModule() override;
105 /// Gather pre-function exception information. Assumes being emitted
106 /// immediately after the function entry point.
107 void beginFunction(const MachineFunction *MF) override;
109 void markFunctionEnd() override;
111 /// Gather and emit post-function exception information.
112 void endFunction(const MachineFunction *) override;
114 /// Emit target-specific EH funclet machinery.
115 void beginFunclet(const MachineBasicBlock &MBB, MCSymbol *Sym) override;
116 void endFunclet() override;
120 #endif