/// specified target triple. This should be carefully written so that a missing
/// target triple gets a sane set of defaults.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
- const char *const *StandardNames) {
-#ifndef NDEBUG
+ ArrayRef<const char *> StandardNames) {
// Verify that the StandardNames array is in alphabetical order.
- for (unsigned F = 1; F < LibFunc::NumLibFuncs; ++F) {
- if (strcmp(StandardNames[F-1], StandardNames[F]) >= 0)
- llvm_unreachable("TargetLibraryInfoImpl function names must be sorted");
+ assert(std::is_sorted(StandardNames.begin(), StandardNames.end(),
+ [](const char *LHS, const char *RHS) {
+ return strcmp(LHS, RHS) < 0;
+ }) &&
+ "TargetLibraryInfoImpl function names must be sorted");
+
+ if (T.getArch() == Triple::r600 ||
+ T.getArch() == Triple::amdgcn) {
+ TLI.setUnavailable(LibFunc::ldexp);
+ TLI.setUnavailable(LibFunc::ldexpf);
+ TLI.setUnavailable(LibFunc::ldexpl);
}
-#endif // !NDEBUG
// There are no library implementations of mempcy and memset for AMD gpus and
// these can be difficult to lower in the backend.
if (T.getArch() == Triple::r600 ||
- T.getArch() == Triple::amdgcn) {
+ T.getArch() == Triple::amdgcn ||
+ T.getArch() == Triple::wasm32 ||
+ T.getArch() == Triple::wasm64) {
TLI.setUnavailable(LibFunc::memcpy);
TLI.setUnavailable(LibFunc::memset);
TLI.setUnavailable(LibFunc::memset_pattern16);
}
// memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
+ // All versions of watchOS support it.
if (T.isMacOSX()) {
if (T.isMacOSXVersionLT(10, 5))
TLI.setUnavailable(LibFunc::memset_pattern16);
} else if (T.isiOS()) {
if (T.isOSVersionLT(3, 0))
TLI.setUnavailable(LibFunc::memset_pattern16);
- } else {
+ } else if (!T.isWatchOS()) {
TLI.setUnavailable(LibFunc::memset_pattern16);
}
}
break;
case Triple::IOS:
+ case Triple::TvOS:
+ case Triple::WatchOS:
TLI.setUnavailable(LibFunc::exp10l);
- if (T.isOSVersionLT(7, 0)) {
+ if (!T.isWatchOS() && (T.isOSVersionLT(7, 0) ||
+ (T.isOSVersionLT(9, 0) &&
+ (T.getArch() == Triple::x86 ||
+ T.getArch() == Triple::x86_64)))) {
TLI.setUnavailable(LibFunc::exp10);
TLI.setUnavailable(LibFunc::exp10f);
} else {
// ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
// Linux (GLIBC):
// http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
- // http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsl.c
+ // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
// http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
switch (T.getOS()) {
case Triple::Darwin:
case Triple::MacOSX:
case Triple::IOS:
+ case Triple::TvOS:
+ case Triple::WatchOS:
case Triple::FreeBSD:
case Triple::Linux:
break;
}
// ffsll is available on at least FreeBSD and Linux (GLIBC):
- // http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsll.c
+ // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
// http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
switch (T.getOS()) {
+ case Triple::Darwin:
+ case Triple::MacOSX:
+ case Triple::IOS:
+ case Triple::TvOS:
+ case Triple::WatchOS:
case Triple::FreeBSD:
case Triple::Linux:
break;
TLI.setUnavailable(LibFunc::ffsll);
}
+ // The following functions are available on at least FreeBSD:
+ // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
+ // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
+ // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
+ if (!T.isOSFreeBSD()) {
+ TLI.setUnavailable(LibFunc::fls);
+ TLI.setUnavailable(LibFunc::flsl);
+ TLI.setUnavailable(LibFunc::flsll);
+ }
+
// The following functions are available on at least Linux:
if (!T.isOSLinux()) {
TLI.setUnavailable(LibFunc::dunder_strdup);
// Check for \01 prefix that is used to mangle __asm declarations and
// strip it if present.
- if (funcName.front() == '\01')
- funcName = funcName.substr(1);
- return funcName;
+ return GlobalValue::getRealLinkageName(funcName);
}
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
switch (VecLib) {
case Accelerate: {
const VecDesc VecFuncs[] = {
+ // Floating-Point Arithmetic and Auxiliary Functions
+ {"ceilf", "vceilf", 4},
+ {"fabsf", "vfabsf", 4},
+ {"llvm.fabs.f32", "vfabsf", 4},
+ {"floorf", "vfloorf", 4},
+ {"sqrtf", "vsqrtf", 4},
+ {"llvm.sqrt.f32", "vsqrtf", 4},
+
+ // Exponential and Logarithmic Functions
{"expf", "vexpf", 4},
{"llvm.exp.f32", "vexpf", 4},
+ {"expm1f", "vexpm1f", 4},
{"logf", "vlogf", 4},
{"llvm.log.f32", "vlogf", 4},
- {"sqrtf", "vsqrtf", 4},
- {"llvm.sqrt.f32", "vsqrtf", 4},
- {"fabsf", "vfabsf", 4},
- {"llvm.fabs.f32", "vfabsf", 4},
+ {"log1pf", "vlog1pf", 4},
+ {"log10f", "vlog10f", 4},
+ {"llvm.log10.f32", "vlog10f", 4},
+ {"logbf", "vlogbf", 4},
+
+ // Trigonometric Functions
+ {"sinf", "vsinf", 4},
+ {"llvm.sin.f32", "vsinf", 4},
+ {"cosf", "vcosf", 4},
+ {"llvm.cos.f32", "vcosf", 4},
+ {"tanf", "vtanf", 4},
+ {"asinf", "vasinf", 4},
+ {"acosf", "vacosf", 4},
+ {"atanf", "vatanf", 4},
+
+ // Hyperbolic Functions
+ {"sinhf", "vsinhf", 4},
+ {"coshf", "vcoshf", 4},
+ {"tanhf", "vtanhf", 4},
+ {"asinhf", "vasinhf", 4},
+ {"acoshf", "vacoshf", 4},
+ {"atanhf", "vatanhf", 4},
};
addVectorizableFunctions(VecFuncs);
break;