mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
* Incorporate the contents of SymTabValue into Function and Module
* Module no longer subclasses Value git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2355 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5240dac674
commit
11aa4770fe
@ -45,7 +45,8 @@ template class ValueHolder<BasicBlock, Function, Function>;
|
|||||||
Function::Function(const FunctionType *Ty, bool isInternal,
|
Function::Function(const FunctionType *Ty, bool isInternal,
|
||||||
const std::string &name)
|
const std::string &name)
|
||||||
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name),
|
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name),
|
||||||
SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) {
|
BasicBlocks(this), ArgumentList(this, this) {
|
||||||
|
ParentSymTab = SymTab = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Function::~Function() {
|
Function::~Function() {
|
||||||
@ -59,6 +60,7 @@ Function::~Function() {
|
|||||||
// Delete all of the method arguments and unlink from symbol table...
|
// Delete all of the method arguments and unlink from symbol table...
|
||||||
ArgumentList.delete_all();
|
ArgumentList.delete_all();
|
||||||
ArgumentList.setParent(0);
|
ArgumentList.setParent(0);
|
||||||
|
delete SymTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
// Specialize setName to take care of symbol table majik
|
||||||
@ -75,7 +77,8 @@ void Function::setParent(Module *parent) {
|
|||||||
Parent = parent;
|
Parent = parent;
|
||||||
|
|
||||||
// Relink symbol tables together...
|
// Relink symbol tables together...
|
||||||
setParentSymTab(Parent ? Parent->getSymbolTableSure() : 0);
|
ParentSymTab = Parent ? Parent->getSymbolTableSure() : 0;
|
||||||
|
if (SymTab) SymTab->setParentSymTab(ParentSymTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FunctionType *Function::getFunctionType() const {
|
const FunctionType *Function::getFunctionType() const {
|
||||||
@ -86,6 +89,27 @@ const Type *Function::getReturnType() const {
|
|||||||
return getFunctionType()->getReturnType();
|
return getFunctionType()->getReturnType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SymbolTable *Function::getSymbolTableSure() {
|
||||||
|
if (!SymTab) SymTab = new SymbolTable(ParentSymTab);
|
||||||
|
return SymTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hasSymbolTable() - Returns true if there is a symbol table allocated to
|
||||||
|
// this object AND if there is at least one name in it!
|
||||||
|
//
|
||||||
|
bool Function::hasSymbolTable() const {
|
||||||
|
if (!SymTab) return false;
|
||||||
|
|
||||||
|
for (SymbolTable::const_iterator I = SymTab->begin();
|
||||||
|
I != SymTab->end(); ++I) {
|
||||||
|
if (I->second.begin() != I->second.end())
|
||||||
|
return true; // Found nonempty type plane!
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// dropAllReferences() - This function causes all the subinstructions to "let
|
// dropAllReferences() - This function causes all the subinstructions to "let
|
||||||
// go" of all references that they are maintaining. This allows one to
|
// go" of all references that they are maintaining. This allows one to
|
||||||
// 'delete' a whole class at a time, even though there may be circular
|
// 'delete' a whole class at a time, even though there may be circular
|
||||||
|
@ -28,9 +28,9 @@ struct GlobalValueRefMap : public std::map<GlobalValue*, ConstantPointerRef*>{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Module::Module()
|
Module::Module() : GlobalList(this, this), FunctionList(this, this) {
|
||||||
: Value(Type::VoidTy, Value::ModuleVal, ""), SymTabValue(this),
|
GVRefMap = 0;
|
||||||
GlobalList(this, this), FunctionList(this, this), GVRefMap(0) {
|
SymTab = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::~Module() {
|
Module::~Module() {
|
||||||
@ -39,8 +39,29 @@ Module::~Module() {
|
|||||||
GlobalList.setParent(0);
|
GlobalList.setParent(0);
|
||||||
FunctionList.delete_all();
|
FunctionList.delete_all();
|
||||||
FunctionList.setParent(0);
|
FunctionList.setParent(0);
|
||||||
|
delete SymTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SymbolTable *Module::getSymbolTableSure() {
|
||||||
|
if (!SymTab) SymTab = new SymbolTable(0);
|
||||||
|
return SymTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hasSymbolTable() - Returns true if there is a symbol table allocated to
|
||||||
|
// this object AND if there is at least one name in it!
|
||||||
|
//
|
||||||
|
bool Module::hasSymbolTable() const {
|
||||||
|
if (!SymTab) return false;
|
||||||
|
|
||||||
|
for (SymbolTable::const_iterator I = SymTab->begin(), E = SymTab->end();
|
||||||
|
I != E; ++I)
|
||||||
|
if (I->second.begin() != I->second.end())
|
||||||
|
return true; // Found nonempty type plane!
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// getOrInsertFunction - Look up the specified function in the module symbol
|
// getOrInsertFunction - Look up the specified function in the module symbol
|
||||||
// table. If it does not exist, add a prototype for the function and return
|
// table. If it does not exist, add a prototype for the function and return
|
||||||
// it. This is nice because it allows most passes to get away with not handling
|
// it. This is nice because it allows most passes to get away with not handling
|
||||||
|
Loading…
x
Reference in New Issue
Block a user