LLVM 23.0.0git
llvm::Intrinsic Namespace Reference

This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM. More...

Classes

struct  IITDescriptor
 This is a type descriptor which explains the type requirements of an intrinsic. More...

Typedefs

using ID = unsigned

Enumerations

enum  IndependentIntrinsics : unsigned { not_intrinsic = 0 }

Functions

LLVM_ABI StringRef getName (ID id)
 Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
LLVM_ABI StringRef getBaseName (ID id)
 Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm.ssa.copy".
LLVM_ABI std::string getName (ID Id, ArrayRef< Type * > OverloadTys, Module *M, FunctionType *FT=nullptr)
 Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx" or "llvm.ssa.copy.p0s_s.1".
LLVM_ABI std::string getNameNoUnnamedTypes (ID Id, ArrayRef< Type * > OverloadTys)
 Return the LLVM name for an intrinsic.
LLVM_ABI FunctionTypegetType (LLVMContext &Context, ID id, ArrayRef< Type * > OverloadTys={})
 Return the function type for an intrinsic.
LLVM_ABI bool isOverloaded (ID id)
 Returns true if the intrinsic can be overloaded.
LLVM_ABI bool isTriviallyScalarizable (ID id)
 Returns true if the intrinsic is trivially scalarizable.
LLVM_ABI bool hasPrettyPrintedArgs (ID id)
 Returns true if the intrinsic has pretty printed immediate arguments.
LLVM_ABI bool isTargetIntrinsic (ID IID)
 isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
LLVM_ABI ID lookupIntrinsicID (StringRef Name)
 This does the actual lookup of an intrinsic ID which matches the given function name.
LLVM_ABI AttributeList getAttributes (LLVMContext &C, ID id, FunctionType *FT)
 Return the attributes for an intrinsic.
LLVM_ABI AttributeSet getFnAttributes (LLVMContext &C, ID id)
 Return the function attributes for an intrinsic.
LLVM_ABI FunctiongetOrInsertDeclaration (Module *M, ID id, ArrayRef< Type * > OverloadTys={})
 Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI FunctiongetOrInsertDeclaration (Module *M, ID IID, Type *RetTy, ArrayRef< Type * > ArgTys)
 Look up the Function declaration of the intrinsic IID in the Module M.
LLVM_ABI FunctiongetDeclarationIfExists (const Module *M, ID id)
 Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
LLVM_ABI FunctiongetDeclarationIfExists (Module *M, ID id, ArrayRef< Type * > OverloadTys, FunctionType *FT=nullptr)
 This version supports overloaded intrinsics.
LLVM_ABI ID getIntrinsicForClangBuiltin (StringRef TargetPrefix, StringRef BuiltinName)
 Map a Clang builtin name to an intrinsic ID.
LLVM_ABI ID getIntrinsicForMSBuiltin (StringRef TargetPrefix, StringRef BuiltinName)
 Map a MS builtin name to an intrinsic ID.
LLVM_ABI bool isConstrainedFPIntrinsic (ID QID)
 Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics".
LLVM_ABI bool hasConstrainedFPRoundingModeOperand (ID QID)
 Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take rounding mode metadata.
LLVM_ABI void getIntrinsicInfoTableEntries (ID id, SmallVectorImpl< IITDescriptor > &T)
 Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
LLVM_ABI bool matchIntrinsicSignature (FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &OverloadTys, raw_ostream &OS)
 Match the specified function type with the type constraints specified by the .td file.
LLVM_ABI bool isSignatureValid (Intrinsic::ID ID, FunctionType *FT, SmallVectorImpl< Type * > &OverloadTys, raw_ostream &OS=nulls())
 Returns true if FT is a valid function type for intrinsic ID.
LLVM_ABI bool isSignatureValid (Function *F, SmallVectorImpl< Type * > &OverloadTys, raw_ostream &OS=nulls())
 Same as previous, but accepts a Function instead of ID and FunctionType.
LLVM_ABI std::optional< Function * > remangleIntrinsicFunction (Function *F)
LLVM_ABI Intrinsic::ID getInterleaveIntrinsicID (unsigned Factor)
 Returns the corresponding llvm.vector.interleaveN intrinsic for factor N.
LLVM_ABI Intrinsic::ID getDeinterleaveIntrinsicID (unsigned Factor)
 Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor N.
