From 081134741b40b342fb2f85722c9cea5d412489a8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 29 Dec 2009 09:01:33 +0000 Subject: Final step in the metadata API restructuring: move the getMDKindID/getMDKindNames methods to LLVMContext (and add convenience methods to Module), eliminating MetadataContext. Move the state that it maintains out to LLVMContext. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92259 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Instruction.h | 2 -- include/llvm/LLVMContext.h | 20 +++++++++++++++----- include/llvm/Metadata.h | 23 ----------------------- include/llvm/Module.h | 11 ++++++++++- include/llvm/Value.h | 1 - 5 files changed, 25 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index d7161cf..d45da97 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -22,7 +22,6 @@ namespace llvm { class LLVMContext; class MDNode; -class MetadataContextImpl; template class SymbolTableListTraits; @@ -316,7 +315,6 @@ private: return Value::getSubclassDataFromValue(); } - friend class MetadataContextImpl; void setHasMetadata(bool V) { setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) | (V ? HasMetadataBit : 0)); diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index b9ffeb0..6d36d5e 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -18,7 +18,8 @@ namespace llvm { class LLVMContextImpl; -class MetadataContext; +class StringRef; +template class SmallVectorImpl; /// This is an important class for using LLVM in a threaded context. It /// (opaquely) owns and manages the core "global" data of LLVM's core @@ -31,14 +32,23 @@ class LLVMContext { void operator=(LLVMContext&); public: - LLVMContextImpl* const pImpl; - MetadataContext &getMetadata(); + LLVMContextImpl *const pImpl; LLVMContext(); ~LLVMContext(); + + /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. + /// This ID is uniqued across modules in the current LLVMContext. + unsigned getMDKindID(StringRef Name) const; + + /// getMDKindNames - Populate client supplied SmallVector with the name for + /// custom metadata IDs registered in this LLVMContext. ID #0 is not used, + /// so it is filled in as an empty string. + void getMDKindNames(SmallVectorImpl &Result) const; }; -/// FOR BACKWARDS COMPATIBILITY - Returns a global context. -extern LLVMContext& getGlobalContext(); +/// getGlobalContext - Returns a global context. This is for LLVM clients that +/// only care about operating on a single thread. +extern LLVMContext &getGlobalContext(); } diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index c25ce22..86eba35 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -25,7 +25,6 @@ class Constant; class Instruction; class LLVMContext; class Module; -class MetadataContextImpl; template class SmallVectorImpl; //===----------------------------------------------------------------------===// @@ -204,28 +203,6 @@ public: } }; -//===----------------------------------------------------------------------===// -/// MetadataContext - MetadataContext handles uniquing and assignment of IDs for -/// custom metadata types. -/// -class MetadataContext { - MetadataContext(MetadataContext&); // DO NOT IMPLEMENT - void operator=(MetadataContext&); // DO NOT IMPLEMENT - - MetadataContextImpl *const pImpl; - friend class Instruction; -public: - MetadataContext(); - ~MetadataContext(); - - /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. - unsigned getMDKindID(StringRef Name) const; - - /// getMDKindNames - Populate client supplied SmallVector with the name for - /// each custom metadata ID. ID #0 is not used, so it is filled in as empty. - void getMDKindNames(SmallVectorImpl &) const; -}; - } // end llvm namespace #endif diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 895ee01..9a8b53a 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -184,7 +184,7 @@ public: /// Get the global data context. /// @returns LLVMContext - a container for LLVM's global information - LLVMContext& getContext() const { return Context; } + LLVMContext &getContext() const { return Context; } /// Get any module-scope inline assembly blocks. /// @returns a string containing the module-scope inline assembly blocks. @@ -222,6 +222,15 @@ public: /// if a global with the specified name is not found. GlobalValue *getNamedValue(StringRef Name) const; + /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. + /// This ID is uniqued across modules in the current LLVMContext. + unsigned getMDKindID(StringRef Name) const; + + /// getMDKindNames - Populate client supplied SmallVector with the name for + /// custom metadata IDs registered in this LLVMContext. ID #0 is not used, + /// so it is filled in as an empty string. + void getMDKindNames(SmallVectorImpl &Result) const; + /// @} /// @name Function Accessors /// @{ diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 1be6ffd..4d94a30 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -41,7 +41,6 @@ class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; class LLVMContext; -class MetadataContextImpl; class Twine; //===----------------------------------------------------------------------===// -- cgit v1.1