comparison gen/statements.cpp @ 778:4adf0f742896

Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead. Fixed some casts to bool that were using truncation.
author Christian Kamm <kamm incasoftware de>
date Sat, 22 Nov 2008 18:35:52 +0100
parents 9688da40cd4d
children 340acf1535d0
comparison
equal deleted inserted replaced
777:961e249eb2aa 778:4adf0f742896
166 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb; 166 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb;
167 167
168 if (cond_val->getType() != LLType::Int1Ty) { 168 if (cond_val->getType() != LLType::Int1Ty) {
169 if (Logger::enabled()) 169 if (Logger::enabled())
170 Logger::cout() << "if conditional: " << *cond_val << '\n'; 170 Logger::cout() << "if conditional: " << *cond_val << '\n';
171 cond_val = DtoBoolean(loc, cond_e); 171 cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal();
172 } 172 }
173 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); 173 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb());
174 174
175 // replace current scope 175 // replace current scope
176 gIR->scope() = IRScope(ifbb,elsebb); 176 gIR->scope() = IRScope(ifbb,elsebb);
254 // replace current scope 254 // replace current scope
255 gIR->scope() = IRScope(whilebb,endbb); 255 gIR->scope() = IRScope(whilebb,endbb);
256 256
257 // create the condition 257 // create the condition
258 DValue* cond_e = condition->toElem(p); 258 DValue* cond_e = condition->toElem(p);
259 LLValue* cond_val = DtoBoolean(loc, cond_e); 259 LLValue* cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal();
260 delete cond_e; 260 delete cond_e;
261 261
262 // conditional branch 262 // conditional branch
263 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); 263 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb());
264 264
310 llvm::BranchInst::Create(condbb, gIR->scopebb()); 310 llvm::BranchInst::Create(condbb, gIR->scopebb());
311 gIR->scope() = IRScope(condbb,endbb); 311 gIR->scope() = IRScope(condbb,endbb);
312 312
313 // create the condition 313 // create the condition
314 DValue* cond_e = condition->toElem(p); 314 DValue* cond_e = condition->toElem(p);
315 LLValue* cond_val = DtoBoolean(loc, cond_e); 315 LLValue* cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal();
316 delete cond_e; 316 delete cond_e;
317 317
318 // conditional branch 318 // conditional branch
319 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); 319 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb());
320 320
355 // create the condition 355 // create the condition
356 LLValue* cond_val; 356 LLValue* cond_val;
357 if (condition) 357 if (condition)
358 { 358 {
359 DValue* cond_e = condition->toElem(p); 359 DValue* cond_e = condition->toElem(p);
360 cond_val = DtoBoolean(loc, cond_e); 360 cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal();
361 delete cond_e; 361 delete cond_e;
362 } 362 }
363 else 363 else
364 { 364 {
365 cond_val = DtoConstBool(true); 365 cond_val = DtoConstBool(true);