Added debugging support.

llvm-svn: 605
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index a41262d..723a71c 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -83,6 +83,44 @@
   return i;
 }
 
+void
+Value::dump() const
+{
+  DebugValue(*this);
+}
+
+ostream&
+operator<<(ostream &o, const Value& I)
+{
+  switch (I.getValueType()) {
+  case Value::TypeVal:       return o << I.castTypeAsserting();
+  case Value::ConstantVal:   WriteToAssembly((const ConstPoolVal*)&I,o);break;
+  case Value::MethodArgumentVal: return o << I.getType() << " "<< I.getName();
+  case Value::InstructionVal:WriteToAssembly((const Instruction *)&I, o);break;
+  case Value::BasicBlockVal: WriteToAssembly((const BasicBlock  *)&I, o);break;
+  case Value::MethodVal:     WriteToAssembly((const Method      *)&I, o);break;
+  case Value::GlobalVal:     WriteToAssembly((const GlobalVariable*)&I,o);break;
+  case Value::ModuleVal:     WriteToAssembly((const Module      *)&I,o); break;
+  default: return o << "<unknown value type: " << I.getValueType() << ">";
+  }
+  return o;
+}
+
+void
+DebugValue(const Value* V)
+{
+  if (V)
+    cerr << *V << endl;
+  else
+    cerr << "<NULL value>" << endl;
+}
+
+void
+DebugValue(const Value& V)
+{
+  cerr << V << endl;
+}
+
 
 //===----------------------------------------------------------------------===//
 //                                 User Class