LLVM API Documentation

GCMetadataPrinter.h

Go to the documentation of this file.
00001 //===-- llvm/CodeGen/GCMetadataPrinter.h - Prints asm GC tables -*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // The abstract base class GCMetadataPrinter supports writing GC metadata tables
00011 // as assembly code. This is a separate class from GCStrategy in order to allow
00012 // users of the LLVM JIT to avoid linking with the AsmWriter.
00013 //
00014 // Subclasses of GCMetadataPrinter must be registered using the
00015 // GCMetadataPrinterRegistry. This is separate from the GCStrategy itself
00016 // because these subclasses are logically plugins for the AsmWriter.
00017 //
00018 //===----------------------------------------------------------------------===//
00019 
00020 #ifndef LLVM_CODEGEN_GCMETADATAPRINTER_H
00021 #define LLVM_CODEGEN_GCMETADATAPRINTER_H
00022 
00023 #include "llvm/CodeGen/GCMetadata.h"
00024 #include "llvm/CodeGen/GCStrategy.h"
00025 #include "llvm/Support/Registry.h"
00026 
00027 namespace llvm {
00028   
00029   class GCMetadataPrinter;
00030   class raw_ostream;
00031   
00032   /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
00033   /// defaults from Registry.
00034   typedef Registry<GCMetadataPrinter> GCMetadataPrinterRegistry;
00035   
00036   /// GCMetadataPrinter - Emits GC metadata as assembly code.
00037   /// 
00038   class GCMetadataPrinter {
00039   public:
00040     typedef GCStrategy::list_type list_type;
00041     typedef GCStrategy::iterator iterator;
00042     
00043   private:
00044     GCStrategy *S;
00045     
00046     friend class AsmPrinter;
00047     
00048   protected:
00049     // May only be subclassed.
00050     GCMetadataPrinter();
00051     
00052     // Do not implement.
00053     GCMetadataPrinter(const GCMetadataPrinter &);
00054     GCMetadataPrinter &operator=(const GCMetadataPrinter &);
00055     
00056   public:
00057     GCStrategy &getStrategy() { return *S; }
00058     const Module &getModule() const { return S->getModule(); }
00059     
00060     /// begin/end - Iterate over the collected function metadata.
00061     iterator begin() { return S->begin(); }
00062     iterator end()   { return S->end();   }
00063     
00064     /// beginAssembly/finishAssembly - Emit module metadata as assembly code.
00065     virtual void beginAssembly(raw_ostream &OS, AsmPrinter &AP,
00066                                const TargetAsmInfo &TAI);
00067     
00068     virtual void finishAssembly(raw_ostream &OS, AsmPrinter &AP,
00069                                 const TargetAsmInfo &TAI);
00070     
00071     virtual ~GCMetadataPrinter();
00072   };
00073   
00074 }
00075 
00076 #endif