[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map

This commit is contained in:
Christian Kamm
2008-05-01 13:05:53 +02:00
parent 48f1a9c507
commit 24726394f6
22 changed files with 465 additions and 487 deletions
+25 -25
View File
@@ -116,7 +116,7 @@ const llvm::Type* DtoType(Type* t)
TypeStruct* ts = (TypeStruct*)t;
assert(ts->sym);
DtoResolveDsymbol(ts->sym);
return ts->sym->irStruct->recty.get();//t->llvmType->get();
return gIR->irDsymbol[ts->sym].irStruct->recty.get();//t->llvmType->get();
}
case Tclass: {
@@ -139,7 +139,7 @@ const llvm::Type* DtoType(Type* t)
TypeClass* tc = (TypeClass*)t;
assert(tc->sym);
DtoResolveDsymbol(tc->sym);
return getPtrToType(tc->sym->irStruct->recty.get());//t->llvmType->get());
return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get());//t->llvmType->get());
}
// functions
@@ -561,8 +561,8 @@ llvm::Constant* DtoConstFieldInitializer(Type* t, Initializer* init)
TypeStruct* ts = (TypeStruct*)t;
assert(ts);
assert(ts->sym);
assert(ts->sym->irStruct->constInit);
_init = ts->sym->irStruct->constInit;
assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
_init = gIR->irDsymbol[ts->sym].irStruct->constInit;
}
else if (t->ty == Tclass)
{
@@ -724,7 +724,7 @@ static const llvm::Type* get_next_frame_ptr_type(Dsymbol* sc)
assert(p->isFuncDeclaration() || p->isClassDeclaration());
if (FuncDeclaration* fd = p->isFuncDeclaration())
{
llvm::Value* v = gIR->irFunc[fd]->nestedVar;
llvm::Value* v = gIR->irDsymbol[fd].irFunc->nestedVar;
assert(v);
return v->getType();
}
@@ -754,9 +754,9 @@ static llvm::Value* get_frame_ptr_impl(FuncDeclaration* func, Dsymbol* sc, llvm:
if (fd->toParent2() == func)
{
if (!gIR->irFunc[func]->nestedVar)
if (!gIR->irDsymbol[func].irFunc->nestedVar)
return NULL;
return DtoBitCast(v, gIR->irFunc[func]->nestedVar->getType());
return DtoBitCast(v, gIR->irDsymbol[func].irFunc->nestedVar->getType());
}
v = DtoBitCast(v, get_next_frame_ptr_type(fd));
@@ -770,7 +770,7 @@ static llvm::Value* get_frame_ptr_impl(FuncDeclaration* func, Dsymbol* sc, llvm:
else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
{
size_t idx = 2;
//idx += cd->irStruct->interfaceVec.size();
//idx += gIR->irDsymbol[cd].irStruct->interfaceVec.size();
v = DtoGEPi(v,0,idx,"tmp");
v = DtoLoad(v);
}
@@ -807,10 +807,10 @@ static llvm::Value* get_frame_ptr(FuncDeclaration* func)
// in the right scope already
if (func == irfunc->decl)
return gIR->irFunc[irfunc->decl]->nestedVar;
return gIR->irDsymbol[irfunc->decl].irFunc->nestedVar;
// use the 'this' pointer
llvm::Value* ptr = gIR->irFunc[irfunc->decl]->thisVar;
llvm::Value* ptr = gIR->irDsymbol[irfunc->decl].irFunc->thisVar;
assert(ptr);
// return the fully resolved frame pointer
@@ -878,10 +878,10 @@ llvm::Value* DtoNestedVariable(VarDeclaration* vd)
assert(ptr && "nested var, but no context");
// we must cast here to be sure. nested classes just have a void*
ptr = DtoBitCast(ptr, gIR->irFunc[func]->nestedVar->getType());
ptr = DtoBitCast(ptr, gIR->irDsymbol[func].irFunc->nestedVar->getType());
// index nested var and load (if necessary)
llvm::Value* v = DtoGEPi(ptr, 0, vd->irLocal->nestedIndex, "tmp");
llvm::Value* v = DtoGEPi(ptr, 0, gIR->irDsymbol[vd].irLocal->nestedIndex, "tmp");
// references must be loaded, for normal variables this IS already the variable storage!!!
if (vd->isParameter() && (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type)))
v = DtoLoad(v);
@@ -964,9 +964,9 @@ void DtoAssign(DValue* lhs, DValue* rhs)
llvm::Value* tmp = rhs->getRVal();
FuncDeclaration* fdecl = gIR->func()->decl;
// respecify the this param
if (!llvm::isa<llvm::AllocaInst>(gIR->irFunc[fdecl]->thisVar))
gIR->irFunc[fdecl]->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
DtoStore(tmp, gIR->irFunc[fdecl]->thisVar);
if (!llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[fdecl].irFunc->thisVar))
gIR->irDsymbol[fdecl].irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
DtoStore(tmp, gIR->irDsymbol[fdecl].irFunc->thisVar);
}
// regular class ref -> class ref assignment
else {
@@ -1572,8 +1572,8 @@ void DtoDefineDsymbol(Dsymbol* dsym)
void DtoConstInitGlobal(VarDeclaration* vd)
{
if (vd->llvmInitialized) return;
vd->llvmInitialized = gIR->dmodule;
if (gIR->irDsymbol[vd].initialized) return;
gIR->irDsymbol[vd].initialized = gIR->dmodule;
Logger::println("* DtoConstInitGlobal(%s)", vd->toChars());
LOG_SCOPE;
@@ -1605,8 +1605,8 @@ void DtoConstInitGlobal(VarDeclaration* vd)
llvm::GlobalVariable* gv = llvm::cast<llvm::GlobalVariable>(_init);
assert(t->ty == Tstruct);
TypeStruct* ts = (TypeStruct*)t;
assert(ts->sym->irStruct->constInit);
_init = ts->sym->irStruct->constInit;
assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
_init = gIR->irDsymbol[ts->sym].irStruct->constInit;
}
// array single value init
else if (isaArray(_type))
@@ -1626,11 +1626,11 @@ void DtoConstInitGlobal(VarDeclaration* vd)
if (_init && _init->getType() != _type)
_type = _init->getType();
llvm::cast<llvm::OpaqueType>(vd->irGlobal->type.get())->refineAbstractTypeTo(_type);
_type = vd->irGlobal->type.get();
llvm::cast<llvm::OpaqueType>(gIR->irDsymbol[vd].irGlobal->type.get())->refineAbstractTypeTo(_type);
_type = gIR->irDsymbol[vd].irGlobal->type.get();
assert(!_type->isAbstract());
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->irGlobal->value);
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(gIR->irDsymbol[vd].irGlobal->value);
if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl))
{
gvar->setInitializer(_init);
@@ -1728,7 +1728,7 @@ void DtoEmptyAllLists()
void DtoForceDeclareDsymbol(Dsymbol* dsym)
{
if (dsym->llvmDeclared) return;
if (gIR->irDsymbol[dsym].declared) return;
Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toPrettyChars());
LOG_SCOPE;
DtoResolveDsymbol(dsym);
@@ -1742,7 +1742,7 @@ void DtoForceDeclareDsymbol(Dsymbol* dsym)
void DtoForceConstInitDsymbol(Dsymbol* dsym)
{
if (dsym->llvmInitialized) return;
if (gIR->irDsymbol[dsym].initialized) return;
Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toPrettyChars());
LOG_SCOPE;
DtoResolveDsymbol(dsym);
@@ -1757,7 +1757,7 @@ void DtoForceConstInitDsymbol(Dsymbol* dsym)
void DtoForceDefineDsymbol(Dsymbol* dsym)
{
if (dsym->llvmDefined) return;
if (gIR->irDsymbol[dsym].defined) return;
Logger::println("DtoForceDefineDsymbol(%s)", dsym->toPrettyChars());
LOG_SCOPE;
DtoResolveDsymbol(dsym);