[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h

Chris Lattner sabre at nondot.org
Fri Feb 9 20:51:37 PST 2007



Changes in directory llvm/lib/Bytecode/Writer:

SlotCalculator.cpp updated: 1.95 -> 1.96
SlotCalculator.h updated: 1.37 -> 1.38
---
Log message:

refactor callers of insertType.  inline insertType into its one remaining caller.


---
Diffs of the changes:  (+11 -23)

 SlotCalculator.cpp |   28 +++++++++++-----------------
 SlotCalculator.h   |    6 ------
 2 files changed, 11 insertions(+), 23 deletions(-)


Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.95 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.96
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.95	Fri Feb  9 22:47:51 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp	Fri Feb  9 22:51:21 2007
@@ -50,17 +50,17 @@
   // Reader.h which uses them directly to extract values of these types.
   SC_DEBUG("Inserting primitive types:\n");
                                     // See WellKnownTypeSlots in Reader.h
-  insertType(Type::VoidTy  ); // 0: VoidTySlot
-  insertType(Type::FloatTy ); // 1: FloatTySlot
-  insertType(Type::DoubleTy); // 2: DoubleTySlot
-  insertType(Type::LabelTy ); // 3: LabelTySlot
+  getOrCreateTypeSlot(Type::VoidTy  ); // 0: VoidTySlot
+  getOrCreateTypeSlot(Type::FloatTy ); // 1: FloatTySlot
+  getOrCreateTypeSlot(Type::DoubleTy); // 2: DoubleTySlot
+  getOrCreateTypeSlot(Type::LabelTy ); // 3: LabelTySlot
   assert(TypeMap.size() == Type::FirstDerivedTyID &&"Invalid primitive insert");
   // Above here *must* correspond 1:1 with the primitive types.
-  insertType(Type::Int1Ty  ); // 4: BoolTySlot
-  insertType(Type::Int8Ty  ); // 5: Int8TySlot
-  insertType(Type::Int16Ty ); // 6: Int16TySlot
-  insertType(Type::Int32Ty ); // 7: Int32TySlot
-  insertType(Type::Int64Ty ); // 8: Int64TySlot
+  getOrCreateTypeSlot(Type::Int1Ty  ); // 4: BoolTySlot
+  getOrCreateTypeSlot(Type::Int8Ty  ); // 5: Int8TySlot
+  getOrCreateTypeSlot(Type::Int16Ty ); // 6: Int16TySlot
+  getOrCreateTypeSlot(Type::Int32Ty ); // 7: Int32TySlot
+  getOrCreateTypeSlot(Type::Int64Ty ); // 8: Int64TySlot
 }
 
 SlotCalculator::SlotCalculator(const Module *M) {
@@ -356,15 +356,9 @@
 }
 
 
-unsigned SlotCalculator::getOrCreateTypeSlot(const Type* T) {
-  int SlotNo = getTypeSlot(T);        // Check to see if it's already in!
+unsigned SlotCalculator::getOrCreateTypeSlot(const Type *Ty) {
+  int SlotNo = getTypeSlot(Ty);        // Check to see if it's already in!
   if (SlotNo != -1) return (unsigned)SlotNo;
-  return insertType(T);
-}
-
-unsigned SlotCalculator::insertType(const Type *Ty) {
-  assert(Ty && "Can't insert a null type!");
-  assert(getTypeSlot(Ty) == -1 && "Type is already in the table!");
 
   // Insert the current type before any subtypes.  This is important because
   // recursive types elements are inserted in a bottom up order.  Changing


Index: llvm/lib/Bytecode/Writer/SlotCalculator.h
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.37 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.38
--- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.37	Fri Feb  9 22:47:51 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.h	Fri Feb  9 22:51:21 2007
@@ -111,12 +111,6 @@
   int getOrCreateSlot(const Value *V);
   unsigned getOrCreateTypeSlot(const Type *T);
 
-  // insertValue - Insert a value into the value table... Return the
-  // slot that it occupies, or -1 if the declaration is to be ignored
-  // because of the IgnoreNamedNodes flag.
-  //
-  unsigned insertType(const Type *T);
-
   // doInsertValue - Small helper function to be called only be insertVal.
   unsigned doInsertType(const Type *T);
 






More information about the llvm-commits mailing list