X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FValue.h;h=7e7b415ffdeed671b1ba2ec26cf13a283633a236;hb=bdf7a3ade1041e10b2f94f4ef093d040dc32663a;hp=bc741f27b0aaf900474f8f3b3ae42f82d2ac4ba6;hpb=c7f7c1dc5067a36c8ae337610dcbbe55d525c80c;p=oota-llvm.git diff --git a/include/llvm/Value.h b/include/llvm/Value.h index bc741f27b0a..7e7b415ffde 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -34,9 +34,12 @@ class InlineAsm; class ValueSymbolTable; class TypeSymbolTable; template class StringMapEntry; +template +class AssertingVH; typedef StringMapEntry ValueName; class raw_ostream; class AssemblyAnnotationWriter; +class ValueHandleBase; //===----------------------------------------------------------------------===// // Value Class @@ -50,11 +53,21 @@ class AssemblyAnnotationWriter; /// automatically updates the module's symbol table. /// /// Every value has a "use list" that keeps track of which other Values are -/// using this Value. +/// using this Value. A Value can also have an arbitrary number of ValueHandle +/// objects that watch it and listen to RAUW and Destroy events see +/// llvm/Support/ValueHandle.h for details. +/// /// @brief LLVM Value Representation class Value { - const unsigned short SubclassID; // Subclass identifier (for isa/dyn_cast) + const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast) + unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this? protected: + /// SubclassOptionalData - This member is similar to SubclassData, however it + /// is for holding information which may be used to aid optimization, but + /// which may be cleared to zero without affecting conservative + /// interpretation. + unsigned char SubclassOptionalData : 7; + /// SubclassData - This member is defined by this class, but is not used for /// anything. Subclasses can use it to hold whatever state they find useful. /// This field is initialized to zero by the ctor. @@ -65,6 +78,7 @@ private: friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name. friend class SymbolTable; // Allow SymbolTable to directly poke Name. + friend class ValueHandleBase; ValueName *Name; void operator=(const Value &); // Do not implement @@ -132,6 +146,12 @@ public: // Only use when in type resolution situations! void uncheckedReplaceAllUsesWith(Value *V); + /// clearOptionalData - Clear any optional optimization data from this Value. + /// Transformation passes must call this method whenever changing the IR + /// in a way that would affect the values produced by this Value, unless + /// it takes special care to ensure correctness in some other way. + void clearOptionalData() { SubclassOptionalData = 0; } + //---------------------------------------------------------------------- // Methods for handling the chain of uses of this Value. // @@ -195,13 +215,15 @@ public: ConstantStructVal, // This is an instance of ConstantStruct ConstantVectorVal, // This is an instance of ConstantVector ConstantPointerNullVal, // This is an instance of ConstantPointerNull + MDStringVal, // This is an instance of MDString + MDNodeVal, // This is an instance of MDNode InlineAsmVal, // This is an instance of InlineAsm PseudoSourceValueVal, // This is an instance of PseudoSourceValue InstructionVal, // This is an instance of Instruction // Markers: ConstantFirstVal = FunctionVal, - ConstantLastVal = ConstantPointerNullVal + ConstantLastVal = MDNodeVal }; /// getValueID - Return an ID for the concrete type of this object. This is @@ -243,7 +265,7 @@ public: return const_cast(this)->getUnderlyingObject(); } - /// DoPHITranslation - If this value is a PHI node with CurBB as a its parent, + /// DoPHITranslation - If this value is a PHI node with CurBB as its parent, /// return the value in the PHI node corresponding to PredBB. If not, return /// ourself. This is useful if you want to know the value something has in a /// predecessor block. @@ -303,6 +325,19 @@ template <> inline bool isa_impl(const Value &Val) { return isa(Val) || isa(Val) || isa(Val); } + + +// Value* is only 4-byte aligned. +template<> +class PointerLikeTypeTraits { + typedef Value* PT; +public: + static inline void *getAsVoidPointer(PT P) { return P; } + static inline PT getFromVoidPointer(void *P) { + return static_cast(P); + } + enum { NumLowBitsAvailable = 2 }; +}; } // End llvm namespace