Mercurial > projects > ldc
comparison gen/tollvm.c @ 85:f869c636a113 trunk
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
Fixed initialization of function local static variables, with a non const initializer (now happens on first call using a global to make sure it only happens once.)
author | lindquist |
---|---|
date | Fri, 02 Nov 2007 06:32:32 +0100 |
parents | 339422268de1 |
children |
comparison
equal
deleted
inserted
replaced
84:169711a7126e | 85:f869c636a113 |
---|---|
888 return _init; | 888 return _init; |
889 } | 889 } |
890 | 890 |
891 ////////////////////////////////////////////////////////////////////////////////////////// | 891 ////////////////////////////////////////////////////////////////////////////////////////// |
892 | 892 |
893 void DtoInitializer(Initializer* init) | 893 elem* DtoInitializer(Initializer* init) |
894 { | 894 { |
895 if (ExpInitializer* ex = init->isExpInitializer()) | 895 if (ExpInitializer* ex = init->isExpInitializer()) |
896 { | 896 { |
897 Logger::println("expression initializer"); | 897 Logger::println("expression initializer"); |
898 elem* e = ex->exp->toElem(gIR); | 898 return ex->exp->toElem(gIR); |
899 delete e; | 899 } |
900 else if (init->isVoidInitializer()) | |
901 { | |
902 // do nothing | |
900 } | 903 } |
901 else { | 904 else { |
902 Logger::println("unsupported initializer: %s", init->toChars()); | 905 Logger::println("unsupported initializer: %s", init->toChars()); |
903 } | 906 assert(0); |
907 } | |
908 return 0; | |
904 } | 909 } |
905 | 910 |
906 ////////////////////////////////////////////////////////////////////////////////////////// | 911 ////////////////////////////////////////////////////////////////////////////////////////// |
907 | 912 |
908 llvm::Value* DtoGEP(llvm::Value* ptr, llvm::Value* i0, llvm::Value* i1, const std::string& var, llvm::BasicBlock* bb) | 913 llvm::Value* DtoGEP(llvm::Value* ptr, llvm::Value* i0, llvm::Value* i1, const std::string& var, llvm::BasicBlock* bb) |
1458 size_t llt_sz = gTargetData->getTypeSize(llt->getContainedType(0)); | 1463 size_t llt_sz = gTargetData->getTypeSize(llt->getContainedType(0)); |
1459 assert(os % llt_sz == 0); | 1464 assert(os % llt_sz == 0); |
1460 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp"); | 1465 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp"); |
1461 return new llvm::GetElementPtrInst(ptr, DtoConstUint(os / llt_sz), "tmp", gIR->scopebb()); | 1466 return new llvm::GetElementPtrInst(ptr, DtoConstUint(os / llt_sz), "tmp", gIR->scopebb()); |
1462 } | 1467 } |
1468 | |
1469 ////////////////////////////////////////////////////////////////////////////////////////// | |
1470 | |
1471 bool DtoIsTemplateInstance(Dsymbol* s) | |
1472 { | |
1473 assert(s); | |
1474 if (s->isTemplateInstance() && !s->isTemplateMixin()) | |
1475 return true; | |
1476 else if (s->parent) | |
1477 return DtoIsTemplateInstance(s->parent); | |
1478 return false; | |
1479 } |