[llvm-commits] [llvm] r77370 - in /llvm/trunk: include/llvm/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/Target/ARM/AsmPrinter/ lib/Target/Alpha/AsmPrinter/ lib/Target/CellSPU/AsmPrinter/ lib/Target/Mips/AsmPrinter/ lib/Target/PowerPC/AsmPrinter/ lib/Target/Sparc/AsmPrinter/ lib/Target/X86/AsmPrinter/ lib/Transforms/Utils/ lib/VMCore/

Devang Patel dpatel at apple.com
Tue Jul 28 14:49:47 PDT 2009


Author: dpatel
Date: Tue Jul 28 16:49:47 2009
New Revision: 77370

URL: http://llvm.org/viewvc/llvm-project?rev=77370&view=rev
Log:
Rename MDNode.h header. It defines MDnode and other metadata classes.
New name is Metadata.h.


Added:
    llvm/trunk/include/llvm/Metadata.h
      - copied, changed from r77349, llvm/trunk/include/llvm/MDNode.h
    llvm/trunk/lib/VMCore/Metadata.cpp
Removed:
    llvm/trunk/include/llvm/MDNode.h
Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
    llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
    llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
    llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
    llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
    llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
    llvm/trunk/lib/VMCore/AsmWriter.cpp
    llvm/trunk/lib/VMCore/CMakeLists.txt
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/LLVMContext.cpp
    llvm/trunk/lib/VMCore/LLVMContextImpl.cpp
    llvm/trunk/lib/VMCore/Value.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp

Removed: llvm/trunk/include/llvm/MDNode.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MDNode.h?rev=77369&view=auto

==============================================================================
--- llvm/trunk/include/llvm/MDNode.h (original)
+++ llvm/trunk/include/llvm/MDNode.h (removed)
@@ -1,163 +0,0 @@
-//===-- llvm/Metadata.h - Constant class subclass definitions ---*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-/// @file
-/// This file contains the declarations for the subclasses of Constant, 
-/// which represent the different flavors of constant values that live in LLVM.
-/// Note that Constants are immutable (once created they never change) and are 
-/// fully shared by structural equivalence.  This means that two structurally
-/// equivalent constants will always have the same address.  Constant's are
-/// created on demand as needed and never deleted: thus clients don't have to
-/// worry about the lifetime of the objects.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MDNODE_H
-#define LLVM_MDNODE_H
-
-#include "llvm/Constant.h"
-#include "llvm/Type.h"
-#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ValueHandle.h"
-
-namespace llvm {
-
-//===----------------------------------------------------------------------===//
-// MetadataBase  - A base class for MDNode and MDString.
-class MetadataBase : public Value {
-protected:
-  MetadataBase(const Type *Ty, unsigned scid)
-    : Value(Ty, scid) {}
-
-public:
-  /// getType() specialization - Type is always MetadataTy.
-  ///
-  inline const Type *getType() const {
-    return Type::MetadataTy;
-  }
-
-  /// isNullValue - Return true if this is the value that would be returned by
-  /// getNullValue.  This always returns false because getNullValue will never
-  /// produce metadata.
-  virtual bool isNullValue() const {
-    return false;
-  }
-
-  /// Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const MDString *) { return true; }
-  static bool classof(const Value *V) {
-    return V->getValueID() == MDStringVal || V->getValueID() == MDNodeVal;
-  }
-};
-
-//===----------------------------------------------------------------------===//
-/// MDString - a single uniqued string.
-/// These are used to efficiently contain a byte sequence for metadata.
-///
-class MDString : public MetadataBase {
-  MDString(const MDString &);            // DO NOT IMPLEMENT
-  StringRef Str;
-  friend class LLVMContextImpl;
-
-protected:
-  explicit MDString(const char *begin, unsigned l)
-    : MetadataBase(Type::MetadataTy, Value::MDStringVal), Str(begin, l) {}
-
-public:
-  StringRef getString() const { return Str; }
-
-  unsigned length() const { return Str.size(); }
-
-  /// begin() - Pointer to the first byte of the string.
-  ///
-  const char *begin() const { return Str.begin(); }
-
-  /// end() - Pointer to one byte past the end of the string.
-  ///
-  const char *end() const { return Str.end(); }
-
-  /// Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const MDString *) { return true; }
-  static bool classof(const Value *V) {
-    return V->getValueID() == MDStringVal;
-  }
-};
-
-//===----------------------------------------------------------------------===//
-/// MDNode - a tuple of other values.
-/// These contain a list of the values that represent the metadata. 
-///
-class MDNode : public MetadataBase, public FoldingSetNode {
-  MDNode(const MDNode &);      // DO NOT IMPLEMENT
-
-  friend class LLVMContextImpl;
-
-  void replaceElement(Value *From, Value *To);
-
-  SmallVector<WeakVH, 4> Node;
-  typedef SmallVectorImpl<WeakVH>::iterator elem_iterator;
-
-protected:
-  explicit MDNode(Value*const* Vals, unsigned NumVals);
-public:
-  typedef SmallVectorImpl<WeakVH>::const_iterator const_elem_iterator;
-
-  Value *getElement(unsigned i) const {
-    return Node[i];
-  }
-
-  unsigned getNumElements() const {
-    return Node.size();
-  }
-
-  bool elem_empty() const {
-    return Node.empty();
-  }
-
-  const_elem_iterator elem_begin() const {
-    return Node.begin();
-  }
-
-  const_elem_iterator elem_end() const {
-    return Node.end();
-  }
-
-  /// getType() specialization - Type is always MetadataTy.
-  ///
-  inline const Type *getType() const {
-    return Type::MetadataTy;
-  }
-
-  /// isNullValue - Return true if this is the value that would be returned by
-  /// getNullValue.  This always returns false because getNullValue will never
-  /// produce metadata.
-  virtual bool isNullValue() const {
-    return false;
-  }
-
-  /// Profile - calculate a unique identifier for this MDNode to collapse
-  /// duplicates
-  void Profile(FoldingSetNodeID &ID) const;
-
-  virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) {
-    llvm_unreachable("This should never be called because MDNodes have no ops");
-  }
-
-  /// Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const MDNode *) { return true; }
-  static bool classof(const Value *V) {
-    return V->getValueID() == MDNodeVal;
-  }
-};
-
-} // end llvm namespace
-
-#endif

