# HG changeset patch # User lindquist # Date 1210012139 -7200 # Node ID a64becf2a7024111502a04cd0e5686cbe82ebb62 # Parent a8cd9bc1021aa165507700d7c9eaf7fdf4564c54 [svn r180] Fixed complex negation, and tango.math.Math now compiles. diff -r a8cd9bc1021a -r a64becf2a702 gen/complex.cpp --- 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(); diff -r a8cd9bc1021a -r a64becf2a702 gen/complex.h --- 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); diff -r a8cd9bc1021a -r a64becf2a702 gen/toir.cpp --- 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); diff -r a8cd9bc1021a -r a64becf2a702 tango/tango/math/Math.d --- 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 { diff -r a8cd9bc1021a -r a64becf2a702 tangotests/stdout2.d --- 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); }