Lines Matching refs:CI
65 static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI, in ReplaceCallWith() argument
70 Module *M = CI->getParent()->getParent()->getParent(); in ReplaceCallWith()
78 IRBuilder<> Builder(CI->getParent(), CI); in ReplaceCallWith()
81 NewCI->setName(CI->getName()); in ReplaceCallWith()
82 if (!CI->use_empty()) in ReplaceCallWith()
83 CI->replaceAllUsesWith(NewCI); in ReplaceCallWith()
317 static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname, in ReplaceFPIntrinsicWithCall() argument
320 CallSite CS(CI); in ReplaceFPIntrinsicWithCall()
321 switch (CI->getArgOperand(0)->getType()->getTypeID()) { in ReplaceFPIntrinsicWithCall()
324 ReplaceCallWith(Fname, CI, CS.arg_begin(), CS.arg_end(), in ReplaceFPIntrinsicWithCall()
325 Type::getFloatTy(CI->getContext())); in ReplaceFPIntrinsicWithCall()
328 ReplaceCallWith(Dname, CI, CS.arg_begin(), CS.arg_end(), in ReplaceFPIntrinsicWithCall()
329 Type::getDoubleTy(CI->getContext())); in ReplaceFPIntrinsicWithCall()
334 ReplaceCallWith(LDname, CI, CS.arg_begin(), CS.arg_end(), in ReplaceFPIntrinsicWithCall()
335 CI->getArgOperand(0)->getType()); in ReplaceFPIntrinsicWithCall()
340 void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { in LowerIntrinsicCall() argument
341 IRBuilder<> Builder(CI->getParent(), CI); in LowerIntrinsicCall()
342 LLVMContext &Context = CI->getContext(); in LowerIntrinsicCall()
344 const Function *Callee = CI->getCalledFunction(); in LowerIntrinsicCall()
347 CallSite CS(CI); in LowerIntrinsicCall()
358 Value *V = CI->getArgOperand(0); in LowerIntrinsicCall()
359 CI->replaceAllUsesWith(V); in LowerIntrinsicCall()
368 Value *V = ReplaceCallWith("setjmp", CI, CS.arg_begin(), CS.arg_end(), in LowerIntrinsicCall()
370 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
371 CI->replaceAllUsesWith(V); in LowerIntrinsicCall()
375 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
376 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); in LowerIntrinsicCall()
380 ReplaceCallWith("longjmp", CI, CS.arg_begin(), CS.arg_end(), in LowerIntrinsicCall()
387 ReplaceCallWith("abort", CI, CS.arg_end(), CS.arg_end(), in LowerIntrinsicCall()
392 CI->replaceAllUsesWith(LowerCTPOP(Context, CI->getArgOperand(0), CI)); in LowerIntrinsicCall()
396 CI->replaceAllUsesWith(LowerBSWAP(Context, CI->getArgOperand(0), CI)); in LowerIntrinsicCall()
400 CI->replaceAllUsesWith(LowerCTLZ(Context, CI->getArgOperand(0), CI)); in LowerIntrinsicCall()
405 Value *Src = CI->getArgOperand(0); in LowerIntrinsicCall()
410 Src = LowerCTPOP(Context, Builder.CreateAnd(NotSrc, SrcM1), CI); in LowerIntrinsicCall()
411 CI->replaceAllUsesWith(Src); in LowerIntrinsicCall()
423 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); in LowerIntrinsicCall()
432 CI->replaceAllUsesWith(ConstantPointerNull::get( in LowerIntrinsicCall()
433 cast<PointerType>(CI->getType()))); in LowerIntrinsicCall()
444 CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0)); in LowerIntrinsicCall()
453 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); in LowerIntrinsicCall()
458 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); in LowerIntrinsicCall()
466 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
469 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
470 Ops[1] = CI->getArgOperand(1); in LowerIntrinsicCall()
472 ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
477 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
480 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
481 Ops[1] = CI->getArgOperand(1); in LowerIntrinsicCall()
483 ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
488 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
491 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
493 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1), in LowerIntrinsicCall()
497 ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
501 ReplaceFPIntrinsicWithCall(CI, "sqrtf", "sqrt", "sqrtl"); in LowerIntrinsicCall()
505 ReplaceFPIntrinsicWithCall(CI, "logf", "log", "logl"); in LowerIntrinsicCall()
509 ReplaceFPIntrinsicWithCall(CI, "log2f", "log2", "log2l"); in LowerIntrinsicCall()
513 ReplaceFPIntrinsicWithCall(CI, "log10f", "log10", "log10l"); in LowerIntrinsicCall()
517 ReplaceFPIntrinsicWithCall(CI, "expf", "exp", "expl"); in LowerIntrinsicCall()
521 ReplaceFPIntrinsicWithCall(CI, "exp2f", "exp2", "exp2l"); in LowerIntrinsicCall()
525 ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl"); in LowerIntrinsicCall()
530 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
531 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); in LowerIntrinsicCall()
536 CI->replaceAllUsesWith(UndefValue::get(CI->getType())); in LowerIntrinsicCall()
544 assert(CI->use_empty() && in LowerIntrinsicCall()
546 CI->eraseFromParent(); in LowerIntrinsicCall()
549 bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { in LowerToByteSwap() argument
551 if (CI->getNumArgOperands() != 1 || in LowerToByteSwap()
552 CI->getType() != CI->getArgOperand(0)->getType() || in LowerToByteSwap()
553 !CI->getType()->isIntegerTy()) in LowerToByteSwap()
556 IntegerType *Ty = dyn_cast<IntegerType>(CI->getType()); in LowerToByteSwap()
561 Module *M = CI->getParent()->getParent()->getParent(); in LowerToByteSwap()
564 Value *Op = CI->getArgOperand(0); in LowerToByteSwap()
565 Op = CallInst::Create(Int, Op, CI->getName(), CI); in LowerToByteSwap()
567 CI->replaceAllUsesWith(Op); in LowerToByteSwap()
568 CI->eraseFromParent(); in LowerToByteSwap()