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 DwarfCFIException : public EHStreamer {
  21. /// Per-function flag to indicate if .cfi_personality should be emitted.
  22. bool shouldEmitPersonality = false;
  23. /// Per-function flag to indicate if .cfi_personality must be emitted.
  24. bool forceEmitPersonality = false;
  25. /// Per-function flag to indicate if .cfi_lsda should be emitted.
  26. bool shouldEmitLSDA = false;
  27. /// Per-function flag to indicate if frame CFI info should be emitted.
  28. bool shouldEmitCFI = false;
  29. /// Per-module flag to indicate if .cfi_section has beeen emitted.
  30. bool hasEmittedCFISections = false;
  31. /// Vector of all personality functions seen so far in the module.
  32. std::vector<const GlobalValue *> Personalities;
  33. void addPersonality(const GlobalValue *Personality);
  34. public:
  35. //===--------------------------------------------------------------------===//
  36. // Main entry points.
  37. //
  38. DwarfCFIException(AsmPrinter *A);
  39. ~DwarfCFIException() override;
  40. /// Emit all exception information that should come after the content.
  41. void endModule() override;
  42. /// Gather pre-function exception information. Assumes being emitted
  43. /// immediately after the function entry point.
  44. void beginFunction(const MachineFunction *MF) override;
  45. /// Gather and emit post-function exception information.
  46. void endFunction(const MachineFunction *) override;
  47. void beginBasicBlockSection(const MachineBasicBlock &MBB) override;
  48. void endBasicBlockSection(const MachineBasicBlock &MBB) override;
  49. };
  50. class LLVM_LIBRARY_VISIBILITY ARMException : public EHStreamer {
  51. /// Per-function flag to indicate if frame CFI info should be emitted.
  52. bool shouldEmitCFI = false;
  53. /// Per-module flag to indicate if .cfi_section has beeen emitted.
  54. bool hasEmittedCFISections = false;
  55. void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override;
  56. ARMTargetStreamer &getTargetStreamer();
  57. public:
  58. //===--------------------------------------------------------------------===//
  59. // Main entry points.
  60. //
  61. ARMException(AsmPrinter *A);
  62. ~ARMException() override;
  63. /// Emit all exception information that should come after the content.
  64. void endModule() override {}
  65. /// Gather pre-function exception information. Assumes being emitted
  66. /// immediately after the function entry point.
  67. void beginFunction(const MachineFunction *MF) override;
  68. /// Gather and emit post-function exception information.
  69. void endFunction(const MachineFunction *) override;
  70. void markFunctionEnd() override;
  71. };
  72. class LLVM_LIBRARY_VISIBILITY AIXException : public EHStreamer {
  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 endModule() override {}
  79. void beginFunction(const MachineFunction *MF) override {}
  80. void endFunction(const MachineFunction *MF) override;
  81. };
  82. } // End of namespace llvm
  83. #endif