LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Friends | List of all members
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 (const TargetLibraryInfoImpl &Impl, std::optional< const Function * > F=std::nullopt)
 
 TargetLibraryInfo (const TargetLibraryInfo &TLI)=default
 
 TargetLibraryInfo (TargetLibraryInfo &&TLI)=default
 
TargetLibraryInfooperator= (const TargetLibraryInfo &TLI)=default
 
TargetLibraryInfooperator= (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.
 
bool getLibFunc (StringRef funcName, LibFunc &F) const
 Searches for a particular function name.
 
bool getLibFunc (const Function &FDecl, LibFunc &F) const
 
bool getLibFunc (const CallBase &CB, LibFunc &F) const
 If a callbase does not have the 'nobuiltin' attribute, return if the called function is a known library function and set F to that function.
 
bool getLibFunc (unsigned int Opcode, Type *Ty, LibFunc &F) const
 Searches for a function name using an Instruction Opcode.
 
void disableAllFunctions () LLVM_ATTRIBUTE_UNUSED
 Disables all builtins.
 
void setUnavailable (LibFunc F) LLVM_ATTRIBUTE_UNUSED
 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 VecDescgetVectorMappingInfo (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 getWCharSize (const Module &M) const
 Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
 
unsigned getSizeTSize (const Module &M) const
 Returns the size of the size_t type in bits.
 
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.
 

Static Public Member Functions

static void initExtensionsForTriple (bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)
 
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 281 of file TargetLibraryInfo.h.

Constructor & Destructor Documentation

◆ TargetLibraryInfo() [1/3]

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() [2/3]

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

◆ TargetLibraryInfo() [3/3]

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

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 326 of file TargetLibraryInfo.h.

◆ disableAllFunctions()

void llvm::TargetLibraryInfo::disableAllFunctions ( )
inline

Disables all builtins.

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

Definition at line 370 of file TargetLibraryInfo.h.

Referenced by TargetLibraryInfo().

◆ getAttrList()

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

Definition at line 543 of file TargetLibraryInfo.h.

References llvm::CallingConv::C, and Signed.

◆ getExtAttrForI32Param() [1/2]

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

Definition at line 505 of file TargetLibraryInfo.h.

References Signed.

◆ getExtAttrForI32Param() [2/2]

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

Definition at line 495 of file TargetLibraryInfo.h.

References initExtensionsForTriple(), and Signed.

◆ getExtAttrForI32Return() [1/2]

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

Definition at line 535 of file TargetLibraryInfo.h.

References Signed.

◆ getExtAttrForI32Return() [2/2]

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

Definition at line 525 of file TargetLibraryInfo.h.

References initExtensionsForTriple(), and Signed.

◆ getIntSize()

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

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

Definition at line 564 of file TargetLibraryInfo.h.

References llvm::TargetLibraryInfoImpl::getIntSize().

Referenced by getIntTy().

◆ getLibFunc() [1/4]

bool llvm::TargetLibraryInfo::getLibFunc ( const CallBase CB,
LibFunc F 
) const
inline

If a callbase does not have the 'nobuiltin' attribute, return if the called function is a known library function and set F to that function.

Definition at line 356 of file TargetLibraryInfo.h.

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

◆ getLibFunc() [2/4]

bool llvm::TargetLibraryInfo::getLibFunc ( const Function FDecl,
LibFunc F 
) const
inline

Definition at line 350 of file TargetLibraryInfo.h.

References F, and llvm::TargetLibraryInfoImpl::getLibFunc().

◆ getLibFunc() [3/4]

bool llvm::TargetLibraryInfo::getLibFunc ( StringRef  funcName,
LibFunc F 
) const
inline

◆ getLibFunc() [4/4]

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

Searches for a function name using an Instruction Opcode.

Currently, only the frem instruction is supported.

Definition at line 363 of file TargetLibraryInfo.h.

References F, and llvm::TargetLibraryInfoImpl::getLibFunc().

◆ getName()

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

◆ 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.

References llvm::TargetLibraryInfoImpl::getSizeTSize().

Referenced by getSizeTTy().

◆ 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

◆ getVectorMappingInfo()

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

◆ getWCharSize()

unsigned llvm::TargetLibraryInfo::getWCharSize ( const Module M) const
inline

Returns the size of the wchar_t type in bytes or 0 if the size is unknown.

This queries the 'wchar_size' metadata.

Definition at line 556 of file TargetLibraryInfo.h.

References llvm::TargetLibraryInfoImpl::getWCharSize().

◆ 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 582 of file TargetLibraryInfo.h.

References llvm::TargetLibraryInfoImpl::getWidestVF().

Referenced by addMappingsFromTLI(), and llvm::isTLIScalarize().

◆ has()

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

◆ 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().

Referenced by llvm::maybeMarkSanitizerLibraryCallNoBuiltin(), and llvm::FastISel::selectInstruction().

◆ initExtensionsForTriple()

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

◆ invalidate() [1/2]

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

Definition at line 576 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 572 of file TargetLibraryInfo.h.

◆ isFunctionVectorizable() [1/2]

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

◆ 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 588 of file TargetLibraryInfo.h.

References isFunctionVectorizable().

Referenced by isKnownLibFunction().

◆ 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 337 of file TargetLibraryInfo.h.

References F.

Referenced by llvm::isLibFuncEmittable().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ 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().

Friends And Related Function Documentation

◆ TargetLibraryAnalysis

friend class TargetLibraryAnalysis
friend

Definition at line 282 of file TargetLibraryInfo.h.

◆ TargetLibraryInfoWrapperPass

friend class TargetLibraryInfoWrapperPass
friend

Definition at line 283 of file TargetLibraryInfo.h.


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