• 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.
36   ///
37   class GCMetadataPrinter {
38   public:
39     typedef GCStrategy::list_type list_type;
40     typedef GCStrategy::iterator iterator;
41 
42   private:
43     GCStrategy *S;
44 
45     friend class AsmPrinter;
46 
47   protected:
48     // May only be subclassed.
49     GCMetadataPrinter();
50 
51   private:
52     GCMetadataPrinter(const GCMetadataPrinter &) LLVM_DELETED_FUNCTION;
53     GCMetadataPrinter &
54       operator=(const GCMetadataPrinter &) LLVM_DELETED_FUNCTION;
55 
56   public:
getStrategy()57     GCStrategy &getStrategy() { return *S; }
getModule()58     const Module &getModule() const { return S->getModule(); }
59 
60     /// begin/end - Iterate over the collected function metadata.
begin()61     iterator begin() { return S->begin(); }
end()62     iterator end()   { return S->end();   }
63 
64     /// beginAssembly/finishAssembly - Emit module metadata as assembly code.
65     virtual void beginAssembly(AsmPrinter &AP);
66 
67     virtual void finishAssembly(AsmPrinter &AP);
68 
69     virtual ~GCMetadataPrinter();
70   };
71 
72 }
73 
74 #endif
75