23 "No vector functions library"),
25 "Accelerate framework"),
29 #define TLI_DEFINE_STRING
30 #include "llvm/Analysis/TargetLibraryInfo.def"
55 const char *
const *StandardNames) {
59 if (strcmp(StandardNames[
F-1], StandardNames[
F]) >= 0)
78 }
else if (T.
isiOS()) {
364 memset(AvailableArray, -1,
sizeof(AvailableArray));
371 memset(AvailableArray, -1,
sizeof(AvailableArray));
377 : CustomNames(TLI.CustomNames) {
378 memcpy(AvailableArray, TLI.AvailableArray,
sizeof(AvailableArray));
379 VectorDescs = TLI.VectorDescs;
380 ScalarDescs = TLI.ScalarDescs;
384 : CustomNames(std::move(TLI.CustomNames)) {
387 VectorDescs = TLI.VectorDescs;
388 ScalarDescs = TLI.ScalarDescs;
392 CustomNames = TLI.CustomNames;
393 memcpy(AvailableArray, TLI.AvailableArray,
sizeof(AvailableArray));
398 CustomNames = std::move(TLI.CustomNames);
417 const char *
const *Start = &StandardNames[0];
421 if (funcName.
empty())
424 const char *
const *
I = std::lower_bound(
425 Start, End, funcName, [](
const char *LHS,
StringRef RHS) {
426 return std::strncmp(LHS, RHS.
data(), RHS.
size()) < 0;
428 if (I != End && *I == funcName) {
436 memset(AvailableArray, 0,
sizeof(AvailableArray));
458 VectorDescs.insert(VectorDescs.end(), Fns.
begin(), Fns.
end());
461 ScalarDescs.insert(ScalarDescs.end(), Fns.
begin(), Fns.
end());
471 {
"ceilf",
"vceilf", 4},
472 {
"fabsf",
"vfabsf", 4},
473 {
"llvm.fabs.f32",
"vfabsf", 4},
474 {
"floorf",
"vfloorf", 4},
475 {
"sqrtf",
"vsqrtf", 4},
476 {
"llvm.sqrt.f32",
"vsqrtf", 4},
479 {
"expf",
"vexpf", 4},
480 {
"llvm.exp.f32",
"vexpf", 4},
481 {
"expm1f",
"vexpm1f", 4},
482 {
"logf",
"vlogf", 4},
483 {
"llvm.log.f32",
"vlogf", 4},
484 {
"log1pf",
"vlog1pf", 4},
485 {
"log10f",
"vlog10f", 4},
486 {
"llvm.log10.f32",
"vlog10f", 4},
487 {
"logbf",
"vlogbf", 4},
490 {
"sinf",
"vsinf", 4},
491 {
"llvm.sin.f32",
"vsinf", 4},
492 {
"cosf",
"vcosf", 4},
493 {
"llvm.cos.f32",
"vcosf", 4},
494 {
"tanf",
"vtanf", 4},
495 {
"asinf",
"vasinf", 4},
496 {
"acosf",
"vacosf", 4},
497 {
"atanf",
"vatanf", 4},
500 {
"sinhf",
"vsinhf", 4},
501 {
"coshf",
"vcoshf", 4},
502 {
"tanhf",
"vtanhf", 4},
503 {
"asinhf",
"vasinhf", 4},
504 {
"acoshf",
"vacoshf", 4},
505 {
"atanhf",
"vatanhf", 4},
517 if (funcName.
empty())
520 std::vector<VecDesc>::const_iterator
I = std::lower_bound(
521 VectorDescs.begin(), VectorDescs.end(), funcName,
523 return I != VectorDescs.end() &&
StringRef(I->ScalarFnName) == funcName;
531 std::vector<VecDesc>::const_iterator
I = std::lower_bound(
533 while (I != VectorDescs.end() &&
StringRef(I->ScalarFnName) ==
F) {
534 if (I->VectorizationFactor == VF)
535 return I->VectorFnName;
542 unsigned &VF)
const {
547 std::vector<VecDesc>::const_iterator
I = std::lower_bound(
549 if (I == VectorDescs.end() ||
StringRef(I->VectorFnName) !=
F)
551 VF = I->VectorizationFactor;
552 return I->ScalarFnName;
571 std::unique_ptr<TargetLibraryInfoImpl> &Impl =
596 char TargetLibraryAnalysis::PassID;
600 "Target Library Information",
false,
true)
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
ValuesClass< DataType > LLVM_END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc,...)
const_iterator end(StringRef path)
Get end iterator over path.
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS)
static std::string normalize(StringRef Str)
normalize - Turn an arbitrary machine specification into the canonical triple form (or something sens...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
size_t size() const
size - Get the string size.
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
addVectorizableFunctions - Add a set of scalar -> vector mappings, queryable via getVectorizedFunctio...
value_type read(const void *memory)
Read a value of a particular endianness from memory.
A Module instance is used to store all the information related to an LLVM module. ...
static StringRef sanitizeFunctionName(StringRef funcName)
VectorLibrary
List of known vector-functions libraries.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
void disableAllFunctions()
Disables all builtins.
TargetLibraryInfoWrapperPass()
Implementation of the target library information.
const_iterator begin(StringRef path)
Get begin iterator over path.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
isFunctionVectorizable - Return true if the function F has a vector equivalent with vectorization fac...
void setAvailableWithName(LibFunc::Func F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used...
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
bool isOSWindows() const
Tests whether the OS is Windows.
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
getVectorizedFunction - Return the name of the equivalent of F, vectorized with factor VF...
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
TargetLibraryInfo run(Module &M)
unsigned isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
void setUnavailable(LibFunc::Func F)
Forces a function to be marked as unavailable.
bool isOSLinux() const
Tests whether the OS is Linux.
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
Searches for a particular function name.
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
bool isiOS() const
Is this an iOS triple.
initializer< Ty > init(const Ty &Val)
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)
const char * VectorFnName
static cl::opt< TargetLibraryInfoImpl::VectorLibrary > ClVectorLibrary("vector-library", cl::Hidden, cl::desc("Vector functions library"), cl::init(TargetLibraryInfoImpl::NoLibrary), cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary,"none","No vector functions library"), clEnumValN(TargetLibraryInfoImpl::Accelerate,"Accelerate","Accelerate framework"), clEnumValEnd))
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const char *const *StandardNames)
initialize - Initialize the set of available library functions based on the specified target triple...
Triple - Helper class for working with autoconf configuration names.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X or iOS).
static bool hasSinCosPiStret(const Triple &T)
ImmutablePass class - This class is used to provide information that does not need to be run...
VecDesc - Describes a possible vectorization of a function.
Provides information about what library functions are available for the current target.
StringRef getScalarizedFunction(StringRef F, unsigned &VF) const
getScalarizedFunction - Return the name of the equivalent of F, scalarized.
TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib)
Calls addVectorizableFunctions with a known preset of functions for the given vector library...
const char * ScalarFnName
void write(void *memory, value_type value)
Write a value to memory with a particular endianness.
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isOSVersionLT - Helper function for doing comparisons against version numbers included in the target ...
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static StringRef getRealLinkageName(StringRef Name)
If special LLVM prefix that is used to inform the asm printer to not emit usual symbol prefix before ...
static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S)
Module * getParent()
Get the module that this global value is contained inside of...
std::error_code access(const Twine &Path, AccessMode Mode)
Can the file be accessed?
StringRef - Represent a constant reference to a string, i.e.
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)
bool empty() const
empty - Check if the string is empty.