Mercurial > projects > ldc
comparison gen/classes.cpp @ 1560:1d5c3354b3c2
getNullValue is in Constant again
Requires LLVM >= r77721
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Fri, 31 Jul 2009 23:01:29 +0200 |
parents | d6e8d5db259f |
children | 8d086d552909 |
comparison
equal
deleted
inserted
replaced
1559:06d5cc873350 | 1560:1d5c3354b3c2 |
---|---|
209 LLValue* val = DtoBitCast(tc->sym->ir.irStruct->getVtblSymbol(), tmp->getType()->getContainedType(0)); | 209 LLValue* val = DtoBitCast(tc->sym->ir.irStruct->getVtblSymbol(), tmp->getType()->getContainedType(0)); |
210 DtoStore(val, tmp); | 210 DtoStore(val, tmp); |
211 | 211 |
212 // monitor always defaults to zero | 212 // monitor always defaults to zero |
213 tmp = DtoGEPi(dst,0,1,"monitor"); | 213 tmp = DtoGEPi(dst,0,1,"monitor"); |
214 val = gIR->context().getNullValue(tmp->getType()->getContainedType(0)); | 214 val = LLConstant::getNullValue(tmp->getType()->getContainedType(0)); |
215 DtoStore(val, tmp); | 215 DtoStore(val, tmp); |
216 | 216 |
217 // done? | 217 // done? |
218 if (n == 0) | 218 if (n == 0) |
219 return; | 219 return; |
260 } | 260 } |
261 // class -> bool | 261 // class -> bool |
262 else if (to->ty == Tbool) { | 262 else if (to->ty == Tbool) { |
263 IF_LOG Logger::println("to bool"); | 263 IF_LOG Logger::println("to bool"); |
264 LLValue* llval = val->getRVal(); | 264 LLValue* llval = val->getRVal(); |
265 LLValue* zero = gIR->context().getNullValue(llval->getType()); | 265 LLValue* zero = LLConstant::getNullValue(llval->getType()); |
266 return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp")); | 266 return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp")); |
267 } | 267 } |
268 // class -> integer | 268 // class -> integer |
269 else if (to->isintegral()) { | 269 else if (to->isintegral()) { |
270 IF_LOG Logger::println("to %s", to->toChars()); | 270 IF_LOG Logger::println("to %s", to->toChars()); |
324 | 324 |
325 // Check whether the original value was null, and return null if so. | 325 // Check whether the original value was null, and return null if so. |
326 // Sure we could have jumped over the code above in this case, but | 326 // Sure we could have jumped over the code above in this case, but |
327 // it's just a GEP and (maybe) a pointer-to-pointer BitCast, so it | 327 // it's just a GEP and (maybe) a pointer-to-pointer BitCast, so it |
328 // should be pretty cheap and perfectly safe even if the original was null. | 328 // should be pretty cheap and perfectly safe even if the original was null. |
329 LLValue* isNull = gIR->ir->CreateICmpEQ(orig, gIR->context().getNullValue(orig->getType()), ".nullcheck"); | 329 LLValue* isNull = gIR->ir->CreateICmpEQ(orig, LLConstant::getNullValue(orig->getType()), ".nullcheck"); |
330 v = gIR->ir->CreateSelect(isNull, gIR->context().getNullValue(ifType), v, ".interface"); | 330 v = gIR->ir->CreateSelect(isNull, LLConstant::getNullValue(ifType), v, ".interface"); |
331 | 331 |
332 // return r-value | 332 // return r-value |
333 return new DImValue(_to, v); | 333 return new DImValue(_to, v); |
334 } | 334 } |
335 // class -> interface | 335 // class -> interface |
600 | 600 |
601 LLConstant* size = DtoConstSize_t(nvars); | 601 LLConstant* size = DtoConstSize_t(nvars); |
602 LLConstant* ptr; | 602 LLConstant* ptr; |
603 | 603 |
604 if (nvars == 0) | 604 if (nvars == 0) |
605 return gIR->context().getNullValue( arrayT ); | 605 return LLConstant::getNullValue( arrayT ); |
606 | 606 |
607 // array type | 607 // array type |
608 const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars); | 608 const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars); |
609 LLConstant* arrInit = LLConstantArray::get(arrTy, arrayInits); | 609 LLConstant* arrInit = LLConstantArray::get(arrTy, arrayInits); |
610 | 610 |