inline the global 'getInstrOperandRegClass' function into its callers
[oota-llvm.git] / lib / Bitcode / Writer / ValueEnumerator.h
index 3d3cbff8d0e206caa0bba3a1f56b4b486e59294c..40eeabb2b6aa7ccb2b52f02fad3812ba4044c3c2 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -15,6 +15,7 @@
 #define VALUE_ENUMERATOR_H
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/Attributes.h"
 #include <vector>
 
 namespace llvm {
@@ -24,7 +25,7 @@ class Value;
 class BasicBlock;
 class Function;
 class Module;
-class ParamAttrsList;
+class AttrListPtr;
 class TypeSymbolTable;
 class ValueSymbolTable;
 
@@ -44,9 +45,9 @@ private:
   ValueMapType ValueMap;
   ValueList Values;
   
-  typedef DenseMap<const ParamAttrsList*, unsigned> ParamAttrMapType;
-  ParamAttrMapType ParamAttrMap;
-  std::vector<const ParamAttrsList*> ParamAttrs;
+  typedef DenseMap<void*, unsigned> AttributeMapType;
+  AttributeMapType AttributeMap;
+  std::vector<AttrListPtr> Attributes;
   
   /// BasicBlocks - This contains all the basic blocks for the currently
   /// incorporated function.  Their reverse mapping is stored in ValueMap.
@@ -75,10 +76,10 @@ public:
     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!");
+  unsigned getAttributeID(const AttrListPtr &PAL) const {
+    if (PAL.isEmpty()) return 0;  // Null maps to zero.
+    AttributeMapType::const_iterator I = AttributeMap.find(PAL.getRawPointer());
+    assert(I != AttributeMap.end() && "Attribute not in ValueEnumerator!");
     return I->second;
   }
 
@@ -94,15 +95,10 @@ public:
   const std::vector<const BasicBlock*> &getBasicBlocks() const {
     return BasicBlocks; 
   }
-  const std::vector<const ParamAttrsList*> &getParamAttrs() const {
-    return ParamAttrs;
+  const std::vector<AttrListPtr> &getAttributes() const {
+    return Attributes;
   }
 
-  /// 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.
-  int PurgeAggregateValues();
-  
   /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
   /// use these two methods to get its data into the ValueEnumerator!
   ///
@@ -110,9 +106,12 @@ public:
   void purgeFunction();
 
 private:
+  void OptimizeConstants(unsigned CstStart, unsigned CstEnd);
+    
   void EnumerateValue(const Value *V);
   void EnumerateType(const Type *T);
-  void EnumerateParamAttrs(const ParamAttrsList *PAL);
+  void EnumerateOperandType(const Value *V);
+  void EnumerateAttributes(const AttrListPtr &PAL);
   
   void EnumerateTypeSymbolTable(const TypeSymbolTable &ST);
   void EnumerateValueSymbolTable(const ValueSymbolTable &ST);