LLVM  17.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::TargetLibraryInfoImpl Class Reference

Implementation of the target library information. More...

#include "llvm/Analysis/TargetLibraryInfo.h"

Public Types

enum  VectorLibrary {
  NoLibrary, Accelerate, DarwinLibSystemM, LIBMVEC_X86,
  MASSV, SVML, SLEEFGNUABI
}
 List of known vector-functions libraries. More...
 

Public Member Functions

 TargetLibraryInfoImpl ()
 
 TargetLibraryInfoImpl (const Triple &T)
 
 TargetLibraryInfoImpl (const TargetLibraryInfoImpl &TLI)
 
 TargetLibraryInfoImpl (TargetLibraryInfoImpl &&TLI)
 
TargetLibraryInfoImploperator= (const TargetLibraryInfoImpl &TLI)
 
TargetLibraryInfoImploperator= (TargetLibraryInfoImpl &&TLI)
 
bool getLibFunc (StringRef funcName, LibFunc &F) const
 Searches for a particular function name. More...
 
bool getLibFunc (const Function &FDecl, LibFunc &F) const
 Searches for a particular function name, also checking that its type is valid for the library function matching that name. More...
 
void setUnavailable (LibFunc F)
 Forces a function to be marked as unavailable. More...
 
void setAvailable (LibFunc F)
 Forces a function to be marked as available. More...
 
void setAvailableWithName (LibFunc F, StringRef Name)
 Forces a function to be marked as available and provide an alternate name that must be used. More...
 
void disableAllFunctions ()
 Disables all builtins. More...
 
void addVectorizableFunctions (ArrayRef< VecDesc > Fns)
 Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction. More...
 
void addVectorizableFunctionsFromVecLib (enum VectorLibrary VecLib, const llvm::Triple &TargetTriple)
 Calls addVectorizableFunctions with a known preset of functions for the given vector library. More...
 
bool isFunctionVectorizable (StringRef F, const ElementCount &VF) const
 Return true if the function F has a vector equivalent with vectorization factor VF. More...
 
bool isFunctionVectorizable (StringRef F) const
 Return true if the function F has a vector equivalent with any vectorization factor. More...
 
StringRef getVectorizedFunction (StringRef F, const ElementCount &VF) const
 Return the name of the equivalent of F, vectorized with factor VF. More...
 
void setShouldExtI32Param (bool Val)
 Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they correspond to C-level int or unsigned int, respectively. More...
 
void setShouldExtI32Return (bool Val)
 Set to true iff i32 results from library functions should have signext or zeroext attributes if they correspond to C-level int or unsigned int, respectively. More...
 
void setShouldSignExtI32Param (bool Val)
 Set to true iff i32 parameters to library functions should have signext attribute if they correspond to C-level int or unsigned int. More...
 
void setShouldSignExtI32Return (bool Val)
 Set to true iff i32 results from library functions should have signext attribute if they correspond to C-level int or unsigned int. More...
 
unsigned getWCharSize (const Module &M) const
 Returns the size of the wchar_t type in bytes or 0 if the size is unknown. More...
 
unsigned getSizeTSize (const Module &M) const
 Returns the size of the size_t type in bits. More...
 
unsigned getIntSize () const
 Get size of a C-level int or unsigned int, in bits. More...
 
void setIntSize (unsigned Bits)
 Initialize the C-level size of an integer. More...
 
