54 GV->setAlignment(M->getDataLayout().getPrefTypeAlign(
getInt8Ty()));
68 I->setDebugLoc(StoredDL.
orElse(
I->getDebugLoc()));
72 Type *SrcTy = V->getType();
81 "Expected StructTypes with equal number of elements");
86 "Expected ArrayTypes with equal number of elements");
91 for (
unsigned I = 0;
I < NumElements; ++
I) {
110 if (isa<FPMathOperator>(CI))
116 Value *VScale =
B.CreateVScale(Ty);
120 return B.CreateNUWMul(VScale, ConstantInt::get(Ty, Scale));
124 if (EC.isFixed() || EC.isZero())
125 return ConstantInt::get(Ty, EC.getKnownMinValue());
131 if (
Size.isFixed() ||
Size.isZero())
132 return ConstantInt::get(Ty,
Size.getKnownMinValue());
139 if (isa<ScalableVectorType>(DstType)) {
140 Type *StepVecType = DstType;
149 if (StepVecType != DstType)
154 unsigned NumEls = cast<FixedVectorType>(DstType)->getNumElements();
158 for (
unsigned i = 0; i < NumEls; ++i)
159 Indices.
push_back(ConstantInt::get(STy, i));
174 cast<MemSetInst>(CI)->setDestAlignment(*
Align);
184 Type *Tys[] = {Dst->getType(),
Size->getType()};
189 cast<MemSetInst>(CI)->setDestAlignment(*DstAlign);
204 cast<AnyMemSetInst>(CI)->setDestAlignment(Alignment);
214 assert((IntrID == Intrinsic::memcpy || IntrID == Intrinsic::memcpy_inline ||
215 IntrID == Intrinsic::memmove) &&
216 "Unexpected intrinsic ID");
218 Type *Tys[] = {Dst->getType(), Src->getType(),
Size->getType()};
222 auto* MCI = cast<MemTransferInst>(CI);
224 MCI->setDestAlignment(*DstAlign);
226 MCI->setSourceAlignment(*SrcAlign);
227 MCI->setAAMetadata(AAInfo);
234 assert(DstAlign >= ElementSize &&
235 "Pointer alignment must be at least element size");
236 assert(SrcAlign >= ElementSize &&
237 "Pointer alignment must be at least element size");
239 Type *Tys[] = {Dst->getType(), Src->getType(),
Size->getType()};
245 auto *AMCI = cast<AnyMemCpyInst>(CI);
246 AMCI->setDestAlignment(DstAlign);
247 AMCI->setSourceAlignment(SrcAlign);
248 AMCI->setAAMetadata(AAInfo);
254 assert(Val &&
"isConstantOne does not work with nullptr Val");
255 const ConstantInt *CVal = dyn_cast<ConstantInt>(Val);
256 return CVal && CVal->
isOne();
268 ArraySize = ConstantInt::get(IntPtrTy, 1);
269 else if (ArraySize->
getType() != IntPtrTy)
274 AllocSize = ArraySize;
277 AllocSize =
CreateMul(ArraySize, AllocSize,
"mallocsize");
281 assert(AllocSize->
getType() == IntPtrTy &&
"malloc arg is wrong size");
288 MallocFunc = M->getOrInsertFunction(
"malloc", BPTy, IntPtrTy);
294 F->setReturnDoesNotAlias();
306 return CreateMalloc(IntPtrTy, AllocTy, AllocSize, ArraySize, {}, MallocF,
313 assert(Source->getType()->isPointerTy() &&
314 "Can not free something of nonpointer type!");
321 FunctionCallee FreeFunc = M->getOrInsertFunction(
"free", VoidTy, VoidPtrTy);
323 Result->setTailCall();
325 Result->setCallingConv(
F->getCallingConv());
333 assert(DstAlign >= ElementSize &&
334 "Pointer alignment must be at least element size");
335 assert(SrcAlign >= ElementSize &&
336 "Pointer alignment must be at least element size");
338 Type *Tys[] = {Dst->getType(), Src->getType(),
Size->getType()};
341 CreateIntrinsic(Intrinsic::memmove_element_unordered_atomic, Tys, Ops);
351 Value *Ops[] = {Src};
352 Type *Tys[] = { Src->getType() };
357 Value *Ops[] = {Acc, Src};
358 return CreateIntrinsic(Intrinsic::vector_reduce_fadd, {Src->getType()}, Ops);
362 Value *Ops[] = {Acc, Src};
363 return CreateIntrinsic(Intrinsic::vector_reduce_fmul, {Src->getType()}, Ops);
367 return getReductionIntrinsic(Intrinsic::vector_reduce_add, Src);
371 return getReductionIntrinsic(Intrinsic::vector_reduce_mul, Src);
375 return getReductionIntrinsic(Intrinsic::vector_reduce_and, Src);
379 return getReductionIntrinsic(Intrinsic::vector_reduce_or, Src);
383 return getReductionIntrinsic(Intrinsic::vector_reduce_xor, Src);
388 IsSigned ? Intrinsic::vector_reduce_smax : Intrinsic::vector_reduce_umax;
389 return getReductionIntrinsic(
ID, Src);
394 IsSigned ? Intrinsic::vector_reduce_smin : Intrinsic::vector_reduce_umin;
395 return getReductionIntrinsic(
ID, Src);
399 return getReductionIntrinsic(Intrinsic::vector_reduce_fmax, Src);
403 return getReductionIntrinsic(Intrinsic::vector_reduce_fmin, Src);
407 return getReductionIntrinsic(Intrinsic::vector_reduce_fmaximum, Src);
411 return getReductionIntrinsic(Intrinsic::vector_reduce_fminimum, Src);
415 assert(isa<PointerType>(
Ptr->getType()) &&
416 "lifetime.start only applies to pointers.");
421 assert(isa<PointerType>(
Ptr->getType()) &&
422 "lifetime.end only applies to pointers.");
428 assert(isa<PointerType>(
Ptr->getType()) &&
429 "invariant.start only applies to pointers.");
434 "invariant.start requires the size to be an i64");
438 Type *ObjectPtr[1] = {
Ptr->getType()};
443 if (
auto *V = dyn_cast<GlobalVariable>(
Ptr))
444 return V->getAlign();
445 if (
auto *
A = dyn_cast<GlobalAlias>(
Ptr))
451 assert(isa<GlobalValue>(
Ptr) && cast<GlobalValue>(
Ptr)->isThreadLocal() &&
452 "threadlocal_address only applies to thread local variables.");
466 "an assumption condition must be of type i1");
491 auto *PtrTy = cast<PointerType>(
Ptr->getType());
493 assert(Mask &&
"Mask should not be all-ones (null)");
496 Type *OverloadedTypes[] = { Ty, PtrTy };
498 return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
499 OverloadedTypes,
Name);
510 auto *PtrTy = cast<PointerType>(
Ptr->getType());
513 assert(Mask &&
"Mask should not be all-ones (null)");
514 Type *OverloadedTypes[] = { DataTy, PtrTy };
516 return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
542 auto *VecTy = cast<VectorType>(Ty);
544 auto *PtrsTy = cast<VectorType>(Ptrs->
getType());
545 assert(NumElts == PtrsTy->getElementCount() &&
"Element count mismatch");
553 Type *OverloadedTypes[] = {Ty, PtrsTy};
558 return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, OverloadedTypes,
571 auto *PtrsTy = cast<VectorType>(Ptrs->
getType());
572 auto *DataTy = cast<VectorType>(
Data->getType());
578 Type *OverloadedTypes[] = {DataTy, PtrsTy};
583 return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, OverloadedTypes);
600 assert(Mask &&
"Mask should not be all-ones (null)");
603 Type *OverloadedTypes[] = {Ty};
604 Value *Ops[] = {
Ptr, Mask, PassThru};
605 CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_expandload, Ops,
606 OverloadedTypes,
Name);
623 assert(Mask &&
"Mask should not be all-ones (null)");
624 Type *OverloadedTypes[] = {DataTy};
626 CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_compressstore, Ops,
633template <
typename T0>
634static std::vector<Value *>
637 std::vector<Value *> Args;
638 Args.push_back(
B.getInt64(
ID));
639 Args.push_back(
B.getInt32(NumPatchBytes));
640 Args.push_back(ActualCallee);
641 Args.push_back(
B.getInt32(CallArgs.
size()));
642 Args.push_back(
B.getInt32(Flags));
646 Args.push_back(
B.getInt32(0));
647 Args.push_back(
B.getInt32(0));
652template<
typename T1,
typename T2,
typename T3>
653static std::vector<OperandBundleDef>
657 std::vector<OperandBundleDef> Rval;
661 Rval.emplace_back(
"gc-transition",
668template <
typename T0,
typename T1,
typename T2,
typename T3>
678 M, Intrinsic::experimental_gc_statepoint,
682 *Builder,
ID, NumPatchBytes, ActualCallee.
getCallee(), Flags, CallArgs);
697 return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
699 CallArgs, std::nullopt , DeoptArgs, GCArgs,
Name);
708 return CreateGCStatepointCallCommon<Value *, Use, Use, Value *>(
709 this,
ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
710 DeoptArgs, GCArgs,
Name);
717 return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
719 CallArgs, std::nullopt, DeoptArgs, GCArgs,
Name);
722template <
typename T0,
typename T1,
typename T2,
typename T3>
733 M, Intrinsic::experimental_gc_statepoint,
736 std::vector<Value *> Args =
741 FnStatepoint, NormalDest, UnwindDest, Args,
754 return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
755 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
757 std::nullopt , DeoptArgs, GCArgs,
Name);
766 return CreateGCStatepointInvokeCommon<Value *, Use, Use, Value *>(
767 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
768 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs,
Name);
776 return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
777 this,
ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
785 Type *Types[] = {ResultType};
787 Value *Args[] = {Statepoint};
792 int BaseOffset,
int DerivedOffset,
794 Type *Types[] = {ResultType};
797 return CreateIntrinsic(Intrinsic::experimental_gc_relocate, Types, Args, {},
805 {PtrTy, PtrTy}, {DerivedPtr}, {},
Name);
811 return CreateIntrinsic(Intrinsic::experimental_gc_get_pointer_offset, {PtrTy},
812 {DerivedPtr}, {},
Name);
861 matchIntrinsicSignature(FTy,
TableRef, OverloadTys);
864 "Wrong types for intrinsic!");
873 const Twine &
Name,
MDNode *FPMathTag, std::optional<RoundingMode> Rounding,
874 std::optional<fp::ExceptionBehavior> Except) {
875 Value *RoundingV = getConstrainedFPRounding(Rounding);
876 Value *ExceptV = getConstrainedFPExcept(Except);
881 {L, R, RoundingV, ExceptV},
nullptr,
Name);
883 setFPAttrs(
C, FPMathTag, UseFMF);
890 std::optional<RoundingMode> Rounding,
891 std::optional<fp::ExceptionBehavior> Except) {
892 Value *RoundingV = getConstrainedFPRounding(Rounding);
893 Value *ExceptV = getConstrainedFPExcept(Except);
903 setFPAttrs(
C, FPMathTag, UseFMF);
910 std::optional<fp::ExceptionBehavior> Except) {
911 Value *ExceptV = getConstrainedFPExcept(Except);
918 setFPAttrs(
C, FPMathTag, UseFMF);
925 assert(Ops.
size() == 2 &&
"Invalid number of operands!");
927 Ops[0], Ops[1],
Name, FPMathTag);
930 assert(Ops.
size() == 1 &&
"Invalid number of operands!");
932 Ops[0],
Name, FPMathTag);
939 const Twine &
Name,
MDNode *FPMathTag, std::optional<RoundingMode> Rounding,
940 std::optional<fp::ExceptionBehavior> Except) {
941 Value *ExceptV = getConstrainedFPExcept(Except);
947 Value *RoundingV = getConstrainedFPRounding(Rounding);
956 if (isa<FPMathOperator>(
C))
957 setFPAttrs(
C, FPMathTag, UseFMF);
966 auto ID = IsSignaling ? Intrinsic::experimental_constrained_fcmps
967 : Intrinsic::experimental_constrained_fcmp;
980 const Twine &
Name, std::optional<fp::ExceptionBehavior> Except) {
981 Value *PredicateV = getConstrainedFPPredicate(
P);
982 Value *ExceptV = getConstrainedFPExcept(Except);
985 {L, R, PredicateV, ExceptV},
nullptr,
Name);
992 std::optional<RoundingMode> Rounding,
993 std::optional<fp::ExceptionBehavior> Except) {
997 UseArgs.
push_back(getConstrainedFPRounding(Rounding));
998 UseArgs.
push_back(getConstrainedFPExcept(Except));
1020 Sel = addBranchMetadata(Sel, Prof, Unpred);
1022 if (isa<FPMathOperator>(Sel))
1030 "Pointer subtraction operand types must match!");
1039 assert(isa<PointerType>(
Ptr->getType()) &&
1040 "launder.invariant.group only applies to pointers.");
1041 auto *PtrType =
Ptr->getType();
1044 M, Intrinsic::launder_invariant_group, {PtrType});
1049 "LaunderInvariantGroup should take and return the same type");
1055 assert(isa<PointerType>(
Ptr->getType()) &&
1056 "strip.invariant.group only applies to pointers.");
1058 auto *PtrType =
Ptr->getType();
1061 M, Intrinsic::strip_invariant_group, {PtrType});
1066 "StripInvariantGroup should take and return the same type");
1072 auto *Ty = cast<VectorType>(V->getType());
1073 if (isa<ScalableVectorType>(Ty)) {
1081 int NumElts = Ty->getElementCount().getKnownMinValue();
1082 for (
int i = 0; i < NumElts; ++i)
1089 assert(isa<VectorType>(V1->
getType()) &&
"Unexpected type");
1091 "Splice expects matching operand types!");
1093 if (
auto *VTy = dyn_cast<ScalableVectorType>(V1->
getType())) {
1102 unsigned NumElts = cast<FixedVectorType>(V1->
getType())->getNumElements();
1103 assert(((-Imm <= NumElts) || (Imm < NumElts)) &&
1104 "Invalid immediate for vector splice!");
1107 unsigned Idx = (NumElts + Imm) % NumElts;
1109 for (
unsigned I = 0;
I < NumElts; ++
I)
1110 Mask.push_back(
Idx +
I);
1123 assert(EC.isNonZero() &&
"Cannot splat to an empty vector!");
1131 Zeros.
resize(EC.getKnownMinValue());
1138 "Unexpected number of operands to interleave");
1141 assert(isa<VectorType>(Ops[0]->
getType()) &&
"Unexpected type");
1144 for (
unsigned I = 1;
I < Ops.
size();
I++) {
1146 "Vector interleave expects matching operand types!");
1151 auto *SubvecTy = cast<VectorType>(Ops[0]->
getType());
1153 SubvecTy->getElementCount() * Ops.
size());
1163 "Invalid Base ptr type for preserve.array.access.index.");
1179 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1187 "Invalid Base ptr type for preserve.union.access.index.");
1194 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1200 Type *ElTy,
Value *
Base,
unsigned Index,
unsigned FieldIndex,
1204 "Invalid Base ptr type for preserve.struct.access.index.");
1218 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1232 Value *OffsetValue) {
1243 Value *OffsetValue) {
1245 "trying to create an alignment assumption on a non-pointer?");
1246 assert(Alignment != 0 &&
"Invalid Alignment");
1247 auto *PtrTy = cast<PointerType>(PtrValue->
getType());
1249 Value *AlignValue = ConstantInt::get(IntPtrTy, Alignment);
1250 return CreateAlignmentAssumptionHelper(
DL, PtrValue, AlignValue, OffsetValue);
1256 Value *OffsetValue) {
1258 "trying to create an alignment assumption on a non-pointer?");
1259 return CreateAlignmentAssumptionHelper(
DL, PtrValue, Alignment, OffsetValue);
1265 "trying to create an deferenceable assumption on a non-pointer?");
1269 {DereferenceableOpB});
1275void ConstantFolder::anchor() {}
1276void NoFolder::anchor() {}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef< TableEntry > TableRef
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool isConstantOne(const Value *Val)
isConstantOne - Return true only if val is constant int 1
static InvokeInst * CreateGCStatepointInvokeCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef< T0 > InvokeArgs, std::optional< ArrayRef< T1 > > TransitionArgs, std::optional< ArrayRef< T2 > > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
static CallInst * CreateGCStatepointCallCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, std::optional< ArrayRef< T1 > > TransitionArgs, std::optional< ArrayRef< T2 > > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
static Value * CreateVScaleMultiple(IRBuilderBase &B, Type *Ty, uint64_t Scale)
static std::vector< OperandBundleDef > getStatepointBundles(std::optional< ArrayRef< T1 > > TransitionArgs, std::optional< ArrayRef< T2 > > DeoptArgs, ArrayRef< T3 > GCArgs)
static std::vector< Value * > getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs)
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > & Cond
static SymbolRef::Type getType(const Symbol *Sym)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
void setCallingConv(CallingConv::ID CC)
void addRetAttr(Attribute::AttrKind Kind)
Adds the attribute to the return value.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static LLVM_ABI Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
This is the shared class of boolean and integer constants.
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
DebugLoc orElse(DebugLoc Other) const
If this DebugLoc is non-empty, returns this DebugLoc; otherwise, selects Other.
static constexpr ElementCount getFixed(ScalarTy MinVal)
This instruction compares its operands according to the predicate given to the constructor.
This provides a helper for copying FMF from an instruction or setting specified flags.
FastMathFlags get(FastMathFlags Default) const
Convenience struct for specifying and reasoning about fast-math flags.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
FunctionType * getFunctionType()
Class to represent function types.
Type * getParamType(unsigned i) const
Parameter type accessors.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Type * getReturnType() const
Returns the type of the ret val.
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
Module * getParent()
Get the module that this global value is contained inside of...
@ PrivateLinkage
Like Internal, but omit from symbol table.
Common base class shared among various IRBuilders.
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
LLVM_ABI Value * CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS, const Twine &Name="")
Return the i64 difference between two pointer values, dividing out the size of the pointed-to objects...
LLVM_ABI CallInst * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateFAddReduce(Value *Acc, Value *Src)
Create a sequential vector fadd reduction intrinsic of the source vector.
LLVM_ABI Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
LLVM_ABI CallInst * CreateConstrainedFPUnroundedBinOp(Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
LLVM_ABI CallInst * CreateThreadLocalAddress(Value *Ptr)
Create a call to llvm.threadlocal.address intrinsic.
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
LLVM_ABI CallInst * CreateMaskedCompressStore(Value *Val, Value *Ptr, MaybeAlign Align, Value *Mask=nullptr)
Create a call to Masked Compress Store intrinsic.
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
LLVM_ABI Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
LLVM_ABI CallInst * CreateGCGetPointerBase(Value *DerivedPtr, const Twine &Name="")
Create a call to the experimental.gc.pointer.base intrinsic to get the base pointer for the specified...
LLVM_ABI CallInst * CreateLifetimeStart(Value *Ptr)
Create a lifetime.start intrinsic.
LLVM_ABI CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, ArrayRef< Value * > CallArgs, std::optional< ArrayRef< Value * > > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
LLVM_ABI CallInst * CreateLifetimeEnd(Value *Ptr)
Create a lifetime.end intrinsic.
LLVM_ABI CallInst * CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name="", std::optional< fp::ExceptionBehavior > Except=std::nullopt)
LLVM_ABI Value * CreateSelectFMF(Value *C, Value *True, Value *False, FMFSource FMFSource, const Twine &Name="", Instruction *MDFrom=nullptr)
LLVM_ABI CallInst * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
LLVM_ABI Value * CreateVectorSplice(Value *V1, Value *V2, int64_t Imm, const Twine &Name="")
Return a vector splice intrinsic if using scalable vectors, otherwise return a shufflevector.
LLVM_ABI CallInst * CreateAssumption(Value *Cond, ArrayRef< OperandBundleDef > OpBundles={})
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
LLVM_ABI Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
LLVM_ABI Value * CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex, MDNode *DbgInfo)
LLVM_ABI CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, unsigned Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer.
LLVM_ABI CallInst * CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
LLVM_ABI CallInst * CreateConstrainedFPCall(Function *Callee, ArrayRef< Value * > Args, const Twine &Name="", std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
LLVM_ABI Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Create an invoke instruction.
LLVM_ABI CallInst * CreateGCGetPointerOffset(Value *DerivedPtr, const Twine &Name="")
Create a call to the experimental.gc.get.pointer.offset intrinsic to get the offset of the specified ...
LLVM_ABI CallInst * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateConstrainedFPBinOp(Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
IntegerType * getIntPtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type of an integer with size at least as big as that of a pointer in the given address spac...
LLVM_ABI Value * CreateAggregateCast(Value *V, Type *DestTy)
Cast between aggregate types that must have identical structure but may differ in their leaf types.
BasicBlock * GetInsertBlock() const
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
LLVM_ABI CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert an element unordered-atomic memmove between the specified pointers.
LLVM_ABI Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
LLVM_ABI CallInst * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Value * getAllOnesMask(ElementCount NumElts)
Return an all true boolean vector (mask) with NumElts lanes.
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
LLVM_ABI CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF=nullptr, const Twine &Name="")
LLVM_ABI CallInst * CreateFPMinReduce(Value *Src)
Create a vector float min reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateFPMaximumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
LLVM_ABI Value * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type.
LLVM_ABI Value * createIsFPClass(Value *FPNum, unsigned Test)
LLVM_ABI CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
LLVM_ABI CallInst * CreateFPMaxReduce(Value *Src)
Create a vector float max reduction intrinsic of the source vector.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
LLVM_ABI CallInst * CreateFree(Value *Source, ArrayRef< OperandBundleDef > Bundles={})
Generate the IR for a call to the builtin free function.
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
LLVM_ABI DebugLoc getCurrentDebugLocation() const
Get location information used by debugging information.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
LLVM_ABI CallInst * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert a memset to the specified pointer and the specified value.
LLVM_ABI Value * CreateNAryOp(unsigned Opc, ArrayRef< Value * > Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
LLVM_ABI CallInst * CreateConstrainedFPIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name, MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
This function is like CreateIntrinsic for constrained fp intrinsics.
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
LLVMContext & getContext() const
LLVM_ABI Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
LLVM_ABI CallInst * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
LLVM_ABI 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 ...
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
LLVM_ABI Value * CreateTypeSize(Type *Ty, TypeSize Size)
Create an expression which evaluates to the number of units in Size at runtime.
LLVM_ABI CallInst * CreateDereferenceableAssumption(Value *PtrValue, Value *SizeValue)
Create an assume intrinsic call that represents an dereferencable assumption on the provided pointer.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
LLVM_ABI CallInst * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert an element unordered-atomic memcpy between the specified pointers.
void setConstrainedFPCallAttr(CallBase *I)
LLVM_ABI InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > InvokeArgs, std::optional< ArrayRef< Value * > > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
LLVM_ABI CallInst * CreateMaskedExpandLoad(Type *Ty, Value *Ptr, MaybeAlign Align, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Expand Load intrinsic.
const IRBuilderFolder & Folder
LLVM_ABI CallInst * CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI Value * CreateVectorInterleave(ArrayRef< Value * > Ops, const Twine &Name="")
LLVM_ABI CallInst * CreateFMulReduce(Value *Acc, Value *Src)
Create a sequential vector fmul reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, Value *Val, Value *Size, bool IsVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
LLVM_ABI 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...
LLVM_ABI Value * CreateStepVector(Type *DstType, const Twine &Name="")
Creates a vector of type DstType with the linear sequence <0, 1, ...>
LLVM_ABI Value * CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex, MDNode *DbgInfo)
LLVM_ABI CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
LLVM_ABI Instruction * CreateNoAliasScopeDeclaration(Value *Scope)
Create a llvm.experimental.noalias.scope.decl intrinsic call.
LLVM_ABI CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
LLVM_ABI GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0, Module *M=nullptr, bool AddNull=true)
Make a new global variable with initializer type i8*.
LLVM_ABI Value * CreateElementCount(Type *Ty, ElementCount EC)
Create an expression which evaluates to the number of elements in EC at runtime.
LLVM_ABI CallInst * CreateFPMinimumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateConstrainedFPCast(Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
LLVM_ABI Value * CreateStripInvariantGroup(Value *Ptr)
Create a strip.invariant.group intrinsic call.
LLVM_ABI CallInst * CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
~IRBuilderCallbackInserter() override
virtual ~IRBuilderDefaultInserter()
virtual Value * FoldCmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const =0
virtual Value * FoldSelect(Value *C, Value *True, Value *False) const =0
virtual ~IRBuilderFolder()
virtual Value * FoldBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Type *Ty, Instruction *FMFSource=nullptr) const =0
LLVM_ABI void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
LLVM_ABI void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
A Module instance is used to store all the information related to an LLVM module.
A container for an operand bundle being viewed as a set of values rather than a set of uses.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
This class represents the LLVM 'select' instruction.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isArrayTy() const
True if this is an instance of ArrayType.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Type * getArrayElementType() const
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
bool isStructTy() const
True if this is an instance of StructType.
bool isAggregateType() const
Return true if the type is an aggregate type.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
LLVM_ABI Type * getStructElementType(unsigned N) const
bool isVoidTy() const
Return true if this is 'void'.
LLVM_ABI unsigned getStructNumElements() const
LLVM_ABI uint64_t getArrayNumElements() const
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
MatchIntrinsicTypesResult
@ MatchIntrinsicTypes_Match
LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take ...
LLVM_ABI Intrinsic::ID getInterleaveIntrinsicID(unsigned Factor)
Returns the corresponding llvm.vector.interleaveN intrinsic for factor N.
This is an optimization pass for GlobalISel generic memory operations.
MaybeAlign getAlign(const CallInst &I, unsigned Index)
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.