diff options
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.h')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.h b/lib/Bitcode/Writer/ValueEnumerator.h index 40eeabb2b6aa..da63dde2a279 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.h +++ b/lib/Bitcode/Writer/ValueEnumerator.h @@ -22,9 +22,11 @@ namespace llvm { class Type; class Value; +class Instruction; class BasicBlock; class Function; class Module; +class MetadataBase; class AttrListPtr; class TypeSymbolTable; class ValueSymbolTable; @@ -44,11 +46,17 @@ private: typedef DenseMap<const Value*, unsigned> ValueMapType; ValueMapType ValueMap; ValueList Values; + ValueList MDValues; + ValueMapType MDValueMap; typedef DenseMap<void*, unsigned> AttributeMapType; AttributeMapType AttributeMap; std::vector<AttrListPtr> Attributes; + typedef DenseMap<const Instruction*, unsigned> InstructionMapType; + InstructionMapType InstructionMap; + unsigned InstructionCount; + /// BasicBlocks - This contains all the basic blocks for the currently /// incorporated function. Their reverse mapping is stored in ValueMap. std::vector<const BasicBlock*> BasicBlocks; @@ -64,18 +72,17 @@ private: public: ValueEnumerator(const Module *M); - unsigned getValueID(const Value *V) const { - ValueMapType::const_iterator I = ValueMap.find(V); - assert(I != ValueMap.end() && "Value not in slotcalculator!"); - return I->second-1; - } - + unsigned getValueID(const Value *V) const; + unsigned getTypeID(const Type *T) const { TypeMapType::const_iterator I = TypeMap.find(T); assert(I != TypeMap.end() && "Type not in ValueEnumerator!"); return I->second-1; } - + + unsigned getInstructionID(const Instruction *I) const; + void setInstructionID(const Instruction *I); + unsigned getAttributeID(const AttrListPtr &PAL) const { if (PAL.isEmpty()) return 0; // Null maps to zero. AttributeMapType::const_iterator I = AttributeMap.find(PAL.getRawPointer()); @@ -91,6 +98,7 @@ public: } const ValueList &getValues() const { return Values; } + const ValueList &getMDValues() const { return MDValues; } const TypeList &getTypes() const { return Types; } const std::vector<const BasicBlock*> &getBasicBlocks() const { return BasicBlocks; @@ -108,6 +116,7 @@ public: private: void OptimizeConstants(unsigned CstStart, unsigned CstEnd); + void EnumerateMetadata(const MetadataBase *MD); void EnumerateValue(const Value *V); void EnumerateType(const Type *T); void EnumerateOperandType(const Value *V); |