LLVM 24.0.0git
llvm::TargetLibraryInfo Class Reference

Provides information about what library functions are available for the current target. More...

#include "llvm/Analysis/TargetLibraryInfo.h"

Public Member Functions

 TargetLibraryInfo ()=delete
 TargetLibraryInfo (const TargetLibraryInfoImpl &Impl, std::optional< const Function * > F=std::nullopt)
 TargetLibraryInfo (const TargetLibraryInfo &TLI)=default
 TargetLibraryInfo (TargetLibraryInfo &&TLI)=default
TargetLibraryInfo & operator= (const TargetLibraryInfo &TLI)=default
TargetLibraryInfo & operator= (TargetLibraryInfo &&TLI)=default
bool areInlineCompatible (const TargetLibraryInfo &CalleeTLI, bool AllowCallerSuperset) const
 Determine whether a callee with the given TLI can be inlined into caller with this TLI, based on 'nobuiltin' attributes.
bool isValidProtoForLibFunc (const FunctionType &FTy, LibFunc F, const Module &M) const
 Return true if the function type FTy is valid for the library function F, regardless of whether the function is available.
LibFunc getLibFunc (StringRef funcName) const
 Searches for a particular function name.
LibFunc getLibFunc (const Function &FDecl) const
LibFunc getLibFunc (const CallBase &CB) const
 If a callbase does not have the 'nobuiltin' attribute, return the library function the callee is, and NotLibFunc otherwise.
LibFunc getLibFunc (unsigned int Opcode, Type *Ty) const
 Searches for a function name using an Instruction Opcode.
void disableAllFunctions ()
 Disables all builtins.
void setUnavailable (LibFunc F)
 Forces a function to be marked as unavailable.
TargetLibraryInfoImpl::AvailabilityState getState (LibFunc F) const
bool has (LibFunc F) const
 Tests whether a library function is available.
bool isFunctionVectorizable (StringRef F, const ElementCount &VF) const
bool isFunctionVectorizable (StringRef F) const
StringRef getVectorizedFunction (StringRef F, const ElementCount &VF, bool Masked=false) const
const VecDesc * getVectorMappingInfo (StringRef F, const ElementCount &VF, bool Masked) const
bool hasOptimizedCodeGen (LibFunc F) const
 Tests if the function is both available and a candidate for optimized code generation.
StringRef getName (LibFunc F) const
Attribute::AttrKind getExtAttrForI32Param (bool Signed=true) const
Attribute::AttrKind getExtAttrForI32Return (bool Signed=true) const
AttributeList getAttrList (LLVMContext *C, ArrayRef< unsigned > ArgNos, bool Signed, bool Ret=false, AttributeList AL=AttributeList()) const
unsigned getSizeTSize (const Module &M) const
 Returns the size of the size_t type in bits.
IntegerType * getSizeTType (const Module &M) const
 Returns an IntegerType corresponding to size_t.
ConstantInt * getAsSizeT (uint64_t V, const Module &M) const
 Returns a constant materialized as a size_t type.
unsigned getIntSize () const
 Get size of a C-level int or unsigned int, in bits.
