}
}
-static CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
- IRBuilderBase *Builder,
- const Twine &Name = "",
- Instruction *FMFSource = nullptr,
- ArrayRef<OperandBundleDef> OpBundles = {}) {
- CallInst *CI = Builder->CreateCall(Callee, Ops, OpBundles, Name);
+CallInst *
+IRBuilderBase::createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
+ const Twine &Name, Instruction *FMFSource,
+ ArrayRef<OperandBundleDef> OpBundles) {
+ CallInst *CI = CreateCall(Callee, Ops, OpBundles, Name);
if (FMFSource)
CI->copyFastMathFlags(FMFSource);
return CI;
Module *M = GetInsertBlock()->getParent()->getParent();
Function *TheFn =
Intrinsic::getDeclaration(M, Intrinsic::vscale, {Scaling->getType()});
- CallInst *CI = createCallHelper(TheFn, {}, this, Name);
+ CallInst *CI = CreateCall(TheFn, {}, {}, Name);
return cast<ConstantInt>(Scaling)->getSExtValue() == 1
? CI
: CreateMul(CI, Scaling);
Module *M = BB->getParent()->getParent();
Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
if (Align)
cast<MemSetInst>(CI)->setDestAlignment(*Align);
Module *M = BB->getParent()->getParent();
Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset_inline, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
if (DstAlign)
cast<MemSetInlineInst>(CI)->setDestAlignment(*DstAlign);
Function *TheFn = Intrinsic::getDeclaration(
M, Intrinsic::memset_element_unordered_atomic, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
cast<AtomicMemSetInst>(CI)->setDestAlignment(Alignment);
Module *M = BB->getParent()->getParent();
Function *TheFn = Intrinsic::getDeclaration(M, IntrID, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
auto* MCI = cast<MemTransferInst>(CI);
if (DstAlign)
Module *M = F->getParent();
Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
auto *MCI = cast<MemCpyInlineInst>(CI);
if (DstAlign)
Function *TheFn = Intrinsic::getDeclaration(
M, Intrinsic::memcpy_element_unordered_atomic, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
// Set the alignment of the pointer args.
auto *AMCI = cast<AtomicMemCpyInst>(CI);
Module *M = BB->getParent()->getParent();
Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
auto *MMI = cast<MemMoveInst>(CI);
if (DstAlign)
Function *TheFn = Intrinsic::getDeclaration(
M, Intrinsic::memmove_element_unordered_atomic, Tys);
- CallInst *CI = createCallHelper(TheFn, Ops, this);
+ CallInst *CI = CreateCall(TheFn, Ops);
// Set the alignment of the pointer args.
CI->addParamAttr(0, Attribute::getWithAlignment(CI->getContext(), DstAlign));
return CI;
}
-static CallInst *getReductionIntrinsic(IRBuilderBase *Builder, Intrinsic::ID ID,
- Value *Src) {
- Module *M = Builder->GetInsertBlock()->getParent()->getParent();
+CallInst *IRBuilderBase::getReductionIntrinsic(Intrinsic::ID ID, Value *Src) {
+ Module *M = GetInsertBlock()->getParent()->getParent();
Value *Ops[] = {Src};
Type *Tys[] = { Src->getType() };
auto Decl = Intrinsic::getDeclaration(M, ID, Tys);
- return createCallHelper(Decl, Ops, Builder);
+ return CreateCall(Decl, Ops);
}
CallInst *IRBuilderBase::CreateFAddReduce(Value *Acc, Value *Src) {
Value *Ops[] = {Acc, Src};
auto Decl = Intrinsic::getDeclaration(M, Intrinsic::vector_reduce_fadd,
{Src->getType()});
- return createCallHelper(Decl, Ops, this);
+ return CreateCall(Decl, Ops);
}
CallInst *IRBuilderBase::CreateFMulReduce(Value *Acc, Value *Src) {
Value *Ops[] = {Acc, Src};
auto Decl = Intrinsic::getDeclaration(M, Intrinsic::vector_reduce_fmul,
{Src->getType()});
- return createCallHelper(Decl, Ops, this);
+ return CreateCall(Decl, Ops);
}
CallInst *IRBuilderBase::CreateAddReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_add, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_add, Src);
}
CallInst *IRBuilderBase::CreateMulReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_mul, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_mul, Src);
}
CallInst *IRBuilderBase::CreateAndReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_and, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_and, Src);
}
CallInst *IRBuilderBase::CreateOrReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_or, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_or, Src);
}
CallInst *IRBuilderBase::CreateXorReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_xor, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_xor, Src);
}
CallInst *IRBuilderBase::CreateIntMaxReduce(Value *Src, bool IsSigned) {
auto ID =
IsSigned ? Intrinsic::vector_reduce_smax : Intrinsic::vector_reduce_umax;
- return getReductionIntrinsic(this, ID, Src);
+ return getReductionIntrinsic(ID, Src);
}
CallInst *IRBuilderBase::CreateIntMinReduce(Value *Src, bool IsSigned) {
auto ID =
IsSigned ? Intrinsic::vector_reduce_smin : Intrinsic::vector_reduce_umin;
- return getReductionIntrinsic(this, ID, Src);
+ return getReductionIntrinsic(ID, Src);
}
CallInst *IRBuilderBase::CreateFPMaxReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_fmax, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_fmax, Src);
}
CallInst *IRBuilderBase::CreateFPMinReduce(Value *Src) {
- return getReductionIntrinsic(this, Intrinsic::vector_reduce_fmin, Src);
+ return getReductionIntrinsic(Intrinsic::vector_reduce_fmin, Src);
}
CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr, ConstantInt *Size) {
Module *M = BB->getParent()->getParent();
Function *TheFn =
Intrinsic::getDeclaration(M, Intrinsic::lifetime_start, {Ptr->getType()});
- return createCallHelper(TheFn, Ops, this);
+ return CreateCall(TheFn, Ops);
}
CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
Module *M = BB->getParent()->getParent();
Function *TheFn =
Intrinsic::getDeclaration(M, Intrinsic::lifetime_end, {Ptr->getType()});
- return createCallHelper(TheFn, Ops, this);
+ return CreateCall(TheFn, Ops);
}
CallInst *IRBuilderBase::CreateInvariantStart(Value *Ptr, ConstantInt *Size) {
Module *M = BB->getParent()->getParent();
Function *TheFn =
Intrinsic::getDeclaration(M, Intrinsic::invariant_start, ObjectPtr);
- return createCallHelper(TheFn, Ops, this);
+ return CreateCall(TheFn, Ops);
}
CallInst *
Value *Ops[] = { Cond };
Module *M = BB->getParent()->getParent();
Function *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume);
- return createCallHelper(FnAssume, Ops, this, "", nullptr, OpBundles);
+ return CreateCall(FnAssume, Ops, OpBundles);
}
Instruction *IRBuilderBase::CreateNoAliasScopeDeclaration(Value *Scope) {
Module *M = BB->getModule();
auto *FnIntrinsic = Intrinsic::getDeclaration(
M, Intrinsic::experimental_noalias_scope_decl, {});
- return createCallHelper(FnIntrinsic, {Scope}, this);
+ return CreateCall(FnIntrinsic, {Scope});
}
/// Create a call to a Masked Load intrinsic.
const Twine &Name) {
Module *M = BB->getParent()->getParent();
Function *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
- return createCallHelper(TheFn, Ops, this, Name);
+ return CreateCall(TheFn, Ops, {}, Name);
}
/// Create a call to a Masked Gather intrinsic.
Function *FnGCResult = Intrinsic::getDeclaration(M, ID, Types);
Value *Args[] = {Statepoint};
- return createCallHelper(FnGCResult, Args, this, Name);
+ return CreateCall(FnGCResult, Args, {}, Name);
}
CallInst *IRBuilderBase::CreateGCRelocate(Instruction *Statepoint,
Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
Value *Args[] = {Statepoint, getInt32(BaseOffset), getInt32(DerivedOffset)};
- return createCallHelper(FnGCRelocate, Args, this, Name);
+ return CreateCall(FnGCRelocate, Args, {}, Name);
}
CallInst *IRBuilderBase::CreateGCGetPointerBase(Value *DerivedPtr,
Type *PtrTy = DerivedPtr->getType();
Function *FnGCFindBase = Intrinsic::getDeclaration(
M, Intrinsic::experimental_gc_get_pointer_base, {PtrTy, PtrTy});
- return createCallHelper(FnGCFindBase, {DerivedPtr}, this, Name);
+ return CreateCall(FnGCFindBase, {DerivedPtr}, {}, Name);
}
CallInst *IRBuilderBase::CreateGCGetPointerOffset(Value *DerivedPtr,
Type *PtrTy = DerivedPtr->getType();
Function *FnGCGetOffset = Intrinsic::getDeclaration(
M, Intrinsic::experimental_gc_get_pointer_offset, {PtrTy});
- return createCallHelper(FnGCGetOffset, {DerivedPtr}, this, Name);
+ return CreateCall(FnGCGetOffset, {DerivedPtr}, {}, Name);
}
CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V,
const Twine &Name) {
Module *M = BB->getModule();
Function *Fn = Intrinsic::getDeclaration(M, ID, {V->getType()});
- return createCallHelper(Fn, {V}, this, Name, FMFSource);
+ return createCallHelper(Fn, {V}, Name, FMFSource);
}
CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS,
const Twine &Name) {
Module *M = BB->getModule();
Function *Fn = Intrinsic::getDeclaration(M, ID, { LHS->getType() });
- return createCallHelper(Fn, {LHS, RHS}, this, Name, FMFSource);
+ return createCallHelper(Fn, {LHS, RHS}, Name, FMFSource);
}
CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID,
const Twine &Name) {
Module *M = BB->getModule();
Function *Fn = Intrinsic::getDeclaration(M, ID, Types);
- return createCallHelper(Fn, Args, this, Name, FMFSource);
+ return createCallHelper(Fn, Args, Name, FMFSource);
}
CallInst *IRBuilderBase::CreateConstrainedFPBinOp(