Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1545:7fcb72d518f6
More factory methods moved to LLVMContext
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Wed, 15 Jul 2009 18:09:41 +0200 |
parents | 61f12f4651b5 |
children | a326f145a57b |
comparison
equal
deleted
inserted
replaced
1544:8863cf7236e6 | 1545:7fcb72d518f6 |
---|---|
307 mismatch = true; | 307 mismatch = true; |
308 } | 308 } |
309 | 309 |
310 LLConstant* constarr; | 310 LLConstant* constarr; |
311 if (mismatch) | 311 if (mismatch) |
312 constarr = LLConstantStruct::get(initvals); | 312 constarr = gIR->context().getConstantStruct(initvals); |
313 else | 313 else |
314 constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals); | 314 constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals); |
315 | 315 |
316 // std::cout << "constarr: " << *constarr << std::endl; | 316 // std::cout << "constarr: " << *constarr << std::endl; |
317 | 317 |
392 | 392 |
393 ////////////////////////////////////////////////////////////////////////////////////////// | 393 ////////////////////////////////////////////////////////////////////////////////////////// |
394 LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr) | 394 LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr) |
395 { | 395 { |
396 LLConstant* values[2] = { dim, ptr }; | 396 LLConstant* values[2] = { dim, ptr }; |
397 return llvm::ConstantStruct::get(values, 2); | 397 return gIR->context().getConstantStruct(values, 2); |
398 } | 398 } |
399 | 399 |
400 ////////////////////////////////////////////////////////////////////////////////////////// | 400 ////////////////////////////////////////////////////////////////////////////////////////// |
401 static bool isInitialized(Type* et) { | 401 static bool isInitialized(Type* et) { |
402 // Strip static array types from element type | 402 // Strip static array types from element type |
824 if (esz == nsz) | 824 if (esz == nsz) |
825 return len; | 825 return len; |
826 | 826 |
827 LLSmallVector<LLValue*, 3> args; | 827 LLSmallVector<LLValue*, 3> args; |
828 args.push_back(len); | 828 args.push_back(len); |
829 args.push_back(llvm::ConstantInt::get(DtoSize_t(), esz, false)); | 829 args.push_back(gIR->context().getConstantInt(DtoSize_t(), esz, false)); |
830 args.push_back(llvm::ConstantInt::get(DtoSize_t(), nsz, false)); | 830 args.push_back(gIR->context().getConstantInt(DtoSize_t(), nsz, false)); |
831 | 831 |
832 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); | 832 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); |
833 return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp").getInstruction(); | 833 return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp").getInstruction(); |
834 } | 834 } |
835 | 835 |
960 { | 960 { |
961 error(loc, "invalid cast from '%s' to '%s', the element sizes don't line up", fromtype->toChars(), totype->toChars()); | 961 error(loc, "invalid cast from '%s' to '%s', the element sizes don't line up", fromtype->toChars(), totype->toChars()); |
962 fatal(); | 962 fatal(); |
963 } | 963 } |
964 | 964 |
965 rval2 = llvm::ConstantInt::get(DtoSize_t(), arrty->getNumElements(), false); | 965 rval2 = gIR->context().getConstantInt(DtoSize_t(), arrty->getNumElements(), false); |
966 if (fromtype->nextOf()->size() != totype->nextOf()->size()) | 966 if (fromtype->nextOf()->size() != totype->nextOf()->size()) |
967 rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0)); | 967 rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0)); |
968 rval = DtoBitCast(uval, ptrty); | 968 rval = DtoBitCast(uval, ptrty); |
969 } | 969 } |
970 else { | 970 else { |