Binary ops had the wrong result type for real op imaginary.

Fixes:
run/creal_03
This commit is contained in:
Christian Kamm
2008-08-17 12:21:53 +02:00
parent d0fec06c7d
commit 521a988e43
3 changed files with 17 additions and 15 deletions

View File

@@ -24,15 +24,15 @@ DValue* DtoBinSub(DValue* lhs, DValue* rhs)
//////////////////////////////////////////////////////////////////////////////
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 @@ DValue* DtoBinDiv(DValue* lhs, DValue* rhs)
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 @@ DValue* DtoBinRem(DValue* lhs, DValue* rhs)
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 );
}

View File

@@ -95,9 +95,11 @@ LLConstant* DtoTypeInfoOf(Type* ty, bool base=true);
// 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();

View File

@@ -653,7 +653,7 @@ DValue* MulExp::toElem(IRState* p)
return DtoComplexMul(loc, type, l, r);
}
return DtoBinMul(l,r);
return DtoBinMul(type, l, r);
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -671,7 +671,7 @@ DValue* MulAssignExp::toElem(IRState* p)
res = DtoComplexMul(loc, type, l, r);
}
else {
res = DtoBinMul(l,r);
res = DtoBinMul(type, l, r);
}
DtoAssign(loc, l, res);
@@ -692,7 +692,7 @@ DValue* DivExp::toElem(IRState* p)
return DtoComplexDiv(loc, type, l, r);
}
return DtoBinDiv(l, r);
return DtoBinDiv(type, l, r);
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -710,7 +710,7 @@ DValue* DivAssignExp::toElem(IRState* p)
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* ModExp::toElem(IRState* p)
DValue* l = e1->toElem(p);
DValue* r = e2->toElem(p);
return DtoBinRem(l, r);
return DtoBinRem(type, l, r);
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -740,7 +740,7 @@ DValue* ModAssignExp::toElem(IRState* p)
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;