1//===-- DwarfException.h - Dwarf Exception Framework -----------*- 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 dwarf exception info into asm files.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
15
16#include "EHStreamer.h"
17#include "llvm/CodeGen/AsmPrinter.h"
18#include "llvm/MC/MCDwarf.h"
19
20namespace llvm {
21class MachineFunction;
22class ARMTargetStreamer;
23
24class LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer {
25protected:
26  DwarfCFIExceptionBase(AsmPrinter *A);
27
28  /// Per-function flag to indicate if frame CFI info should be emitted.
29  bool shouldEmitCFI;
30  /// Per-module flag to indicate if .cfi_section has beeen emitted.
31  bool hasEmittedCFISections;
32
33  void markFunctionEnd() override;
34  void endFragment() override;
35};
36
37class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase {
38  /// Per-function flag to indicate if .cfi_personality should be emitted.
39  bool shouldEmitPersonality;
40
41  /// Per-function flag to indicate if .cfi_personality must be emitted.
42  bool forceEmitPersonality;
43
44  /// Per-function flag to indicate if .cfi_lsda should be emitted.
45  bool shouldEmitLSDA;
46
47  /// Per-function flag to indicate if frame moves info should be emitted.
48  bool shouldEmitMoves;
49
50public:
51  //===--------------------------------------------------------------------===//
52  // Main entry points.
53  //
54  DwarfCFIException(AsmPrinter *A);
55  ~DwarfCFIException() override;
56
57  /// Emit all exception information that should come after the content.
58  void endModule() override;
59
60  /// Gather pre-function exception information.  Assumes being emitted
61  /// immediately after the function entry point.
62  void beginFunction(const MachineFunction *MF) override;
63
64  /// Gather and emit post-function exception information.
65  void endFunction(const MachineFunction *) override;
66
67  void beginFragment(const MachineBasicBlock *MBB,
68                     ExceptionSymbolProvider ESP) override;
69};
70
71class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase {
72  void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override;
73  ARMTargetStreamer &getTargetStreamer();
74
75public:
76  //===--------------------------------------------------------------------===//
77  // Main entry points.
78  //
79  ARMException(AsmPrinter *A);
80  ~ARMException() override;
81
82  /// Emit all exception information that should come after the content.
83  void endModule() override {}
84
85  /// Gather pre-function exception information.  Assumes being emitted
86  /// immediately after the function entry point.
87  void beginFunction(const MachineFunction *MF) override;
88
89  /// Gather and emit post-function exception information.
90  void endFunction(const MachineFunction *) override;
91};
92} // End of namespace llvm
93
94#endif
95