void getWidestVF (StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const
 Returns the largest vectorization factor used in the list of vector functions. More...
 

Static Public Member Functions

static bool isCallingConvCCompatible (CallBase *CI)
 Returns true if call site / callee has cdecl-compatible calling conventions. More...
 
static bool isCallingConvCCompatible (Function *Callee)
 

Friends

class TargetLibraryInfo
 

Detailed Description

Implementation of the target library information.

This class constructs tables that hold the target library information and make it available. However, it is somewhat expensive to compute and only depends on the triple. So users typically interact with the TargetLibraryInfo wrapper below.

Definition at line 50 of file TargetLibraryInfo.h.

Member Enumeration Documentation

◆ VectorLibrary

List of known vector-functions libraries.

The vector-functions library defines, which functions are vectorizable and with which factor. The library can be specified by either frontend, or a commandline option, and then used by addVectorizableFunctionsFromVecLib for filling up the tables of vectorizable functions.

Enumerator
NoLibrary 
Accelerate 
DarwinLibSystemM 
LIBMVEC_X86 
MASSV 
SVML 
SLEEFGNUABI 

Definition at line 91 of file TargetLibraryInfo.h.

Constructor & Destructor Documentation

◆ TargetLibraryInfoImpl() [1/4]

TargetLibraryInfoImpl::TargetLibraryInfoImpl ( )

Definition at line 860 of file TargetLibraryInfo.cpp.

References initialize().

◆ TargetLibraryInfoImpl() [2/4]

TargetLibraryInfoImpl::TargetLibraryInfoImpl ( const Triple T)
explicit

Definition at line 867 of file TargetLibraryInfo.cpp.

References initialize().

◆ TargetLibraryInfoImpl() [3/4]

TargetLibraryInfoImpl::TargetLibraryInfoImpl ( const TargetLibraryInfoImpl TLI)

Definition at line 874 of file TargetLibraryInfo.cpp.

References memcpy().

◆ TargetLibraryInfoImpl() [4/4]

TargetLibraryInfoImpl::TargetLibraryInfoImpl ( TargetLibraryInfoImpl &&  TLI)

Definition at line 885 of file TargetLibraryInfo.cpp.

References llvm::sys::path::begin(), llvm::sys::path::end(), and move.

Member Function Documentation

◆ addVectorizableFunctions()

void TargetLibraryInfoImpl::addVectorizableFunctions ( ArrayRef< VecDesc Fns)

Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction.

Definition at line 1130 of file TargetLibraryInfo.cpp.

References llvm::append_range(), compareByScalarFnName(), compareByVectorFnName(), and llvm::sort().

Referenced by addVectorizableFunctionsFromVecLib().

◆ addVectorizableFunctionsFromVecLib()

void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib ( enum VectorLibrary  VecLib,
const llvm::Triple TargetTriple 
)

Calls addVectorizableFunctions with a known preset of functions for the given vector library.

Definition at line 1138 of file TargetLibraryInfo.cpp.

References llvm::Triple::aarch64, llvm::Triple::aarch64_be, Accelerate, addVectorizableFunctions(), DarwinLibSystemM, llvm::Triple::getArch(), LIBMVEC_X86, MASSV, NoLibrary, SLEEFGNUABI, and SVML.

Referenced by initialize().

◆ disableAllFunctions()

void TargetLibraryInfoImpl::disableAllFunctions ( )

Disables all builtins.

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

Definition at line 1114 of file TargetLibraryInfo.cpp.

Referenced by initialize().

◆ getIntSize()

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

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

Definition at line 209 of file TargetLibraryInfo.h.

Referenced by llvm::TargetLibraryInfo::getIntSize().

◆ getLibFunc() [1/2]

bool TargetLibraryInfoImpl::getLibFunc ( const Function FDecl,
LibFunc F 
) const

Searches for a particular function name, also checking that its type is valid for the library function matching that name.

If it is one of the known library functions, return true and set F to the corresponding value.

FDecl is assumed to have a parent Module when using this function.

Definition at line 1100 of file TargetLibraryInfo.cpp.

References assert(), F, llvm::Function::getFunctionType(), getLibFunc(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::Function::isIntrinsic(), and M.

◆ getLibFunc() [2/2]

bool TargetLibraryInfoImpl::getLibFunc ( StringRef  funcName,
LibFunc F 
) const

Searches for a particular function name.

If it is one of the known library functions, return true and set F to the corresponding value.

Definition at line 932 of file TargetLibraryInfo.cpp.

References llvm::sys::path::begin(), llvm::StringRef::empty(), and sanitizeFunctionName().

Referenced by getLibFunc(), and llvm::TargetLibraryInfo::getLibFunc().

◆ getSizeTSize()

unsigned TargetLibraryInfoImpl::getSizeTSize ( const Module M) const

Returns the size of the size_t type in bits.

Definition at line 1248 of file TargetLibraryInfo.cpp.

References M.

Referenced by llvm::TargetLibraryInfo::getSizeTSize().

◆ getVectorizedFunction()

StringRef TargetLibraryInfoImpl::getVectorizedFunction ( StringRef  F,
const ElementCount VF 
) const

Return the name of the equivalent of F, vectorized with factor VF.

If no such mapping exists, return the empty string.

Definition at line 1218 of file TargetLibraryInfo.cpp.

References compareWithScalarFnName(), F, I, llvm::lower_bound(), and sanitizeFunctionName().

Referenced by llvm::TargetLibraryInfo::getVectorizedFunction(), and isFunctionVectorizable().

◆ getWCharSize()

unsigned TargetLibraryInfoImpl::getWCharSize ( const Module M) const

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 1241 of file TargetLibraryInfo.cpp.

References M.

Referenced by llvm::TargetLibraryInfo::getWCharSize().

◆ getWidestVF()

void TargetLibraryInfoImpl::getWidestVF ( StringRef  ScalarF,
ElementCount FixedVF,
ElementCount Scalable 
) const

◆ isCallingConvCCompatible() [1/2]

bool TargetLibraryInfoImpl::isCallingConvCCompatible ( CallBase CI)
static

◆ isCallingConvCCompatible() [2/2]

bool TargetLibraryInfoImpl::isCallingConvCCompatible ( Function Callee)
static

Definition at line 143 of file TargetLibraryInfo.cpp.

References F, and isCallingConvCCompatible().

◆ isFunctionVectorizable() [1/2]

bool TargetLibraryInfoImpl::isFunctionVectorizable ( StringRef  F) const

Return true if the function F has a vector equivalent with any vectorization factor.

Definition at line 1207 of file TargetLibraryInfo.cpp.

References compareWithScalarFnName(), llvm::StringRef::empty(), I, llvm::lower_bound(), and sanitizeFunctionName().

◆ isFunctionVectorizable() [2/2]

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

Return true if the function F has a vector equivalent with vectorization factor VF.

Definition at line 163 of file TargetLibraryInfo.h.

References llvm::StringRef::empty(), F, and getVectorizedFunction().

Referenced by llvm::TargetLibraryInfo::isFunctionVectorizable().

◆ operator=() [1/2]

TargetLibraryInfoImpl & TargetLibraryInfoImpl::operator= ( const TargetLibraryInfoImpl TLI)

Definition at line 898 of file TargetLibraryInfo.cpp.

References memcpy().

◆ operator=() [2/2]

TargetLibraryInfoImpl & TargetLibraryInfoImpl::operator= ( TargetLibraryInfoImpl &&  TLI)

Definition at line 909 of file TargetLibraryInfo.cpp.

References llvm::sys::path::begin(), llvm::sys::path::end(), and move.

◆ setAvailable()

void llvm::TargetLibraryInfoImpl::setAvailable ( LibFunc  F)
inline

Forces a function to be marked as available.

Definition at line 131 of file TargetLibraryInfo.h.

References F.

Referenced by initialize().

◆ setAvailableWithName()

void llvm::TargetLibraryInfoImpl::setAvailableWithName ( LibFunc  F,
StringRef  Name 
)
inline

Forces a function to be marked as available and provide an alternate name that must be used.

Definition at line 137 of file TargetLibraryInfo.h.

References assert(), and F.

Referenced by initialize().

◆ setIntSize()

void llvm::TargetLibraryInfoImpl::setIntSize ( unsigned  Bits)
inline

Initialize the C-level size of an integer.

Definition at line 214 of file TargetLibraryInfo.h.

References llvm::tgtok::Bits.

Referenced by initialize().

◆ setShouldExtI32Param()

void llvm::TargetLibraryInfoImpl::setShouldExtI32Param ( bool  Val)
inline

Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they correspond to C-level int or unsigned int, respectively.

Definition at line 178 of file TargetLibraryInfo.h.

Referenced by initialize().

◆ setShouldExtI32Return()

void llvm::TargetLibraryInfoImpl::setShouldExtI32Return ( bool  Val)
inline

Set to true iff i32 results from library functions should have signext or zeroext attributes if they correspond to C-level int or unsigned int, respectively.

Definition at line 185 of file TargetLibraryInfo.h.

Referenced by initialize().

◆ setShouldSignExtI32Param()

void llvm::TargetLibraryInfoImpl::setShouldSignExtI32Param ( bool  Val)
inline

Set to true iff i32 parameters to library functions should have signext attribute if they correspond to C-level int or unsigned int.

Definition at line 191 of file TargetLibraryInfo.h.

Referenced by initialize().

◆ setShouldSignExtI32Return()

void llvm::TargetLibraryInfoImpl::setShouldSignExtI32Return ( bool  Val)
inline

Set to true iff i32 results from library functions should have signext attribute if they correspond to C-level int or unsigned int.

Definition at line 197 of file TargetLibraryInfo.h.

Referenced by initialize().

◆ setUnavailable()

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

Forces a function to be marked as unavailable.

Definition at line 126 of file TargetLibraryInfo.h.

References F, and Unavailable.

Referenced by initialize().

Friends And Related Function Documentation

◆ TargetLibraryInfo

friend class TargetLibraryInfo
friend

Definition at line 51 of file TargetLibraryInfo.h.


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