Mercurial > projects > ldc
comparison gen/statements.cpp @ 270:d9d5d59873d8 trunk
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
Branch statements now emit a new block after it.
Fixed the _adSort runtime function had a bad signature.
Added a missing dot prefix on compiler generated string tables for string switch.
Fixed, PTRSIZE seems like it was wrong on 64bit, now it definitely gets set properly.
author | lindquist |
---|---|
date | Mon, 16 Jun 2008 16:01:19 +0200 |
parents | 23d0d9855cad |
children | 1e6e2b5d5bfe |
comparison
equal
deleted
inserted
replaced
269:967178e31a13 | 270:d9d5d59873d8 |
---|---|
438 ScopeStatement* tmp; | 438 ScopeStatement* tmp; |
439 while(tmp = targetLoopStatement->isScopeStatement()) | 439 while(tmp = targetLoopStatement->isScopeStatement()) |
440 targetLoopStatement = tmp->statement; | 440 targetLoopStatement = tmp->statement; |
441 | 441 |
442 // find the right break block and jump there | 442 // find the right break block and jump there |
443 bool found = false; | |
443 IRState::LoopScopeVec::reverse_iterator it; | 444 IRState::LoopScopeVec::reverse_iterator it; |
444 for(it = p->loopbbs.rbegin(); it != p->loopbbs.rend(); ++it) { | 445 for(it = p->loopbbs.rbegin(); it != p->loopbbs.rend(); ++it) { |
445 if(it->s == targetLoopStatement) { | 446 if(it->s == targetLoopStatement) { |
446 llvm::BranchInst::Create(it->end, p->scopebb()); | 447 llvm::BranchInst::Create(it->end, p->scopebb()); |
447 return; | 448 found = true; |
449 break; | |
448 } | 450 } |
449 } | 451 } |
450 assert(0); | 452 assert(found); |
451 } | 453 } |
452 else { | 454 else { |
453 emit_finallyblocks(p, enclosingtryfinally, p->loopbbs.back().enclosingtryfinally); | 455 emit_finallyblocks(p, enclosingtryfinally, p->loopbbs.back().enclosingtryfinally); |
454 llvm::BranchInst::Create(p->loopbbs.back().end, p->scopebb()); | 456 llvm::BranchInst::Create(p->loopbbs.back().end, p->scopebb()); |
455 } | 457 } |
458 | |
459 // the break terminated this basicblock, start a new one | |
460 llvm::BasicBlock* oldend = gIR->scopeend(); | |
461 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterbreak", p->topfunc(), oldend); | |
462 p->scope() = IRScope(bb,oldend); | |
456 } | 463 } |
457 | 464 |
458 ////////////////////////////////////////////////////////////////////////////// | 465 ////////////////////////////////////////////////////////////////////////////// |
459 | 466 |
460 void ContinueStatement::toIR(IRState* p) | 467 void ContinueStatement::toIR(IRState* p) |
722 } | 729 } |
723 // build static array for ptr or final array | 730 // build static array for ptr or final array |
724 const LLType* elemTy = DtoType(condition->type); | 731 const LLType* elemTy = DtoType(condition->type); |
725 const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size()); | 732 const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size()); |
726 LLConstant* arrInit = llvm::ConstantArray::get(arrTy, inits); | 733 LLConstant* arrInit = llvm::ConstantArray::get(arrTy, inits); |
727 llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, "string_switch_table_data", gIR->module); | 734 llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data", gIR->module); |
728 | 735 |
729 const LLType* elemPtrTy = getPtrToType(elemTy); | 736 const LLType* elemPtrTy = getPtrToType(elemTy); |
730 LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy); | 737 LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy); |
731 | 738 |
732 // build the static table | 739 // build the static table |
737 std::vector<LLConstant*> sinits; | 744 std::vector<LLConstant*> sinits; |
738 sinits.push_back(DtoConstSize_t(inits.size())); | 745 sinits.push_back(DtoConstSize_t(inits.size())); |
739 sinits.push_back(arrPtr); | 746 sinits.push_back(arrPtr); |
740 LLConstant* sInit = llvm::ConstantStruct::get(sTy, sinits); | 747 LLConstant* sInit = llvm::ConstantStruct::get(sTy, sinits); |
741 | 748 |
742 switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, "string_switch_table", gIR->module); | 749 switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, ".string_switch_table", gIR->module); |
743 } | 750 } |
744 | 751 |
745 // body block | 752 // body block |
746 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("switchbody", p->topfunc(), oldend); | 753 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("switchbody", p->topfunc(), oldend); |
747 | 754 |