Mercurial > projects > ldc
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);