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

LLVM llvm at cs.uiuc.edu
Sun May 16 18:49:01 PDT 2004


Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.128.2.1 -> 1.128.2.2

---
Log message:

Changes to reflect interface changes in SymbolTable and the fact that
Type is no longer a Value.


---
Diffs of the changes:  (+28 -35)

Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.128.2.1 llvm/lib/VMCore/AsmWriter.cpp:1.128.2.2
--- llvm/lib/VMCore/AsmWriter.cpp:1.128.2.1	Wed May 12 11:33:43 2004
+++ llvm/lib/VMCore/AsmWriter.cpp	Sun May 16 18:49:32 2004
@@ -59,7 +59,6 @@
 }
 
 static SlotCalculator *createSlotCalculator(const Value *V) {
-  assert(!isa<Type>(V) && "Can't create an SC for a type!");
   if (const Argument *FA = dyn_cast<Argument>(V)) {
     return new SlotCalculator(FA->getParent(), false);
   } else if (const Instruction *I = dyn_cast<Instruction>(V)) {
@@ -105,19 +104,15 @@
                               std::map<const Type *, std::string> &TypeNames) {
   if (!M) return;
   const SymbolTable &ST = M->getSymbolTable();
-  SymbolTable::type_const_iterator PI = ST.find(Type::TypeTy);
-  if (PI != ST.end()) {
-    SymbolTable::value_const_iterator VI = PI->second.begin();
-    for (; VI != PI->second.end(); ++VI) {
-      // As a heuristic, don't insert pointer to primitive types, because
-      // they are used too often to have a single useful name.
-      //
-      const Type *Ty = cast<Type>(VI->second);
-      if (!isa<PointerType>(Ty) ||
-          !cast<PointerType>(Ty)->getElementType()->isPrimitiveType() ||
-          isa<OpaqueType>(cast<PointerType>(Ty)->getElementType()))
-        TypeNames.insert(std::make_pair(Ty, getLLVMName(VI->first)));
-    }
+  SymbolTable::type_const_iterator TI = ST.type_begin();
+  for (; TI != ST.type_end(); ++TI ) {
+    // As a heuristic, don't insert pointer to primitive types, because
+    // they are used too often to have a single useful name.
+    const Type *Ty = TI->second;
+    if (!isa<PointerType>(Ty) ||
+	!cast<PointerType>(Ty)->getElementType()->isPrimitiveType() ||
+        isa<OpaqueType>(cast<PointerType>(Ty)->getElementType()))
+      TypeNames.insert(std::make_pair(Ty, getLLVMName(TI->first)));
   }
 }
 
@@ -401,11 +396,6 @@
       if (Table) {
 	Slot = Table->getSlot(V);
       } else {
-        if (const Type *Ty = dyn_cast<Type>(V)) {
-          Out << Ty->getDescription();
-          return;
-        }
-
         Table = createSlotCalculator(V);
         if (Table == 0) { Out << "BAD VALUE TYPE!"; return; }
 
@@ -606,28 +596,30 @@
 
 
 /// printSymbolTable - Run through symbol table looking for named constants
-/// if a named constant is found, emit it's declaration...
-///
+/// if a named constant is found, emit it's declaration. Do the same for
+/// types.
 void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
-  for (SymbolTable::type_const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
-    SymbolTable::value_const_iterator I = ST.type_begin(TI->first);
-    SymbolTable::value_const_iterator End = ST.type_end(TI->first);
+  for (SymbolTable::plane_const_iterator PI = ST.plane_begin(); 
+       PI != ST.plane_end(); ++PI) {
+    SymbolTable::value_const_iterator I = ST.value_begin(PI->first);
+    SymbolTable::value_const_iterator End = ST.value_end(PI->first);
     
     for (; I != End; ++I) {
       const Value *V = I->second;
       if (const Constant *CPV = dyn_cast<Constant>(V)) {
 	printConstant(CPV);
-      } else if (const Type *Ty = dyn_cast<Type>(V)) {
-        assert(Ty->getType() == Type::TypeTy && TI->first == Type::TypeTy);
-	*Out << "\t" << getLLVMName(I->first) << " = type ";
-
-        // Make sure we print out at least one level of the type structure, so
-        // that we do not get %FILE = type %FILE
-        //
-        printTypeAtLeastOneLevel(Ty) << "\n";
-      }
+      } 
     }
   }
+  for (SymbolTable::type_const_iterator TI = ST.type_begin();
+       TI != ST.type_end(); ++TI ) {
+    const Type* Ty = TI->second;
+    *Out << "\t" << getLLVMName(TI->first) << " = type ";
+
+    // Make sure we print out at least one level of the type structure, so
+    // that we do not get %FILE = type %FILE
+    printTypeAtLeastOneLevel(Ty) << "\n";
+  }
 }
 
 
@@ -1013,7 +1005,7 @@
   o << getType() << " " << getName();
 }
 
-void Value::dump() const { print(std::cerr); }
+void PrintableItem::dump() const { this->print(std::cerr); }
 
 //===----------------------------------------------------------------------===//
 //  CachedWriter Class Implementation
@@ -1039,7 +1031,6 @@
   switch (V->getValueType()) {
   case Value::ConstantVal:
   case Value::ArgumentVal:       AW->writeOperand(V, true, true); break;
-  case Value::TypeVal:           AW->write(cast<Type>(V)); break;
   case Value::InstructionVal:    AW->write(cast<Instruction>(V)); break;
   case Value::BasicBlockVal:     AW->write(cast<BasicBlock>(V)); break;
   case Value::FunctionVal:       AW->write(cast<Function>(V)); break;
@@ -1062,3 +1053,5 @@
   Out = &os;
   if (AW) AW->setStream(os);
 }
+
+// vim: sw=2





More information about the llvm-commits mailing list