• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #ifndef LLVM_CODEGEN_GCMETADATAPRINTER_H
21 #define LLVM_CODEGEN_GCMETADATAPRINTER_H
22 
23 #include "llvm/CodeGen/GCMetadata.h"
24 #include "llvm/CodeGen/GCStrategy.h"
25 #include "llvm/Support/Registry.h"
26 
27 namespace llvm {
28 
29 class GCMetadataPrinter;
30 
31 /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
32 /// defaults from Registry.
33 typedef Registry<GCMetadataPrinter> GCMetadataPrinterRegistry;
34 
35 /// GCMetadataPrinter - Emits GC metadata as assembly code.  Instances are
36 /// created, managed, and owned by the AsmPrinter.
37 class GCMetadataPrinter {
38 private:
39   GCStrategy *S;
40   friend class AsmPrinter;
41 
42 protected:
43   // May only be subclassed.
44   GCMetadataPrinter();
45 
46 private:
47   GCMetadataPrinter(const GCMetadataPrinter &) = delete;
48   GCMetadataPrinter &operator=(const GCMetadataPrinter &) = delete;
49 
50 public:
getStrategy()51   GCStrategy &getStrategy() { return *S; }
52 
53   /// Called before the assembly for the module is generated by
54   /// the AsmPrinter (but after target specific hooks.)
beginAssembly(Module & M,GCModuleInfo & Info,AsmPrinter & AP)55   virtual void beginAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
56   /// Called after the assembly for the module is generated by
57   /// the AsmPrinter (but before target specific hooks)
finishAssembly(Module & M,GCModuleInfo & Info,AsmPrinter & AP)58   virtual void finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
59 
60   virtual ~GCMetadataPrinter();
61 };
62 }
63 
64 #endif
65