1//===-- TargetLibraryInfo.cpp - Runtime library information ----------------==// 
  3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 
  4// See https://llvm.org/LICENSE.txt for license information. 
  5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 
  7//===----------------------------------------------------------------------===// 
  9// This file implements the TargetLibraryInfo class. 
  11//===----------------------------------------------------------------------===// 
  27 "No vector functions library"),
 
  29 "Accelerate framework"),
 
  31 "Darwin_libsystem_m", 
"Darwin libsystem_m"),
 
  33 "GLIBC Vector Math library"),
 
  35 "IBM MASS vector library"),
 
  37 "Intel SVML library"),
 
  39 "SIMD Library for Evaluating Elementary Functions"),
 
  41 "Arm Performance Libraries"),
 
  43 "AMD vector math library")));
 
  47#define TLI_DEFINE_STRING 
  48#include "llvm/Analysis/TargetLibraryInfo.def" 
  52 assert(!VectorFnName.empty() && 
"Vector function name must not be empty.");
 
  55 Out << VABIPrefix << 
"_" << ScalarFnName << 
"(" << VectorFnName << 
")";
 
  56 return std::string(Out.
str());
 
 
  59// Recognized types of library function arguments and return types. 
  62  Bool, 
// 8 bits on all targets 
  67  Long, 
// Either 32 or 64 bits. 
  70  LLong, 
// 64 bits on all targets. 
  75  LDbl, 
// Any floating type (TODO: tighten this up). 
  77  Ptr, 
// Any pointer type. 
  80  Same, 
// Same argument type as the previous one. 
 
  87#include "llvm/Analysis/TargetLibraryInfo.def" 
 
  91 "Missing library function signatures");
 
  94 // Only Darwin variants have _stret versions of combined trig functions. 
  98 // The ABI is rather complicated on x86, so don't do anything special there. 
  102 if (
T.isMacOSX() && 
T.isMacOSXVersionLT(10, 9))
 
  105 if (
T.isiOS() && 
T.isOSVersionLT(7, 0))
 
 
  112 // Posix removed support from bcmp() in 2001, but the glibc and several 
  113 // implementations of the libc still have it. 
  115 return TT.isGNUEnvironment() || TT.isMusl();
 
  116 // Both NetBSD and OpenBSD are planning to remove the function. Windows does 
  118 return TT.isOSFreeBSD() || TT.isOSSolaris();
 
 
  132 // The iOS ABI diverges from the standard in some cases, so for now don't 
  133 // try to simplify those calls. 
  137 if (!FuncTy->getReturnType()->isPointerTy() &&
 
  138 !FuncTy->getReturnType()->isIntegerTy() &&
 
  139 !FuncTy->getReturnType()->isVoidTy())
 
  142 for (
auto *Param : FuncTy->params()) {
 
  143 if (!Param->isPointerTy() && !Param->isIntegerTy())
 
 
  159 return ::isCallingConvCCompatible(
F->getCallingConv(),
 
  160 F->getParent()->getTargetTriple(),
 
  161 F->getFunctionType());
 
 
  165 bool ShouldExtI32Param, ShouldExtI32Return;
 
  166 bool ShouldSignExtI32Param, ShouldSignExtI32Return;
 
  168 ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param,
 
  169 ShouldSignExtI32Return, 
T);
 
  175 // Let's assume by default that the size of int is 32 bits, unless the target 
  176 // is a 16-bit architecture because then it most likely is 16 bits. If that 
  177 // isn't true for a target those defaults should be overridden below. 
 
  181/// Initialize the set of available library functions based on the specified 
  182/// target triple. This should be carefully written so that a missing target 
  183/// triple gets a sane set of defaults. 
  186 // Set IO unlocked variants as unavailable 
  187 // Set them as available per system below 
  199 // There is really no runtime library on AMDGPU, apart from 
  200 // __kmpc_alloc/free_shared. 
  208 // DXIL does not support libcalls, and disabling them here prevents a number 
  209 // of passes from introducing libcalls into DXIL which would otherwise 
  210 // complicate lowering/legalization 
  216 // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and 
  217 // later. All versions of watchOS support it. 
  219 // available IO unlocked variants on Mac OS X 
  226 if (
T.isMacOSXVersionLT(10, 5)) {
 
  231 } 
