Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1554:d6e8d5db259f
LLVMContext changes up to r77366
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Thu, 30 Jul 2009 15:25:10 +0200 |
parents | a326f145a57b |
children | 06d5cc873350 |
comparison
equal
deleted
inserted
replaced
1553:f55ca8a1598c | 1554:d6e8d5db259f |
---|---|
307 mismatch = true; | 307 mismatch = true; |
308 } | 308 } |
309 | 309 |
310 LLConstant* constarr; | 310 LLConstant* constarr; |
311 if (mismatch) | 311 if (mismatch) |
312 constarr = gIR->context().getConstantStruct(initvals); | 312 constarr = LLConstantStruct::get(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 gIR->context().getConstantStruct(values, 2); | 397 return LLConstantStruct::get(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 |
782 case TOKlg: | 782 case TOKlg: |
783 cmpop = llvm::ICmpInst::ICMP_NE; | 783 cmpop = llvm::ICmpInst::ICMP_NE; |
784 break; | 784 break; |
785 case TOKleg: | 785 case TOKleg: |
786 skip = true; | 786 skip = true; |
787 res = gIR->context().getConstantIntTrue(); | 787 res = gIR->context().getTrue(); |
788 break; | 788 break; |
789 case TOKunord: | 789 case TOKunord: |
790 skip = true; | 790 skip = true; |
791 res = gIR->context().getConstantIntFalse(); | 791 res = gIR->context().getFalse(); |
792 break; | 792 break; |
793 | 793 |
794 default: | 794 default: |
795 assert(0); | 795 assert(0); |
796 } | 796 } |
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(gIR->context().getConstantInt(DtoSize_t(), esz, false)); | 829 args.push_back(LLConstantInt::get(DtoSize_t(), esz, false)); |
830 args.push_back(gIR->context().getConstantInt(DtoSize_t(), nsz, false)); | 830 args.push_back(LLConstantInt::get(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 = gIR->context().getConstantInt(DtoSize_t(), arrty->getNumElements(), false); | 965 rval2 = LLConstantInt::get(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 { |