LLVM_ABI void printImmArg (ID IID, unsigned ArgIdx, raw_ostream &OS, const Constant *ImmArgVal)
 Print the argument info for the arguments with ArgInfo.

Variables

static const int NoAliasScopeDeclScopeArg = 0

Detailed Description

This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.

The enum values are returned by Function::getIntrinsicID().

Typedef Documentation

◆ ID

Definition at line 28 of file GenericSSAContext.h.

Enumeration Type Documentation

◆ IndependentIntrinsics

Enumerator
not_intrinsic 

Definition at line 47 of file Intrinsics.h.

Function Documentation

◆ getAttributes()

LLVM_ABI AttributeList llvm::Intrinsic::getAttributes ( LLVMContext & C,
ID id,
FunctionType * FT )

◆ getBaseName()

StringRef llvm::Intrinsic::getBaseName ( ID id)

Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm.ssa.copy".

Definition at line 44 of file Intrinsics.cpp.

References assert().

Referenced by llvm::VPWidenIntrinsicRecipe::getIntrinsicName(), getIntrinsicNameImpl(), getName(), llvm::SDNode::getOperationName(), and llvm::MachineOperand::print().

◆ getDeclarationIfExists() [1/2]

◆ getDeclarationIfExists() [2/2]

Function * llvm::Intrinsic::getDeclarationIfExists ( Module * M,
ID id,
ArrayRef< Type * > OverloadTys,
FunctionType * FT = nullptr )

This version supports overloaded intrinsics.

Definition at line 811 of file Intrinsics.cpp.

References llvm::Function::getFunction(), and getName().

◆ getDeinterleaveIntrinsicID()

Intrinsic::ID llvm::Intrinsic::getDeinterleaveIntrinsicID ( unsigned Factor)

Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor N.

Definition at line 1218 of file Intrinsics.cpp.

References assert(), and InterleaveIntrinsics.

Referenced by llvm::VPInterleaveEVLRecipe::execute(), and llvm::VPInterleaveRecipe::execute().

◆ getFnAttributes()

LLVM_ABI AttributeSet llvm::Intrinsic::getFnAttributes ( LLVMContext & C,
ID id )

◆ getInterleaveIntrinsicID()

Intrinsic::ID llvm::Intrinsic::getInterleaveIntrinsicID ( unsigned Factor)

Returns the corresponding llvm.vector.interleaveN intrinsic for factor N.

Definition at line 1213 of file Intrinsics.cpp.

References assert(), and InterleaveIntrinsics.

Referenced by llvm::IRBuilderBase::CreateVectorInterleave().

◆ getIntrinsicForClangBuiltin()

LLVM_ABI ID llvm::Intrinsic::getIntrinsicForClangBuiltin ( StringRef TargetPrefix,
StringRef BuiltinName )

Map a Clang builtin name to an intrinsic ID.

References LLVM_ABI.

◆ getIntrinsicForMSBuiltin()

LLVM_ABI ID llvm::Intrinsic::getIntrinsicForMSBuiltin ( StringRef TargetPrefix,
StringRef BuiltinName )

Map a MS builtin name to an intrinsic ID.

References LLVM_ABI.

◆ getIntrinsicInfoTableEntries()

void llvm::Intrinsic::getIntrinsicInfoTableEntries ( ID id,
SmallVectorImpl< IITDescriptor > & T )

Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.

Definition at line 446 of file Intrinsics.cpp.

References DecodeIITType(), and T.

Referenced by getOrInsertDeclaration(), getType(), and isSignatureValid().

◆ getName() [1/2]

StringRef llvm::Intrinsic::getName ( ID id)

Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".

Note, this version is for intrinsics with no overloads. Use the other version of getName if overloads are required.

Definition at line 49 of file Intrinsics.cpp.

References assert(), getBaseName(), and isOverloaded().

Referenced by getOrInsertIntrinsicDeclarationImpl(), LLVMIntrinsicCopyOverloadedName2(), LLVMIntrinsicGetName(), remangleIntrinsicFunction(), replaceWithCallToVeclib(), reportInvalidTensormapReplaceUsage(), and llvm::IRSimilarity::IRInstructionData::setCalleeName().

◆ getName() [2/2]

