Rename some GC classes so that their roll will hopefully be clearer.
[oota-llvm.git] / include / llvm / CodeGen / GCMetadataPrinter.h
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 #include <iosfwd>
27 #include <string>
28
29 namespace llvm {
30   
31   class GCMetadataPrinter;
32   
33   /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
34   /// defaults from Registry.
35   typedef Registry<GCMetadataPrinter> GCMetadataPrinterRegistry;
36   
37   /// GCMetadataPrinter - Emits GC metadata as assembly code.
38   /// 
39   class GCMetadataPrinter {
40   public:
41     typedef GCStrategy::list_type list_type;
42     typedef GCStrategy::iterator iterator;
43     
44   private:
45     GCStrategy *S;
46     
47     friend class AsmPrinter;
48     
49   protected:
50     // May only be subclassed.
51     GCMetadataPrinter();
52     
53     // Do not implement.
54     GCMetadataPrinter(const GCMetadataPrinter &);
55     GCMetadataPrinter &operator=(const GCMetadataPrinter &);
56     
57   public:
58     GCStrategy &getStrategy() { return *S; }
59     const Module &getModule() const { return S->getModule(); }
60     
61     /// begin/end - Iterate over the collected function metadata.
62     iterator begin() { return S->begin(); }
63     iterator end()   { return S->end();   }
64     
65     /// beginAssembly/finishAssembly - Emit module metadata as assembly code.
66     virtual void beginAssembly(std::ostream &OS, AsmPrinter &AP,
67                                const TargetAsmInfo &TAI);
68     
69     virtual void finishAssembly(std::ostream &OS, AsmPrinter &AP,
70                                 const TargetAsmInfo &TAI);
71     
72     virtual ~GCMetadataPrinter();
73   };
74   
75 }
76
77 #endif