changeset 164:a64becf2a702 trunk

[svn r180] Fixed complex negation, and tango.math.Math now compiles.
author lindquist
date Mon, 05 May 2008 20:28:59 +0200
parents a8cd9bc1021a
children 9922b9982552
files gen/complex.cpp gen/complex.h gen/toir.cpp tango/tango/math/Math.d tangotests/stdout2.d
diffstat 5 files changed, 31 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gen/complex.cpp	Mon May 05 07:36:29 2008 +0200
+++ b/gen/complex.cpp	Mon May 05 20:28:59 2008 +0200
@@ -282,6 +282,24 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
+DValue* DtoComplexNeg(Type* type, DValue* val)
+{
+    val = DtoComplex(type, val);
+
+    llvm::Value *a, *b, *re, *im;
+
+    // values
+    DtoGetComplexParts(val, a, b);
+
+    // sub up
+    re = gIR->ir->CreateNeg(a, "tmp");
+    im = gIR->ir->CreateNeg(b, "tmp");
+
+    return new DComplexValue(type, re, im);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
 llvm::Value* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs)
 {
     Type* type = lhs->getType();
--- a/gen/complex.h	Mon May 05 07:36:29 2008 +0200
+++ b/gen/complex.h	Mon May 05 20:28:59 2008 +0200
@@ -23,6 +23,7 @@
 DValue* DtoComplexSub(Type* type, DValue* lhs, DValue* rhs);
 DValue* DtoComplexMul(Type* type, DValue* lhs, DValue* rhs);
 DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs);
+DValue* DtoComplexNeg(Type* type, DValue* val);
 
 llvm::Value* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs);
 
--- a/gen/toir.cpp	Mon May 05 07:36:29 2008 +0200
+++ b/gen/toir.cpp	Mon May 05 20:28:59 2008 +0200
@@ -2394,8 +2394,12 @@
     LOG_SCOPE;
 
     DValue* l = e1->toElem(p);
+
+    if (type->iscomplex()) {
+        return DtoComplexNeg(type, l);
+    }
+
     llvm::Value* val = l->getRVal();
-
     Type* t = DtoDType(type);
 
     llvm::Value* zero = 0;
@@ -2407,7 +2411,10 @@
         else if (t->ty == Tfloat64 || t->ty == Tfloat80 || t->ty == Timaginary64 || t->ty == Timaginary80)
             zero = llvm::ConstantFP::get(val->getType(), llvm::APFloat(0.0));
         else
-        assert(0);
+        {
+            Logger::println("unhandled fp negation of type %s", t->toChars());
+            assert(0);
+        }
     }
     else
         assert(0);
--- a/tango/tango/math/Math.d	Mon May 05 07:36:29 2008 +0200
+++ b/tango/tango/math/Math.d	Mon May 05 20:28:59 2008 +0200
@@ -369,6 +369,8 @@
 {
     version (GNU) {
         return tanl(x);
+    } else version (LLVMDC) {
+        return tango.stdc.math.tanl(x);
     } else {
     asm
     {
--- a/tangotests/stdout2.d	Mon May 05 07:36:29 2008 +0200
+++ b/tangotests/stdout2.d	Mon May 05 20:28:59 2008 +0200
@@ -4,5 +4,5 @@
 
 void main()
 {
-    Stdout.formatln("{} {} {}", "a", "b", 1);
+    Stdout.formatln("{} {} {}", "a", "b", 1.0);
 }