comparison gen/complex.cpp @ 1426:ae70c438b281

Allow complex -> integral casts.
author Christian Kamm <kamm incasoftware de>
date Thu, 28 May 2009 20:26:26 +0200
parents 3cf0066e6faf
children 087dafe5262a
comparison
equal deleted inserted replaced
1425:925779c19395 1426:ae70c438b281
436 LLValue* v = val->getRVal(); 436 LLValue* v = val->getRVal();
437 LLValue* impart = gIR->ir->CreateExtractValue(v, 1, ".im_part"); 437 LLValue* impart = gIR->ir->CreateExtractValue(v, 1, ".im_part");
438 DImValue* im = new DImValue(to, impart); 438 DImValue* im = new DImValue(to, impart);
439 return DtoCastFloat(loc, im, to); 439 return DtoCastFloat(loc, im, to);
440 } 440 }
441 else if (to->isfloating()) { 441 else if (to->isfloating() || to->isintegral()) {
442 // FIXME: this loads both values, even when we only need one 442 // FIXME: this loads both values, even when we only need one
443 LLValue* v = val->getRVal(); 443 LLValue* v = val->getRVal();
444 LLValue* repart = gIR->ir->CreateExtractValue(v, 0, ".re_part"); 444 LLValue* repart = gIR->ir->CreateExtractValue(v, 0, ".re_part");
445 DImValue* re = new DImValue(to, repart); 445 Type *extractty;
446 if (vty->ty == Tcomplex32) {
447 extractty = Type::tfloat32;
448 } else if (vty->ty == Tcomplex64) {
449 extractty = Type::tfloat64;
450 } else if (vty->ty == Tcomplex80) {
451 extractty = Type::tfloat80;
452 }
453 DImValue* re = new DImValue(extractty, repart);
446 return DtoCastFloat(loc, re, to); 454 return DtoCastFloat(loc, re, to);
447 } 455 }
448 else if (to->ty == Tbool) { 456 else if (to->ty == Tbool) {
449 return new DImValue(_to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty))); 457 return new DImValue(_to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty)));
450 } 458 }