Make IrDsymbol to be a typesafe union to reduce memory usage

This commit is contained in:
Alexey Prokhin 2014-09-12 00:17:18 +04:00
parent 5b15095c81
commit 18f33b1815
27 changed files with 465 additions and 293 deletions

View file

@ -18,6 +18,7 @@
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "ir/iraggr.h"
#include "irdsymbol.h"
#include "ir/irtypeclass.h"
#include "ir/irtypestruct.h"
#include <algorithm>
@ -376,3 +377,22 @@ void IrAggr::addFieldInitializers(
}
}
}
IrAggr *getIrAggr(AggregateDeclaration *decl, bool create)
{
if (!isIrAggrCreated(decl) && create)
{
assert(decl->ir.irAggr == NULL);
decl->ir.irAggr = new IrAggr(decl);
decl->ir.m_type = IrDsymbol::AggrType;
}
assert(decl->ir.irAggr != NULL);
return decl->ir.irAggr;
}
bool isIrAggrCreated(AggregateDeclaration *decl)
{
int t = decl->ir.type();
assert(t == IrDsymbol::AggrType || t == IrDsymbol::NotSet);
return t == IrDsymbol::AggrType;
}