diff gen/toir.c @ 53:06ccc817acd4 trunk

[svn r57] Added most basic TypeInfo (rebuild lphobos). Fixed some SymOffExp bugs. Added another typeinfo test case.
author lindquist
date Tue, 23 Oct 2007 07:16:02 +0200
parents 0c77619e803b
children 28e99b04a132
line wrap: on
line diff
--- a/gen/toir.c	Tue Oct 23 05:55:12 2007 +0200
+++ b/gen/toir.c	Tue Oct 23 07:16:02 2007 +0200
@@ -1058,7 +1058,7 @@
         Logger::cout() << "what are we calling? : " << *funcval << '\n';
     }
     assert(llfnty);
-    Logger::cout() << "Function LLVM type: " << *llfnty << '\n';
+    //Logger::cout() << "Function LLVM type: " << *llfnty << '\n';
 
     // argument handling
     llvm::FunctionType::param_iterator argiter = llfnty->param_begin();
@@ -1132,7 +1132,7 @@
         Logger::cout() << *llargs[i] << '\n';
     }
 
-    Logger::cout() << "Calling: " << *funcval->getType() << '\n';
+    //Logger::cout() << "Calling: " << *funcval->getType() << '\n';
 
     // call the function
     llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb());
@@ -1155,7 +1155,7 @@
 
 elem* CastExp::toElem(IRState* p)
 {
-    Logger::print("CastExp::toElem: %s\n", toChars());
+    Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars());
     LOG_SCOPE;
     elem* e = new elem;
     elem* u = e1->toElem(p);
@@ -1363,6 +1363,12 @@
             e = new elem;
             assert(llvalue);
             e->mem = llvalue;
+            const llvm::Type* llt = LLVM_DtoType(t);
+            if (llvalue->getType() != llt) {
+                Logger::cout() << "llt is:" << *llt << '\n';
+                //const llvm::PointerType* vpty = llvm::PointerType::get(llvm::Type::Int8Ty);
+                e->mem = p->ir->CreateBitCast(e->mem, llt, "tmp");
+            }
             e->type = elem::VAL;
         }
         else {
@@ -1465,7 +1471,7 @@
             llvm::Value* vtblidx = llvm::ConstantInt::get(llvm::Type::Int32Ty, (size_t)fdecl->vtblIndex, false);
             funcval = LLVM_DtoGEP(e->arg, zero, zero, "tmp", p->scopebb());
             funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
-            funcval = LLVM_DtoGEP(funcval, zero, vtblidx, "tmp", p->scopebb());
+            funcval = LLVM_DtoGEP(funcval, zero, vtblidx, toChars(), p->scopebb());
             funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
             assert(funcval->getType() == fdecl->llvmValue->getType());
             e->callconv = LLVM_DtoCallingConv(fdecl->linkage);
@@ -1925,6 +1931,10 @@
     {
         e->val = LLVM_DtoDynArrayCompare(op,l->mem,r->mem);
     }
+    else if (t->ty == Tdelegate)
+    {
+        e->val = LLVM_DtoCompareDelegate(op,l->mem,r->mem);
+    }
     else
     {
         assert(0 && "Unsupported EqualExp type");