1 //===-- DwarfException.h - Dwarf Exception Framework -----------*- C++ -*--===//
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
7 //===----------------------------------------------------------------------===//
9 // This file contains support for writing dwarf exception info into asm files.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
16 #include "EHStreamer.h"
17 #include "llvm/CodeGen/AsmPrinter.h"
18 #include "llvm/MC/MCDwarf.h"
21 class MachineFunction
;
22 class ARMTargetStreamer
;
24 class LLVM_LIBRARY_VISIBILITY DwarfCFIException
: public EHStreamer
{
25 /// Per-function flag to indicate if .cfi_personality should be emitted.
26 bool shouldEmitPersonality
= false;
28 /// Per-function flag to indicate if .cfi_personality must be emitted.
29 bool forceEmitPersonality
= false;
31 /// Per-function flag to indicate if .cfi_lsda should be emitted.
32 bool shouldEmitLSDA
= false;
34 /// Per-function flag to indicate if frame CFI info should be emitted.
35 bool shouldEmitCFI
= false;
37 /// Per-module flag to indicate if .cfi_section has beeen emitted.
38 bool hasEmittedCFISections
= false;
40 /// Vector of all personality functions seen so far in the module.
41 std::vector
<const GlobalValue
*> Personalities
;
43 void addPersonality(const GlobalValue
*Personality
);
46 //===--------------------------------------------------------------------===//
49 DwarfCFIException(AsmPrinter
*A
);
50 ~DwarfCFIException() override
;
52 /// Emit all exception information that should come after the content.
53 void endModule() override
;
55 /// Gather pre-function exception information. Assumes being emitted
56 /// immediately after the function entry point.
57 void beginFunction(const MachineFunction
*MF
) override
;
59 /// Gather and emit post-function exception information.
60 void endFunction(const MachineFunction
*) override
;
62 void beginBasicBlockSection(const MachineBasicBlock
&MBB
) override
;
63 void endBasicBlockSection(const MachineBasicBlock
&MBB
) override
;
66 class LLVM_LIBRARY_VISIBILITY ARMException
: public EHStreamer
{
67 /// Per-function flag to indicate if frame CFI info should be emitted.
68 bool shouldEmitCFI
= false;
70 /// Per-module flag to indicate if .cfi_section has beeen emitted.
71 bool hasEmittedCFISections
= false;
73 void emitTypeInfos(unsigned TTypeEncoding
, MCSymbol
*TTBaseLabel
) override
;
74 ARMTargetStreamer
&getTargetStreamer();
77 //===--------------------------------------------------------------------===//
80 ARMException(AsmPrinter
*A
);
81 ~ARMException() override
;
83 /// Emit all exception information that should come after the content.
84 void endModule() override
{}
86 /// Gather pre-function exception information. Assumes being emitted
87 /// immediately after the function entry point.
88 void beginFunction(const MachineFunction
*MF
) override
;
90 /// Gather and emit post-function exception information.
91 void endFunction(const MachineFunction
*) override
;
93 void markFunctionEnd() override
;
96 class LLVM_LIBRARY_VISIBILITY AIXException
: public EHStreamer
{
97 /// This is AIX's compat unwind section, which unwinder would use
98 /// to find the location of LSDA area and personality rountine.
99 void emitExceptionInfoTable(const MCSymbol
*LSDA
, const MCSymbol
*PerSym
);
102 AIXException(AsmPrinter
*A
);
104 void endModule() override
{}
105 void beginFunction(const MachineFunction
*MF
) override
{}
106 void endFunction(const MachineFunction
*MF
) override
;
108 } // End of namespace llvm