Mercurial > projects > ldc
comparison gen/statements.cpp @ 364:8014dbd24605 trunk
[svn r385] Fix lvalue cast problems with -= and friends.
Fix complex DtoBoolean.
author | ChristianK |
---|---|
date | Mon, 14 Jul 2008 22:48:03 +0200 |
parents | 44daf304421c |
children | bfb9d28f045a |
comparison
equal
deleted
inserted
replaced
363:4d7495038ae8 | 364:8014dbd24605 |
---|---|
149 match->ir.irLocal->value = allocainst; | 149 match->ir.irLocal->value = allocainst; |
150 } | 150 } |
151 | 151 |
152 DValue* cond_e = condition->toElem(p); | 152 DValue* cond_e = condition->toElem(p); |
153 LLValue* cond_val = cond_e->getRVal(); | 153 LLValue* cond_val = cond_e->getRVal(); |
154 delete cond_e; | |
155 | 154 |
156 llvm::BasicBlock* oldend = gIR->scopeend(); | 155 llvm::BasicBlock* oldend = gIR->scopeend(); |
157 | 156 |
158 llvm::BasicBlock* ifbb = llvm::BasicBlock::Create("if", gIR->topfunc(), oldend); | 157 llvm::BasicBlock* ifbb = llvm::BasicBlock::Create("if", gIR->topfunc(), oldend); |
159 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend); | 158 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend); |
160 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb; | 159 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb; |
161 | 160 |
162 if (cond_val->getType() != LLType::Int1Ty) { | 161 if (cond_val->getType() != LLType::Int1Ty) { |
163 Logger::cout() << "if conditional: " << *cond_val << '\n'; | 162 Logger::cout() << "if conditional: " << *cond_val << '\n'; |
164 cond_val = DtoBoolean(cond_val); | 163 cond_val = DtoBoolean(cond_e); |
165 } | 164 } |
166 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); | 165 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); |
167 | 166 |
168 // replace current scope | 167 // replace current scope |
169 gIR->scope() = IRScope(ifbb,elsebb); | 168 gIR->scope() = IRScope(ifbb,elsebb); |
247 // replace current scope | 246 // replace current scope |
248 gIR->scope() = IRScope(whilebb,endbb); | 247 gIR->scope() = IRScope(whilebb,endbb); |
249 | 248 |
250 // create the condition | 249 // create the condition |
251 DValue* cond_e = condition->toElem(p); | 250 DValue* cond_e = condition->toElem(p); |
252 LLValue* cond_val = DtoBoolean(cond_e->getRVal()); | 251 LLValue* cond_val = DtoBoolean(cond_e); |
253 delete cond_e; | 252 delete cond_e; |
254 | 253 |
255 // conditional branch | 254 // conditional branch |
256 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); | 255 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); |
257 | 256 |
298 body->toIR(p); | 297 body->toIR(p); |
299 p->loopbbs.pop_back(); | 298 p->loopbbs.pop_back(); |
300 | 299 |
301 // create the condition | 300 // create the condition |
302 DValue* cond_e = condition->toElem(p); | 301 DValue* cond_e = condition->toElem(p); |
303 LLValue* cond_val = DtoBoolean(cond_e->getRVal()); | 302 LLValue* cond_val = DtoBoolean(cond_e); |
304 delete cond_e; | 303 delete cond_e; |
305 | 304 |
306 // conditional branch | 305 // conditional branch |
307 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); | 306 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); |
308 | 307 |
340 // replace current scope | 339 // replace current scope |
341 gIR->scope() = IRScope(forbb,forbodybb); | 340 gIR->scope() = IRScope(forbb,forbodybb); |
342 | 341 |
343 // create the condition | 342 // create the condition |
344 DValue* cond_e = condition->toElem(p); | 343 DValue* cond_e = condition->toElem(p); |
345 LLValue* cond_val = DtoBoolean(cond_e->getRVal()); | 344 LLValue* cond_val = DtoBoolean(cond_e); |
346 delete cond_e; | 345 delete cond_e; |
347 | 346 |
348 // conditional branch | 347 // conditional branch |
349 assert(!gIR->scopereturned()); | 348 assert(!gIR->scopereturned()); |
350 llvm::BranchInst::Create(forbodybb, endbb, cond_val, gIR->scopebb()); | 349 llvm::BranchInst::Create(forbodybb, endbb, cond_val, gIR->scopebb()); |