From df6bbeb59cb29482204c0c4b6be45cf9767494fc Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Tue, 18 Sep 2001 12:44:41 +0000 Subject: [PATCH] Added debugging support. llvm-svn: 605 --- llvm/lib/VMCore/Value.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp index a41262d0c64c..723a71cd195c 100644 --- a/llvm/lib/VMCore/Value.cpp +++ b/llvm/lib/VMCore/Value.cpp @@ -83,6 +83,44 @@ User *Value::use_remove(use_iterator &I) { 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 << ""; + } + return o; +} + +void +DebugValue(const Value* V) +{ + if (V) + cerr << *V << endl; + else + cerr << "" << endl; +} + +void +DebugValue(const Value& V) +{ + cerr << V << endl; +} + //===----------------------------------------------------------------------===// // User Class