Mercurial > projects > ldc
comparison gen/statements.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 | d920a244691b |
children | d8357f7004ca |
comparison
equal
deleted
inserted
replaced
352:d920a244691b | 353:a7a26f538d6e |
---|---|
1031 p->asmBlock->s.push_back(a); | 1031 p->asmBlock->s.push_back(a); |
1032 p->asmBlock->internalLabels.push_back(ident); | 1032 p->asmBlock->internalLabels.push_back(ident); |
1033 } | 1033 } |
1034 else | 1034 else |
1035 { | 1035 { |
1036 std::string labelname = ident->toChars(); | |
1037 llvm::BasicBlock*& labelBB = p->func()->labelToBB[labelname]; | |
1038 | |
1036 llvm::BasicBlock* oldend = gIR->scopeend(); | 1039 llvm::BasicBlock* oldend = gIR->scopeend(); |
1037 if (llvmBB) | 1040 if (labelBB != NULL) { |
1038 llvmBB->moveBefore(oldend); | 1041 labelBB->moveBefore(oldend); |
1039 else | 1042 } else { |
1040 llvmBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend); | 1043 labelBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend); |
1044 } | |
1041 | 1045 |
1042 if (!p->scopereturned()) | 1046 if (!p->scopereturned()) |
1043 llvm::BranchInst::Create(llvmBB, p->scopebb()); | 1047 llvm::BranchInst::Create(labelBB, p->scopebb()); |
1044 | 1048 |
1045 p->scope() = IRScope(llvmBB,oldend); | 1049 p->scope() = IRScope(labelBB,oldend); |
1046 } | 1050 } |
1047 | 1051 |
1048 if (statement) | 1052 if (statement) |
1049 statement->toIR(p); | 1053 statement->toIR(p); |
1050 } | 1054 } |