Copied: llvm/trunk/include/llvm/Metadata.h (from r77349, llvm/trunk/include/llvm/MDNode.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?p2=llvm/trunk/include/llvm/Metadata.h&p1=llvm/trunk/include/llvm/MDNode.h&r1=77349&r2=77370&rev=77370&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MDNode.h (original)
+++ llvm/trunk/include/llvm/Metadata.h Tue Jul 28 16:49:47 2009
@@ -1,4 +1,4 @@
-//===-- llvm/Metadata.h - Constant class subclass definitions ---*- C++ -*-===//
+//===-- llvm/Metadata.h - Metadata definitions ------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,13 +8,8 @@
 //===----------------------------------------------------------------------===//
 //
 /// @file
-/// This file contains the declarations for the subclasses of Constant, 
-/// which represent the different flavors of constant values that live in LLVM.
-/// Note that Constants are immutable (once created they never change) and are 
-/// fully shared by structural equivalence.  This means that two structurally
-/// equivalent constants will always have the same address.  Constant's are
-/// created on demand as needed and never deleted: thus clients don't have to
-/// worry about the lifetime of the objects.
+/// This file contains the declarations for metadata subclasses.
+/// They represent the different flavors of metadata that live in LLVM.
 //
 //===----------------------------------------------------------------------===//
 

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jul 28 16:49:47 2009
@@ -19,7 +19,7 @@
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
 #include "llvm/LLVMContext.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/Operator.h"
 #include "llvm/ValueSymbolTable.h"

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 28 16:49:47 2009
@@ -18,7 +18,7 @@
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
 #include "llvm/LLVMContext.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/Operator.h"
 #include "llvm/AutoUpgrade.h"

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jul 28 16:49:47 2009
@@ -19,7 +19,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/Operator.h"
 #include "llvm/TypeSymbolTable.h"

Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Tue Jul 28 16:49:47 2009
@@ -14,7 +14,7 @@
 #include "ValueEnumerator.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/ValueSymbolTable.h"

Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -21,7 +21,7 @@
 #include "ARMMachineFunctionInfo.h"
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"

Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -17,7 +17,7 @@
 #include "AlphaInstrInfo.h"
 #include "AlphaTargetMachine.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"

Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -19,7 +19,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"

Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -22,7 +22,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"

Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -24,7 +24,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"

Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -19,7 +19,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Jul 28 16:49:47 2009
@@ -23,7 +23,7 @@
 #include "llvm/CallingConv.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Type.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Tue Jul 28 16:49:47 2009
@@ -19,7 +19,7 @@
 #include "llvm/GlobalValue.h"
 #include "llvm/Instruction.h"
 #include "llvm/LLVMContext.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ErrorHandling.h"
 using namespace llvm;

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Jul 28 16:49:47 2009
@@ -24,7 +24,7 @@
 #include "llvm/Instruction.h"
 #include "llvm/Instructions.h"
 #include "llvm/Operator.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/ValueSymbolTable.h"
 #include "llvm/TypeSymbolTable.h"

Modified: llvm/trunk/lib/VMCore/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/CMakeLists.txt?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/CMakeLists.txt (original)
+++ llvm/trunk/lib/VMCore/CMakeLists.txt Tue Jul 28 16:49:47 2009
@@ -17,6 +17,7 @@
   LLVMContextImpl.cpp
   LeakDetector.cpp
   Mangler.cpp
+  Metadata.cpp
   Module.cpp
   ModuleProvider.cpp
   Pass.cpp

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jul 28 16:49:47 2009
@@ -17,7 +17,6 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Instructions.h"
-#include "llvm/MDNode.h"
 #include "llvm/Module.h"
 #include "llvm/Operator.h"
 #include "llvm/ADT/FoldingSet.h"
@@ -1225,20 +1224,6 @@
   destroyConstantImpl();
 }
 
