comparison gen/typinf.c @ 81:3587401b6eeb trunk

[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed. Changed: Renamed all the LLVM_Dto... helper function to just Dto...
author lindquist
date Thu, 01 Nov 2007 17:27:18 +0100
parents b706170e24a9
children
comparison
equal deleted inserted replaced
80:7299ff502248 81:3587401b6eeb
300 castbase = llvm::ConstantExpr::getBitCast(castbase, initZ->getOperand(1)->getType()); 300 castbase = llvm::ConstantExpr::getBitCast(castbase, initZ->getOperand(1)->getType());
301 sinits.push_back(castbase); 301 sinits.push_back(castbase);
302 302
303 // char[] name 303 // char[] name
304 char *name = sd->toPrettyChars(); 304 char *name = sd->toPrettyChars();
305 sinits.push_back(LLVM_DtoConstString(name)); 305 sinits.push_back(DtoConstString(name));
306 assert(sinits.back()->getType() == initZ->getOperand(2)->getType()); 306 assert(sinits.back()->getType() == initZ->getOperand(2)->getType());
307 307
308 // void[] init 308 // void[] init
309 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty); 309 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty);
310 if (tinfo->isZeroInit() || !sd->init) // 0 initializer, or the same as the base type 310 if (tinfo->isZeroInit() || !sd->init) // 0 initializer, or the same as the base type
311 { 311 {
312 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); 312 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
313 } 313 }
314 else 314 else
315 { 315 {
316 llvm::Constant* ci = LLVM_DtoConstInitializer(sd->basetype, sd->init); 316 llvm::Constant* ci = DtoConstInitializer(sd->basetype, sd->init);
317 std::string ciname(sd->mangle()); 317 std::string ciname(sd->mangle());
318 ciname.append("__init"); 318 ciname.append("__init");
319 llvm::GlobalVariable* civar = new llvm::GlobalVariable(LLVM_DtoType(sd->basetype),true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module); 319 llvm::GlobalVariable* civar = new llvm::GlobalVariable(DtoType(sd->basetype),true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module);
320 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt); 320 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt);
321 size_t cisize = gTargetData->getTypeSize(LLVM_DtoType(sd->basetype)); 321 size_t cisize = gTargetData->getTypeSize(DtoType(sd->basetype));
322 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(cisize), cicast)); 322 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast));
323 } 323 }
324 324
325 // create the symbol 325 // create the symbol
326 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); 326 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
327 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); 327 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module);
364 castbase = llvm::ConstantExpr::getBitCast(castbase, initZ->getOperand(1)->getType()); 364 castbase = llvm::ConstantExpr::getBitCast(castbase, initZ->getOperand(1)->getType());
365 sinits.push_back(castbase); 365 sinits.push_back(castbase);
366 366
367 // char[] name 367 // char[] name
368 char *name = sd->toPrettyChars(); 368 char *name = sd->toPrettyChars();
369 sinits.push_back(LLVM_DtoConstString(name)); 369 sinits.push_back(DtoConstString(name));
370 assert(sinits.back()->getType() == initZ->getOperand(2)->getType()); 370 assert(sinits.back()->getType() == initZ->getOperand(2)->getType());
371 371
372 // void[] init 372 // void[] init
373 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty); 373 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty);
374 if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type 374 if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type
375 { 375 {
376 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); 376 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
377 } 377 }
378 else 378 else
379 { 379 {
380 const llvm::Type* memty = LLVM_DtoType(sd->memtype); 380 const llvm::Type* memty = DtoType(sd->memtype);
381 llvm::Constant* ci = llvm::ConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned()); 381 llvm::Constant* ci = llvm::ConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned());
382 std::string ciname(sd->mangle()); 382 std::string ciname(sd->mangle());
383 ciname.append("__init"); 383 ciname.append("__init");
384 llvm::GlobalVariable* civar = new llvm::GlobalVariable(memty,true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module); 384 llvm::GlobalVariable* civar = new llvm::GlobalVariable(memty,true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module);
385 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt); 385 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt);
386 size_t cisize = gTargetData->getTypeSize(memty); 386 size_t cisize = gTargetData->getTypeSize(memty);
387 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(cisize), cicast)); 387 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast));
388 } 388 }
389 389
390 // create the symbol 390 // create the symbol
391 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); 391 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
392 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); 392 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module);
542 std::vector<llvm::Constant*> sinits; 542 std::vector<llvm::Constant*> sinits;
543 sinits.push_back(base->llvmVtbl); 543 sinits.push_back(base->llvmVtbl);
544 544
545 // char[] name 545 // char[] name
546 char *name = sd->toPrettyChars(); 546 char *name = sd->toPrettyChars();
547 sinits.push_back(LLVM_DtoConstString(name)); 547 sinits.push_back(DtoConstString(name));
548 Logger::println("************** A"); 548 Logger::println("************** A");
549 assert(sinits.back()->getType() == stype->getElementType(1)); 549 assert(sinits.back()->getType() == stype->getElementType(1));
550 550
551 // void[] init 551 // void[] init
552 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty); 552 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty);
553 if (sd->zeroInit) // 0 initializer, or the same as the base type 553 if (sd->zeroInit) // 0 initializer, or the same as the base type
554 { 554 {
555 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); 555 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
556 } 556 }
557 else 557 else
558 { 558 {
559 assert(sd->llvmInitZ); 559 assert(sd->llvmInitZ);
560 size_t cisize = gTargetData->getTypeSize(tc->llvmType); 560 size_t cisize = gTargetData->getTypeSize(tc->llvmType);
561 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(tc->llvmInit, initpt); 561 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(tc->llvmInit, initpt);
562 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(cisize), cicast)); 562 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast));
563 } 563 }
564 564
565 // toX functions ground work 565 // toX functions ground work
566 FuncDeclaration *fd; 566 FuncDeclaration *fd;
567 FuncDeclaration *fdx; 567 FuncDeclaration *fdx;
682 else { 682 else {
683 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); 683 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
684 } 684 }
685 685
686 // uint m_flags; 686 // uint m_flags;
687 sinits.push_back(LLVM_DtoConstUint(tc->hasPointers())); 687 sinits.push_back(DtoConstUint(tc->hasPointers()));
688 688
689 // create the symbol 689 // create the symbol
690 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); 690 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
691 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); 691 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module);
692 692