Move function codegen data from IrFunction to new FuncGen.

This change reduces memory consumption significantly by releasing the
memory held by the STL containers that are now inside FuncGen.
This commit is contained in:
Christian Kamm
2009-06-20 19:11:44 +02:00
parent 7dbe9baa37
commit 42b3da8ac7
7 changed files with 138 additions and 124 deletions

View File

@@ -93,6 +93,37 @@ void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
FuncGen::FuncGen()
{
landingPad = NULL;
nextUnique.push(0);
}
std::string FuncGen::getScopedLabelName(const char* ident)
{
if(labelScopes.empty())
return std::string(ident);
std::string result = "__";
for(unsigned int i = 0; i < labelScopes.size(); ++i)
result += labelScopes[i] + "_";
return result + ident;
}
void FuncGen::pushUniqueLabelScope(const char* name)
{
std::ostringstream uniquename;
uniquename << name << nextUnique.top()++;
nextUnique.push(0);
labelScopes.push_back(uniquename.str());
}
void FuncGen::popLabelScope()
{
labelScopes.pop_back();
nextUnique.pop();
}
IrFunction::IrFunction(FuncDeclaration* fd)
{
decl = fd;
@@ -116,35 +147,6 @@ IrFunction::IrFunction(FuncDeclaration* fd)
_arguments = NULL;
_argptr = NULL;
landingPad = NULL;
nextUnique.push(0);
}
std::string IrFunction::getScopedLabelName(const char* ident)
{
if(labelScopes.empty())
return std::string(ident);
std::string result = "__";
for(unsigned int i = 0; i < labelScopes.size(); ++i)
result += labelScopes[i] + "_";
return result + ident;
}
void IrFunction::pushUniqueLabelScope(const char* name)
{
std::ostringstream uniquename;
uniquename << name << nextUnique.top()++;
nextUnique.push(0);
labelScopes.push_back(uniquename.str());
}
void IrFunction::popLabelScope()
{
labelScopes.pop_back();
nextUnique.pop();
}
void IrFunction::setNeverInline()