GCMetadataPrinter.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //===- llvm/CodeGen/GCMetadataPrinter.h - Prints asm GC tables --*- 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. // The abstract base class GCMetadataPrinter supports writing GC metadata tables
  10. // as assembly code. This is a separate class from GCStrategy in order to allow
  11. // users of the LLVM JIT to avoid linking with the AsmWriter.
  12. //
  13. // Subclasses of GCMetadataPrinter must be registered using the
  14. // GCMetadataPrinterRegistry. This is separate from the GCStrategy itself
  15. // because these subclasses are logically plugins for the AsmWriter.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_GCMETADATAPRINTER_H
  19. #define LLVM_CODEGEN_GCMETADATAPRINTER_H
  20. #include "llvm/Support/Registry.h"
  21. namespace llvm {
  22. class AsmPrinter;
  23. class GCMetadataPrinter;
  24. class GCModuleInfo;
  25. class GCStrategy;
  26. class Module;
  27. class StackMaps;
  28. /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
  29. /// defaults from Registry.
  30. using GCMetadataPrinterRegistry = Registry<GCMetadataPrinter>;
  31. /// GCMetadataPrinter - Emits GC metadata as assembly code. Instances are
  32. /// created, managed, and owned by the AsmPrinter.
  33. class GCMetadataPrinter {
  34. private:
  35. friend class AsmPrinter;
  36. GCStrategy *S;
  37. protected:
  38. // May only be subclassed.
  39. GCMetadataPrinter();
  40. public:
  41. GCMetadataPrinter(const GCMetadataPrinter &) = delete;
  42. GCMetadataPrinter &operator=(const GCMetadataPrinter &) = delete;
  43. virtual ~GCMetadataPrinter();
  44. GCStrategy &getStrategy() { return *S; }
  45. /// Called before the assembly for the module is generated by
  46. /// the AsmPrinter (but after target specific hooks.)
  47. virtual void beginAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
  48. /// Called after the assembly for the module is generated by
  49. /// the AsmPrinter (but before target specific hooks)
  50. virtual void finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
  51. /// Called when the stack maps are generated. Return true if
  52. /// stack maps with a custom format are generated. Otherwise
  53. /// returns false and the default format will be used.
  54. virtual bool emitStackMaps(StackMaps &SM, AsmPrinter &AP) { return false; }
  55. };
  56. } // end namespace llvm
  57. #endif // LLVM_CODEGEN_GCMETADATAPRINTER_H