DwarfException.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
  13. #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
  14. #include "EHStreamer.h"
  15. #include "llvm/CodeGen/AsmPrinter.h"
  16. #include "llvm/MC/MCDwarf.h"
  17. namespace llvm {
  18. class MachineFunction;
  19. class ARMTargetStreamer;
  20. class LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer {
  21. protected:
  22. DwarfCFIExceptionBase(AsmPrinter *A);
  23. /// Per-function flag to indicate if frame CFI info should be emitted.
  24. bool shouldEmitCFI = false;
  25. /// Per-module flag to indicate if .cfi_section has beeen emitted.
  26. bool hasEmittedCFISections = false;
  27. void markFunctionEnd() override;
  28. void endFragment() override;
  29. };
  30. class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase {
  31. /// Per-function flag to indicate if .cfi_personality should be emitted.
  32. bool shouldEmitPersonality = false;
  33. /// Per-function flag to indicate if .cfi_personality must be emitted.
  34. bool forceEmitPersonality = false;
  35. /// Per-function flag to indicate if .cfi_lsda should be emitted.
  36. bool shouldEmitLSDA = false;
  37. public:
  38. //===--------------------------------------------------------------------===//
  39. // Main entry points.
  40. //
  41. DwarfCFIException(AsmPrinter *A);
  42. ~DwarfCFIException() override;
  43. /// Emit all exception information that should come after the content.
  44. void endModule() override;
  45. /// Gather pre-function exception information. Assumes being emitted
  46. /// immediately after the function entry point.
  47. void beginFunction(const MachineFunction *MF) override;
  48. /// Gather and emit post-function exception information.
  49. void endFunction(const MachineFunction *) override;
  50. void beginFragment(const MachineBasicBlock *MBB,
  51. ExceptionSymbolProvider ESP) override;
  52. void beginBasicBlock(const MachineBasicBlock &MBB) override;
  53. void endBasicBlock(const MachineBasicBlock &MBB) override;
  54. };
  55. class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase {
  56. void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override;
  57. ARMTargetStreamer &getTargetStreamer();
  58. public:
  59. //===--------------------------------------------------------------------===//
  60. // Main entry points.
  61. //
  62. ARMException(AsmPrinter *A);
  63. ~ARMException() override;
  64. /// Emit all exception information that should come after the content.
  65. void endModule() override {}
  66. /// Gather pre-function exception information. Assumes being emitted
  67. /// immediately after the function entry point.
  68. void beginFunction(const MachineFunction *MF) override;
  69. /// Gather and emit post-function exception information.
  70. void endFunction(const MachineFunction *) override;
  71. };
  72. class LLVM_LIBRARY_VISIBILITY AIXException : public DwarfCFIExceptionBase {
  73. /// This is AIX's compat unwind section, which unwinder would use
  74. /// to find the location of LSDA area and personality rountine.
  75. void emitExceptionInfoTable(const MCSymbol *LSDA, const MCSymbol *PerSym);
  76. public:
  77. AIXException(AsmPrinter *A);
  78. void markFunctionEnd() override;
  79. void endModule() override {}
  80. void beginFunction(const MachineFunction *MF) override {}
  81. void endFunction(const MachineFunction *MF) override;
  82. };
  83. } // End of namespace llvm
  84. #endif