comparison gen/llvmhelpers.cpp @ 1560:1d5c3354b3c2

getNullValue is in Constant again Requires LLVM >= r77721
author Benjamin Kramer <benny.kra@gmail.com>
date Fri, 31 Jul 2009 23:01:29 +0200
parents d6e8d5db259f
children 8d086d552909
comparison
equal deleted inserted replaced
1559:06d5cc873350 1560:1d5c3354b3c2
461 461
462 // complex, needs to be first since complex are also floating 462 // complex, needs to be first since complex are also floating
463 if (basetype->iscomplex()) 463 if (basetype->iscomplex())
464 { 464 {
465 const LLType* basefp = DtoComplexBaseType(basetype); 465 const LLType* basefp = DtoComplexBaseType(basetype);
466 LLValue* res = DtoAggrPair(DtoType(type), gIR->context().getNullValue(basefp), gIR->context().getNullValue(basefp)); 466 LLValue* res = DtoAggrPair(DtoType(type), LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp));
467 return new DImValue(type, res); 467 return new DImValue(type, res);
468 } 468 }
469 // integer, floating, pointer and class have no special representation 469 // integer, floating, pointer and class have no special representation
470 else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass) 470 else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass)
471 { 471 {
472 return new DConstValue(type, gIR->context().getNullValue(lltype)); 472 return new DConstValue(type, LLConstant::getNullValue(lltype));
473 } 473 }
474 // dynamic array 474 // dynamic array
475 else if (basety == Tarray) 475 else if (basety == Tarray)
476 { 476 {
477 LLValue* len = DtoConstSize_t(0); 477 LLValue* len = DtoConstSize_t(0);
479 return new DSliceValue(type, len, ptr); 479 return new DSliceValue(type, len, ptr);
480 } 480 }
481 // delegate 481 // delegate
482 else if (basety == Tdelegate) 482 else if (basety == Tdelegate)
483 { 483 {
484 return new DNullValue(type, gIR->context().getNullValue(lltype)); 484 return new DNullValue(type, LLConstant::getNullValue(lltype));
485 } 485 }
486 486
487 // unknown 487 // unknown
488 llvm::cout << "unsupported: null value for " << type->toChars() << '\n'; 488 llvm::cout << "unsupported: null value for " << type->toChars() << '\n';
489 assert(0); 489 assert(0);
574 Logger::cout() << "src: " << *src << "to type: " << *tolltype << '\n'; 574 Logger::cout() << "src: " << *src << "to type: " << *tolltype << '\n';
575 rval = DtoBitCast(src, tolltype); 575 rval = DtoBitCast(src, tolltype);
576 } 576 }
577 else if (totype->ty == Tbool) { 577 else if (totype->ty == Tbool) {
578 LLValue* src = val->getRVal(); 578 LLValue* src = val->getRVal();
579 LLValue* zero = gIR->context().getNullValue(src->getType()); 579 LLValue* zero = LLConstant::getNullValue(src->getType());
580 rval = gIR->ir->CreateICmpNE(src, zero, "tmp"); 580 rval = gIR->ir->CreateICmpNE(src, zero, "tmp");
581 } 581 }
582 else if (totype->isintegral()) { 582 else if (totype->isintegral()) {
583 rval = new llvm::PtrToIntInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); 583 rval = new llvm::PtrToIntInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
584 } 584 }
606 606
607 LLValue* rval; 607 LLValue* rval;
608 608
609 if (totype->ty == Tbool) { 609 if (totype->ty == Tbool) {
610 rval = val->getRVal(); 610 rval = val->getRVal();
611 LLValue* zero = gIR->context().getNullValue(rval->getType()); 611 LLValue* zero = LLConstant::getNullValue(rval->getType());
612 rval = gIR->ir->CreateFCmpUNE(rval, zero, "tmp"); 612 rval = gIR->ir->CreateFCmpUNE(rval, zero, "tmp");
613 } 613 }
614 else if (totype->iscomplex()) { 614 else if (totype->iscomplex()) {
615 return DtoComplex(loc, to, val); 615 return DtoComplex(loc, to, val);
616 } 616 }
1121 } 1121 }
1122 else if (init->isVoidInitializer()) 1122 else if (init->isVoidInitializer())
1123 { 1123 {
1124 Logger::println("const void initializer"); 1124 Logger::println("const void initializer");
1125 const LLType* ty = DtoType(type); 1125 const LLType* ty = DtoType(type);
1126 _init = gIR->context().getNullValue(ty); 1126 _init = LLConstant::getNullValue(ty);
1127 } 1127 }
1128 else { 1128 else {
1129 Logger::println("unsupported const initializer: %s", init->toChars()); 1129 Logger::println("unsupported const initializer: %s", init->toChars());
1130 } 1130 }
1131 return _init; 1131 return _init;