Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1013:8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 28 Feb 2009 22:16:52 +0100 |
parents | 03d7c4aac654 |
children | 3d1b16dabd25 |
comparison
equal
deleted
inserted
replaced
1012:39cf8fa483fd | 1013:8c73ff5f69e0 |
---|---|
198 | 198 |
199 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, funcname); | 199 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, funcname); |
200 assert(fn); | 200 assert(fn); |
201 if (Logger::enabled()) | 201 if (Logger::enabled()) |
202 Logger::cout() << "calling array init function: " << *fn <<'\n'; | 202 Logger::cout() << "calling array init function: " << *fn <<'\n'; |
203 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); | 203 LLCallSite call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); |
204 call->setCallingConv(llvm::CallingConv::C); | 204 call.setCallingConv(llvm::CallingConv::C); |
205 } | 205 } |
206 | 206 |
207 ////////////////////////////////////////////////////////////////////////////////////////// | 207 ////////////////////////////////////////////////////////////////////////////////////////// |
208 | 208 |
209 void DtoSetArray(LLValue* arr, LLValue* dim, LLValue* ptr) | 209 void DtoSetArray(LLValue* arr, LLValue* dim, LLValue* ptr) |
390 bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit(); | 390 bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit(); |
391 const char* fnname = defaultInit ? (zeroInit ? "_d_newarrayT" : "_d_newarrayiT") : "_d_newarrayvT"; | 391 const char* fnname = defaultInit ? (zeroInit ? "_d_newarrayT" : "_d_newarrayiT") : "_d_newarrayvT"; |
392 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); | 392 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); |
393 | 393 |
394 // call allocator | 394 // call allocator |
395 LLValue* newptr = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem")->get(); | 395 LLValue* newptr = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction(); |
396 | 396 |
397 // cast to wanted type | 397 // cast to wanted type |
398 const LLType* dstType = DtoType(arrayType)->getContainedType(1); | 398 const LLType* dstType = DtoType(arrayType)->getContainedType(1); |
399 if (newptr->getType() != dstType) | 399 if (newptr->getType() != dstType) |
400 newptr = DtoBitCast(newptr, dstType, ".gc_mem"); | 400 newptr = DtoBitCast(newptr, dstType, ".gc_mem"); |
433 if (!firstDim) firstDim = dim; | 433 if (!firstDim) firstDim = dim; |
434 DtoStore(dim, DtoGEPi1(dimsArg, i)); | 434 DtoStore(dim, DtoGEPi1(dimsArg, i)); |
435 } | 435 } |
436 | 436 |
437 // call allocator | 437 // call allocator |
438 LLValue* newptr = gIR->CreateCallOrInvoke3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem")->get(); | 438 LLValue* newptr = gIR->CreateCallOrInvoke3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem").getInstruction(); |
439 | 439 |
440 // cast to wanted type | 440 // cast to wanted type |
441 const LLType* dstType = DtoType(arrayType)->getContainedType(1); | 441 const LLType* dstType = DtoType(arrayType)->getContainedType(1); |
442 if (newptr->getType() != dstType) | 442 if (newptr->getType() != dstType) |
443 newptr = DtoBitCast(newptr, dstType, ".gc_mem"); | 443 newptr = DtoBitCast(newptr, dstType, ".gc_mem"); |
474 LLValue* arrPtr = DtoArrayPtr(array); | 474 LLValue* arrPtr = DtoArrayPtr(array); |
475 if (Logger::enabled()) | 475 if (Logger::enabled()) |
476 Logger::cout() << "arrPtr = " << *arrPtr << '\n'; | 476 Logger::cout() << "arrPtr = " << *arrPtr << '\n'; |
477 args.push_back(DtoBitCast(arrPtr, fn->getFunctionType()->getParamType(3), "tmp")); | 477 args.push_back(DtoBitCast(arrPtr, fn->getFunctionType()->getParamType(3), "tmp")); |
478 | 478 |
479 LLValue* newptr = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), ".gc_mem")->get(); | 479 LLValue* newptr = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), ".gc_mem").getInstruction(); |
480 if (newptr->getType() != arrPtr->getType()) | 480 if (newptr->getType() != arrPtr->getType()) |
481 newptr = DtoBitCast(newptr, arrPtr->getType(), ".gc_mem"); | 481 newptr = DtoBitCast(newptr, arrPtr->getType(), ".gc_mem"); |
482 | 482 |
483 return new DSliceValue(arrayType, newdim->getRVal(), newptr); | 483 return new DSliceValue(arrayType, newdim->getRVal(), newptr); |
484 } | 484 } |
682 Logger::cout() << "typeinfo decl: " << *tival << '\n'; | 682 Logger::cout() << "typeinfo decl: " << *tival << '\n'; |
683 | 683 |
684 args.push_back(DtoBitCast(tival, fn->getFunctionType()->getParamType(2))); | 684 args.push_back(DtoBitCast(tival, fn->getFunctionType()->getParamType(2))); |
685 } | 685 } |
686 | 686 |
687 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp"); | 687 LLCallSite call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp"); |
688 | 688 |
689 return call->get(); | 689 return call.getInstruction(); |
690 } | 690 } |
691 | 691 |
692 ////////////////////////////////////////////////////////////////////////////////////////// | 692 ////////////////////////////////////////////////////////////////////////////////////////// |
693 LLValue* DtoArrayEquals(Loc& loc, TOK op, DValue* l, DValue* r) | 693 LLValue* DtoArrayEquals(Loc& loc, TOK op, DValue* l, DValue* r) |
694 { | 694 { |
778 args.push_back(len); | 778 args.push_back(len); |
779 args.push_back(llvm::ConstantInt::get(DtoSize_t(), esz, false)); | 779 args.push_back(llvm::ConstantInt::get(DtoSize_t(), esz, false)); |
780 args.push_back(llvm::ConstantInt::get(DtoSize_t(), nsz, false)); | 780 args.push_back(llvm::ConstantInt::get(DtoSize_t(), nsz, false)); |
781 | 781 |
782 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); | 782 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); |
783 return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp")->get(); | 783 return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp").getInstruction(); |
784 } | 784 } |
785 | 785 |
786 ////////////////////////////////////////////////////////////////////////////////////////// | 786 ////////////////////////////////////////////////////////////////////////////////////////// |
787 LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r) | 787 LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r) |
788 { | 788 { |
991 LLConstant* c = DtoConstUint(loc.linnum); | 991 LLConstant* c = DtoConstUint(loc.linnum); |
992 args.push_back(c); | 992 args.push_back(c); |
993 | 993 |
994 // call | 994 // call |
995 llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds"); | 995 llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds"); |
996 CallOrInvoke* call = gIR->CreateCallOrInvoke(errorfn, args.begin(), args.end()); | 996 gIR->CreateCallOrInvoke(errorfn, args.begin(), args.end()); |
997 | 997 |
998 // the function does not return | 998 // the function does not return |
999 gIR->ir->CreateUnreachable(); | 999 gIR->ir->CreateUnreachable(); |
1000 | 1000 |
1001 // if ok, proceed in okbb | 1001 // if ok, proceed in okbb |