comparison gen/llvmhelpers.cpp @ 353:a7a26f538d6e trunk

[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
author ChristianK
date Mon, 14 Jul 2008 11:07:15 +0200
parents 385a18242485
children d8357f7004ca
comparison
equal deleted inserted replaced
352:d920a244691b 353:a7a26f538d6e
184 184
185 // if the target label is inside inline asm, error 185 // if the target label is inside inline asm, error
186 if(lblstmt->asmLabel) 186 if(lblstmt->asmLabel)
187 error("cannot goto into inline asm block", loc->toChars()); 187 error("cannot goto into inline asm block", loc->toChars());
188 188
189 if (lblstmt->llvmBB == NULL) 189 // find target basic block
190 lblstmt->llvmBB = llvm::BasicBlock::Create("label", gIR->topfunc()); 190 std::string labelname = target->toChars();
191 llvm::BasicBlock*& targetBB = gIR->func()->labelToBB[labelname];
192 if (targetBB == NULL)
193 targetBB = llvm::BasicBlock::Create("label", gIR->topfunc());
191 194
192 // find finallys between goto and label 195 // find finallys between goto and label
193 EnclosingHandler* endfinally = enclosinghandler; 196 EnclosingHandler* endfinally = enclosinghandler;
194 while(endfinally != NULL && endfinally != lblstmt->enclosinghandler) { 197 while(endfinally != NULL && endfinally != lblstmt->enclosinghandler) {
195 endfinally = endfinally->getEnclosing(); 198 endfinally = endfinally->getEnclosing();
200 error("cannot goto into try block", loc->toChars()); 203 error("cannot goto into try block", loc->toChars());
201 204
202 // emit code for finallys between goto and label 205 // emit code for finallys between goto and label
203 DtoEnclosingHandlers(enclosinghandler, endfinally); 206 DtoEnclosingHandlers(enclosinghandler, endfinally);
204 207
205 llvm::BranchInst::Create(lblstmt->llvmBB, gIR->scopebb()); 208 llvm::BranchInst::Create(targetBB, gIR->scopebb());
206 } 209 }
207 210
208 /****************************************************************************************/ 211 /****************************************************************************************/
209 /*//////////////////////////////////////////////////////////////////////////////////////// 212 /*////////////////////////////////////////////////////////////////////////////////////////
210 // TRY-FINALLY, VOLATILE AND SYNCHRONIZED HELPER 213 // TRY-FINALLY, VOLATILE AND SYNCHRONIZED HELPER