diff gen/tollvm.cpp @ 364:8014dbd24605 trunk

[svn r385] Fix lvalue cast problems with -= and friends. Fix complex DtoBoolean.
author ChristianK
date Mon, 14 Jul 2008 22:48:03 +0200
parents f273f5c58a9a
children bfb9d28f045a
line wrap: on
line diff
--- a/gen/tollvm.cpp	Mon Jul 14 21:49:54 2008 +0200
+++ b/gen/tollvm.cpp	Mon Jul 14 22:48:03 2008 +0200
@@ -326,10 +326,13 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
-LLValue* DtoBoolean(LLValue* val)
+LLValue* DtoBoolean(DValue* dval)
 {
+    Type* dtype = dval->getType()->toBasetype();
+    LLValue* val = dval->getRVal();
     const LLType* t = val->getType();
-    if (t->isInteger())
+
+    if (dtype->isintegral())
     {
         if (t == LLType::Int1Ty)
             return val;
@@ -338,16 +341,20 @@
             return new llvm::ICmpInst(llvm::ICmpInst::ICMP_NE, val, zero, "tmp", gIR->scopebb());
         }
     }
-    else if (t->isFloatingPoint())
+    else if (dtype->iscomplex())
+    {
+        return DtoComplexEquals(TOKnotequal, dval, DtoComplex(dtype, new DNullValue(Type::tint8, llvm::ConstantInt::get(LLType::Int8Ty, 0))));
+    }
+    else if (dtype->isfloating())
     {
         LLValue* zero = llvm::Constant::getNullValue(t);
         return new llvm::FCmpInst(llvm::FCmpInst::FCMP_ONE, val, zero, "tmp", gIR->scopebb());
     }
-    else if (isaPointer(t)) {
+    else if (dtype->ty == Tpointer) {
         LLValue* zero = llvm::Constant::getNullValue(t);
         return new llvm::ICmpInst(llvm::ICmpInst::ICMP_NE, val, zero, "tmp", gIR->scopebb());
     }
-    std::cout << "unsupported -> bool : " << *t << '\n';
+    std::cout << "unsupported -> bool : " << dtype->toChars() << " " << *t << '\n';
     assert(0);
     return 0;
 }