else if (
T.isiOS()) {
 
  232 if (
T.isOSVersionLT(3, 0)) {
 
  237 } 
else if (!
T.isWatchOS()) {
 
  256 !
T.isMacOSXVersionLT(10, 7)) {
 
  257 // x86-32 OSX has a scheme where fwrite and fputs (and some other functions 
  258 // we don't care about) have two versions; on recent OSX, the one we want 
  259 // has a $UNIX2003 suffix. The two implementations are identical except 
  260 // for the return value in some edge cases. However, we don't want to 
  261 // generate code that depends on the old symbols. 
  266 // iprintf and friends are only available on XCore, TCE, and Emscripten. 
  274 // __small_printf and friends are only available on Emscripten. 
  281 if (
T.isOSWindows() && !
T.isOSCygMing()) {
 
  282 // XXX: The earliest documentation available at the moment is for VS2015/VC19: 
  283 // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015 
  284 // XXX: In order to use an MSVCRT older than VC19, 
  285 // the specific library version must be explicit in the target triple, 
  286 // e.g., x86_64-pc-windows-msvc18. 
  287 bool hasPartialC99 = 
true;
 
  288 if (
T.isKnownWindowsMSVCEnvironment()) {
 
  290 hasPartialC99 = (Version.getMajor() == 0 || Version.getMajor() >= 19);
 
  293 // Latest targets support C89 math functions, in part. 
  296 bool hasPartialFloat = (isARM ||
 
  299 // Win32 does not support float C89 math functions, in general. 
  300 if (!hasPartialFloat) {
 
  330 // Win32 does not support long double C89 math functions. 
  358 // Win32 does not fully support C99 math functions. 
  359 if (!hasPartialC99) {
 
  405 // Win32 does not support long double C99 math functions. 
  427 // Win32 does not support these functions, but 
  428 // they are generally available on POSIX-compliant systems. 
  454 if (
T.isOSWindows() && !
T.isWindowsCygwinEnvironment()) {
 
  455 // These functions aren't available in either MSVC or MinGW environments. 
  489 // MinGW does have ldexpf, but it is a plain wrapper over regular ldexp. 
  490 // Therefore it's not beneficial to transform code to use it, i.e. 
  491 // just pretend that the function is not available. 
  495 // Pick just one set of new/delete variants. 
  496 if (
T.isOSMSVCRT()) {
 
  497 // MSVC, doesn't have the Itanium new/delete. 
  534 TLI.
setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t);
 
  537 TLI.
setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t);
 
  543 // Not MSVC, assume it's Itanium. 
  568 // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0 
  569 // and their names are __exp10 and __exp10f. exp10l is not available on 
  572 if (
T.isMacOSXVersionLT(10, 9)) {
 
  585 if (!
T.isWatchOS() &&
 
  586 (
T.isOSVersionLT(7, 0) || (
T.isOSVersionLT(9, 0) && 
T.isX86()))) {
 
  595 // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely 
  596 // buggy prior to glibc version 2.18. Until this version is widely deployed 
  597 // or we have a reasonable detection strategy, we cannot use exp10 reliably 
  600 // Fall through to disable all of them. 
  608 // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and 
  610 // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html 
  611 // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c 
  612 // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html 
  627 // ffsll is available on at least FreeBSD and Linux (GLIBC): 
  628 // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c 
  629 // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html 
  644 // The following functions are available on at least FreeBSD: 
  645 // http://svn.freebsd.org/base/head/lib/libc/string/fls.c 
  646 // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c 
  647 // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c 
  648 if (!
T.isOSFreeBSD()) {
 
  654 // The following functions are only available on GNU/Linux (using glibc). 
  655 // Linux variants without glibc (eg: bionic, musl) may have some subset. 
  656 if (!
T.isOSLinux() || !
T.isGNUEnvironment()) {
 
  663 // But, Android and musl have memalign. 
  664 if (!
T.isAndroid() && !
T.isMusl())
 
  677 // Relaxed math functions are included in math-finite.h on Linux (GLIBC). 
  678 // Note that math-finite.h is no longer supported by top-of-tree GLIBC, 
  679 // so we keep these functions around just so that they're recognized by 
  680 // the ConstantFolder. 
  728 if ((
T.isOSLinux() && 
T.isGNUEnvironment()) ||
 
  729 (
T.isAndroid() && !
T.isAndroidVersionLT(28))) {
 
  730 // available IO unlocked variants on GNU/Linux and Android P or later 
  744 // PS4/PS5 do have memalign. 
  747 // PS4/PS5 do not have new/delete with "unsigned int" size parameter; 
  748 // they only have the "unsigned long" versions. 
  762 // None of the *_chk functions. 
  782 // Various Posix system functions. 
  833 // Miscellaneous other functions not provided. 
  873 if (
T.isOSFreeBSD()) {
 
  901 // As currently implemented in clang, NVPTX code has no standard library to 
  902 // speak of. Headers provide a standard-ish library implementation, but many 
  903 // of the signatures are wrong -- for example, many libm functions are not 
  906 // libdevice, an IR library provided by nvidia, is linked in by the front-end, 
  907 // but only used functions are provided to llvm. Moreover, most of the 
  908 // functions in libdevice don't map precisely to standard library functions. 
  910 // FIXME: Having no standard library prevents e.g. many fastmath 
  911 // optimizations, so this situation should be fixed. 
  918 // TODO: We could enable the following two according to [0] but we haven't 
  919 // done an evaluation wrt. the performance implications. 
  921 // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#dynamic-global-memory-allocation-and-operations 
  923 // TLI.setAvailable(llvm::LibFunc_memcpy); 
  924 // TLI.setAvailable(llvm::LibFunc_memset); 
  932 // These vec_malloc/free routines are only available on AIX. 
 
  946/// Initialize the set of available library functions based on the specified 
  947/// target triple. This should be carefully written so that a missing target 
  948/// triple gets a sane set of defaults. 
  956 // Default to everything being available. 
  957 memset(AvailableArray, -1, 
sizeof(AvailableArray));
 
 
  963 : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
 
  964 ShouldExtI32Return(TLI.ShouldExtI32Return),
 
  965 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
 
  966 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
 
  967 SizeOfInt(TLI.SizeOfInt) {
 
  968 memcpy(AvailableArray, TLI.AvailableArray, 
sizeof(AvailableArray));
 
  969 VectorDescs = TLI.VectorDescs;
 
  970 ScalarDescs = TLI.ScalarDescs;
 
 
  974 : CustomNames(
std::
move(TLI.CustomNames)),
 
  975 ShouldExtI32Param(TLI.ShouldExtI32Param),
 
  976 ShouldExtI32Return(TLI.ShouldExtI32Return),
 
  977 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
 
  978 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
 
  979 SizeOfInt(TLI.SizeOfInt) {
 
  980 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
 
  982 VectorDescs = TLI.VectorDescs;
 
  983 ScalarDescs = TLI.ScalarDescs;
 
 
  987 CustomNames = TLI.CustomNames;
 
  988 ShouldExtI32Param = TLI.ShouldExtI32Param;
 
  989 ShouldExtI32Return = TLI.ShouldExtI32Return;
 
  990 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
 
  991 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
 
  992 SizeOfInt = TLI.SizeOfInt;
 
  993 memcpy(AvailableArray, TLI.AvailableArray, 
sizeof(AvailableArray));
 
 
  998 CustomNames = std::move(TLI.CustomNames);
 
  999 ShouldExtI32Param = TLI.ShouldExtI32Param;
 
  1000 ShouldExtI32Return = TLI.ShouldExtI32Return;
 
  1001 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
 
  1002 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
 
  1003 SizeOfInt = TLI.SizeOfInt;
 
  1004 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
 
 
  1010 // Filter out empty names and names containing null bytes, those can't be in 
  1015 // Check for 01円 prefix that is used to mangle __asm declarations and 
  1016 // strip it if present. 
 
  1025 for (
const auto &Func : StandardNames)
 
  1026 Indices[Func] = 
static_cast<LibFunc >(Idx++);
 
 
  1032 if (funcName.
empty())
 
  1038 if (
auto Loc = Indices.
find(funcName); 
Loc != Indices.
end()) {
 
 
  1045// Return true if ArgTy matches Ty. 
  1048 unsigned SizeTBits) {
 
  1051 return Ty->isVoidTy();
 
  1053 return Ty->isIntegerTy(8);
 
  1055 return Ty->isIntegerTy(16);
 
  1057 return Ty->isIntegerTy(32);
 
  1059 return Ty->isIntegerTy(IntBits);
 
  1061 return Ty->isIntegerTy() && Ty->getPrimitiveSizeInBits() >= IntBits;
 
  1063 return Ty->isIntegerTy();
 
  1065 // TODO: Figure out and use long size. 
  1066 return Ty->isIntegerTy() && Ty->getPrimitiveSizeInBits() >= IntBits;
 
  1068 return Ty->isIntegerTy(64);
 
  1070 return Ty->isIntegerTy(64);
 
  1073 return Ty->isIntegerTy(SizeTBits);
 
  1075 return Ty->isFloatTy();
 
  1077 return Ty->isDoubleTy();
 
  1078 // TODO: Tighten this up. 
  1080 return Ty->isFloatingPointTy();
 
  1082 return Ty->isFloatingPointTy();
 
  1084 return Ty->isPointerTy();
 
  1086 return Ty->isStructTy();
 
 
  1096 int SizeTSizeBits) {
 
  1098 case LibFunc_size_returning_new: {
 
  1099 if (FTy.getNumParams() != 1 ||
 
  1100 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits)) {
 
  1104 case LibFunc_size_returning_new_hot_cold: {
 
  1105 if (FTy.getNumParams() != 2 ||
 
  1106 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
 
  1107 !FTy.getParamType(1)->isIntegerTy(8)) {
 
  1111 case LibFunc_size_returning_new_aligned: {
 
  1112 if (FTy.getNumParams() != 2 ||
 
  1113 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
 
  1114 !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits)) {
 
  1118 case LibFunc_size_returning_new_aligned_hot_cold:
 
  1119 if (FTy.getNumParams() != 3 ||
 
  1120 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
 
  1121 !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits) ||
 
  1122 !FTy.getParamType(2)->isIntegerTy(8)) {
 
  1130 auto &Context = M.getContext();
 
  1134 return FTy.getReturnType() == SizedPtrTy;
 
 
  1137bool TargetLibraryInfoImpl::isValidProtoForLibFunc(
const FunctionType &FTy,
 
  1140 unsigned NumParams = FTy.getNumParams();
 
  1143 // Special handling for <complex.h> functions: 
  1146 case LibFunc_cabsl: {
 
  1147 Type *RetTy = FTy.getReturnType();
 
  1151 Type *ParamTy = FTy.getParamType(0);
 
  1152 // NOTE: These prototypes are target specific and currently support 
  1153 // "complex" passed as an array or discrete real & imaginary parameters. 
  1154 // Add other calling conventions to enable libcall optimizations. 
  1158 else if (NumParams == 2)
 
  1159 return ParamTy == RetTy && FTy.getParamType(1) == RetTy;
 
  1163 // Special handling for the sincospi functions that return either 
  1164 // a struct or vector: 
  1165 case LibFunc_sincospi_stret:
 
  1166 case LibFunc_sincospif_stret: {
 
  1170 Type *RetTy = FTy.getReturnType();
 
  1171 Type *ParamTy = FTy.getParamType(0);
 
  1173 if (Ty->getNumElements() != 2)
 
  1175 return (Ty->getElementType(0) == ParamTy &&
 
  1176 Ty->getElementType(1) == ParamTy);
 
  1180 if (Ty->getNumElements() != 2)
 
  1182 return Ty->getElementType() == ParamTy;
 
  1187 // Special handling of __size_returning_new functions that return a struct 
  1188 // of type {void*, size_t}. 
  1189 case LibFunc_size_returning_new:
 
  1190 case LibFunc_size_returning_new_hot_cold:
 
  1191 case LibFunc_size_returning_new_aligned:
 
  1192 case LibFunc_size_returning_new_aligned_hot_cold:
 
  1202 // Iterate over the type ids in the function prototype, matching each 
  1203 // against the function's type FTy, starting with its return type. 
  1204 // Return true if both match in number and kind, inclduing the ellipsis. 
  1205 Type *Ty = FTy.getReturnType(), *LastTy = Ty;
 
  1207 for (
auto TyID : ProtoTypes) {
 
  1208 if (Idx && TyID == 
Void)
 
  1209 // Except in the first position where it designates the function's 
  1210 // return type Void ends the argument list. 
  1213 if (TyID == 
Ellip) {
 
  1214 // The ellipsis ends the protoype list but is not a part of FTy's 
  1215 // argument list. Except when it's last it must be followed by 
  1217 assert(Idx == ProtoTypes.size() - 1 || ProtoTypes[Idx + 1] == 
Void);
 
  1218 return FTy.isFunctionVarArg();
 
  1222 assert(Idx != 0 && 
"Type ID 'Same' must not be first!");
 
  1226 if (!Ty || !
matchType(TyID, Ty, IntBits, SizeTBits))
 
  1231 if (Idx == NumParams) {
 
  1232 // There's at least one and at most two more type ids than there are 
  1233 // arguments in FTy's argument list. 
  1239 Ty = FTy.getParamType(Idx++);
 
  1242 // Return success only if all entries on both lists have been processed 
  1243 // and the function is not a variadic one. 
  1244 return Idx == NumParams + 1 && !FTy.isFunctionVarArg();
 
  1249 // Intrinsics don't overlap w/libcalls; if our module has a large number of 
  1250 // intrinsics, this ends up being an interesting compile time win since we 
  1251 // avoid string normalization and comparison. 
  1255 assert(M && 
"Expecting FDecl to be connected to a Module.");
 
  1257 if (FDecl.LibFuncCache == Function::UnknownLibFunc)
 
  1264 F = FDecl.LibFuncCache;
 
 
  1270 // Must be a frem instruction with float or double arguments. 
  1271 if (Opcode != Instruction::FRem || (!Ty->isDoubleTy() && !Ty->isFloatTy()))
 
  1274 F = Ty->isDoubleTy() ? LibFunc_fmod : LibFunc_fmodf;
 
 
  1279 memset(AvailableArray, 0, 
sizeof(AvailableArray));
 
 
  1283 return LHS.getScalarFnName() < 
RHS.getScalarFnName();
 
 
  1287 return LHS.getVectorFnName() < 
RHS.getVectorFnName();
 
 
  1291 return LHS.getScalarFnName() < S;
 
 
  1303#define TLI_DEFINE_ACCELERATE_VECFUNCS 
  1304#include "llvm/Analysis/VecFuncs.def" 
  1305#undef TLI_DEFINE_ACCELERATE_VECFUNCS 
 
  1309#define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS 
  1310#include "llvm/Analysis/VecFuncs.def" 
  1311#undef TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS 
 
  1315#define TLI_DEFINE_LIBMVEC_X86_VECFUNCS 
  1316#include "llvm/Analysis/VecFuncs.def" 
  1317#undef TLI_DEFINE_LIBMVEC_X86_VECFUNCS 
 
  1321#define TLI_DEFINE_LIBMVEC_AARCH64_VECFUNCS 
  1322#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX, CC) \ 
  1323 {SCAL, VEC, VF, MASK, VABI_PREFIX, CC}, 
  1324#include "llvm/Analysis/VecFuncs.def" 
  1325#undef TLI_DEFINE_LIBMVEC_AARCH64_VECFUNCS 
 
  1329#define TLI_DEFINE_MASSV_VECFUNCS 
  1330#include "llvm/Analysis/VecFuncs.def" 
  1331#undef TLI_DEFINE_MASSV_VECFUNCS 
 
  1335#define TLI_DEFINE_SVML_VECFUNCS 
  1336#include "llvm/Analysis/VecFuncs.def" 
  1337#undef TLI_DEFINE_SVML_VECFUNCS 
 
  1341#define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS 
  1342#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \ 
  1343 {SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX, /* CC = */ std::nullopt}, 
  1344#include "llvm/Analysis/VecFuncs.def" 
  1345#undef TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS 
 
  1348#define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS 
  1349#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \ 
  1350 {SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX, /* CC = */ std::nullopt}, 
  1351#include "llvm/Analysis/VecFuncs.def" 
  1352#undef TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS 
 
  1355#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS 
  1356#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \ 
  1357 {SCAL, VEC, VF, MASK, VABI_PREFIX, /* CC = */ std::nullopt}, 
  1358#include "llvm/Analysis/VecFuncs.def" 
  1359#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS 
 
  1363#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV 
  1364#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \ 
  1365 {SCAL, VEC, VF, MASK, VABI_PREFIX, /* CC = */ std::nullopt}, 
  1366#include "llvm/Analysis/VecFuncs.def" 
  1367#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV 
 
  1371#define TLI_DEFINE_ARMPL_VECFUNCS 
  1372#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX, CC) \ 
  1373 {SCAL, VEC, VF, MASK, VABI_PREFIX, CC}, 
  1374#include "llvm/Analysis/VecFuncs.def" 
  1375#undef TLI_DEFINE_ARMPL_VECFUNCS 
 
  1379#define TLI_DEFINE_AMDLIBM_VECFUNCS 
  1380#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \ 
  1381 {SCAL, VEC, VF, MASK, VABI_PREFIX, /* CC = */ std::nullopt}, 
  1382#include "llvm/Analysis/VecFuncs.def" 
  1383#undef TLI_DEFINE_AMDLIBM_VECFUNCS 
 
  1398 switch (TargetTriple.
getArch()) {
 
  1421 switch (TargetTriple.
getArch()) {
 
  1437 switch (TargetTriple.
getArch()) {
 
 
  1458 if (funcName.
empty())
 
  1461 std::vector<VecDesc>::const_iterator 
I =
 
  1463 return I != VectorDescs.end() && 
StringRef(
I->getScalarFnName()) == funcName;
 
 
  1481 std::vector<VecDesc>::const_iterator 
I =
 
  1483 while (
I != VectorDescs.end() && 
StringRef(
I->getScalarFnName()) == 
F) {
 
  1484 if ((
I->getVectorizationFactor() == VF) && (
I->isMasked() == 
Masked))
 
 
  1493 if (!BaselineInfoImpl)
 
 
  1500 M.getModuleFlag(
"wchar_size")))
 
 
  1506 // There is really no guarantee that sizeof(size_t) is equal to the index 
  1507 // size of the default address space. If that isn't true then it should be 
  1508 // possible to derive the SizeTTy from the target triple here instead and do 
  1511 // Hard coding address space zero may seem unfortunate, but a number of 
  1512 // configurations of common targets (i386, x86-64 x32, aarch64 x32, possibly 
  1513 // others) have larger-than-size_t index sizes on non-default address spaces, 
  1514 // making this the best default. 
  1515 return M.getDataLayout().getIndexSizeInBits(
/*AddressSpace=*/0);
 
 
  1534// Register the basic pass. 
  1536 "Target Library Information", 
false, 
true)
 
  1545 // Use '0' here because a type of the form <vscale x 1 x ElTy> is not the 
  1546 // same as a scalar. 
  1549 if (ScalarF.
empty())
 
  1552 std::vector<VecDesc>::const_iterator 
I =
 
  1554 while (
I != VectorDescs.end() && 
StringRef(
I->getScalarFnName()) == ScalarF) {
 
  1556 I->getVectorizationFactor().isScalable() ? &ScalableVF : &FixedVF;
 
  1558 *VF = 
I->getVectorizationFactor();
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
 
This file contains the declarations for the subclasses of Constant, which represent the different fla...
 
This file defines the DenseMap class.
 
Module.h This file contains the declarations for the Module class.
 
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
 
This file defines the SmallString class.
 
static bool hasSinCosPiStret(const Triple &T)
 
static bool isCallingConvCCompatible(CallingConv::ID CC, const Triple &TT, FunctionType *FuncTy)
 
static StringRef sanitizeFunctionName(StringRef funcName)
 
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
 
static const VecDesc VecFuncs_MASSV[]
 
static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
 
static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits, unsigned SizeTBits)
 
static bool hasBcmp(const Triple &TT)
 
static const VecDesc VecFuncs_SLEEFGNUABI_VF2[]
 
static void initializeBase(TargetLibraryInfoImpl &TLI, const Triple &T)
 
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)
 
static const VecDesc VecFuncs_LIBMVEC_AARCH64[]
 
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS)
 
static const VecDesc VecFuncs_SLEEFGNUABI_VF4[]
 
static const FuncProtoTy Signatures[]
 
static const VecDesc VecFuncs_ArmPL[]
 
const VecDesc VecFuncs_AMDLIBM[]
 
static bool isValidProtoForSizeReturningNew(const FunctionType &FTy, LibFunc F, const Module &M, int SizeTSizeBits)
 
static const VecDesc VecFuncs_LIBMVEC_X86[]
 
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::DarwinLibSystemM, "Darwin_libsystem_m", "Darwin libsystem_m"), clEnumValN(TargetLibraryInfoImpl::LIBMVEC, "LIBMVEC", "GLIBC Vector Math library"), clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV", "IBM MASS vector library"), clEnumValN(TargetLibraryInfoImpl::SVML, "SVML", "Intel SVML library"), clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi", "SIMD Library for Evaluating Elementary Functions"), clEnumValN(TargetLibraryInfoImpl::ArmPL, "ArmPL", "Arm Performance Libraries"), clEnumValN(TargetLibraryInfoImpl::AMDLIBM, "AMDLIBM", "AMD vector math library")))
 
static const VecDesc VecFuncs_DarwinLibSystemM[]
 
static const VecDesc VecFuncs_SVML[]
 
std::array< FuncArgTypeID, 8 > FuncProtoTy
 
static const VecDesc VecFuncs_SLEEFGNUABI_VFScalable[]
 
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)
 
static const VecDesc VecFuncs_Accelerate[]
 
static const VecDesc VecFuncs_SLEEFGNUABI_VFScalableRISCV[]
 
static DenseMap< StringRef, LibFunc > buildIndexMap(ArrayRef< StringLiteral > StandardNames)
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
 
CallingConv::ID getCallingConv() const
 
FunctionType * getFunctionType() const
 
iterator find(const_arg_type_t< KeyT > Val)
 
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
 
static constexpr ElementCount getScalable(ScalarTy MinVal)
 
static constexpr ElementCount getFixed(ScalarTy MinVal)
 
Class to represent function types.
 
FunctionType * getFunctionType() const
Returns the FunctionType for me.
 
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
 
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '1円',...
 
Module * getParent()
Get the module that this global value is contained inside of...
 
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
 
A Module instance is used to store all the information related to an LLVM module.
 
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
 
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
 
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
 
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
 
StringRef - Represent a constant reference to a string, i.e.
 
constexpr bool empty() const
empty - Check if the string is empty.
 
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
 
Class to represent struct types.
 
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
 
LLVM_ABI TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)
 
Implementation of the target library information.
 
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
 
void setShouldExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...
 
LLVM_ABI unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
 
LLVM_ABI bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
 
LLVM_ABI void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const
Returns the largest vectorization factor used in the list of vector functions.
 
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
 
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
 
void setAvailableWithName(LibFunc F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used.
 
TargetLibraryInfoImpl()=delete
 
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
 
LLVM_ABI void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib, const llvm::Triple &TargetTriple)
Calls addVectorizableFunctions with a known preset of functions for the given vector library.
 
void setIntSize(unsigned Bits)
Initialize the C-level size of an integer.
 
LLVM_ABI unsigned getSizeTSize(const Module &M) const
Returns the size of the size_t type in bits.
 
LLVM_ABI void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...
 
LLVM_ABI const VecDesc * getVectorMappingInfo(StringRef F, const ElementCount &VF, bool Masked) const
Return a pointer to a VecDesc object holding all info for scalar to vector mappings in TLI for the eq...
 
static LLVM_ABI bool isCallingConvCCompatible(CallBase *CI)
Returns true if call site / callee has cdecl-compatible calling conventions.
 
void setShouldSignExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext attribute if they correspond t...
 
LLVM_ABI TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
 
LLVM_ABI void disableAllFunctions()
Disables all builtins.
 
VectorLibrary
List of known vector-functions libraries.
 
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
 
LLVM_ABI StringRef getVectorizedFunction(StringRef F, const ElementCount &VF, bool Masked) const
Return the name of the equivalent of F, vectorized with factor VF.
 
void setAvailable(LibFunc F)
Forces a function to be marked as available.
 
TargetLibraryInfoWrapperPass()
The default constructor should not be used and is only for pass manager initialization purposes.
 
Provides information about what library functions are available for the current target.
 
static void initExtensionsForTriple(bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)
 
Triple - Helper class for working with autoconf configuration names.
 
ArchType getArch() const
Get the parsed architecture type of this triple.
 
The instances of the Type class are immutable: once they are created, they are never changed.
 
bool isArrayTy() const
True if this is an instance of ArrayType.
 
Type * getArrayElementType() const
 
LLVM_ABI uint64_t getArrayNumElements() const
 
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
 
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
 
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
 
Provides info so a possible vectorization of a function can be computed.
 
LLVM_ABI std::string getVectorFunctionABIVariantString() const
Returns a vector function ABI variant string on the form: ZGV<isa><mask><vlen><vparams><scalarname>(<...
 
StringRef getVectorFnName() const
 
Represents a version number in the form major[.minor[.subminor[.build]]].
 
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
 
A raw_ostream that writes to an SmallVector or SmallString.
 
StringRef str() const
Return a StringRef for the vector contents.
 
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
 
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
 
@ ARM_APCS
ARM Procedure Calling Standard (obsolete, but still used on some targets).
 
@ ARM_AAPCS
ARM Architecture Procedure Calling Standard calling convention (aka EABI).
 
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
 
@ C
The default llvm calling convention, compatible with C.
 
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
 
initializer< Ty > init(const Ty &Val)
 
This is an optimization pass for GlobalISel generic memory operations.
 
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
 
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
 
auto cast_or_null(const Y &Val)
 
void sort(IteratorTy Start, IteratorTy End)
 
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
 
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
 
Implement std::hash so that hash_code can be used in STL containers.
 
A special type used by analysis passes to provide an address that identifies that particular analysis...