aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-07-21 23:38:33 +0000
committerDan Gohman <gohman@apple.com>2010-07-21 23:38:33 +0000
commit17aa92c92a925b4a674440c7ef088c223990e854 (patch)
treebc129644ee9db39dc25a41c22ce01b14ede5728f /include
parentfcbd1a749f9db4bf144a3343c4d707e1de087a7e (diff)
downloadexternal_llvm-17aa92c92a925b4a674440c7ef088c223990e854.zip
external_llvm-17aa92c92a925b4a674440c7ef088c223990e854.tar.gz
external_llvm-17aa92c92a925b4a674440c7ef088c223990e854.tar.bz2
Make NamedMDNode not be a subclass of Value, and simplify the interface
for creating and populating NamedMDNodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109061 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Metadata.h26
-rw-r--r--include/llvm/Module.h26
-rw-r--r--include/llvm/Value.h1
-rw-r--r--include/llvm/ValueSymbolTable.h88
4 files changed, 16 insertions, 125 deletions
diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h
index 1869890..b5901ce 100644
--- a/include/llvm/Metadata.h
+++ b/include/llvm/Metadata.h
@@ -177,10 +177,11 @@ private:
//===----------------------------------------------------------------------===//
/// NamedMDNode - a tuple of MDNodes.
/// NamedMDNode is always named. All NamedMDNode operand has a type of metadata.
-class NamedMDNode : public Value, public ilist_node<NamedMDNode> {
+class NamedMDNode : public ilist_node<NamedMDNode> {
friend class SymbolTableListTraits<NamedMDNode, Module>;
friend struct ilist_traits<NamedMDNode>;
friend class LLVMContextImpl;
+ friend class Module;
NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT
std::string Name;
@@ -188,18 +189,11 @@ class NamedMDNode : public Value, public ilist_node<NamedMDNode> {
void *Operands; // SmallVector<TrackingVH<MDNode>, 4>
void setParent(Module *M) { Parent = M; }
-protected:
- explicit NamedMDNode(LLVMContext &C, const Twine &N, MDNode*const *Vals,
- unsigned NumVals, Module *M = 0);
-public:
- static NamedMDNode *Create(LLVMContext &C, const Twine &N,
- MDNode *const *MDs,
- unsigned NumMDs, Module *M = 0) {
- return new NamedMDNode(C, N, MDs, NumMDs, M);
- }
- static NamedMDNode *Create(const NamedMDNode *NMD, Module *M = 0);
+protected:
+ explicit NamedMDNode(const Twine &N);
+public:
/// eraseFromParent - Drop all references and remove the node from parent
/// module.
void eraseFromParent();
@@ -223,17 +217,11 @@ public:
/// addOperand - Add metadata operand.
void addOperand(MDNode *M);
- /// setName - Set the name of this named metadata.
- void setName(const Twine &NewName);
-
/// getName - Return a constant reference to this named metadata's name.
StringRef getName() const;
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const NamedMDNode *) { return true; }
- static bool classof(const Value *V) {
- return V->getValueID() == NamedMDNodeVal;
- }
+ /// print - Implement operator<< on NamedMDNode.
+ void print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW = 0) const;
};
} // end llvm namespace
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index 9b7cd4c..45247ec 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -28,7 +28,6 @@ namespace llvm {
class FunctionType;
class GVMaterializer;
class LLVMContext;
-class MDSymbolTable;
template<> struct ilist_traits<Function>
: public SymbolTableListTraits<Function, Module> {
@@ -61,7 +60,7 @@ template<> struct ilist_traits<GlobalAlias>
};
template<> struct ilist_traits<NamedMDNode>
- : public SymbolTableListTraits<NamedMDNode, Module> {
+ : public ilist_default_traits<NamedMDNode> {
// createSentinel is used to get hold of a node that marks the end of
// the list...
NamedMDNode *createSentinel() const {
@@ -72,8 +71,8 @@ template<> struct ilist_traits<NamedMDNode>
NamedMDNode *provideInitialHead() const { return createSentinel(); }
NamedMDNode *ensureHead(NamedMDNode*) const { return createSentinel(); }
static void noteHead(NamedMDNode*, NamedMDNode*) {}
- void addNodeToList(NamedMDNode *N);
- void removeNodeFromList(NamedMDNode *N);
+ void addNodeToList(NamedMDNode *N) {}
+ void removeNodeFromList(NamedMDNode *N) {}
private:
mutable ilist_node<NamedMDNode> Sentinel;
};
@@ -100,7 +99,7 @@ public:
/// The type for the list of aliases.
typedef iplist<GlobalAlias> AliasListType;
/// The type for the list of named metadata.
- typedef iplist<NamedMDNode> NamedMDListType;
+ typedef ilist<NamedMDNode> NamedMDListType;
/// The type for the list of dependent libraries.
typedef std::vector<std::string> LibraryListType;
@@ -151,7 +150,7 @@ private:
std::string ModuleID; ///< Human readable identifier for the module
std::string TargetTriple; ///< Platform target triple Module compiled on
std::string DataLayout; ///< Target data description
- MDSymbolTable *NamedMDSymTab; ///< NamedMDNode names.
+ void *NamedMDSymTab; ///< NamedMDNode names.
friend class Constant;
@@ -331,6 +330,10 @@ public:
/// NamedMDNode with the specified name is not found.
NamedMDNode *getOrInsertNamedMetadata(StringRef Name);
+ /// eraseNamedMetadata - Remove the given NamedMDNode from this module
+ /// and delete it.
+ void eraseNamedMetadata(NamedMDNode *NMD);
+
/// @}
/// @name Type Accessors
/// @{
@@ -417,13 +420,6 @@ public:
static iplist<GlobalAlias> Module::*getSublistAccess(GlobalAlias*) {
return &Module::AliasList;
}
- /// Get the Module's list of named metadata (constant).
- const NamedMDListType &getNamedMDList() const { return NamedMDList; }
- /// Get the Module's list of named metadata.
- NamedMDListType &getNamedMDList() { return NamedMDList; }
- static iplist<NamedMDNode> Module::*getSublistAccess(NamedMDNode *) {
- return &Module::NamedMDList;
- }
/// Get the symbol table of global variable and function identifiers
const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
/// Get the Module's symbol table of global variable and function identifiers.
@@ -432,10 +428,6 @@ public:
const TypeSymbolTable &getTypeSymbolTable() const { return *TypeSymTab; }
/// Get the Module's symbol table of types
TypeSymbolTable &getTypeSymbolTable() { return *TypeSymTab; }
- /// Get the symbol table of named metadata
- const MDSymbolTable &getMDSymbolTable() const { return *NamedMDSymTab; }
- /// Get the Module's symbol table of named metadata
- MDSymbolTable &getMDSymbolTable() { return *NamedMDSymTab; }
/// @}
/// @name Global Variable Iteration
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index cfb4422..0496677 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -220,7 +220,6 @@ public:
ConstantPointerNullVal, // This is an instance of ConstantPointerNull
MDNodeVal, // This is an instance of MDNode
MDStringVal, // This is an instance of MDString
- NamedMDNodeVal, // This is an instance of NamedMDNode
InlineAsmVal, // This is an instance of InlineAsm
PseudoSourceValueVal, // This is an instance of PseudoSourceValue
FixedStackPseudoSourceValueVal, // This is an instance of
diff --git a/include/llvm/ValueSymbolTable.h b/include/llvm/ValueSymbolTable.h
index 7497dae..35fc97b 100644
--- a/include/llvm/ValueSymbolTable.h
+++ b/include/llvm/ValueSymbolTable.h
@@ -128,94 +128,6 @@ private:
/// @}
};
-/// This class provides a symbol table of name/NamedMDNode pairs. It is
-/// essentially a StringMap wrapper.
-
-class MDSymbolTable {
- friend class SymbolTableListTraits<NamedMDNode, Module>;
-/// @name Types
-/// @{
-private:
- /// @brief A mapping of names to metadata
- typedef StringMap<NamedMDNode*> MDMap;
-
-public:
- /// @brief An iterator over a ValueMap.
- typedef MDMap::iterator iterator;
-
- /// @brief A const_iterator over a ValueMap.
- typedef MDMap::const_iterator const_iterator;
-
-/// @}
-/// @name Constructors
-/// @{
-public:
-
- MDSymbolTable(const MDNode &); // DO NOT IMPLEMENT
- void operator=(const MDSymbolTable &); // DO NOT IMPLEMENT
- MDSymbolTable() : mmap(0) {}
- ~MDSymbolTable();
-
-/// @}
-/// @name Accessors
-/// @{
-public:
-
- /// This method finds the value with the given \p Name in the
- /// the symbol table.
- /// @returns the NamedMDNode associated with the \p Name
- /// @brief Lookup a named Value.
- NamedMDNode *lookup(StringRef Name) const { return mmap.lookup(Name); }
-
- /// @returns true iff the symbol table is empty
- /// @brief Determine if the symbol table is empty
- inline bool empty() const { return mmap.empty(); }
-
- /// @brief The number of name/type pairs is returned.
- inline unsigned size() const { return unsigned(mmap.size()); }
-
-/// @}
-/// @name Iteration
-/// @{
-public:
- /// @brief Get an iterator that from the beginning of the symbol table.
- inline iterator begin() { return mmap.begin(); }
-
- /// @brief Get a const_iterator that from the beginning of the symbol table.
- inline const_iterator begin() const { return mmap.begin(); }
-
- /// @brief Get an iterator to the end of the symbol table.
- inline iterator end() { return mmap.end(); }
-
- /// @brief Get a const_iterator to the end of the symbol table.
- inline const_iterator end() const { return mmap.end(); }
-
-/// @}
-/// @name Mutators
-/// @{
-public:
- /// insert - The method inserts a new entry into the stringmap. This will
- /// replace existing entry, if any.
- void insert(StringRef Name, NamedMDNode *Node) {
- StringMapEntry<NamedMDNode *> &Entry =
- mmap.GetOrCreateValue(Name, Node);
- if (Entry.getValue() != Node) {
- mmap.remove(&Entry);
- (void) mmap.GetOrCreateValue(Name, Node);
- }
- }
-
- /// This method removes a NamedMDNode from the symbol table.
- void remove(StringRef Name) { mmap.erase(Name); }
-
-/// @}
-/// @name Internal Data
-/// @{
-private:
- MDMap mmap; ///< The map that holds the symbol table.
-/// @}
-};
-
} // End llvm namespace
#endif