Lines Matching refs:CI

65 static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
70 Module *M = CI->getParent()->getParent()->getParent();
78 IRBuilder<> Builder(CI->getParent(), CI);
81 NewCI->setName(CI->getName());
82 if (!CI->use_empty())
83 CI->replaceAllUsesWith(NewCI);
317 static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
320 CallSite CS(CI);
321 switch (CI->getArgOperand(0)->getType()->getTypeID()) {
324 ReplaceCallWith(Fname, CI, CS.arg_begin(), CS.arg_end(),
325 Type::getFloatTy(CI->getContext()));
328 ReplaceCallWith(Dname, CI, CS.arg_begin(), CS.arg_end(),
329 Type::getDoubleTy(CI->getContext()));
334 ReplaceCallWith(LDname, CI, CS.arg_begin(), CS.arg_end(),
335 CI->getArgOperand(0)->getType());
340 void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
341 IRBuilder<> Builder(CI->getParent(), CI);
342 LLVMContext &Context = CI->getContext();
344 const Function *Callee = CI->getCalledFunction();
347 CallSite CS(CI);
358 Value *V = CI->getArgOperand(0);
359 CI->replaceAllUsesWith(V);
368 Value *V = ReplaceCallWith("setjmp", CI, CS.arg_begin(), CS.arg_end(),
370 if (!CI->getType()->isVoidTy())
371 CI->replaceAllUsesWith(V);
375 if (!CI->getType()->isVoidTy())
376 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
380 ReplaceCallWith("longjmp", CI, CS.arg_begin(), CS.arg_end(),
387 ReplaceCallWith("abort", CI, CS.arg_end(), CS.arg_end(),
392 CI->replaceAllUsesWith(LowerCTPOP(Context, CI->getArgOperand(0), CI));
396 CI->replaceAllUsesWith(LowerBSWAP(Context, CI->getArgOperand(0), CI));
400 CI->replaceAllUsesWith(LowerCTLZ(Context, CI->getArgOperand(0), CI));
405 Value *Src = CI->getArgOperand(0);
410 Src = LowerCTPOP(Context, Builder.CreateAnd(NotSrc, SrcM1), CI);
411 CI->replaceAllUsesWith(Src);
423 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
432 CI->replaceAllUsesWith(ConstantPointerNull::get(
433 cast<PointerType>(CI->getType())));
444 CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0));
453 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
459 CI->replaceAllUsesWith(CI->getOperand(0));
467 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
470 Ops[0] = CI->getArgOperand(0);
471 Ops[1] = CI->getArgOperand(1);
473 ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
478 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
481 Ops[0] = CI->getArgOperand(0);
482 Ops[1] = CI->getArgOperand(1);
484 ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
488 Value *Op0 = CI->getArgOperand(0);
490 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
495 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1),
499 ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
503 ReplaceFPIntrinsicWithCall(CI, "sqrtf", "sqrt", "sqrtl");
507 ReplaceFPIntrinsicWithCall(CI, "logf", "log", "logl");
511 ReplaceFPIntrinsicWithCall(CI, "log2f", "log2", "log2l");
515 ReplaceFPIntrinsicWithCall(CI, "log10f", "log10", "log10l");
519 ReplaceFPIntrinsicWithCall(CI, "expf", "exp", "expl");
523 ReplaceFPIntrinsicWithCall(CI, "exp2f", "exp2", "exp2l");
527 ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl");
532 if (!CI->getType()->isVoidTy())
533 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
538 CI->replaceAllUsesWith(UndefValue::get(CI->getType()));
546 assert(CI->use_empty() &&
548 CI->eraseFromParent();
551 bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) {
553 if (CI->getNumArgOperands() != 1 ||
554 CI->getType() != CI->getArgOperand(0)->getType() ||
555 !CI->getType()->isIntegerTy())
558 IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
563 Module *M = CI->getParent()->getParent()->getParent();
566 Value *Op = CI->getArgOperand(0);
567 Op = CallInst::Create(Int, Op, CI->getName(), CI);
569 CI->replaceAllUsesWith(Op);
570 CI->eraseFromParent();