Mercurial > projects > ldc
comparison gen/statements.cpp @ 305:2b72433d5c8c trunk
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
Fixed problems with label collisions when using labels inside inline asm. LabelStatement is now easily reached given its
Identifier, which should be useful elsewhere too.
Enabled inline asm for building the lib/compiler/llvmdc runtime code, fixing branches out of asm makes this possible.
author | lindquist |
---|---|
date | Fri, 27 Jun 2008 22:04:35 +0200 |
parents | 3ebc136702dd |
children | 6b62e8cdf970 |
comparison
equal
deleted
inserted
replaced
304:3ebc136702dd | 305:2b72433d5c8c |
---|---|
1043 | 1043 |
1044 // if it's an inline asm label, we don't create a basicblock, just emit it in the asm | 1044 // if it's an inline asm label, we don't create a basicblock, just emit it in the asm |
1045 if (p->asmBlock) | 1045 if (p->asmBlock) |
1046 { | 1046 { |
1047 IRAsmStmt* a = new IRAsmStmt; | 1047 IRAsmStmt* a = new IRAsmStmt; |
1048 a->code += p->func()->decl->mangle(); | |
1049 a->code += "_"; | |
1048 a->code += ident->toChars(); | 1050 a->code += ident->toChars(); |
1049 a->code += ":"; | 1051 a->code += ":"; |
1050 p->asmBlock->s.push_back(a); | 1052 p->asmBlock->s.push_back(a); |
1051 p->asmBlock->internalLabels.push_back(ident); | 1053 p->asmBlock->internalLabels.push_back(ident); |
1052 } | 1054 } |
1053 else | 1055 else |
1054 { | 1056 { |
1055 | |
1056 assert(tf == NULL); | 1057 assert(tf == NULL); |
1057 | 1058 |
1058 llvm::BasicBlock* oldend = gIR->scopeend(); | 1059 llvm::BasicBlock* oldend = gIR->scopeend(); |
1059 if (llvmBB) | 1060 if (llvmBB) |
1060 llvmBB->moveBefore(oldend); | 1061 llvmBB->moveBefore(oldend); |
1061 else | 1062 else |
1062 llvmBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend); | 1063 llvmBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend); |
1063 | 1064 |
1064 if (!p->scopereturned()) | 1065 if (!p->scopereturned()) |
1065 llvm::BranchInst::Create(llvmBB, p->scopebb()); | 1066 llvm::BranchInst::Create(llvmBB, p->scopebb()); |
1066 | 1067 |
1067 p->scope() = IRScope(llvmBB,oldend); | 1068 p->scope() = IRScope(llvmBB,oldend); |
1068 } | 1069 } |
1069 | 1070 |
1070 if (statement) | 1071 if (statement) |
1071 statement->toIR(p); | 1072 statement->toIR(p); |
1084 assert(tf == NULL); | 1085 assert(tf == NULL); |
1085 | 1086 |
1086 llvm::BasicBlock* oldend = gIR->scopeend(); | 1087 llvm::BasicBlock* oldend = gIR->scopeend(); |
1087 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend); | 1088 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend); |
1088 | 1089 |
1089 DtoGoto(&loc, label, enclosingtryfinally); | 1090 DtoGoto(&loc, label->ident, enclosingtryfinally); |
1090 | 1091 |
1091 p->scope() = IRScope(bb,oldend); | 1092 p->scope() = IRScope(bb,oldend); |
1092 } | 1093 } |
1093 | 1094 |
1094 ////////////////////////////////////////////////////////////////////////////// | 1095 ////////////////////////////////////////////////////////////////////////////// |