comparison gen/llvmhelpers.cpp @ 757:2c730d530c98

Special case DtoCastInt for bool.
author Christian Kamm <kamm incasoftware de>
date Mon, 10 Nov 2008 20:55:24 +0100
parents 46d0755451a4
children f04dde6e882c
comparison
equal deleted inserted replaced
756:a58784e0f035 757:2c730d530c98
568 if (rval->getType() == tolltype) { 568 if (rval->getType() == tolltype) {
569 return new DImValue(_to, rval); 569 return new DImValue(_to, rval);
570 } 570 }
571 571
572 if (to->isintegral()) { 572 if (to->isintegral()) {
573 if (fromsz < tosz) { 573 if (fromsz < tosz || from->ty == Tbool) {
574 if (Logger::enabled()) 574 if (Logger::enabled())
575 Logger::cout() << "cast to: " << *tolltype << '\n'; 575 Logger::cout() << "cast to: " << *tolltype << '\n';
576 if (from->isunsigned() || from->ty == Tbool) { 576 if (from->isunsigned() || from->ty == Tbool) {
577 rval = new llvm::ZExtInst(rval, tolltype, "tmp", gIR->scopebb()); 577 rval = new llvm::ZExtInst(rval, tolltype, "tmp", gIR->scopebb());
578 } else { 578 } else {
579 rval = new llvm::SExtInst(rval, tolltype, "tmp", gIR->scopebb()); 579 rval = new llvm::SExtInst(rval, tolltype, "tmp", gIR->scopebb());
580 } 580 }
581 } 581 }
582 else if (fromsz > tosz) { 582 else if (fromsz > tosz || to->ty == Tbool) {
583 rval = new llvm::TruncInst(rval, tolltype, "tmp", gIR->scopebb()); 583 rval = new llvm::TruncInst(rval, tolltype, "tmp", gIR->scopebb());
584 } 584 }
585 else { 585 else {
586 rval = DtoBitCast(rval, tolltype); 586 rval = DtoBitCast(rval, tolltype);
587 } 587 }