57 GV->setAlignment(M->getDataLayout().getPrefTypeAlign(
getInt8Ty()));
72 I->setDebugLoc(StoredDL.orElse(
I->getDebugLoc()));
76 Type *SrcTy = V->getType();
80 if (SrcTy->isAggregateType()) {
82 if (SrcTy->isStructTy()) {
85 "Expected StructTypes with equal number of elements");
86 NumElements = SrcTy->getStructNumElements();
88 assert(SrcTy->isArrayTy() && DestTy->
isArrayTy() &&
"Expected ArrayType");
90 "Expected ArrayTypes with equal number of elements");
91 NumElements = SrcTy->getArrayNumElements();
95 for (
unsigned I = 0;
I < NumElements; ++
I) {
111 Type *OldTy = V->getType();
117 "Integer types must be the exact same to convert.");
122 Type *InTy = In->getType();
152 return CreateIntToPtr(CreateBitCastLike(V,
DL.getIntPtrType(NewTy)), NewTy);
163 return CreateBitCastLike(
CreatePtrToInt(V,
DL.getIntPtrType(OldTy)), NewTy);
175 if (OldAS != NewAS) {
178 DL.getIntPtrType(NewTy)),
183 return CreateBitCastLike(V, NewTy);
197 Value *VScale =
B.CreateVScale(Ty);
201 return B.CreateNUWMul(VScale, ConstantInt::get(Ty, Scale));
205 if (EC.isFixed() || EC.isZero())
206 return ConstantInt::get(Ty, EC.getKnownMinValue());
212 if (
Size.isFixed() ||
Size.isZero())
213 return ConstantInt::get(Ty,
Size.getKnownMinValue());
230 Type *StepVecType = DstType;
239 if (StepVecType != DstType)
249 for (
unsigned i = 0; i < NumEls; ++i)
251 ConstantInt::get(STy, i,
false,
true));
267 CI->setDestAlignment(*
Align);
277 Type *Tys[] = {Dst->getType(),
Size->getType()};
283 CI->setDestAlignment(*DstAlign);
296 Intrinsic::memset_element_unordered_atomic, Tys,
Ops));
297 CI->setDestAlignment(Alignment);
307 assert((IntrID == Intrinsic::memcpy || IntrID == Intrinsic::memcpy_inline ||
308 IntrID == Intrinsic::memmove) &&
309 "Unexpected intrinsic ID");
311 Type *Tys[] = {Dst->getType(), Src->getType(),
Size->getType()};
317 MCI->setDestAlignment(*DstAlign);
319 MCI->setSourceAlignment(*SrcAlign);
320 MCI->setAAMetadata(AAInfo);
327 assert(DstAlign >= ElementSize &&
328 "Pointer alignment must be at least element size");
329 assert(SrcAlign >= ElementSize &&
330 "Pointer alignment must be at least element size");
332 Type *Tys[] = {Dst->getType(), Src->getType(),
Size->getType()};
335 Intrinsic::memcpy_element_unordered_atomic, Tys,
Ops));
338 AMCI->setDestAlignment(DstAlign);
339 AMCI->setSourceAlignment(SrcAlign);
340 AMCI->setAAMetadata(AAInfo);
346 assert(Val &&
"isConstantOne does not work with nullptr Val");
348 return CVal && CVal->
isOne();
360 ArraySize = ConstantInt::get(
IntPtrTy, 1);
366 AllocSize = ArraySize;
369 AllocSize =
CreateMul(ArraySize, AllocSize,
"mallocsize");
380 MallocFunc = M->getOrInsertFunction(
"malloc", BPTy,
IntPtrTy);
386 F->setReturnDoesNotAlias();
404 assert(Source->getType()->isPointerTy() &&
405 "Can not free something of nonpointer type!");
412 FunctionCallee FreeFunc = M->getOrInsertFunction(
"free", VoidTy, VoidPtrTy);
414 Result->setTailCall();
416 Result->setCallingConv(
F->getCallingConv());
424 assert(DstAlign >= ElementSize &&
425 "Pointer alignment must be at least element size");
426 assert(SrcAlign >= ElementSize &&
427 "Pointer alignment must be at least element size");
429 Type *Tys[] = {Dst->getType(), Src->getType(),
Size->getType()};
432 Intrinsic::memmove_element_unordered_atomic, Tys,
Ops);
443 Type *Tys[] = { Src->getType() };
458 return getReductionIntrinsic(Intrinsic::vector_reduce_add, Src);
462 return getReductionIntrinsic(Intrinsic::vector_reduce_mul, Src);
466 return getReductionIntrinsic(Intrinsic::vector_reduce_and, Src);
470 return getReductionIntrinsic(Intrinsic::vector_reduce_or, Src);
474 return getReductionIntrinsic(Intrinsic::vector_reduce_xor, Src);
479 IsSigned ? Intrinsic::vector_reduce_smax : Intrinsic::vector_reduce_umax;
480 return getReductionIntrinsic(ID, Src);
485 IsSigned ? Intrinsic::vector_reduce_smin : Intrinsic::vector_reduce_umin;
486 return getReductionIntrinsic(ID, Src);
490 return getReductionIntrinsic(Intrinsic::vector_reduce_fmax, Src);
494 return getReductionIntrinsic(Intrinsic::vector_reduce_fmin, Src);
498 return getReductionIntrinsic(Intrinsic::vector_reduce_fmaximum, Src);
502 return getReductionIntrinsic(Intrinsic::vector_reduce_fminimum, Src);
506 return getReductionIntrinsic(Intrinsic::vector_reduce_fmaximumnum, Src);
510 return getReductionIntrinsic(Intrinsic::vector_reduce_fminimumnum, Src);
515 "lifetime.start only applies to pointers.");
522 "lifetime.end only applies to pointers.");
530 "invariant.start only applies to pointers.");
535 "invariant.start requires the size to be an i64");
546 return V->getAlign();
554 "threadlocal_address only applies to thread local variables.");
556 llvm::Intrinsic::threadlocal_address, {Ptr->
getType()}, {Ptr});
566 "an assumption condition must be of type i1");
575 Intrinsic::assume, {}, Args,
576 nullptr,
"", OpBundles);
581 Intrinsic::experimental_noalias_scope_decl, {}, {Scope});
597 assert(Ty->isVectorTy() &&
"Type should be vector");
598 assert(Mask &&
"Mask should not be all-ones (null)");
601 Type *OverloadedTypes[] = { Ty, PtrTy };
602 Value *
Ops[] = {Ptr, Mask, PassThru};
604 CreateMaskedIntrinsic(Intrinsic::masked_load,
Ops, OverloadedTypes, Name);
620 assert(Mask &&
"Mask should not be all-ones (null)");
621 Type *OverloadedTypes[] = { DataTy, PtrTy };
624 CreateMaskedIntrinsic(Intrinsic::masked_store,
Ops, OverloadedTypes);
655 assert(NumElts == PtrsTy->getElementCount() &&
"Element count mismatch");
663 Type *OverloadedTypes[] = {Ty, PtrsTy};
664 Value *
Ops[] = {Ptrs, Mask, PassThru};
668 CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_gather,
Ops,
669 OverloadedTypes, Name);
690 Type *OverloadedTypes[] = {DataTy, PtrsTy};
696 CreateMaskedIntrinsic(Intrinsic::masked_scatter,
Ops, OverloadedTypes);
714 assert(Ty->isVectorTy() &&
"Type should be vector");
715 assert(Mask &&
"Mask should not be all-ones (null)");
719 Type *OverloadedTypes[] = {Ty, PtrTy};
720 Value *
Ops[] = {Ptr, Mask, PassThru};
721 CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_expandload,
Ops,
722 OverloadedTypes, Name);
739 assert(Mask &&
"Mask should not be all-ones (null)");
741 Type *OverloadedTypes[] = {DataTy, PtrTy};
743 CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_compressstore,
Ops,
750template <
typename T0>
751static std::vector<Value *>
754 std::vector<Value *> Args;
755 Args.push_back(
B.getInt64(ID));
756 Args.push_back(
B.getInt32(NumPatchBytes));
757 Args.push_back(ActualCallee);
758 Args.push_back(
B.getInt32(CallArgs.
size()));
759 Args.push_back(
B.getInt32(Flags));
763 Args.push_back(
B.getInt32(0));
764 Args.push_back(
B.getInt32(0));
769template<
typename T1,
typename T2,
typename T3>
770static std::vector<OperandBundleDef>
774 std::vector<OperandBundleDef> Rval;
778 Rval.emplace_back(
"gc-transition",
785template <
typename T0,
typename T1,
typename T2,
typename T3>
792 Module *M = Builder->getModule();
795 M, Intrinsic::experimental_gc_statepoint,
799 *Builder, ID, NumPatchBytes, ActualCallee.
getCallee(), Flags, CallArgs);
816 CallArgs, std::nullopt , DeoptArgs, GCArgs, Name);
826 this, ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
827 DeoptArgs, GCArgs, Name);
836 CallArgs, std::nullopt, DeoptArgs, GCArgs, Name);
839template <
typename T0,
typename T1,
typename T2,
typename T3>
847 Module *M = Builder->getModule();
850 M, Intrinsic::experimental_gc_statepoint,
853 std::vector<Value *> Args =
858 FnStatepoint, NormalDest, UnwindDest, Args,
872 this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
874 std::nullopt , DeoptArgs, GCArgs, Name);
884 this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
885 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs, Name);
894 this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
902 Type *Types[] = {ResultType};
904 Value *Args[] = {Statepoint};
909 int BaseOffset,
int DerivedOffset,
911 Type *Types[] = {ResultType};
915 Types, Args, {}, Name);
922 Intrinsic::experimental_gc_get_pointer_base, PtrTy, DerivedPtr, {}, Name);
929 Intrinsic::experimental_gc_get_pointer_offset, {PtrTy}, {DerivedPtr}, {},
954 return createCallHelper(Fn, {LHS, RHS}, Name,
FMFSource);
963 return createCallHelper(Fn, Args, Name,
FMFSource, OpBundles);
974 return createCallHelper(Fn, Args, Name,
FMFSource);
1008 const Twine &Name,
MDNode *FPMathTag, std::optional<RoundingMode> Rounding,
1009 std::optional<fp::ExceptionBehavior> Except) {
1010 Value *RoundingV = getConstrainedFPRounding(Rounding);
1011 Value *ExceptV = getConstrainedFPExcept(Except);
1015 ID, {L->getType()}, {L, R, RoundingV, ExceptV},
nullptr, Name, {});
1017 setFPAttrs(
C, FPMathTag, UseFMF);
1024 std::optional<RoundingMode> Rounding,
1025 std::optional<fp::ExceptionBehavior> Except) {
1026 Value *RoundingV = getConstrainedFPRounding(Rounding);
1027 Value *ExceptV = getConstrainedFPExcept(Except);
1037 setFPAttrs(
C, FPMathTag, UseFMF);
1044 std::optional<fp::ExceptionBehavior> Except) {
1045 Value *ExceptV = getConstrainedFPExcept(Except);
1049 ID, {L->getType()}, {L, R, ExceptV},
nullptr, Name, {});
1051 setFPAttrs(
C, FPMathTag, UseFMF);
1058 assert(
Ops.size() == 2 &&
"Invalid number of operands!");
1060 Ops[0],
Ops[1], Name, FPMathTag);
1063 assert(
Ops.size() == 1 &&
"Invalid number of operands!");
1065 Ops[0], Name, FPMathTag);
1072 const Twine &Name,
MDNode *FPMathTag, std::optional<RoundingMode> Rounding,
1073 std::optional<fp::ExceptionBehavior> Except) {
1074 Value *ExceptV = getConstrainedFPExcept(Except);
1080 Value *RoundingV = getConstrainedFPRounding(Rounding);
1082 ID, {DestTy, V->getType()}, {V, RoundingV, ExceptV},
nullptr, Name, {});
1089 setFPAttrs(
C, FPMathTag, UseFMF);
1098 auto ID = IsSignaling ? Intrinsic::experimental_constrained_fcmps
1099 : Intrinsic::experimental_constrained_fcmp;
1112 const Twine &Name, std::optional<fp::ExceptionBehavior> Except) {
1113 Value *PredicateV = getConstrainedFPPredicate(
P);
1114 Value *ExceptV = getConstrainedFPExcept(Except);
1117 ID, {L->getType()}, {L, R, PredicateV, ExceptV},
nullptr, Name, {});
1124 std::optional<RoundingMode> Rounding,
1125 std::optional<fp::ExceptionBehavior> Except) {
1129 UseArgs.
push_back(getConstrainedFPRounding(Rounding));
1130 UseArgs.
push_back(getConstrainedFPExcept(Except));
1140 const Twine &Name) {
1152 const Twine &Name) {
1174 Sel = addBranchMetadata(Sel, Prof, Unpred);
1178 return Insert(Sel, Name);
1183 assert(LHS->getType() == RHS->getType() &&
1184 "Pointer subtraction operand types must match!");
1187 return CreateSub(LHSAddr, RHSAddr, Name, IsNUW);
1190 const Twine &Name) {
1202 "launder.invariant.group only applies to pointers.");
1203 auto *PtrType = Ptr->
getType();
1206 M, Intrinsic::launder_invariant_group, {PtrType});
1211 "LaunderInvariantGroup should take and return the same type");
1213 return CreateCall(FnLaunderInvariantGroup, {Ptr});
1226 int NumElts = Ty->getElementCount().getKnownMinValue();
1227 for (
int i = 0; i < NumElts; ++i)
1233 unsigned Idx = (NumElts +
Imm) % NumElts;
1235 for (
unsigned I = 0;
I < NumElts; ++
I)
1236 Mask.push_back(Idx +
I);
1244 "Splice expects matching operand types!");
1251 getSpliceMask(COffset->getZExtValue(), FVTy->getNumElements()));
1254 {V1, V2, Offset}, {}, Name);
1259 const Twine &Name) {
1262 "Splice expects matching operand types!");
1269 getSpliceMask(-COffset->getZExtValue(), FVTy->getNumElements()));
1272 {V1, V2, Offset}, {}, Name);
1276 const Twine &Name) {
1282 const Twine &Name) {
1283 assert(EC.isNonZero() &&
"Cannot splat to an empty vector!");
1291 Zeros.
resize(EC.getKnownMinValue());
1296 const Twine &Name) {
1298 "Unexpected number of operands to interleave");
1304 for (
unsigned I = 1;
I <
Ops.size();
I++) {
1306 "Vector interleave expects matching operand types!");
1313 SubvecTy->getElementCount() *
Ops.size());
1323 "Invalid Base ptr type for preserve.array.access.index.");
1334 Intrinsic::preserve_array_access_index, {ResultType,
BaseType},
1335 {
Base, DimV, LastIndexV});
1339 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1347 "Invalid Base ptr type for preserve.union.access.index.");
1355 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1361 Type *ElTy,
Value *
Base,
unsigned Index,
unsigned FieldIndex,
1365 "Invalid Base ptr type for preserve.struct.access.index.");
1374 Intrinsic::preserve_struct_access_index, {ResultType,
BaseType},
1375 {
Base, GEPIndex, DIIndex});
1379 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1393 Value *OffsetValue) {
1404 Value *OffsetValue) {
1406 "trying to create an alignment assumption on a non-pointer?");
1407 assert(Alignment != 0 &&
"Invalid Alignment");
1409 return CreateAlignmentAssumptionHelper(
DL, PtrValue, AlignValue, OffsetValue);
1415 Value *OffsetValue) {
1417 "trying to create an alignment assumption on a non-pointer?");
1418 return CreateAlignmentAssumptionHelper(
DL, PtrValue, Alignment, OffsetValue);
1424 "trying to create a deferenceable assumption on a non-pointer?");
1432 "trying to create a nonnull assumption on a non-pointer?");
1439 "trying to create a range assumption on a non-integer?");
1441 "trying to create a range assumption which doesn't assume anything?");
1450 if (
auto *V =
Folder.FoldGEP(
DL, Ty, Ptr, IdxList, NW))
1456 unsigned IdxSize =
DL.getIndexTypeSizeInBits(Ptr->
getType());
1457 if (Ty->isIntegerTy(8) && IdxList[0]->getType()->isIntOrIntVectorTy(IdxSize))
1461 for (; GTI != GTE; ++GTI) {
1463 Type *IdxTy =
Op->getType()->getWithNewBitWidth(IdxSize);
1467 if (OpC->isNullValue() && !IsSplat)
1470 if (
StructType *STy = GTI.getStructTypeOrNull()) {
1471 uint64_t OpValue = OpC->getUniqueInteger().getZExtValue();
1472 uint64_t
Offset =
DL.getStructLayout(STy)->getElementOffset(OpValue);
1483 if (
Op->getType() != IdxTy)
1486 TypeSize Stride = GTI.getSequentialElementStride(
DL);
1492 Ptr, ConstantInt::get(IdxTy, OpC->getValue() * StrideInt), Name, NW);
1501void IRBuilderFolder::anchor() {}
1502void ConstantFolder::anchor() {}
1503void NoFolder::anchor() {}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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 MaybeAlign getAlign(Value *Ptr)
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)
static SmallVector< int, 8 > getSpliceMask(int64_t Imm, unsigned NumElts)
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
This file contains the declarations for profiling metadata utility functions.
SmallVector< MachineOperand, 4 > Cond
static SymbolRef::Type getType(const Symbol *Sym)
static const char PassName[]
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
LLVM_ABI TypeSize getAllocationBaseSize(const DataLayout &DL) const
Get the size of the allocated type.
LLVM_ABI bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
const Value * getArraySize() const
Get the number of elements allocated.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
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.
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, bool ByteString=false)
This method constructs a CDS and initializes it with a text string.
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)
This class represents a range of values.
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.
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()
Type * getParamType(unsigned i) const
Parameter type accessors.
Type * getReturnType() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Type * getReturnType() const
Returns the type of the ret val.
Represents flags for the getelementptr instruction/expression.
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
@ 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 CallInst * CreateIntrinsicWithoutFolding(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={})
Create a call to intrinsic ID with Args, mangled using OverloadTypes.
LLVM_ABI Value * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
LLVM_ABI Value * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
LLVM_ABI Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
LLVM_ABI Value * CreateSelectFMFWithUnknownProfile(Value *C, Value *True, Value *False, FMFSource FMFSource, StringRef PassName, const Twine &Name="")
const DataLayout & getDataLayout() const
Get data layout.
LLVM_ABI Value * CreateFPMinReduce(Value *Src)
Create a vector float min reduction intrinsic of the source vector.
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 Value * CreateAllocationSize(Type *DestTy, AllocaInst *AI)
Get allocation size of an alloca as a runtime Value* (handles both static and dynamic allocas and vsc...
Value * CreateScaledPtrAdd(Value *Ptr, uint64_t Scale, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
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 * CreateNonnullAssumption(Value *PtrValue)
Create an assume intrinsic call that represents a nonnull assumption on the provided pointer.
LLVM_ABI Value * CreateFPMaximumNumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
LLVM_ABI Value * CreateFPMaximumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
LLVM_ABI Value * CreateVectorSpliceRight(Value *V1, Value *V2, Value *Offset, const Twine &Name="")
Create a vector.splice.right intrinsic call, or a shufflevector that produces the same result if the ...
LLVM_ABI CallInst * CreateLifetimeEnd(Value *Ptr)
Create a lifetime.end intrinsic.
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
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 Value * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
Value * CreatePtrToAddr(Value *V, const Twine &Name="")
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 * 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 * CreateFPMinimumNumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
LLVM_ABI Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
LLVM_ABI CallInst * CreateMalloc(Type *IntPtrTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF=nullptr, const Twine &Name="")
LLVM_ABI Value * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
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 ...
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
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)
Value * CreateExtractVector(Type *DstType, Value *SrcVec, Value *Idx, const Twine &Name="")
Create a call to the vector.extract intrinsic.
LLVM_ABI Value * CreateAggregateCast(Value *V, Type *DestTy)
Cast between aggregate types that must have identical structure but may differ in their leaf types.
Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
LLVM_ABI CallInst * CreateRangeAssumption(Value *Int, ConstantRange Range)
LLVM_ABI CallInst * CreateAssumption(Value *Cond)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
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.
Module * getModule() const
Get the module.
LLVM_ABI Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
LLVM_ABI Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
LLVM_ABI Value * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
LLVM_ABI Value * CreateBitPreservingCastChain(const DataLayout &DL, Value *V, Type *NewTy)
Create a chain of casts to convert V to NewTy, preserving the bit pattern of V.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
LLVM_ABI Value * CreateVectorSpliceLeft(Value *V1, Value *V2, Value *Offset, const Twine &Name="")
Create a vector.splice.left intrinsic call, or a shufflevector that produces the same result if the r...
Value * getAllOnesMask(ElementCount NumElts)
Return an all true boolean vector (mask) with NumElts lanes.
LLVM_ABI Value * CreateFPMaxReduce(Value *Src)
Create a vector float max reduction intrinsic of the source vector.
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
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 Value * CreateOrReduce(Value *Src)
Create a vector int OR 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="")
LLVM_ABI Value * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
LLVM_ABI Value * CreateFPMinimumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
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)
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
LLVM_ABI Value * CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name="", bool IsNUW=false)
Return the difference between two pointer values.
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 * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={}, function_ref< void(CallInst *)> SetFn=[](CallInst *) {})
Variant to create a possibly constant-folded intrinsic.
LLVM_ABI Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
LLVM_ABI Value * CreateSelectWithUnknownProfile(Value *C, Value *True, Value *False, StringRef PassName, const Twine &Name="")
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)
LLVM_ABI CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, uint64_t Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer.
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 a dereferencable assumption on the provided pointer.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
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 Value * CreateFAddReduce(Value *Acc, Value *Src)
Create a sequential vector fadd reduction intrinsic of the source vector.
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 Value * 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.
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
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)
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Value * CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec, Value *Idx, const Twine &Name="")
Create a call to the vector.insert intrinsic.
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 Value * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *Op, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
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 * 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 CallInst * CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
virtual Value * FoldCmp(CmpInst::Predicate P, Value *LHS, Value *RHS) 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(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
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, const Instruction *MDFrom=nullptr)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Class to represent struct types.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI Type * getStructElementType(unsigned N) const
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)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Type * getArrayElementType() const
LLVM_ABI unsigned getStructNumElements() const
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVM_ABI uint64_t getArrayNumElements() const
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isStructTy() const
True if this is an instance of StructType.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
bool isVoidTy() const
Return true if this is 'void'.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
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.
static VectorType * getWithSizeAndScalar(VectorType *SizeTy, Type *EltTy)
This static method attempts to construct a VectorType with the same size-in-bits as SizeTy but with a...
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-Point Intrinsics" that take r...
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI Intrinsic::ID getInterleaveIntrinsicID(unsigned Factor)
Returns the corresponding llvm.vector.interleaveN intrinsic for factor N.
LLVM_ABI FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > OverloadTys={})
Return the function type for an intrinsic.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void setExplicitlyUnknownBranchWeightsIfProfiled(Instruction &I, StringRef PassName, const Function *F=nullptr)
Like setExplicitlyUnknownBranchWeights(...), but only sets unknown branch weights in the new instruct...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto map_to_vector(ContainerTy &&C, FuncTy &&F)
Map a range to a SmallVector with element types deduced from the mapping.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
gep_type_iterator gep_type_end(const User *GEP)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
OperandBundleDefT< Value * > OperandBundleDef
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
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.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.