1193323Sed//===-- DwarfException.h - Dwarf Exception Framework -----------*- C++ -*--===//
2193323Sed//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6193323Sed//
7193323Sed//===----------------------------------------------------------------------===//
8193323Sed//
9193323Sed// This file contains support for writing dwarf exception info into asm files.
10193323Sed//
11193323Sed//===----------------------------------------------------------------------===//
12193323Sed
13280031Sdim#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
14280031Sdim#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
15193323Sed
16276479Sdim#include "EHStreamer.h"
17223017Sdim#include "llvm/CodeGen/AsmPrinter.h"
18309124Sdim#include "llvm/MC/MCDwarf.h"
19193323Sed
20193323Sednamespace llvm {
21206274Srdivackyclass MachineFunction;
22261991Sdimclass ARMTargetStreamer;
23193323Sed
24288943Sdimclass LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer {
25288943Sdimprotected:
26288943Sdim  DwarfCFIExceptionBase(AsmPrinter *A);
27288943Sdim
28288943Sdim  /// Per-function flag to indicate if frame CFI info should be emitted.
29288943Sdim  bool shouldEmitCFI;
30314564Sdim  /// Per-module flag to indicate if .cfi_section has beeen emitted.
31314564Sdim  bool hasEmittedCFISections;
32288943Sdim
33288943Sdim  void markFunctionEnd() override;
34309124Sdim  void endFragment() override;
35288943Sdim};
36288943Sdim
37288943Sdimclass LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase {
38288943Sdim  /// Per-function flag to indicate if .cfi_personality should be emitted.
39221345Sdim  bool shouldEmitPersonality;
40218893Sdim
41309124Sdim  /// Per-function flag to indicate if .cfi_personality must be emitted.
42309124Sdim  bool forceEmitPersonality;
43309124Sdim
44288943Sdim  /// Per-function flag to indicate if .cfi_lsda should be emitted.
45221345Sdim  bool shouldEmitLSDA;
46221345Sdim
47288943Sdim  /// Per-function flag to indicate if frame moves info should be emitted.
48218893Sdim  bool shouldEmitMoves;
49218893Sdim
50218893Sdimpublic:
51218893Sdim  //===--------------------------------------------------------------------===//
52218893Sdim  // Main entry points.
53218893Sdim  //
54218893Sdim  DwarfCFIException(AsmPrinter *A);
55288943Sdim  ~DwarfCFIException() override;
56218893Sdim
57288943Sdim  /// Emit all exception information that should come after the content.
58276479Sdim  void endModule() override;
59218893Sdim
60288943Sdim  /// Gather pre-function exception information.  Assumes being emitted
61288943Sdim  /// immediately after the function entry point.
62276479Sdim  void beginFunction(const MachineFunction *MF) override;
63218893Sdim
64288943Sdim  /// Gather and emit post-function exception information.
65276479Sdim  void endFunction(const MachineFunction *) override;
66309124Sdim
67309124Sdim  void beginFragment(const MachineBasicBlock *MBB,
68309124Sdim                     ExceptionSymbolProvider ESP) override;
69218893Sdim};
70218893Sdim
71288943Sdimclass LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase {
72341825Sdim  void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override;
73261991Sdim  ARMTargetStreamer &getTargetStreamer();
74261991Sdim
75218893Sdimpublic:
76218893Sdim  //===--------------------------------------------------------------------===//
77218893Sdim  // Main entry points.
78218893Sdim  //
79223017Sdim  ARMException(AsmPrinter *A);
80288943Sdim  ~ARMException() override;
81218893Sdim
82288943Sdim  /// Emit all exception information that should come after the content.
83314564Sdim  void endModule() override {}
84218893Sdim
85288943Sdim  /// Gather pre-function exception information.  Assumes being emitted
86288943Sdim  /// immediately after the function entry point.
87276479Sdim  void beginFunction(const MachineFunction *MF) override;
88218893Sdim
89288943Sdim  /// Gather and emit post-function exception information.
90276479Sdim  void endFunction(const MachineFunction *) override;
91218893Sdim};
92193323Sed} // End of namespace llvm
93193323Sed
94193323Sed#endif
95