mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 07:00:46 +03:00
Make IrDsymbol to be a typesafe union to reduce memory usage
This commit is contained in:
parent
5b15095c81
commit
18f33b1815
27 changed files with 465 additions and 293 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "gen/llvm.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "ir/irdsymbol.h"
|
||||
#include "ir/irfunction.h"
|
||||
#include <sstream>
|
||||
|
||||
|
@ -96,3 +97,22 @@ void IrFunction::setAlwaysInline()
|
|||
func->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
#endif
|
||||
}
|
||||
|
||||
IrFunction *getIrFunc(FuncDeclaration *decl, bool create)
|
||||
{
|
||||
if (!isIrFuncCreated(decl) && create)
|
||||
{
|
||||
assert(decl->ir.irFunc == NULL);
|
||||
decl->ir.irFunc = new IrFunction(decl);
|
||||
decl->ir.m_type = IrDsymbol::FuncType;
|
||||
}
|
||||
assert(decl->ir.irFunc != NULL);
|
||||
return decl->ir.irFunc;
|
||||
}
|
||||
|
||||
bool isIrFuncCreated(FuncDeclaration *decl)
|
||||
{
|
||||
int t = decl->ir.type();
|
||||
assert(t == IrDsymbol::FuncType || t == IrDsymbol::NotSet);
|
||||
return t == IrDsymbol::FuncType;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue