AsmPrinterHandler.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /// Please note that some AsmPrinter implementations may not call
  50. /// beginFunction at all.
  51. virtual void endFunction(const MachineFunction *MF) = 0;
  52. virtual void beginFragment(const MachineBasicBlock *MBB,
  53. ExceptionSymbolProvider ESP) {}
  54. virtual void endFragment() {}
  55. /// Emit target-specific EH funclet machinery.
  56. virtual void beginFunclet(const MachineBasicBlock &MBB,
  57. MCSymbol *Sym = nullptr) {}
  58. virtual void endFunclet() {}
  59. /// Process beginning of an instruction.
  60. virtual void beginInstruction(const MachineInstr *MI) = 0;
  61. /// Process end of an instruction.
  62. virtual void endInstruction() = 0;
  63. /// Process beginning of a basic block during basic block sections.
  64. virtual void beginBasicBlock(const MachineBasicBlock &MBB) {}
  65. /// Process end of a basic block during basic block sections.
  66. virtual void endBasicBlock(const MachineBasicBlock &MBB) {}
  67. };
  68. } // End of namespace llvm
  69. #endif
  70. #ifdef __GNUC__
  71. #pragma GCC diagnostic pop
  72. #endif