61 Value *IRBuilderBase::getCastedInt8PtrValue(
Value *Ptr) {
62 auto *PT = cast<PointerType>(Ptr->
getType());
63 if (PT->getElementType()->isIntegerTy(8))
103 Ptr = getCastedInt8PtrValue(Ptr);
112 cast<MemSetInst>(CI)->setDestAlignment(Align->value());
119 CI->
setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
122 CI->
setMetadata(LLVMContext::MD_noalias, NoAliasTag);
131 Ptr = getCastedInt8PtrValue(Ptr);
136 M, Intrinsic::memset_element_unordered_atomic, Tys);
140 cast<AtomicMemSetInst>(CI)->setDestAlignment(Alignment);
147 CI->
setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
150 CI->
setMetadata(LLVMContext::MD_noalias, NoAliasTag);
161 Size, isVolatile, TBAATag, TBAAStructTag, ScopeTag,
167 Value *Size,
bool isVolatile,
170 Dst = getCastedInt8PtrValue(Dst);
171 Src = getCastedInt8PtrValue(Src);
180 auto* MCI = cast<MemCpyInst>(CI);
182 MCI->setDestAlignment(*DstAlign);
184 MCI->setSourceAlignment(*SrcAlign);
192 CI->
setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
195 CI->
setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
198 CI->
setMetadata(LLVMContext::MD_noalias, NoAliasTag);
204 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
Value *Size,
207 assert(DstAlign >= ElementSize &&
208 "Pointer alignment must be at least element size");
209 assert(SrcAlign >= ElementSize &&
210 "Pointer alignment must be at least element size");
211 Dst = getCastedInt8PtrValue(Dst);
212 Src = getCastedInt8PtrValue(Src);
218 M, Intrinsic::memcpy_element_unordered_atomic, Tys);
223 auto *AMCI = cast<AtomicMemCpyInst>(CI);
224 AMCI->setDestAlignment(DstAlign);
225 AMCI->setSourceAlignment(SrcAlign);
233 CI->
setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
236 CI->
setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
239 CI->
setMetadata(LLVMContext::MD_noalias, NoAliasTag);
246 Value *Size,
bool isVolatile,
249 Dst = getCastedInt8PtrValue(Dst);
250 Src = getCastedInt8PtrValue(Src);
259 auto *MMI = cast<MemMoveInst>(CI);
261 MMI->setDestAlignment(*DstAlign);
263 MMI->setSourceAlignment(*SrcAlign);
270 CI->
setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
273 CI->
setMetadata(LLVMContext::MD_noalias, NoAliasTag);
279 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
Value *Size,
282 assert(DstAlign >= ElementSize &&
283 "Pointer alignment must be at least element size");
284 assert(SrcAlign >= ElementSize &&
285 "Pointer alignment must be at least element size");
286 Dst = getCastedInt8PtrValue(Dst);
287 Src = getCastedInt8PtrValue(Src);
293 M, Intrinsic::memmove_element_unordered_atomic, Tys);
309 CI->
setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
312 CI->
setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
315 CI->
setMetadata(LLVMContext::MD_noalias, NoAliasTag);
323 Value *Ops[] = {Src};
331 Value *Ops[] = {Acc, Src};
334 M, Intrinsic::experimental_vector_reduce_v2_fadd, Tys);
340 Value *Ops[] = {Acc, Src};
343 M, Intrinsic::experimental_vector_reduce_v2_fmul, Tys);
373 auto ID = IsSigned ? Intrinsic::experimental_vector_reduce_smax
374 : Intrinsic::experimental_vector_reduce_umax;
379 auto ID = IsSigned ? Intrinsic::experimental_vector_reduce_smin
380 : Intrinsic::experimental_vector_reduce_umin;
386 this, Intrinsic::experimental_vector_reduce_fmax, Src);
390 Rdx->setFastMathFlags(FMF);
397 this, Intrinsic::experimental_vector_reduce_fmin, Src);
401 Rdx->setFastMathFlags(FMF);
408 "lifetime.start only applies to pointers.");
409 Ptr = getCastedInt8PtrValue(Ptr);
414 "lifetime.start requires the size to be an i64");
424 "lifetime.end only applies to pointers.");
425 Ptr = getCastedInt8PtrValue(Ptr);
430 "lifetime.end requires the size to be an i64");
441 "invariant.start only applies to pointers.");
442 Ptr = getCastedInt8PtrValue(Ptr);
447 "invariant.start requires the size to be an i64");
451 Type *ObjectPtr[1] = {Ptr->getType()};
460 "an assumption condition must be of type i1");
462 Value *Ops[] = { Cond };
479 auto *PtrTy = cast<PointerType>(Ptr->
getType());
480 Type *DataTy = PtrTy->getElementType();
481 assert(DataTy->isVectorTy() &&
"Ptr should point to a vector");
482 assert(Mask &&
"Mask should not be all-ones (null)");
485 Type *OverloadedTypes[] = { DataTy, PtrTy };
487 return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
488 OverloadedTypes, Name);
499 auto *PtrTy = cast<PointerType>(Ptr->
getType());
500 Type *DataTy = PtrTy->getElementType();
501 assert(DataTy->isVectorTy() &&
"Ptr should point to a vector");
502 assert(Mask &&
"Mask should not be all-ones (null)");
503 Type *OverloadedTypes[] = { DataTy, PtrTy };
505 return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
531 auto PtrsTy = cast<VectorType>(Ptrs->
getType());
532 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
533 unsigned NumElts = PtrsTy->getVectorNumElements();
543 Type *OverloadedTypes[] = {DataTy, PtrsTy};
548 return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, OverloadedTypes,
561 auto PtrsTy = cast<VectorType>(Ptrs->
getType());
562 auto DataTy = cast<VectorType>(Data->
getType());
563 unsigned NumElts = PtrsTy->getVectorNumElements();
566 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
567 assert(NumElts == DataTy->getVectorNumElements() &&
568 PtrTy->getElementType() == DataTy->getElementType() &&
569 "Incompatible pointer and data types");
576 Type *OverloadedTypes[] = {DataTy, PtrsTy};
581 return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, OverloadedTypes);
584 template <
typename T0,
typename T1,
typename T2,
typename T3>
585 static std::vector<Value *>
590 std::vector<Value *>
Args;
592 Args.push_back(B.
getInt32(NumPatchBytes));
593 Args.push_back(ActualCallee);
596 Args.insert(Args.end(), CallArgs.
begin(), CallArgs.
end());
598 Args.insert(Args.end(), TransitionArgs.
begin(), TransitionArgs.
end());
600 Args.insert(Args.end(), DeoptArgs.
begin(), DeoptArgs.
end());
601 Args.insert(Args.end(), GCArgs.
begin(), GCArgs.
end());
606 template <
typename T0,
typename T1,
typename T2,
typename T3>
613 auto *FuncPtrType = cast<PointerType>(ActualCallee->
getType());
614 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
615 "actual callee must be a callable value");
619 Type *ArgTypes[] = { FuncPtrType };
624 std::vector<Value *>
Args =
626 CallArgs, TransitionArgs, DeoptArgs, GCArgs);
634 return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
636 CallArgs,
None , DeoptArgs, GCArgs,
Name);
643 return CreateGCStatepointCallCommon<Use, Use, Use, Value *>(
644 this,
ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
645 DeoptArgs, GCArgs,
Name);
652 return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
654 CallArgs,
None, DeoptArgs, GCArgs,
Name);
657 template <
typename T0,
typename T1,
typename T2,
typename T3>
664 auto *FuncPtrType = cast<PointerType>(ActualInvokee->
getType());
665 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
666 "actual callee must be a callable value");
671 M, Intrinsic::experimental_gc_statepoint, {FuncPtrType});
673 std::vector<Value *>
Args =
675 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
685 return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
686 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
688 DeoptArgs, GCArgs,
Name);
696 return CreateGCStatepointInvokeCommon<Use, Use, Use, Value *>(
697 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
698 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs,
Name);
705 return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
706 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
716 Type *Types[] = {ResultType};
729 Type *Types[] = {ResultType};
Common base class shared among various IRBuilders.
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction, which must be an operator which supports these flags.
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static IntegerType * getInt1Ty(LLVMContext &C)
CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memmove between the specified pointers.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CallInst * CreateGCRelocate(Instruction *Statepoint, int BaseOffset, int DerivedOffset, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.relocate intrinsics to project the relocated value of one pointe...
This class represents a function call, abstracting a target machine's calling convention.
Like Internal, but omit from symbol table.
LLVMContext & getContext() const
All values hold a context through their type.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
static CallInst * CreateGCStatepointCallCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, ArrayRef< T1 > TransitionArgs, ArrayRef< T2 > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
CallInst * CreateFAddReduce(Value *Acc, Value *Src)
Create a vector fadd reduction intrinsic of the source vector.
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
CallInst * CreateMaskedGather(Value *Ptrs, unsigned Align, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
CallInst * CreateFPMinReduce(Value *Src, bool NoNaN=false)
Create a vector float min reduction intrinsic of the source vector.
Type * getType() const
All values are typed, get the type of this value.
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
BasicBlock * GetInsertBlock() const
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
This class represents a no-op cast from one type to another.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
CallInst * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static CallInst * createCallHelper(Function *Callee, ArrayRef< Value *> Ops, IRBuilderBase *Builder, const Twine &Name="", Instruction *FMFSource=nullptr)
CallInst * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, ArrayRef< Value *> CallArgs, ArrayRef< Value *> DeoptArgs, ArrayRef< Value *> GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence...
Type * getReturnType() const
Returns the type of the ret val.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
size_t size() const
size - Get the array size.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static InvokeInst * CreateGCStatepointInvokeCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef< T0 > InvokeArgs, ArrayRef< T1 > TransitionArgs, ArrayRef< T2 > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> InvokeArgs, ArrayRef< Value *> DeoptArgs, ArrayRef< Value *> GCArgs, const Twine &Name="")
Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence...
A specialization of it's base class for read-write access to a gc.statepoint.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
static Constant * getAllOnesValue(Type *Ty)
Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
This struct is a compact representation of a valid (non-zero power of two) alignment.
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
const InstListType & getInstList() const
Return the underlying instruction list container.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
CallInst * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
This is the shared class of boolean and integer constants.
CallInst * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Make a new global variable with initializer type i8*.
CallInst * CreateAssumption(Value *Cond)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type *> Types, ArrayRef< Value *> Args, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with args, mangled using Types.
static CallInst * getReductionIntrinsic(IRBuilderBase *Builder, Intrinsic::ID ID, Value *Src)
static InvokeInst * createInvokeHelper(Function *Invokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Ops, IRBuilderBase *Builder, const Twine &Name="")
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align, Value *Mask)
Create a call to Masked Store intrinsic.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
static std::vector< Value * > getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, ArrayRef< T1 > TransitionArgs, ArrayRef< T2 > DeoptArgs, ArrayRef< T3 > GCArgs)
CallInst * CreateFMulReduce(Value *Acc, Value *Src)
Create a vector fmul reduction intrinsic of the source vector.
CallInst * CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
void setNoNaNs(bool B=true)
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
CallInst * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
CallInst * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
iterator insert(iterator where, pointer New)
void setUnnamedAddr(UnnamedAddr Val)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
const Function * getParent() const
Return the enclosing method, or null if none.
CallInst * CreateGCResult(Instruction *Statepoint, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.result intrinsic to extract the result from a call wrapped in a ...
CallInst * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
CallInst * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type. ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, unsigned Align, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
BasicBlock::iterator GetInsertPoint() const
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.start intrinsic.
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
static bool isVolatile(Instruction *Inst)
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memcpy between the specified pointers.
CallInst * CreateFPMaxReduce(Value *Src, bool NoNaN=false)
Create a vector float max reduction intrinsic of the source vector.
BasicBlock::iterator InsertPt
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.