diff options
| author | Chris Lattner <sabre@nondot.org> | 2001-10-03 19:28:15 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2001-10-03 19:28:15 +0000 |
| commit | 25033250278efdbdbe8a7841be31b35d56483cd9 (patch) | |
| tree | 08820cb940cc8da083025e4058aca948a1df3b83 /llvm/lib | |
| parent | 883ad0b3529c6c9bf39f91810e10ab167619f244 (diff) | |
| download | bcm5719-llvm-25033250278efdbdbe8a7841be31b35d56483cd9.tar.gz bcm5719-llvm-25033250278efdbdbe8a7841be31b35d56483cd9.zip | |
Factor parentness out of Module & GlobalVariable into GlobalValue
Implement SymbolTable debug/dump utility
llvm-svn: 710
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/ConstPoolVals.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Function.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/VMCore/SymbolTable.cpp | 26 |
3 files changed, 34 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstPoolVals.cpp b/llvm/lib/VMCore/ConstPoolVals.cpp index eeb7a43069f..be1e582d157 100644 --- a/llvm/lib/VMCore/ConstPoolVals.cpp +++ b/llvm/lib/VMCore/ConstPoolVals.cpp @@ -343,3 +343,10 @@ ConstPoolPointer *ConstPoolPointer::getNull(const PointerType *Ty) { return Result; } +//---- ConstPoolPointerReference::get() implementation... +// +ConstPoolPointerReference *ConstPoolPointerReference::get(GlobalValue *GV) { + assert(GV->getParent()); + // FIXME: These should all be shared! + return new ConstPoolPointerReference(GV); +} diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 372d0d28b91..6e30fe80a77 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -29,7 +29,6 @@ Method::Method(const MethodType *Ty, const string &name) : GlobalValue(PointerType::get(Ty), Value::MethodVal, name), SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) { assert(::isa<MethodType>(Ty) && "Method signature must be of method type!"); - Parent = 0; } Method::~Method() { @@ -90,7 +89,7 @@ GlobalVariable::GlobalVariable(const Type *Ty, bool isConstant, ConstPoolVal *Initializer = 0, const string &Name = "") : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Name), - Parent(0), Constant(isConstant) { + Constant(isConstant) { if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); assert(!isConstant || hasInitializer() && diff --git a/llvm/lib/VMCore/SymbolTable.cpp b/llvm/lib/VMCore/SymbolTable.cpp index 12bf0c7f1ba..09465305e65 100644 --- a/llvm/lib/VMCore/SymbolTable.cpp +++ b/llvm/lib/VMCore/SymbolTable.cpp @@ -173,3 +173,29 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType, cast<const DerivedType>(NewType)->addAbstractTypeUser(this); } } + + +#ifndef NDEBUG +#include "llvm/Assembly/Writer.h" +#include <algorithm> + +static void DumpVal(const pair<const string, Value *> &V) { + cout << " '%" << V.first << "' = " << V.second << endl; +} + +static void DumpPlane(const pair<const Type *, map<const string, Value *> >&P) { + cout << " Plane: " << P.first << endl; + for_each(P.second.begin(), P.second.end(), DumpVal); +} + +void SymbolTable::dump() const { + cout << "Symbol table dump:\n"; + for_each(begin(), end(), DumpPlane); + + if (ParentSymTab) { + cout << "Parent "; + ParentSymTab->dump(); + } +} + +#endif |