-//---- MDNode::get() implementation
-//
-
-MDNode::MDNode(Value*const* Vals, unsigned NumVals)
-  : MetadataBase(Type::MetadataTy, Value::MDNodeVal) {
-  for (unsigned i = 0; i != NumVals; ++i)
-    Node.push_back(WeakVH(Vals[i]));
-}
-
-void MDNode::Profile(FoldingSetNodeID &ID) const {
-  for (const_elem_iterator I = elem_begin(), E = elem_end(); I != E; ++I)
-    ID.AddPointer(*I);
-}
-
 //---- ConstantExpr::get() implementations...
 //
 
@@ -2296,18 +2281,3 @@
   destroyConstant();
 }
 
-void MDNode::replaceElement(Value *From, Value *To) {
-  SmallVector<Value*, 4> Values;
-  Values.reserve(getNumElements());  // Build replacement array...
-  for (unsigned i = 0, e = getNumElements(); i != e; ++i) {
-    Value *Val = getElement(i);
-    if (Val == From) Val = To;
-    Values.push_back(Val);
-  }
-
-  MDNode *Replacement =
-    getType()->getContext().getMDNode(&Values[0], Values.size());
-  assert(Replacement != this && "I didn't contain From!");
-
-  uncheckedReplaceAllUsesWith(Replacement);
-}

Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Jul 28 16:49:47 2009
@@ -16,7 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instruction.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "LLVMContextImpl.h"
 #include <cstdarg>

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Tue Jul 28 16:49:47 2009
@@ -16,7 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/LLVMContext.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 using namespace llvm;
 
 static char getValType(ConstantAggregateZero *CPZ) { return 0; }

Added: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=77370&view=auto

==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (added)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Jul 28 16:49:47 2009
@@ -0,0 +1,45 @@
+//===-- Metadata.cpp - Implement Metadata classes -------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the Metadata classes.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Metadata.h"
+using namespace llvm;
+
+//===----------------------------------------------------------------------===//
+//MDNode implementation
+//
+MDNode::MDNode(Value*const* Vals, unsigned NumVals)
+  : MetadataBase(Type::MetadataTy, Value::MDNodeVal) {
+  for (unsigned i = 0; i != NumVals; ++i)
+    Node.push_back(WeakVH(Vals[i]));
+}
+
+void MDNode::Profile(FoldingSetNodeID &ID) const {
+  for (const_elem_iterator I = elem_begin(), E = elem_end(); I != E; ++I)
+    ID.AddPointer(*I);
+}
+
+void MDNode::replaceElement(Value *From, Value *To) {
+  SmallVector<Value*, 4> Values;
+  Values.reserve(getNumElements());  // Build replacement array...
+  for (unsigned i = 0, e = getNumElements(); i != e; ++i) {
+    Value *Val = getElement(i);
+    if (Val == From) Val = To;
+    Values.push_back(Val);
+  }
+
+  MDNode *Replacement =
+    getType()->getContext().getMDNode(&Values[0], Values.size());
+  assert(Replacement != this && "I didn't contain From!");
+
+  uncheckedReplaceAllUsesWith(Replacement);
+}

Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Tue Jul 28 16:49:47 2009
@@ -18,7 +18,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Operator.h"
 #include "llvm/Module.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/ValueSymbolTable.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Debug.h"

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=77370&r1=77369&r2=77370&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Jul 28 16:49:47 2009
@@ -45,7 +45,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/InlineAsm.h"
 #include "llvm/IntrinsicInst.h"
-#include "llvm/MDNode.h"
+#include "llvm/Metadata.h"
 #include "llvm/Module.h"
 #include "llvm/ModuleProvider.h"
 #include "llvm/Pass.h"





More information about the llvm-commits mailing list