#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
-#include <iosfwd>
#include <string>
namespace llvm {
class AssemblyAnnotationWriter;
class ValueHandleBase;
class LLVMContext;
+class MetadataContextImpl;
//===----------------------------------------------------------------------===//
// Value Class
class Value {
const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
+ unsigned char HasMetadata : 1; // Has a metadata attached to this ?
protected:
/// SubclassOptionalData - This member is similar to SubclassData, however it
/// is for holding information which may be used to aid optimization, but
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
friend class SymbolTable; // Allow SymbolTable to directly poke Name.
friend class ValueHandleBase;
+ friend class MetadataContextImpl;
+ friend class AbstractTypeUser;
ValueName *Name;
void operator=(const Value &); // Do not implement
Value(const Value &); // Do not implement
+protected:
+ /// printCustom - Value subclasses can override this to implement custom
+ /// printing behavior.
+ virtual void printCustom(raw_ostream &O) const;
+
public:
Value(const Type *Ty, unsigned scid);
virtual ~Value();
/// dump - Support for debugging, callable in GDB: V->dump()
//
- virtual void dump() const;
+ void dump() const;
/// print - Implement operator<< on Value.
///
- void print(std::ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
/// All values are typed, get the type of this value.
/// modified.
///
/// This is currently guaranteed to return a StringRef for which data() points
- /// to a valid null terminated string. This usage is deprecated, however, and
- /// clients should not rely on it. If such behavior is needed, clients should
- /// use getNameStr() or switch to an interface that does not depend on null
- /// termination.
+ /// to a valid null terminated string. The use of StringRef.data() is
+ /// deprecated here, however, and clients should not rely on it. If such
+ /// behavior is needed, clients should use expensive getNameStr(), or switch
+ /// to an interface that does not depend on null termination.
StringRef getName() const;
/// getNameStr() - Return the name of the specified value, *constructing a
// 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.
//
GlobalAliasVal, // This is an instance of GlobalAlias
GlobalVariableVal, // This is an instance of GlobalVariable
UndefValueVal, // This is an instance of UndefValue
+ BlockAddressVal, // This is an instance of BlockAddress
ConstantExprVal, // This is an instance of ConstantExpr
ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull
ConstantIntVal, // This is an instance of ConstantInt
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
InstructionVal, // This is an instance of Instruction
return SubclassID;
}
+ /// getRawSubclassOptionalData - Return the raw optional flags value
+ /// contained in this value. This should only be used when testing two
+ /// Values for equivalence.
+ unsigned getRawSubclassOptionalData() const {
+ return SubclassOptionalData;
+ }
+
+ /// hasSameSubclassOptionalData - Test whether the optional flags contained
+ /// in this value are equal to the optional flags in the given value.
+ bool hasSameSubclassOptionalData(const Value *V) const {
+ return SubclassOptionalData == V->SubclassOptionalData;
+ }
+
+ /// intersectOptionalDataWith - Clear any optional flags in this value
+ /// that are not also set in the given value.
+ void intersectOptionalDataWith(const Value *V) {
+ SubclassOptionalData &= V->SubclassOptionalData;
+ }
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Value *) {
return true; // Values are always values.
const BasicBlock *PredBB) const{
return const_cast<Value*>(this)->DoPHITranslation(CurBB, PredBB);
}
+
+ /// hasMetadata - Return true if metadata is attached with this value.
+ bool hasMetadata() const { return HasMetadata; }
};
-inline std::ostream &operator<<(std::ostream &OS, const Value &V) {
- V.print(OS);
- return OS;
-}
inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
V.print(OS);
return OS;