[llvm-commits] CVS: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp ValueEnumerator.h

Chris Lattner sabre at nondot.org
Thu May 3 15:47:01 PDT 2007



Changes in directory llvm/lib/Bitcode/Writer:

ValueEnumerator.cpp updated: 1.8 -> 1.9
ValueEnumerator.h updated: 1.7 -> 1.8
---
Log message:

enumerate parameter attr lists.


---
Diffs of the changes:  (+33 -0)

 ValueEnumerator.cpp |   17 +++++++++++++++++
 ValueEnumerator.h   |   16 ++++++++++++++++
 2 files changed, 33 insertions(+)


Index: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.8 llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.9
--- llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.8	Thu May  3 17:18:21 2007
+++ llvm/lib/Bitcode/Writer/ValueEnumerator.cpp	Thu May  3 17:46:43 2007
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "ValueEnumerator.h"
+#include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/ValueSymbolTable.h"
@@ -143,8 +144,24 @@
   for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
        I != E; ++I)
     EnumerateType(*I);
+  
+  // If this is a function type, enumerate the param attrs.
+  if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty))
+    EnumerateParamAttrs(FTy->getParamAttrs());
 }
 
+void ValueEnumerator::EnumerateParamAttrs(const ParamAttrsList *PAL) {
+  if (PAL == 0) return;  // null is always 0.
+  // Do a lookup.
+  unsigned &Entry = ParamAttrMap[PAL];
+  if (Entry == 0) {
+    // Never saw this before, add it.
+    ParamAttrs.push_back(PAL);
+    Entry = ParamAttrs.size();
+  }
+}
+
+
 /// PurgeAggregateValues - If there are any aggregate values at the end of the
 /// value list, remove them and return the count of the remaining values.  If
 /// there are none, return -1.


Index: llvm/lib/Bitcode/Writer/ValueEnumerator.h
diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.7 llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.8
--- llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.7	Thu Apr 26 00:53:54 2007
+++ llvm/lib/Bitcode/Writer/ValueEnumerator.h	Thu May  3 17:46:43 2007
@@ -24,6 +24,7 @@
 class BasicBlock;
 class Function;
 class Module;
+class ParamAttrsList;
 class TypeSymbolTable;
 class ValueSymbolTable;
 
@@ -43,6 +44,10 @@
   ValueMapType ValueMap;
   ValueList Values;
   
+  typedef DenseMap<const ParamAttrsList*, unsigned> ParamAttrMapType;
+  ParamAttrMapType ParamAttrMap;
+  std::vector<const ParamAttrsList*> ParamAttrs;
+  
   /// BasicBlocks - This contains all the basic blocks for the currently
   /// incorporated function.  Their reverse mapping is stored in ValueMap.
   std::vector<const BasicBlock*> BasicBlocks;
@@ -69,6 +74,13 @@
     assert(I != TypeMap.end() && "Type not in ValueEnumerator!");
     return I->second-1;
   }
+  
+  unsigned getParamAttrID(const ParamAttrsList *PAL) const {
+    if (PAL == 0) return 0;  // Null maps to zero.
+    ParamAttrMapType::const_iterator I = ParamAttrMap.find(PAL);
+    assert(I != ParamAttrMap.end() && "ParamAttr not in ValueEnumerator!");
+    return I->second;
+  }
 
   /// getFunctionConstantRange - Return the range of values that corresponds to
   /// function-local constants.
@@ -82,6 +94,9 @@
   const std::vector<const BasicBlock*> &getBasicBlocks() const {
     return BasicBlocks; 
   }
+  const std::vector<const ParamAttrsList*> getParamAttrs() const {
+    return ParamAttrs;
+  }
 
   /// PurgeAggregateValues - If there are any aggregate values at the end of the
   /// value list, remove them and return the count of the remaining values.  If
@@ -97,6 +112,7 @@
 private:
   void EnumerateValue(const Value *V);
   void EnumerateType(const Type *T);
+  void EnumerateParamAttrs(const ParamAttrsList *PAL);
   
   void EnumerateTypeSymbolTable(const TypeSymbolTable &ST);
   void EnumerateValueSymbolTable(const ValueSymbolTable &ST);






More information about the llvm-commits mailing list