# HG changeset patch # User Christian Kamm # Date 1218968513 -7200 # Node ID ca2dfe98036ca67e961683665df4e86a23616a47 # Parent c9a606d6e6412487ff9993c34c0499153e2f2ff7 Binary ops had the wrong result type for real op imaginary. Fixes: run/creal_03 diff -r c9a606d6e641 -r ca2dfe98036c gen/binops.cpp --- a/gen/binops.cpp Sun Aug 17 11:39:36 2008 +0200 +++ b/gen/binops.cpp Sun Aug 17 12:21:53 2008 +0200 @@ -24,15 +24,15 @@ ////////////////////////////////////////////////////////////////////////////// -DValue* DtoBinMul(DValue* lhs, DValue* rhs) +DValue* DtoBinMul(Type* targettype, DValue* lhs, DValue* rhs) { LLValue* v = gIR->ir->CreateMul(lhs->getRVal(), rhs->getRVal(), "tmp"); - return new DImValue( lhs->getType(), v ); + return new DImValue( targettype, v ); } ////////////////////////////////////////////////////////////////////////////// -DValue* DtoBinDiv(DValue* lhs, DValue* rhs) +DValue* DtoBinDiv(Type* targettype, DValue* lhs, DValue* rhs) { Type* t = lhs->getType(); LLValue *l, *r; @@ -45,12 +45,12 @@ res = gIR->ir->CreateSDiv(l, r, "tmp"); else res = gIR->ir->CreateUDiv(l, r, "tmp"); - return new DImValue( lhs->getType(), res ); + return new DImValue( targettype, res ); } ////////////////////////////////////////////////////////////////////////////// -DValue* DtoBinRem(DValue* lhs, DValue* rhs) +DValue* DtoBinRem(Type* targettype, DValue* lhs, DValue* rhs) { Type* t = lhs->getType(); LLValue *l, *r; @@ -63,5 +63,5 @@ res = gIR->ir->CreateSRem(l, r, "tmp"); else res = gIR->ir->CreateURem(l, r, "tmp"); - return new DImValue( lhs->getType(), res ); + return new DImValue( targettype, res ); } diff -r c9a606d6e641 -r ca2dfe98036c gen/llvmhelpers.h --- a/gen/llvmhelpers.h Sun Aug 17 11:39:36 2008 +0200 +++ b/gen/llvmhelpers.h Sun Aug 17 12:21:53 2008 +0200 @@ -95,9 +95,11 @@ // binary operations DValue* DtoBinAdd(DValue* lhs, DValue* rhs); DValue* DtoBinSub(DValue* lhs, DValue* rhs); -DValue* DtoBinMul(DValue* lhs, DValue* rhs); -DValue* DtoBinDiv(DValue* lhs, DValue* rhs); -DValue* DtoBinRem(DValue* lhs, DValue* rhs); +// these binops need an explicit result type to handling +// to give 'ifloat op float' and 'float op ifloat' the correct type +DValue* DtoBinMul(Type* resulttype, DValue* lhs, DValue* rhs); +DValue* DtoBinDiv(Type* resulttype, DValue* lhs, DValue* rhs); +DValue* DtoBinRem(Type* resulttype, DValue* lhs, DValue* rhs); // target stuff void findDefaultTarget(); diff -r c9a606d6e641 -r ca2dfe98036c gen/toir.cpp --- a/gen/toir.cpp Sun Aug 17 11:39:36 2008 +0200 +++ b/gen/toir.cpp Sun Aug 17 12:21:53 2008 +0200 @@ -653,7 +653,7 @@ return DtoComplexMul(loc, type, l, r); } - return DtoBinMul(l,r); + return DtoBinMul(type, l, r); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -671,7 +671,7 @@ res = DtoComplexMul(loc, type, l, r); } else { - res = DtoBinMul(l,r); + res = DtoBinMul(type, l, r); } DtoAssign(loc, l, res); @@ -692,7 +692,7 @@ return DtoComplexDiv(loc, type, l, r); } - return DtoBinDiv(l, r); + return DtoBinDiv(type, l, r); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -710,7 +710,7 @@ res = DtoComplexDiv(loc, type, l, r); } else { - res = DtoBinDiv(l,r); + res = DtoBinDiv(type, l, r); } DtoAssign(loc, l, res); @@ -727,7 +727,7 @@ DValue* l = e1->toElem(p); DValue* r = e2->toElem(p); - return DtoBinRem(l, r); + return DtoBinRem(type, l, r); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -740,7 +740,7 @@ DValue* l = e1->toElem(p); DValue* r = e2->toElem(p); - DValue* res = DtoBinRem(l, r); + DValue* res = DtoBinRem(type, l, r); DtoAssign(loc, l, res); return res;