23 "No vector functions library"),
25 "Accelerate framework"),
27 "Intel SVML library")));
30 #define TLI_DEFINE_STRING
31 #include "llvm/Analysis/TargetLibraryInfo.def"
62 "TargetLibraryInfoImpl function names must be sorted");
64 bool ShouldExtI32Param =
false, ShouldExtI32Return =
false,
65 ShouldSignExtI32Param =
false;
70 ShouldExtI32Param =
true;
71 ShouldExtI32Return =
true;
77 ShouldSignExtI32Param =
true;
111 }
else if (T.
isiOS()) {
440 memset(AvailableArray, -1,
sizeof(AvailableArray));
447 memset(AvailableArray, -1,
sizeof(AvailableArray));
453 : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
454 ShouldExtI32Return(TLI.ShouldExtI32Return),
455 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
456 memcpy(AvailableArray, TLI.AvailableArray,
sizeof(AvailableArray));
457 VectorDescs = TLI.VectorDescs;
458 ScalarDescs = TLI.ScalarDescs;
462 : CustomNames(std::move(TLI.CustomNames)),
463 ShouldExtI32Param(TLI.ShouldExtI32Param),
464 ShouldExtI32Return(TLI.ShouldExtI32Return),
465 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
468 VectorDescs = TLI.VectorDescs;
469 ScalarDescs = TLI.ScalarDescs;
473 CustomNames = TLI.CustomNames;
474 ShouldExtI32Param = TLI.ShouldExtI32Param;
475 ShouldExtI32Return = TLI.ShouldExtI32Return;
476 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
477 memcpy(AvailableArray, TLI.AvailableArray,
sizeof(AvailableArray));
482 CustomNames = std::move(TLI.CustomNames);
483 ShouldExtI32Param = TLI.ShouldExtI32Param;
484 ShouldExtI32Return = TLI.ShouldExtI32Return;
485 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
504 StringRef const *Start = &StandardNames[0];
508 if (funcName.
empty())
515 if (I != End && *I == funcName) {
522 bool TargetLibraryInfoImpl::isValidProtoForLibFunc(
const FunctionType &FTy,
528 auto IsSizeTTy = [SizeTTy](
Type *Ty) {
529 return SizeTTy ? Ty == SizeTTy : Ty->
isIntegerTy();
534 case LibFunc::strlen:
538 case LibFunc::strchr:
539 case LibFunc::strrchr:
544 case LibFunc::strtol:
545 case LibFunc::strtod:
546 case LibFunc::strtof:
547 case LibFunc::strtoul:
548 case LibFunc::strtoll:
549 case LibFunc::strtold:
550 case LibFunc::strtoull:
551 return ((NumParams == 2 || NumParams == 3) &&
554 case LibFunc::strcat:
559 case LibFunc::strncat:
565 case LibFunc::strcpy_chk:
566 case LibFunc::stpcpy_chk:
571 case LibFunc::strcpy:
572 case LibFunc::stpcpy:
577 case LibFunc::strncpy_chk:
578 case LibFunc::stpncpy_chk:
583 case LibFunc::strncpy:
584 case LibFunc::stpncpy:
590 case LibFunc::strxfrm:
599 case LibFunc::strncmp:
605 case LibFunc::strspn:
606 case LibFunc::strcspn:
611 case LibFunc::strcoll:
612 case LibFunc::strcasecmp:
613 case LibFunc::strncasecmp:
617 case LibFunc::strstr:
622 case LibFunc::strpbrk:
627 case LibFunc::strtok:
628 case LibFunc::strtok_r:
631 case LibFunc::setbuf:
632 case LibFunc::setvbuf:
634 case LibFunc::strdup:
635 case LibFunc::strndup:
638 case LibFunc::sscanf:
640 case LibFunc::statvfs:
641 case LibFunc::sprintf:
644 case LibFunc::snprintf:
647 case LibFunc::setitimer:
650 case LibFunc::system:
652 case LibFunc::malloc:
654 case LibFunc::memcmp:
659 case LibFunc::memchr:
660 case LibFunc::memrchr:
670 case LibFunc::memcpy_chk:
671 case LibFunc::memmove_chk:
676 case LibFunc::memcpy:
677 case LibFunc::mempcpy:
678 case LibFunc::memmove:
684 case LibFunc::memset_chk:
689 case LibFunc::memset:
695 case LibFunc::memccpy:
697 case LibFunc::memalign:
699 case LibFunc::realloc:
704 case LibFunc::rewind:
707 case LibFunc::realpath:
712 case LibFunc::readlink:
723 case LibFunc::calloc:
730 case LibFunc::ferror:
731 case LibFunc::getenv:
732 case LibFunc::getpwnam:
733 case LibFunc::pclose:
734 case LibFunc::perror:
735 case LibFunc::printf:
738 case LibFunc::under_IO_getc:
739 case LibFunc::unlink:
740 case LibFunc::unsetenv:
745 case LibFunc::clearerr:
746 case LibFunc::closedir:
747 case LibFunc::ctermid:
748 case LibFunc::fclose:
750 case LibFunc::fflush:
752 case LibFunc::fileno:
753 case LibFunc::flockfile:
756 case LibFunc::fseeko64:
757 case LibFunc::fseeko:
758 case LibFunc::fsetpos:
760 case LibFunc::ftello64:
761 case LibFunc::ftello:
762 case LibFunc::ftrylockfile:
763 case LibFunc::funlockfile:
765 case LibFunc::getc_unlocked:
766 case LibFunc::getlogin_r:
768 case LibFunc::mktime:
778 case LibFunc::fdopen:
784 case LibFunc::frexpf:
785 case LibFunc::frexpl:
786 case LibFunc::fstatvfs:
794 case LibFunc::fwrite:
803 case LibFunc::fscanf:
804 case LibFunc::fprintf:
807 case LibFunc::fgetpos:
811 case LibFunc::getchar:
812 case LibFunc::getitimer:
814 case LibFunc::ungetc:
817 case LibFunc::utimes:
823 case LibFunc::pwrite:
829 case LibFunc::vscanf:
831 case LibFunc::vsscanf:
834 case LibFunc::vfscanf:
837 case LibFunc::valloc:
839 case LibFunc::vprintf:
841 case LibFunc::vfprintf:
842 case LibFunc::vsprintf:
845 case LibFunc::vsnprintf:
850 case LibFunc::opendir:
853 case LibFunc::tmpfile:
862 case LibFunc::lchown:
866 case LibFunc::dunder_strdup:
867 case LibFunc::dunder_strndup:
870 case LibFunc::dunder_strtok_r:
872 case LibFunc::under_IO_putc:
874 case LibFunc::dunder_isoc99_scanf:
876 case LibFunc::stat64:
877 case LibFunc::lstat64:
878 case LibFunc::statvfs64:
881 case LibFunc::dunder_isoc99_sscanf:
884 case LibFunc::fopen64:
888 case LibFunc::tmpfile64:
890 case LibFunc::fstat64:
891 case LibFunc::fstatvfs64:
893 case LibFunc::open64:
895 case LibFunc::gettimeofday:
903 case LibFunc::msvc_new_int:
904 case LibFunc::msvc_new_longlong:
905 case LibFunc::msvc_new_array_int:
906 case LibFunc::msvc_new_array_longlong:
907 return (NumParams == 1);
909 case LibFunc::memset_pattern16:
910 return (!FTy.
isVarArg() && NumParams == 3 &&
916 case LibFunc::nvvm_reflect:
917 return (NumParams == 1 && isa<PointerType>(FTy.
getParamType(0)));
938 case LibFunc::log10f:
939 case LibFunc::log10l:
947 case LibFunc::floorf:
948 case LibFunc::floorl:
953 case LibFunc::truncf:
954 case LibFunc::truncl:
958 case LibFunc::nearbyint:
959 case LibFunc::nearbyintf:
960 case LibFunc::nearbyintl:
962 case LibFunc::roundf:
963 case LibFunc::roundl:
976 case LibFunc::copysign:
977 case LibFunc::copysignf:
978 case LibFunc::copysignl:
995 case LibFunc::isdigit:
996 case LibFunc::isascii:
997 case LibFunc::toascii:
1003 case LibFunc::llabs:
1007 case LibFunc::cxa_atexit:
1013 case LibFunc::sinpi:
1014 case LibFunc::cospi:
1018 case LibFunc::sinpif:
1019 case LibFunc::cospif:
1039 memset(AvailableArray, 0,
sizeof(AvailableArray));
1059 VectorDescs.insert(VectorDescs.end(), Fns.
begin(), Fns.
end());
1062 ScalarDescs.insert(ScalarDescs.end(), Fns.
begin(), Fns.
end());
1072 {
"ceilf",
"vceilf", 4},
1073 {
"fabsf",
"vfabsf", 4},
1074 {
"llvm.fabs.f32",
"vfabsf", 4},
1075 {
"floorf",
"vfloorf", 4},
1076 {
"sqrtf",
"vsqrtf", 4},
1077 {
"llvm.sqrt.f32",
"vsqrtf", 4},
1080 {
"expf",
"vexpf", 4},
1081 {
"llvm.exp.f32",
"vexpf", 4},
1082 {
"expm1f",
"vexpm1f", 4},
1083 {
"logf",
"vlogf", 4},
1084 {
"llvm.log.f32",
"vlogf", 4},
1085 {
"log1pf",
"vlog1pf", 4},
1086 {
"log10f",
"vlog10f", 4},
1087 {
"llvm.log10.f32",
"vlog10f", 4},
1088 {
"logbf",
"vlogbf", 4},
1091 {
"sinf",
"vsinf", 4},
1092 {
"llvm.sin.f32",
"vsinf", 4},
1093 {
"cosf",
"vcosf", 4},
1094 {
"llvm.cos.f32",
"vcosf", 4},
1095 {
"tanf",
"vtanf", 4},
1096 {
"asinf",
"vasinf", 4},
1097 {
"acosf",
"vacosf", 4},
1098 {
"atanf",
"vatanf", 4},
1101 {
"sinhf",
"vsinhf", 4},
1102 {
"coshf",
"vcoshf", 4},
1103 {
"tanhf",
"vtanhf", 4},
1104 {
"asinhf",
"vasinhf", 4},
1105 {
"acoshf",
"vacoshf", 4},
1106 {
"atanhf",
"vatanhf", 4},
1113 {
"sin",
"__svml_sin2", 2},
1114 {
"sin",
"__svml_sin4", 4},
1115 {
"sin",
"__svml_sin8", 8},
1117 {
"sinf",
"__svml_sinf4", 4},
1118 {
"sinf",
"__svml_sinf8", 8},
1119 {
"sinf",
"__svml_sinf16", 16},
1121 {
"cos",
"__svml_cos2", 2},
1122 {
"cos",
"__svml_cos4", 4},
1123 {
"cos",
"__svml_cos8", 8},
1125 {
"cosf",
"__svml_cosf4", 4},
1126 {
"cosf",
"__svml_cosf8", 8},
1127 {
"cosf",
"__svml_cosf16", 16},
1129 {
"pow",
"__svml_pow2", 2},
1130 {
"pow",
"__svml_pow4", 4},
1131 {
"pow",
"__svml_pow8", 8},
1133 {
"powf",
"__svml_powf4", 4},
1134 {
"powf",
"__svml_powf8", 8},
1135 {
"powf",
"__svml_powf16", 16},
1137 {
"llvm.pow.f64",
"__svml_pow2", 2},
1138 {
"llvm.pow.f64",
"__svml_pow4", 4},
1139 {
"llvm.pow.f64",
"__svml_pow8", 8},
1141 {
"llvm.pow.f32",
"__svml_powf4", 4},
1142 {
"llvm.pow.f32",
"__svml_powf8", 8},
1143 {
"llvm.pow.f32",
"__svml_powf16", 16},
1145 {
"exp",
"__svml_exp2", 2},
1146 {
"exp",
"__svml_exp4", 4},
1147 {
"exp",
"__svml_exp8", 8},
1149 {
"expf",
"__svml_expf4", 4},
1150 {
"expf",
"__svml_expf8", 8},
1151 {
"expf",
"__svml_expf16", 16},
1153 {
"llvm.exp.f64",
"__svml_exp2", 2},
1154 {
"llvm.exp.f64",
"__svml_exp4", 4},
1155 {
"llvm.exp.f64",
"__svml_exp8", 8},
1157 {
"llvm.exp.f32",
"__svml_expf4", 4},
1158 {
"llvm.exp.f32",
"__svml_expf8", 8},
1159 {
"llvm.exp.f32",
"__svml_expf16", 16},
1161 {
"log",
"__svml_log2", 2},
1162 {
"log",
"__svml_log4", 4},
1163 {
"log",
"__svml_log8", 8},
1165 {
"logf",
"__svml_logf4", 4},
1166 {
"logf",
"__svml_logf8", 8},
1167 {
"logf",
"__svml_logf16", 16},
1169 {
"llvm.log.f64",
"__svml_log2", 2},
1170 {
"llvm.log.f64",
"__svml_log4", 4},
1171 {
"llvm.log.f64",
"__svml_log8", 8},
1173 {
"llvm.log.f32",
"__svml_logf4", 4},
1174 {
"llvm.log.f32",
"__svml_logf8", 8},
1175 {
"llvm.log.f32",
"__svml_logf16", 16},
1187 if (funcName.
empty())
1190 std::vector<VecDesc>::const_iterator
I = std::lower_bound(
1191 VectorDescs.begin(), VectorDescs.end(), funcName,
1193 return I != VectorDescs.end() &&
StringRef(I->ScalarFnName) == funcName;
1197 unsigned VF)
const {
1201 std::vector<VecDesc>::const_iterator
I = std::lower_bound(
1203 while (I != VectorDescs.end() &&
StringRef(I->ScalarFnName) ==
F) {
1204 if (I->VectorizationFactor == VF)
1205 return I->VectorFnName;
1212 unsigned &VF)
const {
1217 std::vector<VecDesc>::const_iterator
I = std::lower_bound(
1219 if (I == VectorDescs.end() ||
StringRef(I->VectorFnName) !=
F)
1221 VF = I->VectorizationFactor;
1222 return I->ScalarFnName;
1243 std::unique_ptr<TargetLibraryInfoImpl> &Impl =
1272 "Target Library Information",
false,
true)
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
A parsed version of the target data layout string in and methods for querying it. ...
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...
void setShouldExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...
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. ...
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static StringRef sanitizeFunctionName(StringRef funcName)
VectorLibrary
List of known vector-functions libraries.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
static uint64_t round(uint64_t Acc, uint64_t Input)
void disableAllFunctions()
Disables all builtins.
TargetLibraryInfoWrapperPass()
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Implementation of the target library information.
const_iterator begin(StringRef path)
Get begin iterator over path.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
void setAvailableWithName(LibFunc::Func F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with strcmp
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.
StringRef getName() const
Return a constant reference to the value's name.
bool isOSCygMing() const
Tests for either Cygwin or MinGW OS.
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
Return the name of the equivalent of F, vectorized with factor VF.
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
void setUnavailable(LibFunc::Func F)
Forces a function to be marked as unavailable.
bool isOSLinux() const
Tests whether the OS is Linux.
Class to represent function types.
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
Searches for a particular function name.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
IEEEFloat frexp(const IEEEFloat &Val, int &Exp, IEEEFloat::roundingMode RM)
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
TargetLibraryInfo run(Module &M, ModuleAnalysisManager &)
ValuesClass values(OptsTy...Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
void setAvailable(LibFunc::Func F)
Forces a function to be marked as available.
bool isiOS() const
Is this an iOS triple.
Type * getParamType(unsigned i) const
Parameter type accessors.
initializer< Ty > init(const Ty &Val)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
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"), clEnumValN(TargetLibraryInfoImpl::SVML,"SVML","Intel SVML library")))
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)
bool isWatchOS() const
Is this an Apple watchOS triple.
static const unsigned End
bool isPointerTy() const
True if this is an instance of PointerType.
static void write(bool isBE, void *P, T V)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
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, iOS, or watchOS).
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
static bool hasSinCosPiStret(const Triple &T)
ImmutablePass class - This class is used to provide information that does not need to be run...
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
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...
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
initialize - Initialize the set of available library functions based on the specified target triple...
bool isIntegerTy() const
True if this is an instance of IntegerType.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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)
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
static StringRef getRealLinkageName(StringRef Name)
If special LLVM prefix that is used to inform the asm printer to not emit usual symbol prefix before ...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S)
static void rename(GlobalValue *GV)
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
A special type used by analysis passes to provide an address that identifies that particular analysis...
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)