std::string llvm::Intrinsic::getName ( ID Id,
ArrayRef< Type * > OverloadTys,
Module * M,
FunctionType * FT = nullptr )

Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx" or "llvm.ssa.copy.p0s_s.1".

Note, this version of getName supports overloads. This is less efficient than the StringRef version of this function. If no overloads are required, it is safe to use this version, but better to use the StringRef version. If one of the types is based on an unnamed type, a function type will be computed. Providing FT will avoid this computation.

Definition at line 185 of file Intrinsics.cpp.

References assert(), and getIntrinsicNameImpl().

◆ getNameNoUnnamedTypes()

std::string llvm::Intrinsic::getNameNoUnnamedTypes ( ID Id,
ArrayRef< Type * > OverloadTys )

Return the LLVM name for an intrinsic.

This is a special version only to be used by LLVMIntrinsicCopyOverloadedName. It only supports overloads based on named types.

Definition at line 191 of file Intrinsics.cpp.

References getIntrinsicNameImpl().

Referenced by LLVMIntrinsicCopyOverloadedName().

◆ getOrInsertDeclaration() [1/2]

Function * llvm::Intrinsic::getOrInsertDeclaration ( Module * M,
ID id,
ArrayRef< Type * > OverloadTys = {} )

Look up the Function declaration of the intrinsic id in the Module M.

If it does not exist, add a declaration and return it. Otherwise, return the existing declaration.

The OverloadTys parameter is for intrinsics with overloaded types

Definition at line 774 of file Intrinsics.cpp.

References getOrInsertIntrinsicDeclarationImpl(), and getType().

