[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp

Chris Lattner sabre at nondot.org
Tue Dec 5 21:50:56 PST 2006



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.221 -> 1.222
---
Log message:

remove more code that was only used by the bc writer


---
Diffs of the changes:  (+2 -90)

 AsmWriter.cpp |   92 +---------------------------------------------------------
 1 files changed, 2 insertions(+), 90 deletions(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.221 llvm/lib/VMCore/AsmWriter.cpp:1.222
--- llvm/lib/VMCore/AsmWriter.cpp:1.221	Tue Dec  5 23:42:32 2006
+++ llvm/lib/VMCore/AsmWriter.cpp	Tue Dec  5 23:50:41 2006
@@ -49,7 +49,6 @@
 
   /// @brief A mapping of Values to slot numbers
   typedef std::map<const Value*, unsigned> ValueMap;
-  typedef std::map<const Type*, unsigned> TypeMap;
 
   /// @brief A plane with next slot number and ValueMap
   struct ValuePlane {
@@ -58,13 +57,6 @@
     ValuePlane() { next_slot = 0; } ///< Make sure we start at 0
   };
 
-  struct TypePlane {
-    unsigned next_slot;
-    TypeMap map;
-    TypePlane() { next_slot = 0; }
-    void clear() { map.clear(); next_slot = 0; }
-  };
-
   /// @brief The map of planes by Type
   typedef std::map<const Type*, ValuePlane> TypedPlanes;
 
@@ -86,7 +78,6 @@
   /// plane.  Its an error to ask for something not in the SlotMachine.
   /// Its an error to ask for a Type*
   int getSlot(const Value *V);
-  int getSlot(const Type*Ty);
 
   /// Determine if a Value has a slot or not
   bool hasSlot(const Value* V);
@@ -149,11 +140,9 @@
 
   /// @brief The TypePlanes map for the module level data
   TypedPlanes mMap;
-  TypePlane mTypes;
 
   /// @brief The TypePlanes map for the function level data
   TypedPlanes fMap;
-  TypePlane fTypes;
 
 /// @}
 
@@ -168,12 +157,7 @@
 
 static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
                                    bool PrintName,
-                                 std::map<const Type *, std::string> &TypeTable,
-                                   SlotMachine *Machine);
-
-static void WriteAsOperandInternal(std::ostream &Out, const Type *T,
-                                   bool PrintName,
-                                 std::map<const Type *, std::string> &TypeTable,
+                               std::map<const Type *, std::string> &TypeTable,
                                    SlotMachine *Machine);
 
 static const Module *getModuleFromVal(const Value *V) {
@@ -653,26 +637,6 @@
   return Out;
 }
 
-/// WriteAsOperandInternal - Write the name of the specified value out to
-/// the specified ostream.  This can be useful when you just want to print
-/// int %reg126, not the whole instruction that generated it.
-///
-static void WriteAsOperandInternal(std::ostream &Out, const Type *T,
-                                   bool PrintName,
-                                  std::map<const Type*, std::string> &TypeTable,
-                                   SlotMachine *Machine) {
-  Out << ' ';
-  int Slot;
-  if (Machine) {
-    Slot = Machine->getSlot(T);
-    if (Slot != -1)
-      Out << '%' << Slot;
-    else
-      Out << "<badref>";
-  } else {
-    Out << T->getDescription();
-  }
-}
 
 /// WriteAsOperand - Write the name of the specified value out to the specified
 /// ostream.  This can be useful when you just want to print int %reg126, not
@@ -686,13 +650,9 @@
 
   fillTypeNameTable(Context, TypeNames);
 
-  // if (PrintType)
-    // printTypeInt(Out, V->getType(), TypeNames);
-
   printTypeInt(Out, Ty, TypeNames);
 
-  WriteAsOperandInternal(Out, Ty, PrintName, TypeNames, 0);
-  return Out;
+  return Out << ' ' << Ty->getDescription();
 }
 
 namespace llvm {
@@ -1468,10 +1428,6 @@
   : TheModule(M)    ///< Saved for lazy initialization.
   , TheFunction(0)
   , FunctionProcessed(false)
-  , mMap()
-  , mTypes()
-  , fMap()
-  , fTypes()
 {
 }
 
@@ -1481,10 +1437,6 @@
   : TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization
   , TheFunction(F) ///< Saved for lazy initialization
   , FunctionProcessed(false)
-  , mMap()
-  , mTypes()
-  , fMap()
-  , fTypes()
 {
 }
 
@@ -1547,7 +1499,6 @@
 void SlotMachine::purgeFunction() {
   SC_DEBUG("begin purgeFunction!\n");
   fMap.clear(); // Simply discard the function level map
-  fTypes.clear();
   TheFunction = 0;
   FunctionProcessed = false;
   SC_DEBUG("end purgeFunction!\n");
@@ -1614,45 +1565,6 @@
   return MVI->second;
 }
 
-/// Get the slot number for a value. This function will assert if you
-/// ask for a Value that hasn't previously been inserted with getOrCreateSlot.
-/// Types are forbidden because Type does not inherit from Value (any more).
-int SlotMachine::getSlot(const Type *Ty) {
-  assert(Ty && "Can't get slot for null Type");
-
-  // Check for uninitialized state and do lazy initialization
-  this->initialize();
-
-  if (TheFunction) {
-    // Lookup the Type in the function map
-    TypeMap::const_iterator FTI = fTypes.map.find(Ty);
-    // If the Type doesn't exist in the function map
-    if (FTI == fTypes.map.end()) {
-      TypeMap::const_iterator MTI = mTypes.map.find(Ty);
-      // If we didn't find it, it wasn't inserted
-      if (MTI == mTypes.map.end())
-        return -1;
-      // We found it only at the module level
-      return MTI->second;
-
-    // else the value exists in the function map
-    } else {
-      // Return the slot number as the module's contribution to
-      // the type plane plus the index in the function's contribution
-      // to the type plane.
-      return mTypes.next_slot + FTI->second;
-    }
-  }
-
-  // N.B. Can get here only if either !TheFunction
-
-  // Lookup the value in the module's map
-  TypeMap::const_iterator MTI = mTypes.map.find(Ty);
-  // Make sure we found it.
-  if (MTI == mTypes.map.end()) return -1;
-  // Return it.
-  return MTI->second;
-}
 
 // Create a new slot, or return the existing slot if it is already
 // inserted. Note that the logic here parallels getSlot but instead






More information about the llvm-commits mailing list