62 Value *IRBuilderBase::getCastedInt8PtrValue(
Value *Ptr) {
63 auto *PT = cast<PointerType>(Ptr->
getType());
64 if (PT->getElementType()->isIntegerTy(8))
104 Ptr = getCastedInt8PtrValue(Ptr);
113 cast<MemSetInst>(CI)->setDestAlignment(Align);
131 assert(Align >= ElementSize &&
132 "Pointer alignment must be at least element size.");
134 Ptr = getCastedInt8PtrValue(Ptr);
143 cast<AtomicMemSetInst>(CI)->setDestAlignment(Align);
164 Dst = getCastedInt8PtrValue(Dst);
165 Src = getCastedInt8PtrValue(Src);
174 auto* MCI = cast<MemCpyInst>(CI);
176 MCI->setDestAlignment(DstAlign);
178 MCI->setSourceAlignment(SrcAlign);
201 assert(DstAlign >= ElementSize &&
202 "Pointer alignment must be at least element size");
203 assert(SrcAlign >= ElementSize &&
204 "Pointer alignment must be at least element size");
205 Dst = getCastedInt8PtrValue(Dst);
206 Src = getCastedInt8PtrValue(Src);
217 auto *AMCI = cast<AtomicMemCpyInst>(CI);
218 AMCI->setDestAlignment(DstAlign);
219 AMCI->setSourceAlignment(SrcAlign);
244 Dst = getCastedInt8PtrValue(Dst);
245 Src = getCastedInt8PtrValue(Src);
254 auto *MMI = cast<MemMoveInst>(CI);
256 MMI->setDestAlignment(DstAlign);
258 MMI->setSourceAlignment(SrcAlign);
277 assert(DstAlign >= ElementSize &&
278 "Pointer alignment must be at least element size");
279 assert(SrcAlign >= ElementSize &&
280 "Pointer alignment must be at least element size");
281 Dst = getCastedInt8PtrValue(Dst);
282 Src = getCastedInt8PtrValue(Src);
316 Value *Ops[] = {Src};
324 Value *Ops[] = {Acc, Src};
334 Value *Ops[] = {Acc, Src};
385 Rdx->setFastMathFlags(FMF);
396 Rdx->setFastMathFlags(FMF);
403 "lifetime.start only applies to pointers.");
404 Ptr = getCastedInt8PtrValue(Ptr);
409 "lifetime.start requires the size to be an i64");
419 "lifetime.end only applies to pointers.");
420 Ptr = getCastedInt8PtrValue(Ptr);
425 "lifetime.end requires the size to be an i64");
436 "invariant.start only applies to pointers.");
437 Ptr = getCastedInt8PtrValue(Ptr);
442 "invariant.start requires the size to be an i64");
446 Type *ObjectPtr[1] = {Ptr->getType()};
455 "an assumption condition must be of type i1");
457 Value *Ops[] = { Cond };
474 auto *PtrTy = cast<PointerType>(Ptr->
getType());
475 Type *DataTy = PtrTy->getElementType();
476 assert(DataTy->isVectorTy() &&
"Ptr should point to a vector");
477 assert(Mask &&
"Mask should not be all-ones (null)");
480 Type *OverloadedTypes[] = { DataTy, PtrTy };
483 OverloadedTypes, Name);
494 auto *PtrTy = cast<PointerType>(Ptr->
getType());
495 Type *DataTy = PtrTy->getElementType();
496 assert(DataTy->isVectorTy() &&
"Ptr should point to a vector");
497 assert(Mask &&
"Mask should not be all-ones (null)");
498 Type *OverloadedTypes[] = { DataTy, PtrTy };
526 auto PtrsTy = cast<VectorType>(Ptrs->
getType());
527 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
528 unsigned NumElts = PtrsTy->getVectorNumElements();
538 Type *OverloadedTypes[] = {DataTy, PtrsTy};
556 auto PtrsTy = cast<VectorType>(Ptrs->
getType());
557 auto DataTy = cast<VectorType>(Data->
getType());
558 unsigned NumElts = PtrsTy->getVectorNumElements();
561 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
562 assert(NumElts == DataTy->getVectorNumElements() &&
563 PtrTy->getElementType() == DataTy->getElementType() &&
564 "Incompatible pointer and data types");
571 Type *OverloadedTypes[] = {DataTy, PtrsTy};
579 template <
typename T0,
typename T1,
typename T2,
typename T3>
580 static std::vector<Value *>
585 std::vector<Value *>
Args;
587 Args.push_back(B.
getInt32(NumPatchBytes));
588 Args.push_back(ActualCallee);
591 Args.insert(Args.end(), CallArgs.
begin(), CallArgs.
end());
593 Args.insert(Args.end(), TransitionArgs.
begin(), TransitionArgs.
end());
595 Args.insert(Args.end(), DeoptArgs.
begin(), DeoptArgs.
end());
596 Args.insert(Args.end(), GCArgs.
begin(), GCArgs.
end());
601 template <
typename T0,
typename T1,
typename T2,
typename T3>
608 auto *FuncPtrType = cast<PointerType>(ActualCallee->
getType());
609 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
610 "actual callee must be a callable value");
614 Type *ArgTypes[] = { FuncPtrType };
619 std::vector<Value *>
Args =
621 CallArgs, TransitionArgs, DeoptArgs, GCArgs);
629 return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
631 CallArgs,
None , DeoptArgs, GCArgs,
Name);
638 return CreateGCStatepointCallCommon<Use, Use, Use, Value *>(
639 this,
ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
640 DeoptArgs, GCArgs,
Name);
647 return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
649 CallArgs,
None, DeoptArgs, GCArgs,
Name);
652 template <
typename T0,
typename T1,
typename T2,
typename T3>
659 auto *FuncPtrType = cast<PointerType>(ActualInvokee->
getType());
660 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
661 "actual callee must be a callable value");
668 std::vector<Value *>
Args =
670 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
680 return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
681 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
683 DeoptArgs, GCArgs,
Name);
691 return CreateGCStatepointInvokeCommon<Use, Use, Use, Value *>(
692 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
693 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs,
Name);
700 return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
701 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
711 Type *Types[] = {ResultType};
724 Type *Types[] = {ResultType};
725 Value *FnGCRelocate =
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.
This class represents lattice values for constants.
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.
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.
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.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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)...
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.
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...
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.
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 ...
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...
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)
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 * 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)
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.
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.