mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-10-07 00:26:55 +02:00
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
This commit is contained in:
+58
-58
@@ -61,10 +61,10 @@ DValue* DeclarationExp::toElem(IRState* p)
|
||||
// referenced by nested delegate?
|
||||
if (vd->nestedref) {
|
||||
Logger::println("has nestedref set");
|
||||
assert(vd->irLocal);
|
||||
vd->irLocal->value = gIR->irFunc[p->func()->decl]->nestedVar;
|
||||
assert(vd->irLocal->value);
|
||||
assert(vd->irLocal->nestedIndex >= 0);
|
||||
assert(gIR->irDsymbol[vd].irLocal);
|
||||
gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
|
||||
assert(gIR->irDsymbol[vd].irLocal->value);
|
||||
assert(gIR->irDsymbol[vd].irLocal->nestedIndex >= 0);
|
||||
}
|
||||
// normal stack variable
|
||||
else {
|
||||
@@ -72,16 +72,16 @@ DValue* DeclarationExp::toElem(IRState* p)
|
||||
const llvm::Type* lltype = DtoType(vd->type);
|
||||
llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
|
||||
//allocainst->setAlignment(vd->type->alignsize()); // TODO
|
||||
assert(!vd->irLocal);
|
||||
vd->irLocal = new IrLocal(vd);
|
||||
vd->irLocal->value = allocainst;
|
||||
assert(!gIR->irDsymbol[vd].irLocal);
|
||||
gIR->irDsymbol[vd].irLocal = new IrLocal(vd);
|
||||
gIR->irDsymbol[vd].irLocal->value = allocainst;
|
||||
}
|
||||
|
||||
Logger::cout() << "llvm value for decl: " << *vd->irLocal->value << '\n';
|
||||
Logger::cout() << "llvm value for decl: " << *gIR->irDsymbol[vd].irLocal->value << '\n';
|
||||
DValue* ie = DtoInitializer(vd->init);
|
||||
}
|
||||
|
||||
return new DVarValue(vd, vd->getIrValue(), true);
|
||||
return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
|
||||
}
|
||||
// struct declaration
|
||||
else if (StructDeclaration* s = declaration->isStructDeclaration())
|
||||
@@ -153,11 +153,11 @@ DValue* VarExp::toElem(IRState* p)
|
||||
if (vd->ident == Id::_arguments)
|
||||
{
|
||||
Logger::println("Id::_arguments");
|
||||
/*if (!vd->getIrValue())
|
||||
vd->getIrValue() = p->func()->decl->irFunc->_arguments;
|
||||
assert(vd->getIrValue());
|
||||
return new DVarValue(vd, vd->getIrValue(), true);*/
|
||||
llvm::Value* v = gIR->irFunc[p->func()->decl]->_arguments;
|
||||
/*if (!gIR->irDsymbol[vd].getIrValue())
|
||||
gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_arguments;
|
||||
assert(gIR->irDsymbol[vd].getIrValue());
|
||||
return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/
|
||||
llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_arguments;
|
||||
assert(v);
|
||||
return new DVarValue(vd, v, true);
|
||||
}
|
||||
@@ -165,11 +165,11 @@ DValue* VarExp::toElem(IRState* p)
|
||||
else if (vd->ident == Id::_argptr)
|
||||
{
|
||||
Logger::println("Id::_argptr");
|
||||
/*if (!vd->getIrValue())
|
||||
vd->getIrValue() = p->func()->decl->irFunc->_argptr;
|
||||
assert(vd->getIrValue());
|
||||
return new DVarValue(vd, vd->getIrValue(), true);*/
|
||||
llvm::Value* v = gIR->irFunc[p->func()->decl]->_argptr;
|
||||
/*if (!gIR->irDsymbol[vd].getIrValue())
|
||||
gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_argptr;
|
||||
assert(gIR->irDsymbol[vd].getIrValue());
|
||||
return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/
|
||||
llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_argptr;
|
||||
assert(v);
|
||||
return new DVarValue(vd, v, true);
|
||||
}
|
||||
@@ -186,13 +186,13 @@ DValue* VarExp::toElem(IRState* p)
|
||||
{
|
||||
Logger::println("TypeInfoDeclaration");
|
||||
DtoForceDeclareDsymbol(tid);
|
||||
assert(tid->getIrValue());
|
||||
assert(gIR->irDsymbol[tid].getIrValue());
|
||||
const llvm::Type* vartype = DtoType(type);
|
||||
llvm::Value* m;
|
||||
if (tid->getIrValue()->getType() != getPtrToType(vartype))
|
||||
m = p->ir->CreateBitCast(tid->getIrValue(), vartype, "tmp");
|
||||
if (gIR->irDsymbol[tid].getIrValue()->getType() != getPtrToType(vartype))
|
||||
m = p->ir->CreateBitCast(gIR->irDsymbol[tid].getIrValue(), vartype, "tmp");
|
||||
else
|
||||
m = tid->getIrValue();
|
||||
m = gIR->irDsymbol[tid].getIrValue();
|
||||
return new DVarValue(vd, m, true);
|
||||
}
|
||||
// classinfo
|
||||
@@ -200,8 +200,8 @@ DValue* VarExp::toElem(IRState* p)
|
||||
{
|
||||
Logger::println("ClassInfoDeclaration: %s", cid->cd->toChars());
|
||||
DtoDeclareClassInfo(cid->cd);
|
||||
assert(cid->cd->irStruct->classInfo);
|
||||
return new DVarValue(vd, cid->cd->irStruct->classInfo, true);
|
||||
assert(gIR->irDsymbol[cid->cd].irStruct->classInfo);
|
||||
return new DVarValue(vd, gIR->irDsymbol[cid->cd].irStruct->classInfo, true);
|
||||
}
|
||||
// nested variable
|
||||
else if (vd->nestedref) {
|
||||
@@ -211,16 +211,16 @@ DValue* VarExp::toElem(IRState* p)
|
||||
// function parameter
|
||||
else if (vd->isParameter()) {
|
||||
Logger::println("function param");
|
||||
if (!vd->getIrValue()) {
|
||||
if (!gIR->irDsymbol[vd].getIrValue()) {
|
||||
// TODO: determine this properly
|
||||
// this happens when the DMD frontend generates by pointer wrappers for struct opEquals(S) and opCmp(S)
|
||||
vd->getIrValue() = &p->func()->func->getArgumentList().back();
|
||||
gIR->irDsymbol[vd].getIrValue() = &p->func()->func->getArgumentList().back();
|
||||
}
|
||||
if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->getIrValue())) {
|
||||
return new DVarValue(vd, vd->getIrValue(), true);
|
||||
if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[vd].getIrValue())) {
|
||||
return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
|
||||
}
|
||||
else if (llvm::isa<llvm::Argument>(vd->getIrValue())) {
|
||||
return new DImValue(type, vd->getIrValue());
|
||||
else if (llvm::isa<llvm::Argument>(gIR->irDsymbol[vd].getIrValue())) {
|
||||
return new DImValue(type, gIR->irDsymbol[vd].getIrValue());
|
||||
}
|
||||
else assert(0);
|
||||
}
|
||||
@@ -230,11 +230,11 @@ DValue* VarExp::toElem(IRState* p)
|
||||
vd->toObjFile();
|
||||
DtoConstInitGlobal(vd);
|
||||
}
|
||||
if (!vd->getIrValue() || vd->getIrValue()->getType()->isAbstract()) {
|
||||
if (!gIR->irDsymbol[vd].getIrValue() || gIR->irDsymbol[vd].getIrValue()->getType()->isAbstract()) {
|
||||
Logger::println("global variable not resolved :/ %s", vd->toChars());
|
||||
assert(0);
|
||||
}
|
||||
return new DVarValue(vd, vd->getIrValue(), true);
|
||||
return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
|
||||
}
|
||||
}
|
||||
else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
|
||||
@@ -243,7 +243,7 @@ DValue* VarExp::toElem(IRState* p)
|
||||
if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0)
|
||||
DtoForceDeclareDsymbol(fdecl);
|
||||
}
|
||||
return new DFuncValue(fdecl, gIR->irFunc[fdecl]->func);
|
||||
return new DFuncValue(fdecl, gIR->irDsymbol[fdecl].irFunc->func);
|
||||
}
|
||||
else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration())
|
||||
{
|
||||
@@ -253,8 +253,8 @@ DValue* VarExp::toElem(IRState* p)
|
||||
assert(sdecltype->ty == Tstruct);
|
||||
TypeStruct* ts = (TypeStruct*)sdecltype;
|
||||
assert(ts->sym);
|
||||
assert(ts->sym->irStruct->init);
|
||||
return new DVarValue(type, ts->sym->irStruct->init, true);
|
||||
assert(gIR->irDsymbol[ts->sym].irStruct->init);
|
||||
return new DVarValue(type, gIR->irDsymbol[ts->sym].irStruct->init, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -278,17 +278,17 @@ llvm::Constant* VarExp::toConstElem(IRState* p)
|
||||
assert(sdecltype->ty == Tstruct);
|
||||
TypeStruct* ts = (TypeStruct*)sdecltype;
|
||||
DtoForceConstInitDsymbol(ts->sym);
|
||||
assert(ts->sym->irStruct->constInit);
|
||||
return ts->sym->irStruct->constInit;
|
||||
assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
|
||||
return gIR->irDsymbol[ts->sym].irStruct->constInit;
|
||||
}
|
||||
else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration())
|
||||
{
|
||||
DtoForceDeclareDsymbol(ti);
|
||||
assert(ti->getIrValue());
|
||||
assert(gIR->irDsymbol[ti].getIrValue());
|
||||
const llvm::Type* vartype = DtoType(type);
|
||||
llvm::Constant* m = isaConstant(ti->getIrValue());
|
||||
llvm::Constant* m = isaConstant(gIR->irDsymbol[ti].getIrValue());
|
||||
assert(m);
|
||||
if (ti->getIrValue()->getType() != getPtrToType(vartype))
|
||||
if (gIR->irDsymbol[ti].getIrValue()->getType() != getPtrToType(vartype))
|
||||
m = llvm::ConstantExpr::getBitCast(m, vartype);
|
||||
return m;
|
||||
}
|
||||
@@ -1079,7 +1079,7 @@ DValue* CallExp::toElem(IRState* p)
|
||||
}
|
||||
|
||||
// build type info array
|
||||
assert(Type::typeinfo->irStruct->constInit);
|
||||
assert(gIR->irDsymbol[Type::typeinfo].irStruct->constInit);
|
||||
const llvm::Type* typeinfotype = DtoType(Type::typeinfo->type);
|
||||
const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements());
|
||||
|
||||
@@ -1090,8 +1090,8 @@ DValue* CallExp::toElem(IRState* p)
|
||||
Expression* argexp = (Expression*)arguments->data[i];
|
||||
TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration();
|
||||
DtoForceDeclareDsymbol(tidecl);
|
||||
assert(tidecl->getIrValue());
|
||||
vtypeinfos.push_back(tidecl->getIrValue());
|
||||
assert(gIR->irDsymbol[tidecl].getIrValue());
|
||||
vtypeinfos.push_back(gIR->irDsymbol[tidecl].getIrValue());
|
||||
llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[k], typeinfotype, "tmp");
|
||||
p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,k,"tmp"));
|
||||
}
|
||||
@@ -1233,16 +1233,16 @@ DValue* SymOffExp::toElem(IRState* p)
|
||||
Logger::println("VarDeclaration");
|
||||
|
||||
// handle forward reference
|
||||
if (!vd->llvmDeclared && vd->isDataseg()) {
|
||||
if (!gIR->irDsymbol[vd].declared && vd->isDataseg()) {
|
||||
vd->toObjFile(); // TODO
|
||||
}
|
||||
|
||||
assert(vd->getIrValue());
|
||||
assert(gIR->irDsymbol[vd].getIrValue());
|
||||
Type* t = DtoDType(type);
|
||||
Type* tnext = DtoDType(t->next);
|
||||
Type* vdtype = DtoDType(vd->type);
|
||||
|
||||
llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->getIrValue();
|
||||
llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : gIR->irDsymbol[vd].getIrValue();
|
||||
llvm::Value* varmem = 0;
|
||||
|
||||
if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) {
|
||||
@@ -1317,7 +1317,7 @@ DValue* AddrExp::toElem(IRState* p)
|
||||
FuncDeclaration* fd = fv->func;
|
||||
assert(fd);
|
||||
DtoForceDeclareDsymbol(fd);
|
||||
return new DFuncValue(fd, gIR->irFunc[fd]->func);
|
||||
return new DFuncValue(fd, gIR->irDsymbol[fd].irFunc->func);
|
||||
}
|
||||
else if (DImValue* im = v->isIm()) {
|
||||
Logger::println("is immediate");
|
||||
@@ -1422,7 +1422,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||
// super call
|
||||
if (e1->op == TOKsuper) {
|
||||
DtoForceDeclareDsymbol(fdecl);
|
||||
funcval = gIR->irFunc[fdecl]->func;
|
||||
funcval = gIR->irDsymbol[fdecl].irFunc->func;
|
||||
assert(funcval);
|
||||
}
|
||||
// normal virtual call
|
||||
@@ -1443,7 +1443,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||
// static call
|
||||
else {
|
||||
DtoForceDeclareDsymbol(fdecl);
|
||||
funcval = gIR->irFunc[fdecl]->func;
|
||||
funcval = gIR->irDsymbol[fdecl].irFunc->func;
|
||||
assert(funcval);
|
||||
//assert(funcval->getType() == DtoType(fdecl->type));
|
||||
}
|
||||
@@ -1466,7 +1466,7 @@ DValue* ThisExp::toElem(IRState* p)
|
||||
|
||||
if (VarDeclaration* vd = var->isVarDeclaration()) {
|
||||
llvm::Value* v;
|
||||
v = gIR->irFunc[p->func()->decl]->thisVar;
|
||||
v = gIR->irDsymbol[p->func()->decl].irFunc->thisVar;
|
||||
if (llvm::isa<llvm::AllocaInst>(v))
|
||||
v = new llvm::LoadInst(v, "tmp", p->scopebb());
|
||||
return new DThisValue(vd, v);
|
||||
@@ -1932,7 +1932,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||
}
|
||||
else {
|
||||
assert(ts->sym);
|
||||
DtoStructCopy(emem,ts->sym->irStruct->init);
|
||||
DtoStructCopy(emem,gIR->irDsymbol[ts->sym].irStruct->init);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2216,7 +2216,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
if (DFuncValue* f = u->isFunc()) {
|
||||
//assert(f->vthis);
|
||||
//uval = f->vthis;
|
||||
llvm::Value* nestvar = gIR->irFunc[p->func()->decl]->nestedVar;
|
||||
llvm::Value* nestvar = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
|
||||
if (nestvar)
|
||||
uval = nestvar;
|
||||
else
|
||||
@@ -2256,7 +2256,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
else
|
||||
{
|
||||
DtoForceDeclareDsymbol(func);
|
||||
castfptr = gIR->irFunc[func]->func;
|
||||
castfptr = gIR->irDsymbol[func].irFunc->func;
|
||||
}
|
||||
|
||||
castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0));
|
||||
@@ -2490,7 +2490,7 @@ DValue* FuncExp::toElem(IRState* p)
|
||||
|
||||
llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb());
|
||||
const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0));
|
||||
llvm::Value* llvmNested = gIR->irFunc[p->func()->decl]->nestedVar;
|
||||
llvm::Value* llvmNested = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
|
||||
if (llvmNested == NULL) {
|
||||
llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty);
|
||||
p->ir->CreateStore(nullcontext, context);
|
||||
@@ -2502,8 +2502,8 @@ DValue* FuncExp::toElem(IRState* p)
|
||||
|
||||
llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb());
|
||||
|
||||
assert(gIR->irFunc[fd]->func);
|
||||
llvm::Value* castfptr = new llvm::BitCastInst(gIR->irFunc[fd]->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
|
||||
assert(gIR->irDsymbol[fd].irFunc->func);
|
||||
llvm::Value* castfptr = new llvm::BitCastInst(gIR->irDsymbol[fd].irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
|
||||
new llvm::StoreInst(castfptr, fptr, p->scopebb());
|
||||
|
||||
if (temp)
|
||||
@@ -2632,7 +2632,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
|
||||
unsigned n = elements->dim;
|
||||
|
||||
// unions might have different types for each literal
|
||||
if (sd->irStruct->hasUnions) {
|
||||
if (gIR->irDsymbol[sd].irStruct->hasUnions) {
|
||||
// build the type of the literal
|
||||
std::vector<const llvm::Type*> tys;
|
||||
for (unsigned i=0; i<n; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user