AsmPrinterHandler.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- llvm/CodeGen/AsmPrinterHandler.h -----------------------*- C++ -*--===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains a generic interface for AsmPrinter handlers,
  15. // like debug and EH info emitters.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_ASMPRINTERHANDLER_H
  19. #define LLVM_CODEGEN_ASMPRINTERHANDLER_H
  20. #include "llvm/Support/DataTypes.h"
  21. namespace llvm {
  22. class AsmPrinter;
  23. class MachineBasicBlock;
  24. class MachineFunction;
  25. class MachineInstr;
  26. class MCSymbol;
  27. class Module;
  28. typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm,
  29. const MachineBasicBlock *MBB);
  30. /// Collects and handles AsmPrinter objects required to build debug
  31. /// or EH information.
  32. class AsmPrinterHandler {
  33. public:
  34. virtual ~AsmPrinterHandler();
  35. /// For symbols that have a size designated (e.g. common symbols),
  36. /// this tracks that size.
  37. virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
  38. virtual void beginModule(Module *M) {}
  39. /// Emit all sections that should come after the content.
  40. virtual void endModule() = 0;
  41. /// Gather pre-function debug information.
  42. /// Every beginFunction(MF) call should be followed by an endFunction(MF)
  43. /// call.
  44. virtual void beginFunction(const MachineFunction *MF) = 0;
  45. // Emit any of function marker (like .cfi_endproc). This is called
  46. // before endFunction and cannot switch sections.
  47. virtual void markFunctionEnd();
  48. /// Gather post-function debug information.
  49. virtual void endFunction(const MachineFunction *MF) = 0;
  50. /// Process the beginning of a new basic-block-section within a
  51. /// function. Always called immediately after beginFunction for the first
  52. /// basic-block. When basic-block-sections are enabled, called before the
  53. /// first block of each such section.
  54. virtual void beginBasicBlockSection(const MachineBasicBlock &MBB) {}
  55. /// Process the end of a basic-block-section within a function. When
  56. /// basic-block-sections are enabled, called after the last block in each such
  57. /// section (including the last section in the function). When
  58. /// basic-block-sections are disabled, called at the end of a function,
  59. /// immediately prior to markFunctionEnd.
  60. virtual void endBasicBlockSection(const MachineBasicBlock &MBB) {}
  61. /// Emit target-specific EH funclet machinery.
  62. virtual void beginFunclet(const MachineBasicBlock &MBB,
  63. MCSymbol *Sym = nullptr) {}
  64. virtual void endFunclet() {}
  65. /// Process beginning of an instruction.
  66. virtual void beginInstruction(const MachineInstr *MI) = 0;
  67. /// Process end of an instruction.
  68. virtual void endInstruction() = 0;
  69. };
  70. } // End of namespace llvm
  71. #endif
  72. #ifdef __GNUC__
  73. #pragma GCC diagnostic pop
  74. #endif