Mercurial > projects > ldc
comparison gen/typinf.cpp @ 136:0e28624814e8 trunk
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
author | lindquist |
---|---|
date | Thu, 17 Jan 2008 03:15:12 +0100 |
parents | 44a95ac7368a |
children | ce7b81fb957f |
comparison
equal
deleted
inserted
replaced
135:176bd52b3cf5 | 136:0e28624814e8 |
---|---|
36 #include "gen/runtime.h" | 36 #include "gen/runtime.h" |
37 #include "gen/tollvm.h" | 37 #include "gen/tollvm.h" |
38 #include "gen/arrays.h" | 38 #include "gen/arrays.h" |
39 #include "gen/structs.h" | 39 #include "gen/structs.h" |
40 #include "gen/classes.h" | 40 #include "gen/classes.h" |
41 | |
42 #include "ir/irvar.h" | |
41 | 43 |
42 /******************************************* | 44 /******************************************* |
43 * Get a canonicalized form of the TypeInfo for use with the internal | 45 * Get a canonicalized form of the TypeInfo for use with the internal |
44 * runtime library routines. Canonicalized in that static arrays are | 46 * runtime library routines. Canonicalized in that static arrays are |
45 * represented as dynamic arrays, enums are represented by their | 47 * represented as dynamic arrays, enums are represented by their |
252 tid->llvmResolved = true; | 254 tid->llvmResolved = true; |
253 | 255 |
254 Logger::println("DtoResolveTypeInfo(%s)", tid->toChars()); | 256 Logger::println("DtoResolveTypeInfo(%s)", tid->toChars()); |
255 LOG_SCOPE; | 257 LOG_SCOPE; |
256 | 258 |
257 tid->llvmIRGlobal = new IRGlobal(tid); | 259 tid->irGlobal = new IrGlobal(tid); |
258 | 260 |
259 gIR->declareList.push_back(tid); | 261 gIR->declareList.push_back(tid); |
260 } | 262 } |
261 | 263 |
262 void DtoDeclareTypeInfo(TypeInfoDeclaration* tid) | 264 void DtoDeclareTypeInfo(TypeInfoDeclaration* tid) |
278 if (!found) | 280 if (!found) |
279 { | 281 { |
280 const llvm::Type* t = llvm::OpaqueType::get(); | 282 const llvm::Type* t = llvm::OpaqueType::get(); |
281 llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module); | 283 llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module); |
282 assert(g); | 284 assert(g); |
283 tid->llvmValue = g; | 285 /*if (!tid->irGlobal) |
286 tid->irGlobal = new IrGlobal(tid);*/ | |
287 tid->irGlobal->value = g; | |
284 mangled.append("__TYPE"); | 288 mangled.append("__TYPE"); |
285 gIR->module->addTypeName(mangled, tid->llvmValue->getType()->getContainedType(0)); | 289 gIR->module->addTypeName(mangled, tid->irGlobal->value->getType()->getContainedType(0)); |
286 Logger::println("Got typeinfo var: %s", tid->llvmValue->getName().c_str()); | 290 Logger::println("Got typeinfo var: %s", tid->irGlobal->value->getName().c_str()); |
287 tid->llvmInitialized = true; | 291 tid->llvmInitialized = true; |
288 tid->llvmDefined = true; | 292 tid->llvmDefined = true; |
289 } | 293 } |
290 else if (!tid->llvmValue) { | 294 else if (!tid->irGlobal->value) { |
291 tid->llvmValue = found; | 295 tid->irGlobal->value = found; |
292 tid->llvmInitialized = true; | 296 tid->llvmInitialized = true; |
293 tid->llvmDefined = true; | 297 tid->llvmDefined = true; |
294 } | 298 } |
295 } | 299 } |
296 // custom typedef | 300 // custom typedef |
350 DtoResolveClass(base); | 354 DtoResolveClass(base); |
351 | 355 |
352 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 356 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
353 | 357 |
354 // create the symbol | 358 // create the symbol |
355 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 359 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
356 } | 360 } |
357 | 361 |
358 void TypeInfoTypedefDeclaration::llvmDefine() | 362 void TypeInfoTypedefDeclaration::llvmDefine() |
359 { | 363 { |
360 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars()); | 364 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars()); |
383 Logger::println("generating base typeinfo"); | 387 Logger::println("generating base typeinfo"); |
384 //sd->basetype = sd->basetype->merge(); | 388 //sd->basetype = sd->basetype->merge(); |
385 | 389 |
386 sd->basetype->getTypeInfo(NULL); // generate vtinfo | 390 sd->basetype->getTypeInfo(NULL); // generate vtinfo |
387 assert(sd->basetype->vtinfo); | 391 assert(sd->basetype->vtinfo); |
388 if (!sd->basetype->vtinfo->llvmValue) | 392 DtoForceDeclareDsymbol(sd->basetype->vtinfo); |
389 DtoForceDeclareDsymbol(sd->basetype->vtinfo); | 393 |
390 | 394 assert(sd->basetype->vtinfo->irGlobal->value); |
391 assert(sd->basetype->vtinfo->llvmValue); | 395 assert(llvm::isa<llvm::Constant>(sd->basetype->vtinfo->irGlobal->value)); |
392 assert(llvm::isa<llvm::Constant>(sd->basetype->vtinfo->llvmValue)); | 396 llvm::Constant* castbase = llvm::cast<llvm::Constant>(sd->basetype->vtinfo->irGlobal->value); |
393 llvm::Constant* castbase = llvm::cast<llvm::Constant>(sd->basetype->vtinfo->llvmValue); | |
394 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); | 397 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
395 sinits.push_back(castbase); | 398 sinits.push_back(castbase); |
396 | 399 |
397 // char[] name | 400 // char[] name |
398 char *name = sd->toPrettyChars(); | 401 char *name = sd->toPrettyChars(); |
416 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); | 419 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); |
417 } | 420 } |
418 | 421 |
419 // create the symbol | 422 // create the symbol |
420 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 423 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
421 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 424 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
422 } | 425 } |
423 | 426 |
424 void TypeInfoTypedefDeclaration::toDt(dt_t **pdt) | 427 void TypeInfoTypedefDeclaration::toDt(dt_t **pdt) |
425 { | 428 { |
426 assert(0); | 429 assert(0); |
437 DtoResolveClass(base); | 440 DtoResolveClass(base); |
438 | 441 |
439 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 442 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
440 | 443 |
441 // create the symbol | 444 // create the symbol |
442 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 445 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
443 } | 446 } |
444 | 447 |
445 void TypeInfoEnumDeclaration::llvmDefine() | 448 void TypeInfoEnumDeclaration::llvmDefine() |
446 { | 449 { |
447 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars()); | 450 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars()); |
469 Logger::println("generating base typeinfo"); | 472 Logger::println("generating base typeinfo"); |
470 //sd->basetype = sd->basetype->merge(); | 473 //sd->basetype = sd->basetype->merge(); |
471 | 474 |
472 sd->memtype->getTypeInfo(NULL); // generate vtinfo | 475 sd->memtype->getTypeInfo(NULL); // generate vtinfo |
473 assert(sd->memtype->vtinfo); | 476 assert(sd->memtype->vtinfo); |
474 if (!sd->memtype->vtinfo->llvmValue) | 477 DtoForceDeclareDsymbol(sd->memtype->vtinfo); |
475 DtoForceDeclareDsymbol(sd->memtype->vtinfo); | 478 |
476 | 479 assert(llvm::isa<llvm::Constant>(sd->memtype->vtinfo->irGlobal->value)); |
477 assert(llvm::isa<llvm::Constant>(sd->memtype->vtinfo->llvmValue)); | 480 llvm::Constant* castbase = llvm::cast<llvm::Constant>(sd->memtype->vtinfo->irGlobal->value); |
478 llvm::Constant* castbase = llvm::cast<llvm::Constant>(sd->memtype->vtinfo->llvmValue); | |
479 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); | 481 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
480 sinits.push_back(castbase); | 482 sinits.push_back(castbase); |
481 | 483 |
482 // char[] name | 484 // char[] name |
483 char *name = sd->toPrettyChars(); | 485 char *name = sd->toPrettyChars(); |
502 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); | 504 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); |
503 } | 505 } |
504 | 506 |
505 // create the symbol | 507 // create the symbol |
506 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 508 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
507 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 509 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
508 } | 510 } |
509 | 511 |
510 void TypeInfoEnumDeclaration::toDt(dt_t **pdt) | 512 void TypeInfoEnumDeclaration::toDt(dt_t **pdt) |
511 { | 513 { |
512 assert(0); | 514 assert(0); |
520 DtoResolveClass(base); | 522 DtoResolveClass(base); |
521 | 523 |
522 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 524 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
523 | 525 |
524 // create the symbol | 526 // create the symbol |
525 tid->llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); | 527 tid->irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); |
526 } | 528 } |
527 | 529 |
528 static llvm::Constant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd) | 530 static llvm::Constant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd) |
529 { | 531 { |
530 ClassDeclaration* base = cd; | 532 ClassDeclaration* base = cd; |
541 | 543 |
542 // TypeInfo base | 544 // TypeInfo base |
543 Logger::println("generating base typeinfo"); | 545 Logger::println("generating base typeinfo"); |
544 basetype->getTypeInfo(NULL); | 546 basetype->getTypeInfo(NULL); |
545 assert(basetype->vtinfo); | 547 assert(basetype->vtinfo); |
546 if (!basetype->vtinfo->llvmValue) | 548 DtoForceDeclareDsymbol(basetype->vtinfo); |
547 DtoForceDeclareDsymbol(basetype->vtinfo); | 549 assert(llvm::isa<llvm::Constant>(basetype->vtinfo->irGlobal->value)); |
548 assert(llvm::isa<llvm::Constant>(basetype->vtinfo->llvmValue)); | 550 llvm::Constant* castbase = llvm::cast<llvm::Constant>(basetype->vtinfo->irGlobal->value); |
549 llvm::Constant* castbase = llvm::cast<llvm::Constant>(basetype->vtinfo->llvmValue); | |
550 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); | 551 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
551 sinits.push_back(castbase); | 552 sinits.push_back(castbase); |
552 | 553 |
553 // create the symbol | 554 // create the symbol |
554 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 555 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
555 isaGlobalVar(tid->llvmValue)->setInitializer(tiInit); | 556 isaGlobalVar(tid->irGlobal->value)->setInitializer(tiInit); |
556 } | 557 } |
557 | 558 |
558 /* ========================================================================= */ | 559 /* ========================================================================= */ |
559 | 560 |
560 void TypeInfoPointerDeclaration::llvmDeclare() | 561 void TypeInfoPointerDeclaration::llvmDeclare() |
626 | 627 |
627 // get type of typeinfo class | 628 // get type of typeinfo class |
628 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 629 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
629 | 630 |
630 // create the symbol | 631 // create the symbol |
631 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 632 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
632 } | 633 } |
633 | 634 |
634 void TypeInfoStaticArrayDeclaration::llvmDefine() | 635 void TypeInfoStaticArrayDeclaration::llvmDefine() |
635 { | 636 { |
636 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); | 637 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); |
657 tc->next->getTypeInfo(NULL); | 658 tc->next->getTypeInfo(NULL); |
658 | 659 |
659 // get symbol | 660 // get symbol |
660 assert(tc->next->vtinfo); | 661 assert(tc->next->vtinfo); |
661 DtoForceDeclareDsymbol(tc->next->vtinfo); | 662 DtoForceDeclareDsymbol(tc->next->vtinfo); |
662 llvm::Constant* castbase = isaConstant(tc->next->vtinfo->llvmValue); | 663 llvm::Constant* castbase = isaConstant(tc->next->vtinfo->irGlobal->value); |
663 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); | 664 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
664 sinits.push_back(castbase); | 665 sinits.push_back(castbase); |
665 | 666 |
666 // length | 667 // length |
667 sinits.push_back(DtoConstSize_t(tc->dim->toInteger())); | 668 sinits.push_back(DtoConstSize_t(tc->dim->toInteger())); |
668 | 669 |
669 // create the symbol | 670 // create the symbol |
670 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 671 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
671 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 672 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
672 } | 673 } |
673 | 674 |
674 void TypeInfoStaticArrayDeclaration::toDt(dt_t **pdt) | 675 void TypeInfoStaticArrayDeclaration::toDt(dt_t **pdt) |
675 { | 676 { |
676 assert(0); | 677 assert(0); |
689 | 690 |
690 // get type of typeinfo class | 691 // get type of typeinfo class |
691 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 692 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
692 | 693 |
693 // create the symbol | 694 // create the symbol |
694 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 695 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
695 } | 696 } |
696 | 697 |
697 void TypeInfoAssociativeArrayDeclaration::llvmDefine() | 698 void TypeInfoAssociativeArrayDeclaration::llvmDefine() |
698 { | 699 { |
699 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); | 700 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); |
722 tc->next->getTypeInfo(NULL); | 723 tc->next->getTypeInfo(NULL); |
723 | 724 |
724 // get symbol | 725 // get symbol |
725 assert(tc->next->vtinfo); | 726 assert(tc->next->vtinfo); |
726 DtoForceDeclareDsymbol(tc->next->vtinfo); | 727 DtoForceDeclareDsymbol(tc->next->vtinfo); |
727 llvm::Constant* castbase = isaConstant(tc->next->vtinfo->llvmValue); | 728 llvm::Constant* castbase = isaConstant(tc->next->vtinfo->irGlobal->value); |
728 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); | 729 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
729 sinits.push_back(castbase); | 730 sinits.push_back(castbase); |
730 | 731 |
731 // key typeinfo | 732 // key typeinfo |
732 tc->index->getTypeInfo(NULL); | 733 tc->index->getTypeInfo(NULL); |
733 | 734 |
734 // get symbol | 735 // get symbol |
735 assert(tc->index->vtinfo); | 736 assert(tc->index->vtinfo); |
736 DtoForceDeclareDsymbol(tc->index->vtinfo); | 737 DtoForceDeclareDsymbol(tc->index->vtinfo); |
737 castbase = isaConstant(tc->index->vtinfo->llvmValue); | 738 castbase = isaConstant(tc->index->vtinfo->irGlobal->value); |
738 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(3)); | 739 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(3)); |
739 sinits.push_back(castbase); | 740 sinits.push_back(castbase); |
740 | 741 |
741 // create the symbol | 742 // create the symbol |
742 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 743 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
743 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 744 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
744 } | 745 } |
745 | 746 |
746 void TypeInfoAssociativeArrayDeclaration::toDt(dt_t **pdt) | 747 void TypeInfoAssociativeArrayDeclaration::toDt(dt_t **pdt) |
747 { | 748 { |
748 assert(0); | 749 assert(0); |
822 DtoResolveClass(base); | 823 DtoResolveClass(base); |
823 | 824 |
824 const llvm::StructType* stype = isaStruct(((TypeClass*)base->type)->llvmType->get()); | 825 const llvm::StructType* stype = isaStruct(((TypeClass*)base->type)->llvmType->get()); |
825 | 826 |
826 // create the symbol | 827 // create the symbol |
827 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 828 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
828 } | 829 } |
829 | 830 |
830 void TypeInfoStructDeclaration::llvmDefine() | 831 void TypeInfoStructDeclaration::llvmDefine() |
831 { | 832 { |
832 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars()); | 833 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars()); |
922 if (fdx) | 923 if (fdx) |
923 { | 924 { |
924 fd = fdx->overloadExactMatch(tftohash); | 925 fd = fdx->overloadExactMatch(tftohash); |
925 if (fd) { | 926 if (fd) { |
926 DtoForceDeclareDsymbol(fd); | 927 DtoForceDeclareDsymbol(fd); |
927 assert(fd->llvmValue != 0); | 928 assert(fd->irFunc->func != 0); |
928 llvm::Constant* c = isaConstant(fd->llvmValue); | 929 llvm::Constant* c = isaConstant(fd->irFunc->func); |
929 assert(c); | 930 assert(c); |
930 c = llvm::ConstantExpr::getBitCast(c, ptty); | 931 c = llvm::ConstantExpr::getBitCast(c, ptty); |
931 sinits.push_back(c); | 932 sinits.push_back(c); |
932 } | 933 } |
933 else { | 934 else { |
948 if (fdx) | 949 if (fdx) |
949 { | 950 { |
950 fd = fdx->overloadExactMatch(tfeqptr); | 951 fd = fdx->overloadExactMatch(tfeqptr); |
951 if (fd) { | 952 if (fd) { |
952 DtoForceDeclareDsymbol(fd); | 953 DtoForceDeclareDsymbol(fd); |
953 assert(fd->llvmValue != 0); | 954 assert(fd->irFunc->func != 0); |
954 llvm::Constant* c = isaConstant(fd->llvmValue); | 955 llvm::Constant* c = isaConstant(fd->irFunc->func); |
955 assert(c); | 956 assert(c); |
956 c = llvm::ConstantExpr::getBitCast(c, ptty); | 957 c = llvm::ConstantExpr::getBitCast(c, ptty); |
957 sinits.push_back(c); | 958 sinits.push_back(c); |
958 } | 959 } |
959 else { | 960 else { |
976 if (fdx) | 977 if (fdx) |
977 { | 978 { |
978 fd = fdx->overloadExactMatch(tftostring); | 979 fd = fdx->overloadExactMatch(tftostring); |
979 if (fd) { | 980 if (fd) { |
980 DtoForceDeclareDsymbol(fd); | 981 DtoForceDeclareDsymbol(fd); |
981 assert(fd->llvmValue != 0); | 982 assert(fd->irFunc->func != 0); |
982 llvm::Constant* c = isaConstant(fd->llvmValue); | 983 llvm::Constant* c = isaConstant(fd->irFunc->func); |
983 assert(c); | 984 assert(c); |
984 c = llvm::ConstantExpr::getBitCast(c, ptty); | 985 c = llvm::ConstantExpr::getBitCast(c, ptty); |
985 sinits.push_back(c); | 986 sinits.push_back(c); |
986 } | 987 } |
987 else { | 988 else { |
998 | 999 |
999 // create the symbol | 1000 // create the symbol |
1000 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 1001 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
1001 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); | 1002 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); |
1002 | 1003 |
1003 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 1004 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
1004 } | 1005 } |
1005 | 1006 |
1006 void TypeInfoStructDeclaration::toDt(dt_t **pdt) | 1007 void TypeInfoStructDeclaration::toDt(dt_t **pdt) |
1007 { | 1008 { |
1008 assert(0); | 1009 assert(0); |
1022 | 1023 |
1023 // get type of typeinfo class | 1024 // get type of typeinfo class |
1024 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 1025 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
1025 | 1026 |
1026 // create the symbol | 1027 // create the symbol |
1027 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 1028 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
1028 } | 1029 } |
1029 | 1030 |
1030 void TypeInfoClassDeclaration::llvmDefine() | 1031 void TypeInfoClassDeclaration::llvmDefine() |
1031 { | 1032 { |
1032 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); | 1033 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); |
1054 assert(tc->sym->llvmClass); | 1055 assert(tc->sym->llvmClass); |
1055 sinits.push_back(tc->sym->llvmClass); | 1056 sinits.push_back(tc->sym->llvmClass); |
1056 | 1057 |
1057 // create the symbol | 1058 // create the symbol |
1058 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 1059 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
1059 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 1060 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
1060 } | 1061 } |
1061 | 1062 |
1062 void TypeInfoClassDeclaration::toDt(dt_t **pdt) | 1063 void TypeInfoClassDeclaration::toDt(dt_t **pdt) |
1063 { | 1064 { |
1064 assert(0); | 1065 assert(0); |
1078 | 1079 |
1079 // get type of typeinfo class | 1080 // get type of typeinfo class |
1080 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 1081 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
1081 | 1082 |
1082 // create the symbol | 1083 // create the symbol |
1083 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 1084 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
1084 } | 1085 } |
1085 | 1086 |
1086 void TypeInfoInterfaceDeclaration::llvmDefine() | 1087 void TypeInfoInterfaceDeclaration::llvmDefine() |
1087 { | 1088 { |
1088 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars()); | 1089 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars()); |
1110 assert(tc->sym->llvmClass); | 1111 assert(tc->sym->llvmClass); |
1111 sinits.push_back(tc->sym->llvmClass); | 1112 sinits.push_back(tc->sym->llvmClass); |
1112 | 1113 |
1113 // create the symbol | 1114 // create the symbol |
1114 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 1115 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
1115 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 1116 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
1116 } | 1117 } |
1117 | 1118 |
1118 void TypeInfoInterfaceDeclaration::toDt(dt_t **pdt) | 1119 void TypeInfoInterfaceDeclaration::toDt(dt_t **pdt) |
1119 { | 1120 { |
1120 assert(0); | 1121 assert(0); |
1134 | 1135 |
1135 // get type of typeinfo class | 1136 // get type of typeinfo class |
1136 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); | 1137 const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); |
1137 | 1138 |
1138 // create the symbol | 1139 // create the symbol |
1139 llvmValue = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); | 1140 irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
1140 } | 1141 } |
1141 | 1142 |
1142 void TypeInfoTupleDeclaration::llvmDefine() | 1143 void TypeInfoTupleDeclaration::llvmDefine() |
1143 { | 1144 { |
1144 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars()); | 1145 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars()); |
1173 for (size_t i = 0; i < dim; i++) | 1174 for (size_t i = 0; i < dim; i++) |
1174 { | 1175 { |
1175 Argument *arg = (Argument *)tu->arguments->data[i]; | 1176 Argument *arg = (Argument *)tu->arguments->data[i]; |
1176 arg->type->getTypeInfo(NULL); | 1177 arg->type->getTypeInfo(NULL); |
1177 DtoForceDeclareDsymbol(arg->type->vtinfo); | 1178 DtoForceDeclareDsymbol(arg->type->vtinfo); |
1178 assert(arg->type->vtinfo->llvmValue); | 1179 assert(arg->type->vtinfo->irGlobal->value); |
1179 llvm::Constant* c = isaConstant(arg->type->vtinfo->llvmValue); | 1180 llvm::Constant* c = isaConstant(arg->type->vtinfo->irGlobal->value); |
1180 c = llvm::ConstantExpr::getBitCast(c, tiTy); | 1181 c = llvm::ConstantExpr::getBitCast(c, tiTy); |
1181 arrInits.push_back(c); | 1182 arrInits.push_back(c); |
1182 } | 1183 } |
1183 | 1184 |
1184 // build array type | 1185 // build array type |
1189 llvm::Constant* slice = DtoConstSlice(DtoConstSize_t(dim), arrC); | 1190 llvm::Constant* slice = DtoConstSlice(DtoConstSize_t(dim), arrC); |
1190 sinits.push_back(slice); | 1191 sinits.push_back(slice); |
1191 | 1192 |
1192 // create the symbol | 1193 // create the symbol |
1193 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 1194 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
1194 isaGlobalVar(llvmValue)->setInitializer(tiInit); | 1195 isaGlobalVar(irGlobal->value)->setInitializer(tiInit); |
1195 } | 1196 } |
1196 | 1197 |
1197 void TypeInfoTupleDeclaration::toDt(dt_t **pdt) | 1198 void TypeInfoTupleDeclaration::toDt(dt_t **pdt) |
1198 { | 1199 { |
1199 assert(0); | 1200 assert(0); |