diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-09-18 12:44:41 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-09-18 12:44:41 +0000 |
commit | bb6a8c08493199745aa3cf8c7ca5b468b3ec5a8e (patch) | |
tree | 14f68fc0b801dbd3b3ea1c238c22943a518e67f4 | |
parent | 8f3f5a87f941cb53892a76f9aa67703156e11df1 (diff) |
Added debugging support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@605 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Value.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index a41262d0c6..723a71cd19 100644 --- a/lib/VMCore/Value.cpp +++ b/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 << "<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 |