Referenced by addAssumeNonNull(), convertNvvmIntrinsicToLlvm(), convertToRelLookupTable(), llvm::ConvergenceControlInst::CreateAnchor(), llvm::IRBuilderBase::CreateAssumption(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::MatrixBuilder::CreateColumnMajorLoad(), llvm::MatrixBuilder::CreateColumnMajorStore(), createCoroSave(), llvm::DbgLabelRecord::createDebugIntrinsic(), llvm::DbgVariableRecord::createDebugIntrinsic(), llvm::ConvergenceControlInst::CreateEntry(), CreateGCRelocates(), CreateGCStatepointCallCommon(), CreateGCStatepointInvokeCommon(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateLaunderInvariantGroup(), llvm::ConvergenceControlInst::CreateLoop(), llvm::MatrixBuilder::CreateMatrixMultiply(), llvm::MatrixBuilder::CreateMatrixTranspose(), llvm::IRBuilderBase::CreateStripInvariantGroup(), llvm::IRBuilderBase::CreateUnaryIntrinsic(), llvm::IRBuilderBase::CreateVectorReverse(), llvm::PPCTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(), llvm::LoongArchTargetLowering::emitMaskedAtomicRMWIntrinsic(), llvm::RISCVTargetLowering::emitMaskedAtomicRMWIntrinsic(), llvm::OpenMPIRBuilder::emitScanReduction(), llvm::AArch64TargetLowering::emitStoreConditional(), llvm::ARMTargetLowering::emitStoreConditional(), EvaluateInDifferentTypeImpl(), llvm::VPWidenIntrinsicRecipe::execute(), expandIToFP(), explicifyGuards(), factorizeMinMaxTree(), llvm::AMDGPULibCalls::fold(), foldBitwiseLogicWithIntrinsics(), foldCtpop(), foldCttzCtlz(), foldShuffleOfUnaryOps(), foldSpliceBinOp(), foldSubOfMinMax(), foldToUnsignedSaturatedAdd(), llvm::InstCombinerImpl::foldVectorBinop(), foldVectorCmp(), generateUnsignedDivisionCode(), llvm::memtag::getAndroidSlotPtr(), getOrInsertDeclaration(), llvm::VPIntrinsic::getOrInsertDeclarationForParams(), getStructuredLoadFunction(), getStructuredStoreFunction(), llvm::GCNTTIImpl::hoistLaneIntrinsicThroughOperand(), llvm::InlineFunctionImpl(), insertCall(), insertLifetimeMarkersSurroundingCall(), llvm::BPFCoreSharedInfo::insertPassThrough(), llvm::GCNTTIImpl::instCombineIntrinsic(), llvm::SampleProfileProber::instrumentOneFunc(), LLVMGetIntrinsicDeclaration(), llvm::RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad(), lowerExpectAssume(), lowerGuardIntrinsic(), llvm::RISCVTargetLowering::lowerInterleavedStore(), llvm::RISCVTargetLowering::lowerInterleaveIntrinsicToStore(), llvm::IntrinsicLowering::LowerToByteSwap(), llvm::lowerUnaryVectorIntrinsicAsLoop(), makeIntrinsicCall(), llvm::coro::LowererBase::makeSubFnCall(), matchFunnelShift(), optimizeModularFormat(), optimizeUniformIntrinsic(), processUGT_ADDCST_ADD(), reassociateMinMaxWithConstantInOperand(), llvm::recognizeBSwapOrBitReverseIdiom(), remangleIntrinsicFunction(), llvm::GCNTTIImpl::rewriteIntrinsicWithAddressSpace(), runImpl(), simplifyAMDGCNImageIntrinsic(), llvm::GCNTTIImpl::simplifyAMDGCNLaneIntrinsicDemanded(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), simplifySVEIntrinsic(), llvm::updatePublicTypeTestCalls(), upgradeAMDGCNIntrinsicCall(), llvm::UpgradeARCRuntime(), upgradeArmOrAarch64IntrinsicFunction(), upgradeIntrinsicFunction1(), upgradeNVVMIntrinsicCall(), upgradePTESTIntrinsic(), upgradeX86BF16DPIntrinsic(), upgradeX86BF16Intrinsic(), upgradeX86IntrinsicCall(), upgradeX86IntrinsicFunction(), upgradeX86IntrinsicsWith8BitMask(), upgradeX86MaskedFPCompare(), upgradeX86MultiplyAddBytes(), upgradeX86MultiplyAddWords(), UseTlsOffset(), useTpOffset(), llvm::InstCombinerImpl::visitAllocSite(), llvm::InstCombinerImpl::visitBitCast(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitFPTrunc(), llvm::InstCombinerImpl::visitLoadInst(), llvm::InstCombinerImpl::visitStoreInst(), and llvm::InstCombinerImpl::visitXor().

◆ getOrInsertDeclaration() [2/2]

Function * llvm::Intrinsic::getOrInsertDeclaration ( Module * M,
ID IID,
Type * RetTy,
ArrayRef< Type * > ArgTys )

Look up the Function declaration of the intrinsic IID in the Module M.

If it does not exist, add a declaration and return it. Otherwise, return the existing declaration.

This overload automatically resolves overloaded intrinsics based on the provided return type and argument types. For non-overloaded intrinsics, the return type and argument types are ignored.

Parameters
M- The module to get or insert the intrinsic declaration.
IID- The intrinsic ID.
RetTy- The return type of the intrinsic.
ArgTys- The argument types of the intrinsic.

Definition at line 785 of file Intrinsics.cpp.

References assert(), llvm::FunctionType::get(), getIntrinsicInfoTableEntries(), getOrInsertDeclaration(), getOrInsertIntrinsicDeclarationImpl(), isIntrinsicVarArg(), isOverloaded(), matchIntrinsicSignature(), and llvm::nulls().

◆ getType()

◆ hasConstrainedFPRoundingModeOperand()

bool llvm::Intrinsic::hasConstrainedFPRoundingModeOperand ( Intrinsic::ID QID)

Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take rounding mode metadata.

Definition at line 837 of file Intrinsics.cpp.

Referenced by llvm::IRBuilderBase::CreateConstrainedFPCall(), llvm::IRBuilderBase::CreateConstrainedFPCast(), and llvm::ConstrainedFPIntrinsic::getNonMetadataArgCount().

◆ hasPrettyPrintedArgs()

bool llvm::Intrinsic::hasPrettyPrintedArgs ( ID id)

Returns true if the intrinsic has pretty printed immediate arguments.

Definition at line 632 of file Intrinsics.cpp.

◆ isConstrainedFPIntrinsic()

bool llvm::Intrinsic::isConstrainedFPIntrinsic ( ID QID)

Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics".

Definition at line 825 of file Intrinsics.cpp.

Referenced by llvm::ConstrainedFPIntrinsic::classof().

◆ isOverloaded()

◆ isSignatureValid() [1/2]

bool llvm::Intrinsic::isSignatureValid ( Function * F,
SmallVectorImpl< Type * > & OverloadTys,
raw_ostream & OS = nulls() )

Same as previous, but accepts a Function instead of ID and FunctionType.

Definition at line 1159 of file Intrinsics.cpp.

References F, and isSignatureValid().

◆ isSignatureValid() [2/2]

bool llvm::Intrinsic::isSignatureValid ( Intrinsic::ID ID,
FunctionType * FT,
SmallVectorImpl< Type * > & OverloadTys,
raw_ostream & OS = nulls() )

Returns true if FT is a valid function type for intrinsic ID.

If ID is an overloaded intrinsic, the overload types are pushed into the OverloadTys vector.

Returns false if the given ID and function type combination is not a valid intrinsic call. Also prints the error message to indicate the reason of the mismatch to OS.

Definition at line 1146 of file Intrinsics.cpp.

References getIntrinsicInfoTableEntries(), and matchIntrinsicSignature().

Referenced by isSignatureValid(), modifyIntrinsicCall(), optimizeSection(), remangleIntrinsicFunction(), simplifyAMDGCNImageIntrinsic(), simplifyAMDGCNMemoryIntrinsicDemanded(), and llvm::UpgradeIntrinsicFunction().

◆ isTargetIntrinsic()

bool llvm::Intrinsic::isTargetIntrinsic ( Intrinsic::ID IID)

isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.

If it is a generic intrinsic false is returned.

Definition at line 641 of file Intrinsics.cpp.

Referenced by llvm::BasicTTIImplBase< BasicTTIImpl >::getIntrinsicInstrCost(), llvm::isVectorIntrinsicWithOverloadTypeAtArg(), llvm::isVectorIntrinsicWithScalarOpAtArg(), and llvm::isVectorIntrinsicWithStructReturnOverloadAtField().

◆ isTriviallyScalarizable()

LLVM_ABI bool llvm::Intrinsic::isTriviallyScalarizable ( ID id)

Returns true if the intrinsic is trivially scalarizable.

This means that the intrinsic's argument types are all scalars for the scalar form and all vectors for the vector form.

References LLVM_ABI.

Referenced by llvm::isTriviallyScalarizable().

◆ lookupIntrinsicID()

Intrinsic::ID llvm::Intrinsic::lookupIntrinsicID ( StringRef Name)

This does the actual lookup of an intrinsic ID which matches the given function name.

Definition at line 730 of file Intrinsics.cpp.

References assert(), findTargetSubtable(), isOverloaded(), lookupLLVMIntrinsicByName(), and not_intrinsic.

Referenced by isOldDbgFormatIntrinsic(), and LLVMLookupIntrinsicID().

◆ matchIntrinsicSignature()

bool llvm::Intrinsic::matchIntrinsicSignature ( FunctionType * FTy,
ArrayRef< IITDescriptor > & Infos,
SmallVectorImpl< Type * > & OverloadTys,
raw_ostream & OS )

Match the specified function type with the type constraints specified by the .td file.

If the given type is an overloaded type it is pushed to the OverloadTys vector.

Returns false if the given type matches with the constraints, true otherwise. If returning true, an error message to indicate the reason of mismatch is printed to OS.

Definition at line 1097 of file Intrinsics.cpp.

References llvm::ArrayRef< T >::empty(), llvm::FunctionType::getReturnType(), I, isIntrinsicVarArg(), llvm::FunctionType::isVarArg(), matchIntrinsicType(), llvm::FunctionType::params(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by getOrInsertDeclaration(), and isSignatureValid().

◆ printImmArg()

LLVM_ABI void llvm::Intrinsic::printImmArg ( ID IID,
unsigned ArgIdx,
raw_ostream & OS,
const Constant * ImmArgVal )

Print the argument info for the arguments with ArgInfo.

References LLVM_ABI.

◆ remangleIntrinsicFunction()

std::optional< Function * > llvm::Intrinsic::remangleIntrinsicFunction ( Function * F)

Variable Documentation

◆ NoAliasScopeDeclScopeArg

const int llvm::Intrinsic::NoAliasScopeDeclScopeArg = 0
static