bool invalidate (Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
 Handle invalidation from the pass manager.
bool invalidate (Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
void getWidestVF (StringRef ScalarF, ElementCount &FixedVF, ElementCount &ScalableVF) const
 Returns the largest vectorization factor used in the list of vector functions.
bool isKnownVectorFunctionInLibrary (StringRef F) const
 Check if the function "F" is listed in a library known to LLVM.
bool isErrnoFunctionCall () const
 Returns whether errno is defined as a function call on known environments.

Static Public Member Functions

static StringRef getStandardName (LibFunc F)
 Return the canonical name for a LibFunc.
static LLVM_ABI void initBoolExtensionsForTriple (bool &ShouldZExtBoolParam, bool &ShouldZExtBoolReturn, const Triple &T)
static LLVM_ABI void initExtensionsForTriple (bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)
static Attribute::AttrKind getExtAttrForBoolParam (const Triple &T)
static Attribute::AttrKind getExtAttrForI8Param (bool Signed=true)
static Attribute::AttrKind getExtAttrForI32Param (const Triple &T, bool Signed=true)
static Attribute::AttrKind getExtAttrForI32Return (const Triple &T, bool Signed=true)

Friends

class TargetLibraryAnalysis
class TargetLibraryInfoWrapperPass

Detailed Description

Provides information about what library functions are available for the current target.

This both allows optimizations to handle them specially and frontends to disable such optimizations through -fno-builtin etc.

Definition at line 279 of file TargetLibraryInfo.h.

Constructor & Destructor Documentation

◆ TargetLibraryInfo() [1/4]

llvm::TargetLibraryInfo::TargetLibraryInfo ( )
delete

◆ TargetLibraryInfo() [2/4]

llvm::TargetLibraryInfo::TargetLibraryInfo ( const TargetLibraryInfoImpl & Impl,
std::optional< const Function * > F = std::nullopt )
inlineexplicit

Definition at line 293 of file TargetLibraryInfo.h.

References disableAllFunctions(), F, getLibFunc(), and setUnavailable().

◆ TargetLibraryInfo() [3/4]

llvm::TargetLibraryInfo::TargetLibraryInfo ( const TargetLibraryInfo & TLI)
default

References TargetLibraryInfo(), and TLI.

◆ TargetLibraryInfo() [4/4]

llvm::TargetLibraryInfo::TargetLibraryInfo ( TargetLibraryInfo && TLI)
default

References TargetLibraryInfo(), and TLI.

Member Function Documentation

◆ areInlineCompatible()

bool llvm::TargetLibraryInfo::areInlineCompatible ( const TargetLibraryInfo & CalleeTLI,
bool AllowCallerSuperset ) const
inline

Determine whether a callee with the given TLI can be inlined into caller with this TLI, based on 'nobuiltin' attributes.

When requested, allow inlining into a caller with a superset of the callee's nobuiltin attributes, which is conservatively correct.

Definition at line 325 of file TargetLibraryInfo.h.

References TargetLibraryInfo().

◆ disableAllFunctions()

void llvm::TargetLibraryInfo::disableAllFunctions ( )
inline

Disables all builtins.

This can be used for options like -fno-builtin.

Definition at line 372 of file TargetLibraryInfo.h.

Referenced by TargetLibraryInfo().

◆ getAsSizeT()

ConstantInt * llvm::TargetLibraryInfo::getAsSizeT ( uint64_t V,
const Module & M ) const
inline

Returns a constant materialized as a size_t type.

Definition at line 569 of file TargetLibraryInfo.h.

References getSizeTType(), uint64_t, and V.

◆ getAttrList()

AttributeList llvm::TargetLibraryInfo::getAttrList ( LLVMContext * C,
ArrayRef< unsigned > ArgNos,
bool Signed,
bool Ret = false,
AttributeList AL = AttributeList() ) const
inline

Definition at line 548 of file TargetLibraryInfo.h.

References C(), and llvm::Signed.

◆ getExtAttrForBoolParam()

Attribute::AttrKind llvm::TargetLibraryInfo::getExtAttrForBoolParam ( const Triple & T)
inlinestatic

Definition at line 488 of file TargetLibraryInfo.h.

References initBoolExtensionsForTriple(), llvm::Attribute::None, and T.

◆ getExtAttrForI32Param() [1/2]

Attribute::AttrKind llvm::TargetLibraryInfo::getExtAttrForI32Param ( bool Signed = true) const
inline

Definition at line 510 of file TargetLibraryInfo.h.

References llvm::Signed.

◆ getExtAttrForI32Param() [2/2]

Attribute::AttrKind llvm::TargetLibraryInfo::getExtAttrForI32Param ( const Triple & T,
bool Signed = true )
inlinestatic

Definition at line 500 of file TargetLibraryInfo.h.

References initExtensionsForTriple(), llvm::Signed, and T.

◆ getExtAttrForI32Return() [1/2]

Attribute::AttrKind llvm::TargetLibraryInfo::getExtAttrForI32Return ( bool Signed = true) const
inline

Definition at line 540 of file TargetLibraryInfo.h.

References llvm::Signed.

◆ getExtAttrForI32Return() [2/2]

Attribute::AttrKind llvm::TargetLibraryInfo::getExtAttrForI32Return ( const Triple & T,
bool Signed = true )
inlinestatic

Definition at line 530 of file TargetLibraryInfo.h.

References initExtensionsForTriple(), llvm::Signed, and T.

◆ getExtAttrForI8Param()

Attribute::AttrKind llvm::TargetLibraryInfo::getExtAttrForI8Param ( bool Signed = true)
inlinestatic

Definition at line 494 of file TargetLibraryInfo.h.

References llvm::Signed.

◆ getIntSize()

unsigned llvm::TargetLibraryInfo::getIntSize ( ) const
inline

Get size of a C-level int or unsigned int, in bits.

Definition at line 574 of file TargetLibraryInfo.h.

◆ getLibFunc() [1/4]

LibFunc llvm::TargetLibraryInfo::getLibFunc ( const CallBase & CB) const
inline

If a callbase does not have the 'nobuiltin' attribute, return the library function the callee is, and NotLibFunc otherwise.

Definition at line 355 of file TargetLibraryInfo.h.

References llvm::CallBase::getCalledFunction(), getLibFunc(), and llvm::CallBase::isNoBuiltin().

◆ getLibFunc() [2/4]

LibFunc llvm::TargetLibraryInfo::getLibFunc ( const Function & FDecl) const
inline

Definition at line 349 of file TargetLibraryInfo.h.

◆ getLibFunc() [3/4]

LibFunc llvm::TargetLibraryInfo::getLibFunc ( StringRef funcName) const
inline

Searches for a particular function name.

Returns the corresponding LibFunc if it is one of the known library functions, and NotLibFunc otherwise.

Definition at line 345 of file TargetLibraryInfo.h.

Referenced by llvm::TargetTransformInfo::getArithmeticInstrCost(), getLibFunc(), isIntrinsicOrLFToBeTailCalled(), peephole(), and TargetLibraryInfo().

◆ getLibFunc() [4/4]

LibFunc llvm::TargetLibraryInfo::getLibFunc ( unsigned int Opcode,
Type * Ty ) const
inline

Searches for a function name using an Instruction Opcode.

Currently, only the frem instruction is supported.

Returns NotLibFunc if there is no matching library function.

Definition at line 365 of file TargetLibraryInfo.h.

◆ getName()

StringRef llvm::TargetLibraryInfo::getName ( LibFunc F) const
inline

Definition at line 451 of file TargetLibraryInfo.h.

References assert(), F, and getState().

Referenced by llvm::TargetTransformInfo::getArithmeticInstrCost().

◆ getSizeTSize()

unsigned llvm::TargetLibraryInfo::getSizeTSize ( const Module & M) const
inline

Returns the size of the size_t type in bits.

Definition at line 561 of file TargetLibraryInfo.h.

Referenced by getSizeTType().

◆ getSizeTType()

IntegerType * llvm::TargetLibraryInfo::getSizeTType ( const Module & M) const
inline

Returns an IntegerType corresponding to size_t.

Definition at line 564 of file TargetLibraryInfo.h.

References llvm::IntegerType::get(), and getSizeTSize().

Referenced by getAsSizeT(), and getAtomicMemOpSizeArg().

◆ getStandardName()

StringRef llvm::TargetLibraryInfo::getStandardName ( LibFunc F)
inlinestatic

Return the canonical name for a LibFunc.

This should not be used for semantic purposes, use getName instead.

Definition at line 445 of file TargetLibraryInfo.h.

References F.

◆ getState()

TargetLibraryInfoImpl::AvailabilityState llvm::TargetLibraryInfo::getState ( LibFunc F) const
inline

Definition at line 380 of file TargetLibraryInfo.h.

References assert(), and F.

Referenced by getName(), has(), and hasOptimizedCodeGen().

◆ getVectorizedFunction()

StringRef llvm::TargetLibraryInfo::getVectorizedFunction ( StringRef F,
const ElementCount & VF,
bool Masked = false ) const
inline

Definition at line 397 of file TargetLibraryInfo.h.

References F, and llvm::Masked.

◆ getVectorMappingInfo()

const VecDesc * llvm::TargetLibraryInfo::getVectorMappingInfo ( StringRef F,
const ElementCount & VF,
bool Masked ) const
inline

Definition at line 401 of file TargetLibraryInfo.h.

References F, and llvm::Masked.

◆ getWidestVF()

void llvm::TargetLibraryInfo::getWidestVF ( StringRef ScalarF,
ElementCount & FixedVF,
ElementCount & ScalableVF ) const
inline

Returns the largest vectorization factor used in the list of vector functions.

Definition at line 592 of file TargetLibraryInfo.h.

◆ has()

bool llvm::TargetLibraryInfo::has ( LibFunc F) const
inline

Tests whether a library function is available.

Definition at line 388 of file TargetLibraryInfo.h.

References F, and getState().

◆ hasOptimizedCodeGen()

bool llvm::TargetLibraryInfo::hasOptimizedCodeGen ( LibFunc F) const
inline

Tests if the function is both available and a candidate for optimized code generation.

Definition at line 408 of file TargetLibraryInfo.h.

References F, and getState().

◆ initBoolExtensionsForTriple()

void TargetLibraryInfo::initBoolExtensionsForTriple ( bool & ShouldZExtBoolParam,
bool & ShouldZExtBoolReturn,
const Triple & T )
static

◆ initExtensionsForTriple()

void TargetLibraryInfo::initExtensionsForTriple ( bool & ShouldExtI32Param,
bool & ShouldExtI32Return,
bool & ShouldSignExtI32Param,
bool & ShouldSignExtI32Return,
const Triple & T )
static

◆ invalidate() [1/2]

bool llvm::TargetLibraryInfo::invalidate ( Function & ,
const PreservedAnalyses & ,
FunctionAnalysisManager::Invalidator &  )
inline

Definition at line 586 of file TargetLibraryInfo.h.

◆ invalidate() [2/2]

bool llvm::TargetLibraryInfo::invalidate ( Module & ,
const PreservedAnalyses & ,
ModuleAnalysisManager::Invalidator &  )
inline

Handle invalidation from the pass manager.

If we try to invalidate this info, just return false. It cannot become invalid even if the module or function changes.

Definition at line 582 of file TargetLibraryInfo.h.

◆ isErrnoFunctionCall()

bool llvm::TargetLibraryInfo::isErrnoFunctionCall ( ) const
inline

Returns whether errno is defined as a function call on known environments.

Definition at line 604 of file TargetLibraryInfo.h.

◆ isFunctionVectorizable() [1/2]

bool llvm::TargetLibraryInfo::isFunctionVectorizable ( StringRef F) const
inline

Definition at line 394 of file TargetLibraryInfo.h.

References F.

◆ isFunctionVectorizable() [2/2]

bool llvm::TargetLibraryInfo::isFunctionVectorizable ( StringRef F,
const ElementCount & VF ) const
inline

◆ isKnownVectorFunctionInLibrary()

bool llvm::TargetLibraryInfo::isKnownVectorFunctionInLibrary ( StringRef F) const
inline

Check if the function "F" is listed in a library known to LLVM.

Definition at line 598 of file TargetLibraryInfo.h.

References F, and isFunctionVectorizable().

◆ isValidProtoForLibFunc()

bool llvm::TargetLibraryInfo::isValidProtoForLibFunc ( const FunctionType & FTy,
LibFunc F,
const Module & M ) const
inline

Return true if the function type FTy is valid for the library function F, regardless of whether the function is available.

Definition at line 336 of file TargetLibraryInfo.h.

References F.

◆ operator=() [1/2]

TargetLibraryInfo & llvm::TargetLibraryInfo::operator= ( const TargetLibraryInfo & TLI)
default

References TargetLibraryInfo(), and TLI.

◆ operator=() [2/2]

TargetLibraryInfo & llvm::TargetLibraryInfo::operator= ( TargetLibraryInfo && TLI)
default

References TargetLibraryInfo(), and TLI.

◆ setUnavailable()

void llvm::TargetLibraryInfo::setUnavailable ( LibFunc F)
inline

Forces a function to be marked as unavailable.

Definition at line 375 of file TargetLibraryInfo.h.

References assert(), and F.

Referenced by TargetLibraryInfo().

◆ TargetLibraryAnalysis

friend class TargetLibraryAnalysis
friend

Definition at line 280 of file TargetLibraryInfo.h.

References TargetLibraryAnalysis.

Referenced by TargetLibraryAnalysis.

◆ TargetLibraryInfoWrapperPass

friend class TargetLibraryInfoWrapperPass
friend

Definition at line 281 of file TargetLibraryInfo.h.

References TargetLibraryInfoWrapperPass.

Referenced by TargetLibraryInfoWrapperPass.


The documentation for this class was generated from the following files: