AsmPrinterHandler.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //===-- llvm/CodeGen/AsmPrinterHandler.h -----------------------*- 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 a generic interface for AsmPrinter handlers,
  10. // like debug and EH info emitters.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CODEGEN_ASMPRINTERHANDLER_H
  14. #define LLVM_CODEGEN_ASMPRINTERHANDLER_H
  15. #include "llvm/Support/DataTypes.h"
  16. namespace llvm {
  17. class AsmPrinter;
  18. class MachineBasicBlock;
  19. class MachineFunction;
  20. class MachineInstr;
  21. class MCSymbol;
  22. class Module;
  23. typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm,
  24. const MachineBasicBlock *MBB);
  25. /// Collects and handles AsmPrinter objects required to build debug
  26. /// or EH information.
  27. class AsmPrinterHandler {
  28. public:
  29. virtual ~AsmPrinterHandler();
  30. /// For symbols that have a size designated (e.g. common symbols),
  31. /// this tracks that size.
  32. virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
  33. virtual void beginModule(Module *M) {}
  34. /// Emit all sections that should come after the content.
  35. virtual void endModule() = 0;
  36. /// Gather pre-function debug information.
  37. /// Every beginFunction(MF) call should be followed by an endFunction(MF)
  38. /// call.
  39. virtual void beginFunction(const MachineFunction *MF) = 0;
  40. // Emit any of function marker (like .cfi_endproc). This is called
  41. // before endFunction and cannot switch sections.
  42. virtual void markFunctionEnd();
  43. /// Gather post-function debug information.
  44. /// Please note that some AsmPrinter implementations may not call
  45. /// beginFunction at all.
  46. virtual void endFunction(const MachineFunction *MF) = 0;
  47. virtual void beginFragment(const MachineBasicBlock *MBB,
  48. ExceptionSymbolProvider ESP) {}
  49. virtual void endFragment() {}
  50. /// Emit target-specific EH funclet machinery.
  51. virtual void beginFunclet(const MachineBasicBlock &MBB,
  52. MCSymbol *Sym = nullptr) {}
  53. virtual void endFunclet() {}
  54. /// Process beginning of an instruction.
  55. virtual void beginInstruction(const MachineInstr *MI) = 0;
  56. /// Process end of an instruction.
  57. virtual void endInstruction() = 0;
  58. /// Process beginning of a basic block during basic block sections.
  59. virtual void beginBasicBlock(const MachineBasicBlock &MBB) {}
  60. /// Process end of a basic block during basic block sections.
  61. virtual void endBasicBlock(const MachineBasicBlock &MBB) {}
  62. };
  63. } // End of namespace llvm
  64. #endif