diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Bitcode/LLVMBitCodes.h | 6 | ||||
-rw-r--r-- | include/llvm/MDNode.h | 44 | ||||
-rw-r--r-- | include/llvm/Value.h | 2 |
3 files changed, 10 insertions, 42 deletions
diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 6847ac9472..3d8c246914 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -108,7 +108,8 @@ namespace bitc { }; enum MetadataCodes { - METADATA_STRING = 1 // MDString: [values] + METADATA_STRING = 1, // MDString: [values] + METADATA_NODE = 2 // MDNODE: [n x (type num, value num)] }; // The constants block (CONSTANTS_BLOCK_ID) describes emission for each // constant and maintains an implicit current type value. @@ -131,8 +132,7 @@ namespace bitc { CST_CODE_CE_SHUFFLEVEC = 16, // CE_SHUFFLEVEC: [opval, opval, opval] CST_CODE_CE_CMP = 17, // CE_CMP: [opty, opval, opval, pred] CST_CODE_INLINEASM = 18, // INLINEASM: [sideeffect,asmstr,conststr] - CST_CODE_CE_SHUFVEC_EX = 19, // SHUFVEC_EX: [opty, opval, opval, opval] - CST_CODE_MDNODE = 21 // MDNODE: [n x (type num, value num)] + CST_CODE_CE_SHUFVEC_EX = 19 // SHUFVEC_EX: [opty, opval, opval, opval] }; /// CastOpcodes - These are values used in the bitcode files to encode which diff --git a/include/llvm/MDNode.h b/include/llvm/MDNode.h index d3af74a804..a06d720bf1 100644 --- a/include/llvm/MDNode.h +++ b/include/llvm/MDNode.h @@ -53,7 +53,7 @@ public: /// 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; + return V->getValueID() == MDStringVal || V->getValueID() == MDNodeVal; } }; @@ -91,53 +91,22 @@ public: //===----------------------------------------------------------------------===// /// MDNode - a tuple of other values. -/// These contain a list of the Constants that represent the metadata. The -/// operand list is always empty, query the element list instead. -/// -/// This class will attempt to keep track of values as they are modified. When -/// a value is replaced the element will be replaced with it, and when the -/// value is deleted the element is set to a null pointer. In order to preserve -/// structural equivalence while the elements mutate, the MDNode may call -/// replaceAllUsesWith on itself. Because of this, users of MDNode must use a -/// WeakVH or CallbackVH to hold the node pointer if there is a chance that one -/// of the elements held by the node may change. +/// These contain a list of the values that represent the metadata. /// -class MDNode : public Constant, public FoldingSetNode { +class MDNode : public MetadataBase, public FoldingSetNode { MDNode(const MDNode &); // DO NOT IMPLEMENT friend class LLVMContextImpl; - friend class ElementVH; - struct ElementVH : public CallbackVH { - MDNode *OwningNode; - - ElementVH(Value *V, MDNode *Parent) - : CallbackVH(V), OwningNode(Parent) {} - - ~ElementVH() {} - - /// deleted - Set this entry in the MDNode to 'null'. This will reallocate - /// the MDNode. - virtual void deleted() { - OwningNode->replaceElement(this->operator Value*(), 0); - } - - /// allUsesReplacedWith - Modify the MDNode by replacing this entry with - /// new_value. This will reallocate the MDNode. - virtual void allUsesReplacedWith(Value *new_value) { - OwningNode->replaceElement(this->operator Value*(), new_value); - } - }; - void replaceElement(Value *From, Value *To); - SmallVector<ElementVH, 4> Node; - typedef SmallVectorImpl<ElementVH>::iterator elem_iterator; + SmallVector<WeakVH, 4> Node; + typedef SmallVectorImpl<WeakVH>::iterator elem_iterator; protected: explicit MDNode(Value*const* Vals, unsigned NumVals); public: - typedef SmallVectorImpl<ElementVH>::const_iterator const_elem_iterator; + typedef SmallVectorImpl<WeakVH>::const_iterator const_elem_iterator; Value *getElement(unsigned i) const { return Node[i]; @@ -176,7 +145,6 @@ public: /// duplicates void Profile(FoldingSetNodeID &ID) const; - virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { llvm_unreachable("This should never be called because MDNodes have no ops"); } diff --git a/include/llvm/Value.h b/include/llvm/Value.h index dd01cabb8c..40b1dab295 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -227,7 +227,7 @@ public: // Markers: ConstantFirstVal = FunctionVal, - ConstantLastVal = MDNodeVal + ConstantLastVal = ConstantPointerNullVal }; /// getValueID - Return an ID for the concrete type of this object. This is |