diff options
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Bitcode/LLVMBitCodes.h | 7 | ||||
-rw-r--r-- | include/llvm/Constants.h | 52 | ||||
-rw-r--r-- | include/llvm/MDNode.h | 59 | ||||
-rw-r--r-- | include/llvm/Value.h | 2 |
4 files changed, 65 insertions, 55 deletions
diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 753d0ff..6847ac9 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -33,7 +33,8 @@ namespace bitc { CONSTANTS_BLOCK_ID, FUNCTION_BLOCK_ID, TYPE_SYMTAB_BLOCK_ID, - VALUE_SYMTAB_BLOCK_ID + VALUE_SYMTAB_BLOCK_ID, + METADATA_BLOCK_ID }; @@ -106,6 +107,9 @@ namespace bitc { VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N] }; + enum MetadataCodes { + METADATA_STRING = 1 // MDString: [values] + }; // The constants block (CONSTANTS_BLOCK_ID) describes emission for each // constant and maintains an implicit current type value. enum ConstantsCodes { @@ -128,7 +132,6 @@ namespace bitc { 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_MDSTRING = 20, // MDSTRING: [values] CST_CODE_MDNODE = 21 // MDNODE: [n x (type num, value num)] }; diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 3bf8b14..a9a18d7 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -715,58 +715,6 @@ public: return V->getValueID() == UndefValueVal; } }; - -//===----------------------------------------------------------------------===// -/// MDString - a single uniqued string. -/// These are used to efficiently contain a byte sequence for metadata. -/// -class MDString : public Constant { - MDString(const MDString &); // DO NOT IMPLEMENT - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - MDString(const char *begin, const char *end); - - const char *StrBegin, *StrEnd; - friend class LLVMContextImpl; -protected: - // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s, 0); - } -public: - /// size() - The length of this string. - /// - intptr_t size() const { return StrEnd - StrBegin; } - - /// begin() - Pointer to the first byte of the string. - /// - const char *begin() const { return StrBegin; } - - /// end() - Pointer to one byte past the end of the string. - /// - const char *end() const { return StrEnd; } - - /// 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; - } - - virtual void destroyConstant(); - - /// 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; - } -}; - } // End llvm namespace #endif diff --git a/include/llvm/MDNode.h b/include/llvm/MDNode.h index e394436..d3af74a 100644 --- a/include/llvm/MDNode.h +++ b/include/llvm/MDNode.h @@ -31,6 +31,65 @@ namespace llvm { //===----------------------------------------------------------------------===// +// MetadataBase - A base class for MDNode and MDString. +class MetadataBase : public Value { +public: + MetadataBase(const Type *Ty, unsigned scid) + : Value(Ty, scid) {} + + /// 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; + } +}; + +//===----------------------------------------------------------------------===// +/// 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 + + const char *StrBegin, *StrEnd; + friend class LLVMContextImpl; + +public: + MDString(const char *begin, const char *end) + : MetadataBase(Type::MetadataTy, Value::MDStringVal), + StrBegin(begin), StrEnd(end) {} + + intptr_t size() const { return StrEnd - StrBegin; } + + /// begin() - Pointer to the first byte of the string. + /// + const char *begin() const { return StrBegin; } + + /// end() - Pointer to one byte past the end of the string. + /// + const char *end() const { return StrEnd; } + + /// 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 Constants that represent the metadata. The /// operand list is always empty, query the element list instead. diff --git a/include/llvm/Value.h b/include/llvm/Value.h index b220930..dd01cab 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -219,8 +219,8 @@ 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 + MDStringVal, // This is an instance of MDString InlineAsmVal, // This is an instance of InlineAsm PseudoSourceValueVal, // This is an instance of PseudoSourceValue InstructionVal, // This is an instance of Instruction |