mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 20:06:03 +03:00
[svn r384] Some minor code cleanups.
This commit is contained in:
parent
4bcbe1cf68
commit
27674069e7
5 changed files with 5 additions and 48 deletions
|
@ -798,16 +798,6 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp)
|
||||||
{
|
{
|
||||||
DValue* res = DtoCallDFunc(newexp->allocator, newexp->newargs);
|
DValue* res = DtoCallDFunc(newexp->allocator, newexp->newargs);
|
||||||
mem = DtoBitCast(res->getRVal(), DtoType(tc), "newclass_custom");
|
mem = DtoBitCast(res->getRVal(), DtoType(tc), "newclass_custom");
|
||||||
|
|
||||||
// DtoForceDeclareDsymbol(newexp->allocator);
|
|
||||||
// assert(newexp->newargs);
|
|
||||||
// assert(newexp->newargs->dim == 1);
|
|
||||||
//
|
|
||||||
// llvm::Function* fn = newexp->allocator->ir.irFunc->func;
|
|
||||||
// assert(fn);
|
|
||||||
// DValue* arg = ((Expression*)newexp->newargs->data[0])->toElem(gIR);
|
|
||||||
// mem = gIR->CreateCallOrInvoke(fn, arg->getRVal(), "newclass_custom_alloc")->get();
|
|
||||||
// mem = DtoBitCast(mem, DtoType(tc), "newclass_custom");
|
|
||||||
}
|
}
|
||||||
// default allocator
|
// default allocator
|
||||||
else
|
else
|
||||||
|
@ -1089,8 +1079,6 @@ void ClassDeclaration::offsetToIndex(Type* t, unsigned os, std::vector<unsigned>
|
||||||
assert(r != (unsigned)-1 && "Offset not found in any aggregate field");
|
assert(r != (unsigned)-1 && "Offset not found in any aggregate field");
|
||||||
// vtable is 0, monitor is 1
|
// vtable is 0, monitor is 1
|
||||||
r += 2;
|
r += 2;
|
||||||
// interface offset further
|
|
||||||
//r += vtblInterfaces->dim;
|
|
||||||
// the final index was not pushed
|
// the final index was not pushed
|
||||||
result.push_back(r);
|
result.push_back(r);
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1095,6 @@ LLValue* DtoIndexClass(LLValue* ptr, ClassDeclaration* cd, Type* t, unsigned os,
|
||||||
|
|
||||||
const LLType* st = DtoType(cd->type);
|
const LLType* st = DtoType(cd->type);
|
||||||
if (ptr->getType() != st) {
|
if (ptr->getType() != st) {
|
||||||
//assert(cd->ir.irStruct->hasUnions);
|
|
||||||
ptr = gIR->ir->CreateBitCast(ptr, st, "tmp");
|
ptr = gIR->ir->CreateBitCast(ptr, st, "tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,8 +1103,6 @@ LLValue* DtoIndexClass(LLValue* ptr, ClassDeclaration* cd, Type* t, unsigned os,
|
||||||
|
|
||||||
IrStruct* irstruct = cd->ir.irStruct;
|
IrStruct* irstruct = cd->ir.irStruct;
|
||||||
for (IrStruct::OffsetMap::iterator i=irstruct->offsets.begin(); i!=irstruct->offsets.end(); ++i) {
|
for (IrStruct::OffsetMap::iterator i=irstruct->offsets.begin(); i!=irstruct->offsets.end(); ++i) {
|
||||||
//for (unsigned i=0; i<cd->fields.dim; ++i) {
|
|
||||||
//VarDeclaration* vd = (VarDeclaration*)cd->fields.data[i];
|
|
||||||
VarDeclaration* vd = i->second.var;
|
VarDeclaration* vd = i->second.var;
|
||||||
assert(vd);
|
assert(vd);
|
||||||
Type* vdtype = DtoDType(vd->type);
|
Type* vdtype = DtoDType(vd->type);
|
||||||
|
@ -1195,9 +1180,6 @@ LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl)
|
||||||
Logger::cout() << "funcval casted: " << *funcval << '\n';
|
Logger::cout() << "funcval casted: " << *funcval << '\n';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//assert(funcval->getType() == DtoType(fdecl->type));
|
|
||||||
//cc = DtoCallingConv(fdecl->linkage);
|
|
||||||
|
|
||||||
return funcval;
|
return funcval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,12 +212,6 @@ const llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
|
||||||
return DtoVaFunctionType(fdecl);
|
return DtoVaFunctionType(fdecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unittest has null type, just build it manually
|
|
||||||
/*if (fdecl->isUnitTestDeclaration()) {
|
|
||||||
std::vector<const LLType*> args;
|
|
||||||
return llvm::FunctionType::get(LLType::VoidTy, args, false);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// type has already been resolved
|
// type has already been resolved
|
||||||
if (fdecl->type->ir.type != 0) {
|
if (fdecl->type->ir.type != 0) {
|
||||||
return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
|
return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
|
||||||
|
|
|
@ -381,9 +381,7 @@ static LLValue* get_frame_ptr_impl(FuncDeclaration* func, Dsymbol* sc, LLValue*
|
||||||
}
|
}
|
||||||
else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
|
else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
|
||||||
{
|
{
|
||||||
size_t idx = 2;
|
v = DtoGEPi(v,0,2,"tmp");
|
||||||
//idx += cd->ir.irStruct->interfaceVec.size();
|
|
||||||
v = DtoGEPi(v,0,idx,"tmp");
|
|
||||||
v = DtoLoad(v);
|
v = DtoLoad(v);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -395,11 +393,6 @@ static LLValue* get_frame_ptr_impl(FuncDeclaration* func, Dsymbol* sc, LLValue*
|
||||||
else if (ClassDeclaration* cd = sc->isClassDeclaration())
|
else if (ClassDeclaration* cd = sc->isClassDeclaration())
|
||||||
{
|
{
|
||||||
Logger::println("scope is class: %s", cd->toChars());
|
Logger::println("scope is class: %s", cd->toChars());
|
||||||
/*size_t idx = 2;
|
|
||||||
idx += cd->llvmIrStruct->interfaces.size();
|
|
||||||
v = DtoGEPi(v,0,idx,"tmp");
|
|
||||||
Logger::cout() << "gep = " << *v << '\n';
|
|
||||||
v = DtoLoad(v);*/
|
|
||||||
return get_frame_ptr_impl(func, cd->toParent2(), v);
|
return get_frame_ptr_impl(func, cd->toParent2(), v);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
17
gen/toir.cpp
17
gen/toir.cpp
|
@ -174,11 +174,7 @@ DValue* VarExp::toElem(IRState* p)
|
||||||
if (vd->ident == Id::_arguments)
|
if (vd->ident == Id::_arguments)
|
||||||
{
|
{
|
||||||
Logger::println("Id::_arguments");
|
Logger::println("Id::_arguments");
|
||||||
/*if (!vd->ir.getIrValue())
|
LLValue* v = p->func()->_arguments;
|
||||||
vd->ir.getIrValue() = p->func()->decl->irFunc->_arguments;
|
|
||||||
assert(vd->ir.getIrValue());
|
|
||||||
return new DVarValue(vd, vd->ir.getIrValue(), true);*/
|
|
||||||
LLValue* v = p->func()->decl->ir.irFunc->_arguments;
|
|
||||||
assert(v);
|
assert(v);
|
||||||
return new DVarValue(vd, v, true);
|
return new DVarValue(vd, v, true);
|
||||||
}
|
}
|
||||||
|
@ -186,11 +182,7 @@ DValue* VarExp::toElem(IRState* p)
|
||||||
else if (vd->ident == Id::_argptr)
|
else if (vd->ident == Id::_argptr)
|
||||||
{
|
{
|
||||||
Logger::println("Id::_argptr");
|
Logger::println("Id::_argptr");
|
||||||
/*if (!vd->ir.getIrValue())
|
LLValue* v = p->func()->_argptr;
|
||||||
vd->ir.getIrValue() = p->func()->decl->irFunc->_argptr;
|
|
||||||
assert(vd->ir.getIrValue());
|
|
||||||
return new DVarValue(vd, vd->ir.getIrValue(), true);*/
|
|
||||||
LLValue* v = p->func()->decl->ir.irFunc->_argptr;
|
|
||||||
assert(v);
|
assert(v);
|
||||||
return new DVarValue(vd, v, true);
|
return new DVarValue(vd, v, true);
|
||||||
}
|
}
|
||||||
|
@ -1376,7 +1368,6 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||||
}
|
}
|
||||||
LLValue* vthis = l->getRVal();
|
LLValue* vthis = l->getRVal();
|
||||||
if (!vthis2) vthis2 = vthis;
|
if (!vthis2) vthis2 = vthis;
|
||||||
//unsigned cc = (unsigned)-1;
|
|
||||||
|
|
||||||
// super call
|
// super call
|
||||||
if (e1->op == TOKsuper) {
|
if (e1->op == TOKsuper) {
|
||||||
|
@ -1406,7 +1397,6 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||||
DtoForceDeclareDsymbol(fdecl);
|
DtoForceDeclareDsymbol(fdecl);
|
||||||
funcval = fdecl->ir.irFunc->func;
|
funcval = fdecl->ir.irFunc->func;
|
||||||
assert(funcval);
|
assert(funcval);
|
||||||
//assert(funcval->getType() == DtoType(fdecl->type));
|
|
||||||
}
|
}
|
||||||
return new DFuncValue(fdecl, funcval, vthis2);
|
return new DFuncValue(fdecl, funcval, vthis2);
|
||||||
}
|
}
|
||||||
|
@ -2116,7 +2106,6 @@ BinBitExp(And,And);
|
||||||
BinBitExp(Or,Or);
|
BinBitExp(Or,Or);
|
||||||
BinBitExp(Xor,Xor);
|
BinBitExp(Xor,Xor);
|
||||||
BinBitExp(Shl,Shl);
|
BinBitExp(Shl,Shl);
|
||||||
//BinBitExp(Shr,AShr);
|
|
||||||
BinBitExp(Ushr,LShr);
|
BinBitExp(Ushr,LShr);
|
||||||
|
|
||||||
DValue* ShrExp::toElem(IRState* p)
|
DValue* ShrExp::toElem(IRState* p)
|
||||||
|
@ -2157,6 +2146,8 @@ DValue* HaltExp::toElem(IRState* p)
|
||||||
Logger::print("HaltExp::toElem: %s\n", toChars());
|
Logger::print("HaltExp::toElem: %s\n", toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
|
// FIXME: DMD inserts a trap here... we probably should as well !?!
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
DtoAssert(&loc, NULL);
|
DtoAssert(&loc, NULL);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -113,9 +113,6 @@ void Module::genobjfile(int multiobj)
|
||||||
if (!ClassDeclaration::classinfo->type->ir.type)
|
if (!ClassDeclaration::classinfo->type->ir.type)
|
||||||
ClassDeclaration::classinfo->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());
|
ClassDeclaration::classinfo->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());
|
||||||
|
|
||||||
/*if (!Type::typeinfoclass->type->ir.type)
|
|
||||||
Type::typeinfoclass->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());*/
|
|
||||||
|
|
||||||
// process module members
|
// process module members
|
||||||
for (int k=0; k < members->dim; k++) {
|
for (int k=0; k < members->dim; k++) {
|
||||||
Dsymbol* dsym = (Dsymbol*)(members->data[k]);
|
Dsymbol* dsym = (Dsymbol*)(members->data[k]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue