comparison gen/typinf.cpp @ 275:665b81613475 trunk

[svn r296] Removed: the 'suite' dir, it never took off! Fixed: foreach statement, key-type checks were buggy. Fixed: setting LLVMDC versions on the command line is now an error. Fixed: array compare runtime had incorrect param attrs on call. Fixed: index expressions on dynamic array slices w/o storage was broken. Fixed: scope classes had incorrect finalization in some cases. Fixed: when outputting !ClassInfoS !OffsetTypeInfoS, static class members were trying to be included, crashing the compiler. Fixed: calling LLVMDC with -inline but not any -O option caused assertion failure. Changed: the runtime now uses a single interface to "get" to !TypeInfoS, part of eliminating duplicate !TypeInfo codegen.
author lindquist
date Thu, 19 Jun 2008 17:30:32 +0200
parents a95056b3c996
children ebaf65fc4726
comparison
equal deleted inserted replaced
274:9f228c1e5311 275:665b81613475
381 assert(tinfo->ty == Ttypedef); 381 assert(tinfo->ty == Ttypedef);
382 TypeTypedef *tc = (TypeTypedef *)tinfo; 382 TypeTypedef *tc = (TypeTypedef *)tinfo;
383 TypedefDeclaration *sd = tc->sym; 383 TypedefDeclaration *sd = tc->sym;
384 384
385 // TypeInfo base 385 // TypeInfo base
386 //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType()); 386 LLConstant* castbase = DtoTypeInfoOf(sd->basetype, true);
387 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); 387 assert(castbase->getType() == stype->getElementType(2));
388 Logger::println("generating base typeinfo");
389 //sd->basetype = sd->basetype->merge();
390
391 sd->basetype->getTypeInfo(NULL); // generate vtinfo
392 assert(sd->basetype->vtinfo);
393 DtoForceDeclareDsymbol(sd->basetype->vtinfo);
394
395 assert(sd->basetype->vtinfo->ir.irGlobal->value);
396 assert(llvm::isa<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value));
397 LLConstant* castbase = llvm::cast<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value);
398 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
399 sinits.push_back(castbase); 388 sinits.push_back(castbase);
400 389
401 // char[] name 390 // char[] name
402 char *name = sd->toPrettyChars(); 391 char *name = sd->toPrettyChars();
403 sinits.push_back(DtoConstString(name)); 392 sinits.push_back(DtoConstString(name));
466 assert(tinfo->ty == Tenum); 455 assert(tinfo->ty == Tenum);
467 TypeEnum *tc = (TypeEnum *)tinfo; 456 TypeEnum *tc = (TypeEnum *)tinfo;
468 EnumDeclaration *sd = tc->sym; 457 EnumDeclaration *sd = tc->sym;
469 458
470 // TypeInfo base 459 // TypeInfo base
471 //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType()); 460 LLConstant* castbase = DtoTypeInfoOf(sd->memtype, true);
472 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); 461 assert(castbase->getType() == stype->getElementType(2));
473 Logger::println("generating base typeinfo");
474 //sd->basetype = sd->basetype->merge();
475
476 sd->memtype->getTypeInfo(NULL); // generate vtinfo
477 assert(sd->memtype->vtinfo);
478 DtoForceDeclareDsymbol(sd->memtype->vtinfo);
479
480 assert(llvm::isa<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value));
481 LLConstant* castbase = llvm::cast<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value);
482 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
483 sinits.push_back(castbase); 462 sinits.push_back(castbase);
484 463
485 // char[] name 464 // char[] name
486 char *name = sd->toPrettyChars(); 465 char *name = sd->toPrettyChars();
487 sinits.push_back(DtoConstString(name)); 466 sinits.push_back(DtoConstString(name));
541 520
542 // monitor 521 // monitor
543 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); 522 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
544 523
545 // TypeInfo base 524 // TypeInfo base
546 Logger::println("generating base typeinfo"); 525 LLConstant* castbase = DtoTypeInfoOf(basetype, true);
547 basetype->getTypeInfo(NULL); 526 assert(castbase->getType() == stype->getElementType(2));
548 assert(basetype->vtinfo);
549 DtoForceDeclareDsymbol(basetype->vtinfo);
550 assert(llvm::isa<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value));
551 LLConstant* castbase = llvm::cast<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value);
552 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
553 sinits.push_back(castbase); 527 sinits.push_back(castbase);
554 528
555 // create the symbol 529 // create the symbol
556 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); 530 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits);
557 isaGlobalVar(tid->ir.irGlobal->value)->setInitializer(tiInit); 531 isaGlobalVar(tid->ir.irGlobal->value)->setInitializer(tiInit);
654 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); 628 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
655 629
656 // value typeinfo 630 // value typeinfo
657 assert(tinfo->ty == Tsarray); 631 assert(tinfo->ty == Tsarray);
658 TypeSArray *tc = (TypeSArray *)tinfo; 632 TypeSArray *tc = (TypeSArray *)tinfo;
659 tc->next->getTypeInfo(NULL); 633 LLConstant* castbase = DtoTypeInfoOf(tc->next, true);
660 634 assert(castbase->getType() == stype->getElementType(2));
661 // get symbol
662 assert(tc->next->vtinfo);
663 DtoForceDeclareDsymbol(tc->next->vtinfo);
664 LLConstant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value);
665 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
666 sinits.push_back(castbase); 635 sinits.push_back(castbase);
667 636
668 // length 637 // length
669 sinits.push_back(DtoConstSize_t(tc->dim->toInteger())); 638 sinits.push_back(DtoConstSize_t(tc->dim->toInteger()));
670 639
719 // get type 688 // get type
720 assert(tinfo->ty == Taarray); 689 assert(tinfo->ty == Taarray);
721 TypeAArray *tc = (TypeAArray *)tinfo; 690 TypeAArray *tc = (TypeAArray *)tinfo;
722 691
723 // value typeinfo 692 // value typeinfo
724 tc->next->getTypeInfo(NULL); 693 LLConstant* castbase = DtoTypeInfoOf(tc->next, true);
725 694 assert(castbase->getType() == stype->getElementType(2));
726 // get symbol
727 assert(tc->next->vtinfo);
728 DtoForceDeclareDsymbol(tc->next->vtinfo);
729 LLConstant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value);
730 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
731 sinits.push_back(castbase); 695 sinits.push_back(castbase);
732 696
733 // key typeinfo 697 // key typeinfo
734 tc->index->getTypeInfo(NULL); 698 castbase = DtoTypeInfoOf(tc->index, true);
735 699 assert(castbase->getType() == stype->getElementType(3));
736 // get symbol
737 assert(tc->index->vtinfo);
738 DtoForceDeclareDsymbol(tc->index->vtinfo);
739 castbase = isaConstant(tc->index->vtinfo->ir.irGlobal->value);
740 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(3));
741 sinits.push_back(castbase); 700 sinits.push_back(castbase);
742 701
743 // create the symbol 702 // create the symbol
744 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); 703 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits);
745 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); 704 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
1177 tiTy = getPtrToType(tiTy); 1136 tiTy = getPtrToType(tiTy);
1178 1137
1179 for (size_t i = 0; i < dim; i++) 1138 for (size_t i = 0; i < dim; i++)
1180 { 1139 {
1181 Argument *arg = (Argument *)tu->arguments->data[i]; 1140 Argument *arg = (Argument *)tu->arguments->data[i];
1182 arg->type->getTypeInfo(NULL); 1141 LLConstant* castbase = DtoTypeInfoOf(arg->type, true);
1183 DtoForceDeclareDsymbol(arg->type->vtinfo); 1142 assert(castbase->getType() == tiTy);
1184 assert(arg->type->vtinfo->ir.irGlobal->value); 1143 arrInits.push_back(castbase);
1185 LLConstant* c = isaConstant(arg->type->vtinfo->ir.irGlobal->value);
1186 c = llvm::ConstantExpr::getBitCast(c, tiTy);
1187 arrInits.push_back(c);
1188 } 1144 }
1189 1145
1190 // build array type 1146 // build array type
1191 const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); 1147 const LLArrayType* arrTy = LLArrayType::get(tiTy, dim);
1192 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); 1148 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits);