Lines Matching refs:CI
65 static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI, in ReplaceCallWith() argument
70 Module *M = CI->getModule(); in ReplaceCallWith()
78 IRBuilder<> Builder(CI->getParent(), CI->getIterator()); 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); 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(ConstantInt::get(CI->getType(), 0)); in LowerIntrinsicCall()
439 CI->replaceAllUsesWith(ConstantPointerNull::get( in LowerIntrinsicCall()
440 cast<PointerType>(CI->getType()))); in LowerIntrinsicCall()
451 CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0)); in LowerIntrinsicCall()
460 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); in LowerIntrinsicCall()
466 CI->replaceAllUsesWith(CI->getOperand(0)); in LowerIntrinsicCall()
475 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
478 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
479 Ops[1] = CI->getArgOperand(1); in LowerIntrinsicCall()
481 ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
486 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
489 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
490 Ops[1] = CI->getArgOperand(1); in LowerIntrinsicCall()
492 ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
496 Value *Op0 = CI->getArgOperand(0); in LowerIntrinsicCall()
498 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
503 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1), in LowerIntrinsicCall()
507 ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
511 ReplaceFPIntrinsicWithCall(CI, "sqrtf", "sqrt", "sqrtl"); in LowerIntrinsicCall()
515 ReplaceFPIntrinsicWithCall(CI, "logf", "log", "logl"); in LowerIntrinsicCall()
519 ReplaceFPIntrinsicWithCall(CI, "log2f", "log2", "log2l"); in LowerIntrinsicCall()
523 ReplaceFPIntrinsicWithCall(CI, "log10f", "log10", "log10l"); in LowerIntrinsicCall()
527 ReplaceFPIntrinsicWithCall(CI, "expf", "exp", "expl"); in LowerIntrinsicCall()
531 ReplaceFPIntrinsicWithCall(CI, "exp2f", "exp2", "exp2l"); in LowerIntrinsicCall()
535 ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl"); in LowerIntrinsicCall()
539 ReplaceFPIntrinsicWithCall(CI, "sinf", "sin", "sinl"); in LowerIntrinsicCall()
543 ReplaceFPIntrinsicWithCall(CI, "cosf", "cos", "cosl"); in LowerIntrinsicCall()
547 ReplaceFPIntrinsicWithCall(CI, "floorf", "floor", "floorl"); in LowerIntrinsicCall()
551 ReplaceFPIntrinsicWithCall(CI, "ceilf", "ceil", "ceill"); in LowerIntrinsicCall()
555 ReplaceFPIntrinsicWithCall(CI, "truncf", "trunc", "truncl"); in LowerIntrinsicCall()
559 ReplaceFPIntrinsicWithCall(CI, "roundf", "round", "roundl"); in LowerIntrinsicCall()
563 ReplaceFPIntrinsicWithCall(CI, "copysignf", "copysign", "copysignl"); in LowerIntrinsicCall()
568 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
569 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); in LowerIntrinsicCall()
574 CI->replaceAllUsesWith(UndefValue::get(CI->getType())); in LowerIntrinsicCall()
582 assert(CI->use_empty() && in LowerIntrinsicCall()
584 CI->eraseFromParent(); in LowerIntrinsicCall()
587 bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { in LowerToByteSwap() argument
589 if (CI->getNumArgOperands() != 1 || in LowerToByteSwap()
590 CI->getType() != CI->getArgOperand(0)->getType() || in LowerToByteSwap()
591 !CI->getType()->isIntegerTy()) in LowerToByteSwap()
594 IntegerType *Ty = dyn_cast<IntegerType>(CI->getType()); in LowerToByteSwap()
599 Module *M = CI->getModule(); in LowerToByteSwap()
602 Value *Op = CI->getArgOperand(0); in LowerToByteSwap()
603 Op = CallInst::Create(Int, Op, CI->getName(), CI); in LowerToByteSwap()
605 CI->replaceAllUsesWith(Op); in LowerToByteSwap()
606 CI->eraseFromParent(); in LowerToByteSwap()