GCMetadataPrinter.h 2.6 KB

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