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