[svn r380] Improve complex number support.

This commit is contained in:
Christian Kamm
2008-07-14 17:22:43 +02:00
parent 4d24676beb
commit 7e7441a5f8
4 changed files with 61 additions and 43 deletions

View File

@@ -671,6 +671,9 @@ DValue* DtoCastInt(DValue* val, Type* _to)
rval = DtoBitCast(rval, tolltype);
}
}
else if (to->iscomplex()) {
return DtoComplex(to, val);
}
else if (to->isfloating()) {
if (from->isunsigned()) {
rval = new llvm::UIToFPInst(rval, tolltype, "tmp", gIR->scopebb());
@@ -733,13 +736,15 @@ DValue* DtoCastFloat(DValue* val, Type* to)
LLValue* rval;
if (totype->iscomplex()) {
assert(0);
//return new DImValue(to, DtoComplex(to, val));
return DtoComplex(to, val);
}
else if (totype->isfloating()) {
if ((fromtype->ty == Tfloat80 || fromtype->ty == Tfloat64) && (totype->ty == Tfloat80 || totype->ty == Tfloat64)) {
rval = val->getRVal();
}
else if ((fromtype->ty == Timaginary80 || fromtype->ty == Timaginary64) && (totype->ty == Timaginary80 || totype->ty == Timaginary64)) {
rval = val->getRVal();
}
else if (fromsz < tosz) {
rval = new llvm::FPExtInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
}