62 auto *PT = cast<PointerType>(Ptr->
getType());
63 if (PT->getElementType()->isIntegerTy(8))
103 Ptr = getCastedInt8PtrValue(Ptr);
112 cast<MemSetInst>(CI)->setDestAlignment(Align);
130 assert(Align >= ElementSize &&
131 "Pointer alignment must be at least element size.");
133 Ptr = getCastedInt8PtrValue(Ptr);
138 M, Intrinsic::memset_element_unordered_atomic, Tys);
142 cast<AtomicMemSetInst>(CI)->setDestAlignment(Align);
163 Dst = getCastedInt8PtrValue(Dst);
164 Src = getCastedInt8PtrValue(Src);
173 auto* MCI = cast<MemCpyInst>(CI);
175 MCI->setDestAlignment(DstAlign);
177 MCI->setSourceAlignment(SrcAlign);
200 assert(DstAlign >= ElementSize &&
201 "Pointer alignment must be at least element size");
202 assert(SrcAlign >= ElementSize &&
203 "Pointer alignment must be at least element size");
204 Dst = getCastedInt8PtrValue(Dst);
205 Src = getCastedInt8PtrValue(Src);
211 M, Intrinsic::memcpy_element_unordered_atomic, Tys);
216 auto *AMCI = cast<AtomicMemCpyInst>(CI);
217 AMCI->setDestAlignment(DstAlign);
218 AMCI->setSourceAlignment(SrcAlign);
243 Dst = getCastedInt8PtrValue(Dst);
244 Src = getCastedInt8PtrValue(Src);
253 auto *MMI = cast<MemMoveInst>(CI);
255 MMI->setDestAlignment(DstAlign);
257 MMI->setSourceAlignment(SrcAlign);
276 assert(DstAlign >= ElementSize &&
277 "Pointer alignment must be at least element size");
278 assert(SrcAlign >= ElementSize &&
279 "Pointer alignment must be at least element size");
280 Dst = getCastedInt8PtrValue(Dst);
281 Src = getCastedInt8PtrValue(Src);
287 M, Intrinsic::memmove_element_unordered_atomic, Tys);
315 Value *Ops[] = {Src};
323 Value *Ops[] = {Acc, Src};
327 M, Intrinsic::experimental_vector_reduce_fadd, Tys);
333 Value *Ops[] = {Acc, Src};
337 M, Intrinsic::experimental_vector_reduce_fmul, Tys);
367 auto ID = IsSigned ? Intrinsic::experimental_vector_reduce_smax
368 : Intrinsic::experimental_vector_reduce_umax;
373 auto ID = IsSigned ? Intrinsic::experimental_vector_reduce_smin
374 : Intrinsic::experimental_vector_reduce_umin;
380 this, Intrinsic::experimental_vector_reduce_fmax, Src);
384 Rdx->setFastMathFlags(FMF);
391 this, Intrinsic::experimental_vector_reduce_fmin, Src);
395 Rdx->setFastMathFlags(FMF);
402 "lifetime.start only applies to pointers.");
403 Ptr = getCastedInt8PtrValue(Ptr);
408 "lifetime.start requires the size to be an i64");
418 "lifetime.end only applies to pointers.");
419 Ptr = getCastedInt8PtrValue(Ptr);
424 "lifetime.end requires the size to be an i64");
435 "invariant.start only applies to pointers.");
436 Ptr = getCastedInt8PtrValue(Ptr);
441 "invariant.start requires the size to be an i64");
445 Type *ObjectPtr[1] = {Ptr->getType()};
454 "an assumption condition must be of type i1");
456 Value *Ops[] = { Cond };
473 auto *PtrTy = cast<PointerType>(Ptr->
getType());
474 Type *DataTy = PtrTy->getElementType();
475 assert(DataTy->isVectorTy() &&
"Ptr should point to a vector");
476 assert(Mask &&
"Mask should not be all-ones (null)");
479 Type *OverloadedTypes[] = { DataTy, PtrTy };
481 return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
482 OverloadedTypes, Name);
493 auto *PtrTy = cast<PointerType>(Ptr->
getType());
494 Type *DataTy = PtrTy->getElementType();
495 assert(DataTy->isVectorTy() &&
"Ptr should point to a vector");
496 assert(Mask &&
"Mask should not be all-ones (null)");
497 Type *OverloadedTypes[] = { DataTy, PtrTy };
499 return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
525 auto PtrsTy = cast<VectorType>(Ptrs->
getType());
526 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
527 unsigned NumElts = PtrsTy->getVectorNumElements();
537 Type *OverloadedTypes[] = {DataTy, PtrsTy};
542 return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, OverloadedTypes,
555 auto PtrsTy = cast<VectorType>(Ptrs->
getType());
556 auto DataTy = cast<VectorType>(Data->
getType());
557 unsigned NumElts = PtrsTy->getVectorNumElements();
560 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
561 assert(NumElts == DataTy->getVectorNumElements() &&
562 PtrTy->getElementType() == DataTy->getElementType() &&
563 "Incompatible pointer and data types");
570 Type *OverloadedTypes[] = {DataTy, PtrsTy};
575 return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, OverloadedTypes);
578 template <
typename T0,
typename T1,
typename T2,
typename T3>
579 static std::vector<Value *>
584 std::vector<Value *>
Args;
586 Args.push_back(B.
getInt32(NumPatchBytes));
587 Args.push_back(ActualCallee);
590 Args.insert(Args.end(), CallArgs.
begin(), CallArgs.
end());
592 Args.insert(Args.end(), TransitionArgs.
begin(), TransitionArgs.
end());
594 Args.insert(Args.end(), DeoptArgs.
begin(), DeoptArgs.
end());
595 Args.insert(Args.end(), GCArgs.
begin(), GCArgs.
end());
600 template <
typename T0,
typename T1,
typename T2,
typename T3>
607 auto *FuncPtrType = cast<PointerType>(ActualCallee->
getType());
608 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
609 "actual callee must be a callable value");
613 Type *ArgTypes[] = { FuncPtrType };
618 std::vector<Value *>
Args =
620 CallArgs, TransitionArgs, DeoptArgs, GCArgs);
628 return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
630 CallArgs,
None , DeoptArgs, GCArgs,
Name);
637 return CreateGCStatepointCallCommon<Use, Use, Use, Value *>(
638 this,
ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
639 DeoptArgs, GCArgs,
Name);
646 return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
648 CallArgs,
None, DeoptArgs, GCArgs,
Name);
651 template <
typename T0,
typename T1,
typename T2,
typename T3>
658 auto *FuncPtrType = cast<PointerType>(ActualInvokee->
getType());
659 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
660 "actual callee must be a callable value");
665 M, Intrinsic::experimental_gc_statepoint, {FuncPtrType});
667 std::vector<Value *>
Args =
669 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
679 return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
680 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
682 DeoptArgs, GCArgs,
Name);
690 return CreateGCStatepointInvokeCommon<Use, Use, Use, Value *>(
691 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
692 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs,
Name);
699 return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
700 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
710 Type *Types[] = {ResultType};
723 Type *Types[] = {ResultType};
724 Value *FnGCRelocate =
753 assert(!Args.
empty() &&
"Expected at least one argument to intrinsic");
const T & front() const
front - Get the first element.
Type * getVectorElementType() const
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.
Compute iterated dominance frontiers using a linear time algorithm.
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
A Module instance is used to store all the information related to an LLVM module. ...
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.
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.
static CallInst * Create(Value *Func, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned 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.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
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.
CallInst * CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
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.
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)...
amdgpu Simplify well known AMD library false Value * Callee
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
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 CallInst * createCallHelper(Value *Callee, ArrayRef< Value *> Ops, IRBuilderBase *Builder, const Twine &Name="", Instruction *FMFSource=nullptr)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
CallInst * CreateIntrinsic(Intrinsic::ID ID, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with no operands.
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.
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.
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
const InstListType & getInstList() const
Return the underlying instruction list container.
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 ...
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
static CallInst * getReductionIntrinsic(IRBuilderBase *Builder, Intrinsic::ID ID, Value *Src)
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.
CallInst * CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
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)
static InvokeInst * createInvokeHelper(Value *Invokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Ops, IRBuilderBase *Builder, const Twine &Name="")
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 * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
CallInst * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type. ...
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)
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.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
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.
bool empty() const
empty - Check if the array is empty.