Home | History | Annotate | Download | only in CodeGen

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(Constant::getNullValue(CI->getType()));
458 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
466 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
469 Ops[0] = CI->getArgOperand(0);
470 Ops[1] = CI->getArgOperand(1);
472 ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
477 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
480 Ops[0] = CI->getArgOperand(0);
481 Ops[1] = CI->getArgOperand(1);
483 ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
488 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
491 Ops[0] = CI->getArgOperand(0);
493 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1),
497 ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getArgOperand(0)->getType());
501 ReplaceFPIntrinsicWithCall(CI, "sqrtf", "sqrt", "sqrtl");
505 ReplaceFPIntrinsicWithCall(CI, "logf", "log", "logl");
509 ReplaceFPIntrinsicWithCall(CI, "log2f", "log2", "log2l");
513 ReplaceFPIntrinsicWithCall(CI, "log10f", "log10", "log10l");
517 ReplaceFPIntrinsicWithCall(CI, "expf", "exp", "expl");
521 ReplaceFPIntrinsicWithCall(CI, "exp2f", "exp2", "exp2l");
525 ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl");
530 if (!CI->getType()->isVoidTy())
531 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
536 CI->replaceAllUsesWith(UndefValue::get(CI->getType()));
544 assert(CI->use_empty() &&
546 CI->eraseFromParent();
549 bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) {
551 if (CI->getNumArgOperands() != 1 ||
552 CI->getType() != CI->getArgOperand(0)->getType() ||
553 !CI->getType()->isIntegerTy())
556 IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
561 Module *M = CI->getParent()->getParent()->getParent();
564 Value *Op = CI->getArgOperand(0);
565 Op = CallInst::Create(Int, Op, CI->getName(), CI);
567 CI->replaceAllUsesWith(Op);
568 CI->eraseFromParent();