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

Chris Lattner lattner at cs.uiuc.edu
Sat Jun 26 14:41:00 PDT 2004


Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.143 -> 1.144

---
Log message:

Don't call getValueType directly.  the LLVM optimizer will turn it into the same code anyway :)


---
Diffs of the changes:  (+12 -10)

Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.143 llvm/lib/VMCore/AsmWriter.cpp:1.144
--- llvm/lib/VMCore/AsmWriter.cpp:1.143	Mon Jun 21 16:53:56 2004
+++ llvm/lib/VMCore/AsmWriter.cpp	Sat Jun 26 14:40:40 2004
@@ -1163,16 +1163,18 @@
 
 CachedWriter &CachedWriter::operator<<(const Value *V) {
   assert(AW && SC && "CachedWriter does not have a current module!");
-  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;
-  case Value::GlobalVariableVal: AW->write(cast<GlobalVariable>(V)); break;
-  default: Out << "<unknown value type: " << V->getValueType() << '>'; break;
-  }
+  if (const Instruction *I = dyn_cast<Instruction>(V))
+    AW->write(I);
+  else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V))
+    AW->write(BB);
+  else if (const Function *F = dyn_cast<Function>(V))
+    AW->write(F);
+  else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
+    AW->write(GV);
+  else if (const Type *Ty = dyn_cast<Type>(V))
+    AW->write(Ty);
+  else 
+    AW->writeOperand(V, true, true);
   return *this;
 }
 





More information about the llvm-commits mailing list