Mercurial > projects > ldc
comparison gen/typinf.cpp @ 244:a95056b3c996 trunk
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
Did a lot of smaller cleans up here and there.
Replaced more llvm::Foo with LLFoo for common stuff.
Split up tollvm.cpp.
author | lindquist |
---|---|
date | Mon, 09 Jun 2008 09:37:08 +0200 |
parents | 7816aafeea3c |
children | 665b81613475 |
comparison
equal
deleted
inserted
replaced
243:4d006f7b2ada | 244:a95056b3c996 |
---|---|
33 | 33 |
34 #include "gen/irstate.h" | 34 #include "gen/irstate.h" |
35 #include "gen/logger.h" | 35 #include "gen/logger.h" |
36 #include "gen/runtime.h" | 36 #include "gen/runtime.h" |
37 #include "gen/tollvm.h" | 37 #include "gen/tollvm.h" |
38 #include "gen/llvmhelpers.h" | |
38 #include "gen/arrays.h" | 39 #include "gen/arrays.h" |
39 #include "gen/structs.h" | 40 #include "gen/structs.h" |
40 #include "gen/classes.h" | 41 #include "gen/classes.h" |
41 | 42 |
42 #include "ir/irvar.h" | 43 #include "ir/irvar.h" |
277 // this is a declaration of a builtin __initZ var | 278 // this is a declaration of a builtin __initZ var |
278 if (tid->tinfo->builtinTypeInfo()) { | 279 if (tid->tinfo->builtinTypeInfo()) { |
279 LLValue* found = gIR->module->getNamedGlobal(mangled); | 280 LLValue* found = gIR->module->getNamedGlobal(mangled); |
280 if (!found) | 281 if (!found) |
281 { | 282 { |
282 const LLType* t = llvm::OpaqueType::get(); | 283 const LLType* t = LLOpaqueType::get(); |
283 llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module); | 284 llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module); |
284 assert(g); | 285 assert(g); |
285 /*if (!tid->ir.irGlobal) | 286 /*if (!tid->ir.irGlobal) |
286 tid->ir.irGlobal = new IrGlobal(tid);*/ | 287 tid->ir.irGlobal = new IrGlobal(tid);*/ |
287 tid->ir.irGlobal->value = g; | 288 tid->ir.irGlobal->value = g; |
351 LOG_SCOPE; | 352 LOG_SCOPE; |
352 | 353 |
353 ClassDeclaration* base = Type::typeinfotypedef; | 354 ClassDeclaration* base = Type::typeinfotypedef; |
354 DtoResolveClass(base); | 355 DtoResolveClass(base); |
355 | 356 |
356 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 357 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
357 | 358 |
358 // create the symbol | 359 // create the symbol |
359 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 360 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
360 } | 361 } |
361 | 362 |
365 LOG_SCOPE; | 366 LOG_SCOPE; |
366 | 367 |
367 ClassDeclaration* base = Type::typeinfotypedef; | 368 ClassDeclaration* base = Type::typeinfotypedef; |
368 DtoForceConstInitDsymbol(base); | 369 DtoForceConstInitDsymbol(base); |
369 | 370 |
370 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 371 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
371 Logger::cout() << "got stype: " << *stype << '\n'; | 372 Logger::cout() << "got stype: " << *stype << '\n'; |
372 | 373 |
373 // vtbl | 374 // vtbl |
374 std::vector<LLConstant*> sinits; | 375 std::vector<LLConstant*> sinits; |
375 sinits.push_back(base->ir.irStruct->vtbl); | 376 sinits.push_back(base->ir.irStruct->vtbl); |
376 | 377 |
377 // monitor | 378 // monitor |
378 sinits.push_back(getNullPtr(getPtrToType(llvm::Type::Int8Ty))); | 379 sinits.push_back(getNullPtr(getPtrToType(LLType::Int8Ty))); |
379 | 380 |
380 assert(tinfo->ty == Ttypedef); | 381 assert(tinfo->ty == Ttypedef); |
381 TypeTypedef *tc = (TypeTypedef *)tinfo; | 382 TypeTypedef *tc = (TypeTypedef *)tinfo; |
382 TypedefDeclaration *sd = tc->sym; | 383 TypedefDeclaration *sd = tc->sym; |
383 | 384 |
384 // TypeInfo base | 385 // TypeInfo base |
385 //const llvm::PointerType* basept = isaPointer(initZ->getOperand(1)->getType()); | 386 //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType()); |
386 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); | 387 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); |
387 Logger::println("generating base typeinfo"); | 388 Logger::println("generating base typeinfo"); |
388 //sd->basetype = sd->basetype->merge(); | 389 //sd->basetype = sd->basetype->merge(); |
389 | 390 |
390 sd->basetype->getTypeInfo(NULL); // generate vtinfo | 391 sd->basetype->getTypeInfo(NULL); // generate vtinfo |
401 char *name = sd->toPrettyChars(); | 402 char *name = sd->toPrettyChars(); |
402 sinits.push_back(DtoConstString(name)); | 403 sinits.push_back(DtoConstString(name)); |
403 assert(sinits.back()->getType() == stype->getElementType(3)); | 404 assert(sinits.back()->getType() == stype->getElementType(3)); |
404 | 405 |
405 // void[] init | 406 // void[] init |
406 const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty); | 407 const LLPointerType* initpt = getPtrToType(LLType::Int8Ty); |
407 if (tinfo->isZeroInit() || !sd->init) // 0 initializer, or the same as the base type | 408 if (tinfo->isZeroInit() || !sd->init) // 0 initializer, or the same as the base type |
408 { | 409 { |
409 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), getNullPtr(initpt))); | 410 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), getNullPtr(initpt))); |
410 } | 411 } |
411 else | 412 else |
437 LOG_SCOPE; | 438 LOG_SCOPE; |
438 | 439 |
439 ClassDeclaration* base = Type::typeinfoenum; | 440 ClassDeclaration* base = Type::typeinfoenum; |
440 DtoResolveClass(base); | 441 DtoResolveClass(base); |
441 | 442 |
442 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 443 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
443 | 444 |
444 // create the symbol | 445 // create the symbol |
445 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 446 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
446 } | 447 } |
447 | 448 |
451 LOG_SCOPE; | 452 LOG_SCOPE; |
452 | 453 |
453 ClassDeclaration* base = Type::typeinfoenum; | 454 ClassDeclaration* base = Type::typeinfoenum; |
454 DtoForceConstInitDsymbol(base); | 455 DtoForceConstInitDsymbol(base); |
455 | 456 |
456 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 457 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
457 | 458 |
458 // vtbl | 459 // vtbl |
459 std::vector<LLConstant*> sinits; | 460 std::vector<LLConstant*> sinits; |
460 sinits.push_back(base->ir.irStruct->vtbl); | 461 sinits.push_back(base->ir.irStruct->vtbl); |
461 | 462 |
462 // monitor | 463 // monitor |
463 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 464 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
464 | 465 |
465 assert(tinfo->ty == Tenum); | 466 assert(tinfo->ty == Tenum); |
466 TypeEnum *tc = (TypeEnum *)tinfo; | 467 TypeEnum *tc = (TypeEnum *)tinfo; |
467 EnumDeclaration *sd = tc->sym; | 468 EnumDeclaration *sd = tc->sym; |
468 | 469 |
469 // TypeInfo base | 470 // TypeInfo base |
470 //const llvm::PointerType* basept = isaPointer(initZ->getOperand(1)->getType()); | 471 //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType()); |
471 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); | 472 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); |
472 Logger::println("generating base typeinfo"); | 473 Logger::println("generating base typeinfo"); |
473 //sd->basetype = sd->basetype->merge(); | 474 //sd->basetype = sd->basetype->merge(); |
474 | 475 |
475 sd->memtype->getTypeInfo(NULL); // generate vtinfo | 476 sd->memtype->getTypeInfo(NULL); // generate vtinfo |
485 char *name = sd->toPrettyChars(); | 486 char *name = sd->toPrettyChars(); |
486 sinits.push_back(DtoConstString(name)); | 487 sinits.push_back(DtoConstString(name)); |
487 assert(sinits.back()->getType() == stype->getElementType(3)); | 488 assert(sinits.back()->getType() == stype->getElementType(3)); |
488 | 489 |
489 // void[] init | 490 // void[] init |
490 const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty); | 491 const LLPointerType* initpt = getPtrToType(LLType::Int8Ty); |
491 if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type | 492 if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type |
492 { | 493 { |
493 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); | 494 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); |
494 } | 495 } |
495 else | 496 else |
519 static LLConstant* LLVM_D_Declare_TypeInfoBase(TypeInfoDeclaration* tid, ClassDeclaration* cd) | 520 static LLConstant* LLVM_D_Declare_TypeInfoBase(TypeInfoDeclaration* tid, ClassDeclaration* cd) |
520 { | 521 { |
521 ClassDeclaration* base = cd; | 522 ClassDeclaration* base = cd; |
522 DtoResolveClass(base); | 523 DtoResolveClass(base); |
523 | 524 |
524 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 525 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
525 | 526 |
526 // create the symbol | 527 // create the symbol |
527 tid->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); | 528 tid->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); |
528 } | 529 } |
529 | 530 |
530 static LLConstant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd) | 531 static LLConstant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd) |
531 { | 532 { |
532 ClassDeclaration* base = cd; | 533 ClassDeclaration* base = cd; |
533 DtoForceConstInitDsymbol(base); | 534 DtoForceConstInitDsymbol(base); |
534 | 535 |
535 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 536 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
536 | 537 |
537 // vtbl | 538 // vtbl |
538 std::vector<LLConstant*> sinits; | 539 std::vector<LLConstant*> sinits; |
539 sinits.push_back(base->ir.irStruct->vtbl); | 540 sinits.push_back(base->ir.irStruct->vtbl); |
540 | 541 |
541 // monitor | 542 // monitor |
542 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 543 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
543 | 544 |
544 // TypeInfo base | 545 // TypeInfo base |
545 Logger::println("generating base typeinfo"); | 546 Logger::println("generating base typeinfo"); |
546 basetype->getTypeInfo(NULL); | 547 basetype->getTypeInfo(NULL); |
547 assert(basetype->vtinfo); | 548 assert(basetype->vtinfo); |
624 // init typeinfo class | 625 // init typeinfo class |
625 ClassDeclaration* base = Type::typeinfostaticarray; | 626 ClassDeclaration* base = Type::typeinfostaticarray; |
626 DtoResolveClass(base); | 627 DtoResolveClass(base); |
627 | 628 |
628 // get type of typeinfo class | 629 // get type of typeinfo class |
629 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 630 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
630 | 631 |
631 // create the symbol | 632 // create the symbol |
632 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 633 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
633 } | 634 } |
634 | 635 |
640 // init typeinfo class | 641 // init typeinfo class |
641 ClassDeclaration* base = Type::typeinfostaticarray; | 642 ClassDeclaration* base = Type::typeinfostaticarray; |
642 DtoForceConstInitDsymbol(base); | 643 DtoForceConstInitDsymbol(base); |
643 | 644 |
644 // get type of typeinfo class | 645 // get type of typeinfo class |
645 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 646 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
646 | 647 |
647 // initializer vector | 648 // initializer vector |
648 std::vector<LLConstant*> sinits; | 649 std::vector<LLConstant*> sinits; |
649 // first is always the vtable | 650 // first is always the vtable |
650 sinits.push_back(base->ir.irStruct->vtbl); | 651 sinits.push_back(base->ir.irStruct->vtbl); |
651 | 652 |
652 // monitor | 653 // monitor |
653 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 654 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
654 | 655 |
655 // value typeinfo | 656 // value typeinfo |
656 assert(tinfo->ty == Tsarray); | 657 assert(tinfo->ty == Tsarray); |
657 TypeSArray *tc = (TypeSArray *)tinfo; | 658 TypeSArray *tc = (TypeSArray *)tinfo; |
658 tc->next->getTypeInfo(NULL); | 659 tc->next->getTypeInfo(NULL); |
687 // init typeinfo class | 688 // init typeinfo class |
688 ClassDeclaration* base = Type::typeinfoassociativearray; | 689 ClassDeclaration* base = Type::typeinfoassociativearray; |
689 DtoResolveClass(base); | 690 DtoResolveClass(base); |
690 | 691 |
691 // get type of typeinfo class | 692 // get type of typeinfo class |
692 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 693 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
693 | 694 |
694 // create the symbol | 695 // create the symbol |
695 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 696 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
696 } | 697 } |
697 | 698 |
703 // init typeinfo class | 704 // init typeinfo class |
704 ClassDeclaration* base = Type::typeinfoassociativearray; | 705 ClassDeclaration* base = Type::typeinfoassociativearray; |
705 DtoForceConstInitDsymbol(base); | 706 DtoForceConstInitDsymbol(base); |
706 | 707 |
707 // get type of typeinfo class | 708 // get type of typeinfo class |
708 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 709 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
709 | 710 |
710 // initializer vector | 711 // initializer vector |
711 std::vector<LLConstant*> sinits; | 712 std::vector<LLConstant*> sinits; |
712 // first is always the vtable | 713 // first is always the vtable |
713 sinits.push_back(base->ir.irStruct->vtbl); | 714 sinits.push_back(base->ir.irStruct->vtbl); |
714 | 715 |
715 // monitor | 716 // monitor |
716 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 717 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
717 | 718 |
718 // get type | 719 // get type |
719 assert(tinfo->ty == Taarray); | 720 assert(tinfo->ty == Taarray); |
720 TypeAArray *tc = (TypeAArray *)tinfo; | 721 TypeAArray *tc = (TypeAArray *)tinfo; |
721 | 722 |
820 DtoResolveDsymbol(sd); | 821 DtoResolveDsymbol(sd); |
821 | 822 |
822 ClassDeclaration* base = Type::typeinfostruct; | 823 ClassDeclaration* base = Type::typeinfostruct; |
823 DtoResolveClass(base); | 824 DtoResolveClass(base); |
824 | 825 |
825 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 826 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
826 | 827 |
827 // create the symbol | 828 // create the symbol |
828 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 829 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
829 } | 830 } |
830 | 831 |
839 DtoForceConstInitDsymbol(sd); | 840 DtoForceConstInitDsymbol(sd); |
840 | 841 |
841 ClassDeclaration* base = Type::typeinfostruct; | 842 ClassDeclaration* base = Type::typeinfostruct; |
842 DtoForceConstInitDsymbol(base); | 843 DtoForceConstInitDsymbol(base); |
843 | 844 |
844 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 845 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
845 | 846 |
846 // vtbl | 847 // vtbl |
847 std::vector<LLConstant*> sinits; | 848 std::vector<LLConstant*> sinits; |
848 sinits.push_back(base->ir.irStruct->vtbl); | 849 sinits.push_back(base->ir.irStruct->vtbl); |
849 | 850 |
850 // monitor | 851 // monitor |
851 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 852 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
852 | 853 |
853 // char[] name | 854 // char[] name |
854 char *name = sd->toPrettyChars(); | 855 char *name = sd->toPrettyChars(); |
855 sinits.push_back(DtoConstString(name)); | 856 sinits.push_back(DtoConstString(name)); |
856 //Logger::println("************** A"); | 857 //Logger::println("************** A"); |
857 assert(sinits.back()->getType() == stype->getElementType(2)); | 858 assert(sinits.back()->getType() == stype->getElementType(2)); |
858 | 859 |
859 // void[] init | 860 // void[] init |
860 const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty); | 861 const LLPointerType* initpt = getPtrToType(LLType::Int8Ty); |
861 #if 0 | 862 #if 0 |
862 // the implementation of TypeInfo_Struct uses this to determine size. :/ | 863 // the implementation of TypeInfo_Struct uses this to determine size. :/ |
863 if (sd->zeroInit) // 0 initializer, or the same as the base type | 864 if (sd->zeroInit) // 0 initializer, or the same as the base type |
864 { | 865 { |
865 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); | 866 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); |
916 tfeq = (TypeFunction *)tfeq->semantic(0, &sc); | 917 tfeq = (TypeFunction *)tfeq->semantic(0, &sc); |
917 } | 918 } |
918 #endif | 919 #endif |
919 | 920 |
920 //Logger::println("************** B"); | 921 //Logger::println("************** B"); |
921 const llvm::PointerType* ptty = isaPointer(stype->getElementType(4)); | 922 const LLPointerType* ptty = isaPointer(stype->getElementType(4)); |
922 assert(ptty); | 923 assert(ptty); |
923 | 924 |
924 s = search_function(sd, Id::tohash); | 925 s = search_function(sd, Id::tohash); |
925 fdx = s ? s->isFuncDeclaration() : NULL; | 926 fdx = s ? s->isFuncDeclaration() : NULL; |
926 if (fdx) | 927 if (fdx) |
1023 ClassDeclaration* base = Type::typeinfoclass; | 1024 ClassDeclaration* base = Type::typeinfoclass; |
1024 assert(base); | 1025 assert(base); |
1025 DtoResolveClass(base); | 1026 DtoResolveClass(base); |
1026 | 1027 |
1027 // get type of typeinfo class | 1028 // get type of typeinfo class |
1028 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 1029 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
1029 | 1030 |
1030 // create the symbol | 1031 // create the symbol |
1031 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 1032 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
1032 } | 1033 } |
1033 | 1034 |
1040 ClassDeclaration* base = Type::typeinfoclass; | 1041 ClassDeclaration* base = Type::typeinfoclass; |
1041 assert(base); | 1042 assert(base); |
1042 DtoForceConstInitDsymbol(base); | 1043 DtoForceConstInitDsymbol(base); |
1043 | 1044 |
1044 // get type of typeinfo class | 1045 // get type of typeinfo class |
1045 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 1046 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
1046 | 1047 |
1047 // initializer vector | 1048 // initializer vector |
1048 std::vector<LLConstant*> sinits; | 1049 std::vector<LLConstant*> sinits; |
1049 // first is always the vtable | 1050 // first is always the vtable |
1050 sinits.push_back(base->ir.irStruct->vtbl); | 1051 sinits.push_back(base->ir.irStruct->vtbl); |
1051 | 1052 |
1052 // monitor | 1053 // monitor |
1053 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 1054 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
1054 | 1055 |
1055 // get classinfo | 1056 // get classinfo |
1056 assert(tinfo->ty == Tclass); | 1057 assert(tinfo->ty == Tclass); |
1057 TypeClass *tc = (TypeClass *)tinfo; | 1058 TypeClass *tc = (TypeClass *)tinfo; |
1058 DtoForceDeclareDsymbol(tc->sym); | 1059 DtoForceDeclareDsymbol(tc->sym); |
1080 ClassDeclaration* base = Type::typeinfointerface; | 1081 ClassDeclaration* base = Type::typeinfointerface; |
1081 assert(base); | 1082 assert(base); |
1082 DtoResolveClass(base); | 1083 DtoResolveClass(base); |
1083 | 1084 |
1084 // get type of typeinfo class | 1085 // get type of typeinfo class |
1085 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 1086 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
1086 | 1087 |
1087 // create the symbol | 1088 // create the symbol |
1088 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 1089 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
1089 } | 1090 } |
1090 | 1091 |
1097 ClassDeclaration* base = Type::typeinfointerface; | 1098 ClassDeclaration* base = Type::typeinfointerface; |
1098 assert(base); | 1099 assert(base); |
1099 DtoForceConstInitDsymbol(base); | 1100 DtoForceConstInitDsymbol(base); |
1100 | 1101 |
1101 // get type of typeinfo class | 1102 // get type of typeinfo class |
1102 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 1103 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
1103 | 1104 |
1104 // initializer vector | 1105 // initializer vector |
1105 std::vector<LLConstant*> sinits; | 1106 std::vector<LLConstant*> sinits; |
1106 // first is always the vtable | 1107 // first is always the vtable |
1107 sinits.push_back(base->ir.irStruct->vtbl); | 1108 sinits.push_back(base->ir.irStruct->vtbl); |
1108 | 1109 |
1109 // monitor | 1110 // monitor |
1110 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 1111 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
1111 | 1112 |
1112 // get classinfo | 1113 // get classinfo |
1113 assert(tinfo->ty == Tclass); | 1114 assert(tinfo->ty == Tclass); |
1114 TypeClass *tc = (TypeClass *)tinfo; | 1115 TypeClass *tc = (TypeClass *)tinfo; |
1115 assert(tc->sym->ir.irStruct->classInfo); | 1116 assert(tc->sym->ir.irStruct->classInfo); |
1136 ClassDeclaration* base = Type::typeinfotypelist; | 1137 ClassDeclaration* base = Type::typeinfotypelist; |
1137 assert(base); | 1138 assert(base); |
1138 DtoResolveClass(base); | 1139 DtoResolveClass(base); |
1139 | 1140 |
1140 // get type of typeinfo class | 1141 // get type of typeinfo class |
1141 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 1142 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
1142 | 1143 |
1143 // create the symbol | 1144 // create the symbol |
1144 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 1145 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
1145 } | 1146 } |
1146 | 1147 |
1153 ClassDeclaration* base = Type::typeinfotypelist; | 1154 ClassDeclaration* base = Type::typeinfotypelist; |
1154 assert(base); | 1155 assert(base); |
1155 DtoForceConstInitDsymbol(base); | 1156 DtoForceConstInitDsymbol(base); |
1156 | 1157 |
1157 // get type of typeinfo class | 1158 // get type of typeinfo class |
1158 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); | 1159 const LLStructType* stype = isaStruct(base->type->ir.type->get()); |
1159 | 1160 |
1160 // initializer vector | 1161 // initializer vector |
1161 std::vector<LLConstant*> sinits; | 1162 std::vector<LLConstant*> sinits; |
1162 // first is always the vtable | 1163 // first is always the vtable |
1163 sinits.push_back(base->ir.irStruct->vtbl); | 1164 sinits.push_back(base->ir.irStruct->vtbl); |
1164 | 1165 |
1165 // monitor | 1166 // monitor |
1166 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); | 1167 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty))); |
1167 | 1168 |
1168 // create elements array | 1169 // create elements array |
1169 assert(tinfo->ty == Ttuple); | 1170 assert(tinfo->ty == Ttuple); |
1170 TypeTuple *tu = (TypeTuple *)tinfo; | 1171 TypeTuple *tu = (TypeTuple *)tinfo; |
1171 | 1172 |
1185 c = llvm::ConstantExpr::getBitCast(c, tiTy); | 1186 c = llvm::ConstantExpr::getBitCast(c, tiTy); |
1186 arrInits.push_back(c); | 1187 arrInits.push_back(c); |
1187 } | 1188 } |
1188 | 1189 |
1189 // build array type | 1190 // build array type |
1190 const llvm::ArrayType* arrTy = llvm::ArrayType::get(tiTy, dim); | 1191 const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); |
1191 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); | 1192 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); |
1192 | 1193 |
1193 // build the slice | 1194 // build the slice |
1194 LLConstant* slice = DtoConstSlice(DtoConstSize_t(dim), arrC); | 1195 LLConstant* slice = DtoConstSlice(DtoConstSize_t(dim), arrC); |
1195 sinits.push_back(slice); | 1196 sinits.push_back(slice); |