changeset 363:4d7495038ae8 trunk

[svn r384] Some minor code cleanups.
author lindquist
date Mon, 14 Jul 2008 21:49:54 +0200
parents faa03bf92f0d
children 8014dbd24605
files gen/classes.cpp gen/functions.cpp gen/llvmhelpers.cpp gen/toir.cpp gen/toobj.cpp
diffstat 5 files changed, 5 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/gen/classes.cpp	Mon Jul 14 21:03:15 2008 +0200
+++ b/gen/classes.cpp	Mon Jul 14 21:49:54 2008 +0200
@@ -798,16 +798,6 @@
     {
         DValue* res = DtoCallDFunc(newexp->allocator, newexp->newargs);
         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
     else
@@ -1089,8 +1079,6 @@
     assert(r != (unsigned)-1 && "Offset not found in any aggregate field");
     // vtable is 0, monitor is 1
     r += 2;
-    // interface offset further
-    //r += vtblInterfaces->dim;
     // the final index was not pushed
     result.push_back(r); 
 }
@@ -1107,7 +1095,6 @@
 
     const LLType* st = DtoType(cd->type);
     if (ptr->getType() != st) {
-        //assert(cd->ir.irStruct->hasUnions);
         ptr = gIR->ir->CreateBitCast(ptr, st, "tmp");
     }
 
@@ -1116,8 +1103,6 @@
 
     IrStruct* irstruct = cd->ir.irStruct;
     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;
         assert(vd);
         Type* vdtype = DtoDType(vd->type);
@@ -1195,9 +1180,6 @@
     Logger::cout() << "funcval casted: " << *funcval << '\n';
 #endif
 
-    //assert(funcval->getType() == DtoType(fdecl->type));
-    //cc = DtoCallingConv(fdecl->linkage);
-
     return funcval;
 }
 
--- a/gen/functions.cpp	Mon Jul 14 21:03:15 2008 +0200
+++ b/gen/functions.cpp	Mon Jul 14 21:49:54 2008 +0200
@@ -212,12 +212,6 @@
         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
     if (fdecl->type->ir.type != 0) {
         return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
--- a/gen/llvmhelpers.cpp	Mon Jul 14 21:03:15 2008 +0200
+++ b/gen/llvmhelpers.cpp	Mon Jul 14 21:49:54 2008 +0200
@@ -381,9 +381,7 @@
         }
         else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
         {
-            size_t idx = 2;
-            //idx += cd->ir.irStruct->interfaceVec.size();
-            v = DtoGEPi(v,0,idx,"tmp");
+            v = DtoGEPi(v,0,2,"tmp");
             v = DtoLoad(v);
         }
         else
@@ -395,11 +393,6 @@
     else if (ClassDeclaration* cd = sc->isClassDeclaration())
     {
         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);
     }
     else
--- a/gen/toir.cpp	Mon Jul 14 21:03:15 2008 +0200
+++ b/gen/toir.cpp	Mon Jul 14 21:49:54 2008 +0200
@@ -174,11 +174,7 @@
         if (vd->ident == Id::_arguments)
         {
             Logger::println("Id::_arguments");
-            /*if (!vd->ir.getIrValue())
-                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;
+            LLValue* v = p->func()->_arguments;
             assert(v);
             return new DVarValue(vd, v, true);
         }
@@ -186,11 +182,7 @@
         else if (vd->ident == Id::_argptr)
         {
             Logger::println("Id::_argptr");
-            /*if (!vd->ir.getIrValue())
-                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;
+            LLValue* v = p->func()->_argptr;
             assert(v);
             return new DVarValue(vd, v, true);
         }
@@ -1376,7 +1368,6 @@
         }
         LLValue* vthis = l->getRVal();
         if (!vthis2) vthis2 = vthis;
-        //unsigned cc = (unsigned)-1;
 
         // super call
         if (e1->op == TOKsuper) {
@@ -1406,7 +1397,6 @@
             DtoForceDeclareDsymbol(fdecl);
             funcval = fdecl->ir.irFunc->func;
             assert(funcval);
-            //assert(funcval->getType() == DtoType(fdecl->type));
         }
         return new DFuncValue(fdecl, funcval, vthis2);
     }
@@ -2116,7 +2106,6 @@
 BinBitExp(Or,Or);
 BinBitExp(Xor,Xor);
 BinBitExp(Shl,Shl);
-//BinBitExp(Shr,AShr);
 BinBitExp(Ushr,LShr);
 
 DValue* ShrExp::toElem(IRState* p)
@@ -2157,6 +2146,8 @@
     Logger::print("HaltExp::toElem: %s\n", toChars());
     LOG_SCOPE;
 
+    // FIXME: DMD inserts a trap here... we probably should as well !?!
+
 #if 1
     DtoAssert(&loc, NULL);
 #else
--- a/gen/toobj.cpp	Mon Jul 14 21:03:15 2008 +0200
+++ b/gen/toobj.cpp	Mon Jul 14 21:49:54 2008 +0200
@@ -113,9 +113,6 @@
     if (!ClassDeclaration::classinfo->type->ir.type)
         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
     for (int k=0; k < members->dim; k++) {
         Dsymbol* dsym = (Dsymbol*)(members->data[k]);