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()
314 static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname, in ReplaceFPIntrinsicWithCall() argument
317 CallSite CS(CI); in ReplaceFPIntrinsicWithCall()
318 switch (CI->getArgOperand(0)->getType()->getTypeID()) { in ReplaceFPIntrinsicWithCall()
321 ReplaceCallWith(Fname, CI, CS.arg_begin(), CS.arg_end(), in ReplaceFPIntrinsicWithCall()
322 Type::getFloatTy(CI->getContext())); in ReplaceFPIntrinsicWithCall()
325 ReplaceCallWith(Dname, CI, CS.arg_begin(), CS.arg_end(), in ReplaceFPIntrinsicWithCall()
326 Type::getDoubleTy(CI->getContext())); in ReplaceFPIntrinsicWithCall()
331 ReplaceCallWith(LDname, CI, CS.arg_begin(), CS.arg_end(), in ReplaceFPIntrinsicWithCall()
332 CI->getArgOperand(0)->getType()); in ReplaceFPIntrinsicWithCall()
337 void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { in LowerIntrinsicCall() argument
338 IRBuilder<> Builder(CI); in LowerIntrinsicCall()
339 LLVMContext &Context = CI->getContext(); in LowerIntrinsicCall()
341 const Function *Callee = CI->getCalledFunction(); in LowerIntrinsicCall()
344 CallSite CS(CI); in LowerIntrinsicCall()
355 Value *V = CI->getArgOperand(0); in LowerIntrinsicCall()
356 CI->replaceAllUsesWith(V); in LowerIntrinsicCall()
365 Value *V = ReplaceCallWith("setjmp", CI, CS.arg_begin(), CS.arg_end(), in LowerIntrinsicCall()
367 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
368 CI->replaceAllUsesWith(V); in LowerIntrinsicCall()
372 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
373 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); in LowerIntrinsicCall()
377 ReplaceCallWith("longjmp", CI, CS.arg_begin(), CS.arg_end(), in LowerIntrinsicCall()
384 ReplaceCallWith("abort", CI, CS.arg_end(), CS.arg_end(), in LowerIntrinsicCall()
389 CI->replaceAllUsesWith(LowerCTPOP(Context, CI->getArgOperand(0), CI)); in LowerIntrinsicCall()
393 CI->replaceAllUsesWith(LowerBSWAP(Context, CI->getArgOperand(0), CI)); in LowerIntrinsicCall()
397 CI->replaceAllUsesWith(LowerCTLZ(Context, CI->getArgOperand(0), CI)); in LowerIntrinsicCall()
402 Value *Src = CI->getArgOperand(0); in LowerIntrinsicCall()
407 Src = LowerCTPOP(Context, Builder.CreateAnd(NotSrc, SrcM1), CI); in LowerIntrinsicCall()
408 CI->replaceAllUsesWith(Src); in LowerIntrinsicCall()
420 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); in LowerIntrinsicCall()
429 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 0)); in LowerIntrinsicCall()
436 CI->replaceAllUsesWith( in LowerIntrinsicCall()
437 ConstantPointerNull::get(cast<PointerType>(CI->getType()))); in LowerIntrinsicCall()
442 CI->replaceAllUsesWith( in LowerIntrinsicCall()
443 ConstantPointerNull::get(cast<PointerType>(CI->getType()))); in LowerIntrinsicCall()
454 CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0)); in LowerIntrinsicCall()
464 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); in LowerIntrinsicCall()
470 CI->replaceAllUsesWith(CI->getOperand(0)); in LowerIntrinsicCall()
479 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
482 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
483 Ops[1] = CI->getArgOperand(1); in LowerIntrinsicCall()
485 ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
490 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
493 Ops[0] = CI->getArgOperand(0); in LowerIntrinsicCall()
494 Ops[1] = CI->getArgOperand(1); in LowerIntrinsicCall()
496 ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
500 Value *Op0 = CI->getArgOperand(0); in LowerIntrinsicCall()
502 Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr, in LowerIntrinsicCall()
507 Ops[1] = Builder.CreateIntCast(CI->getArgOperand(1), in LowerIntrinsicCall()
511 ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getArgOperand(0)->getType()); in LowerIntrinsicCall()
515 ReplaceFPIntrinsicWithCall(CI, "sqrtf", "sqrt", "sqrtl"); in LowerIntrinsicCall()
519 ReplaceFPIntrinsicWithCall(CI, "logf", "log", "logl"); in LowerIntrinsicCall()
523 ReplaceFPIntrinsicWithCall(CI, "log2f", "log2", "log2l"); in LowerIntrinsicCall()
527 ReplaceFPIntrinsicWithCall(CI, "log10f", "log10", "log10l"); in LowerIntrinsicCall()
531 ReplaceFPIntrinsicWithCall(CI, "expf", "exp", "expl"); in LowerIntrinsicCall()
535 ReplaceFPIntrinsicWithCall(CI, "exp2f", "exp2", "exp2l"); in LowerIntrinsicCall()
539 ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl"); in LowerIntrinsicCall()
543 ReplaceFPIntrinsicWithCall(CI, "sinf", "sin", "sinl"); in LowerIntrinsicCall()
547 ReplaceFPIntrinsicWithCall(CI, "cosf", "cos", "cosl"); in LowerIntrinsicCall()
551 ReplaceFPIntrinsicWithCall(CI, "floorf", "floor", "floorl"); in LowerIntrinsicCall()
555 ReplaceFPIntrinsicWithCall(CI, "ceilf", "ceil", "ceill"); in LowerIntrinsicCall()
559 ReplaceFPIntrinsicWithCall(CI, "truncf", "trunc", "truncl"); in LowerIntrinsicCall()
563 ReplaceFPIntrinsicWithCall(CI, "roundf", "round", "roundl"); in LowerIntrinsicCall()
567 ReplaceFPIntrinsicWithCall(CI, "copysignf", "copysign", "copysignl"); in LowerIntrinsicCall()
572 if (!CI->getType()->isVoidTy()) in LowerIntrinsicCall()
573 CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); in LowerIntrinsicCall()
578 CI->replaceAllUsesWith(UndefValue::get(CI->getType())); in LowerIntrinsicCall()
586 assert(CI->use_empty() && in LowerIntrinsicCall()
588 CI->eraseFromParent(); in LowerIntrinsicCall()
591 bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { in LowerToByteSwap() argument
593 if (CI->getNumArgOperands() != 1 || in LowerToByteSwap()
594 CI->getType() != CI->getArgOperand(0)->getType() || in LowerToByteSwap()
595 !CI->getType()->isIntegerTy()) in LowerToByteSwap()
598 IntegerType *Ty = dyn_cast<IntegerType>(CI->getType()); in LowerToByteSwap()
603 Module *M = CI->getModule(); in LowerToByteSwap()
606 Value *Op = CI->getArgOperand(0); in LowerToByteSwap()
607 Op = CallInst::Create(Int, Op, CI->getName(), CI); in LowerToByteSwap()
609 CI->replaceAllUsesWith(Op); in LowerToByteSwap()
610 CI->eraseFromParent(); in LowerToByteSwap()