diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/AsmPrinter.h | 14 | ||||
-rw-r--r-- | include/llvm/CodeGen/Collector.h | 46 | ||||
-rw-r--r-- | include/llvm/CodeGen/Collectors.h | 5 |
3 files changed, 57 insertions, 8 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 1bd2d51..27ea221 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -18,11 +18,14 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Support/DataTypes.h" +#include "llvm/ADT/DenseMap.h" #include <set> namespace llvm { + class Collector; class Constant; class ConstantArray; + class GCMetadataPrinter; class GlobalVariable; class GlobalAlias; class MachineConstantPoolEntry; @@ -48,7 +51,12 @@ namespace llvm { /// DebugVariable entries into the dwarf table. This is a short term hack /// that ought be fixed soon. MachineModuleInfo *MMI; - + + // GCMetadataPrinters - The garbage collection metadata printer table. + typedef DenseMap<Collector*,GCMetadataPrinter*> gcp_map_type; + typedef gcp_map_type::iterator gcp_iterator; + gcp_map_type GCMetadataPrinters; + protected: // Necessary for external weak linkage support std::set<const GlobalValue*> ExtWeakSymbols; @@ -91,6 +99,8 @@ namespace llvm { AsmPrinter(std::ostream &o, TargetMachine &TM, const TargetAsmInfo *T); public: + virtual ~AsmPrinter(); + /// SwitchToTextSection - Switch to the specified section of the executable /// if we are not already in it! If GV is non-null and if the global has an /// explicitly requested section, we switch to the section indicated for the @@ -356,7 +366,7 @@ namespace llvm { void EmitXXStructorList(Constant *List); void EmitConstantPool(unsigned Alignment, const char *Section, std::vector<std::pair<MachineConstantPoolEntry,unsigned> > &CP); - + GCMetadataPrinter *GetOrCreateGCPrinter(Collector *C); }; } diff --git a/include/llvm/CodeGen/Collector.h b/include/llvm/CodeGen/Collector.h index 160e523..20b4702 100644 --- a/include/llvm/CodeGen/Collector.h +++ b/include/llvm/CodeGen/Collector.h @@ -60,6 +60,7 @@ namespace llvm { bool CustomWriteBarriers; //< Default is to insert stores. bool CustomRoots; //< Default is to pass through to backend. bool InitRoots; //< If set, roots are nulled during lowering. + bool UsesMetadata; //< If set, backend must emit metadata tables. public: Collector(); @@ -103,12 +104,9 @@ namespace llvm { /// is necessary for most collectors. bool initializeRoots() const { return InitRoots; } - - /// beginAssembly/finishAssembly - Emit module metadata as assembly code. - virtual void beginAssembly(std::ostream &OS, AsmPrinter &AP, - const TargetAsmInfo &TAI); - virtual void finishAssembly(std::ostream &OS, AsmPrinter &AP, - const TargetAsmInfo &TAI); + /// If set, appropriate metadata tables must be emitted by the back-end + /// (assembler, JIT, or otherwise). + bool usesMetadata() const { return UsesMetadata; } /// begin/end - Iterators for function metadata. /// @@ -128,6 +126,42 @@ namespace llvm { virtual bool performCustomLowering(Function &F); }; + // GCMetadataPrinter - Emits GC metadata as assembly code. + class GCMetadataPrinter { + public: + typedef Collector::list_type list_type; + typedef Collector::iterator iterator; + + private: + Collector *Coll; + + friend class AsmPrinter; + + protected: + // May only be subclassed. + GCMetadataPrinter(); + + // Do not implement. + GCMetadataPrinter(const GCMetadataPrinter &); + GCMetadataPrinter &operator=(const GCMetadataPrinter &); + + public: + Collector &getCollector() { return *Coll; } + const Module &getModule() const { return Coll->getModule(); } + + iterator begin() { return Coll->begin(); } + iterator end() { return Coll->end(); } + + /// beginAssembly/finishAssembly - Emit module metadata as assembly code. + virtual void beginAssembly(std::ostream &OS, AsmPrinter &AP, + const TargetAsmInfo &TAI); + + virtual void finishAssembly(std::ostream &OS, AsmPrinter &AP, + const TargetAsmInfo &TAI); + + virtual ~GCMetadataPrinter(); + }; + } #endif diff --git a/include/llvm/CodeGen/Collectors.h b/include/llvm/CodeGen/Collectors.h index 0d9e451..1658da1 100644 --- a/include/llvm/CodeGen/Collectors.h +++ b/include/llvm/CodeGen/Collectors.h @@ -20,11 +20,16 @@ namespace llvm { class Collector; + class GCMetadataPrinter; /// The collector registry uses all the defaults from Registry. /// typedef Registry<Collector> CollectorRegistry; + /// The GC assembly printer registry uses all the defaults from Registry. + /// + typedef Registry<GCMetadataPrinter> GCMetadataPrinterRegistry; + /// FIXME: Collector instances are not useful on their own. These no longer /// serve any purpose except to link in the plugins. |