GCMetadataPrinter.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //===-- llvm/CodeGen/GCMetadataPrinter.h - Prints asm GC tables -*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // The abstract base class GCMetadataPrinter supports writing GC metadata tables
  11. // as assembly code. This is a separate class from GCStrategy in order to allow
  12. // users of the LLVM JIT to avoid linking with the AsmWriter.
  13. //
  14. // Subclasses of GCMetadataPrinter must be registered using the
  15. // GCMetadataPrinterRegistry. This is separate from the GCStrategy itself
  16. // because these subclasses are logically plugins for the AsmWriter.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_CODEGEN_GCMETADATAPRINTER_H
  20. #define LLVM_CODEGEN_GCMETADATAPRINTER_H
  21. #include "llvm/CodeGen/GCMetadata.h"
  22. #include "llvm/CodeGen/GCStrategy.h"
  23. #include "llvm/Support/Registry.h"
  24. namespace llvm {
  25. class GCMetadataPrinter;
  26. /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
  27. /// defaults from Registry.
  28. typedef Registry<GCMetadataPrinter> GCMetadataPrinterRegistry;
  29. /// GCMetadataPrinter - Emits GC metadata as assembly code. Instances are
  30. /// created, managed, and owned by the AsmPrinter.
  31. class GCMetadataPrinter {
  32. private:
  33. GCStrategy *S;
  34. friend class AsmPrinter;
  35. protected:
  36. // May only be subclassed.
  37. GCMetadataPrinter();
  38. private:
  39. GCMetadataPrinter(const GCMetadataPrinter &) = delete;
  40. GCMetadataPrinter &operator=(const GCMetadataPrinter &) = delete;
  41. public:
  42. GCStrategy &getStrategy() { return *S; }
  43. /// Called before the assembly for the module is generated by
  44. /// the AsmPrinter (but after target specific hooks.)
  45. virtual void beginAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
  46. /// Called after the assembly for the module is generated by
  47. /// the AsmPrinter (but before target specific hooks)
  48. virtual void finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
  49. virtual ~GCMetadataPrinter();
  50. };
  51. }
  52. #endif