1 //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the TargetLibraryInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Analysis/TargetLibraryInfo.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/Support/CommandLine.h"
19 static cl::opt<TargetLibraryInfoImpl::VectorLibrary> ClVectorLibrary(
20 "vector-library", cl::Hidden, cl::desc("Vector functions library"),
21 cl::init(TargetLibraryInfoImpl::NoLibrary),
22 cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none",
23 "No vector functions library"),
24 clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate",
25 "Accelerate framework"),
28 const char *const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
29 #define TLI_DEFINE_STRING
30 #include "llvm/Analysis/TargetLibraryInfo.def"
33 static bool hasSinCosPiStret(const Triple &T) {
34 // Only Darwin variants have _stret versions of combined trig functions.
38 // The ABI is rather complicated on x86, so don't do anything special there.
39 if (T.getArch() == Triple::x86)
42 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9))
45 if (T.isiOS() && T.isOSVersionLT(7, 0))
51 /// initialize - Initialize the set of available library functions based on the
52 /// specified target triple. This should be carefully written so that a missing
53 /// target triple gets a sane set of defaults.
54 static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
55 const char *const *StandardNames) {
57 // Verify that the StandardNames array is in alphabetical order.
58 for (unsigned F = 1; F < LibFunc::NumLibFuncs; ++F) {
59 if (strcmp(StandardNames[F-1], StandardNames[F]) >= 0)
60 llvm_unreachable("TargetLibraryInfoImpl function names must be sorted");
64 // There are no library implementations of mempcy and memset for AMD gpus and
65 // these can be difficult to lower in the backend.
66 if (T.getArch() == Triple::r600 ||
67 T.getArch() == Triple::amdgcn) {
68 TLI.setUnavailable(LibFunc::memcpy);
69 TLI.setUnavailable(LibFunc::memset);
70 TLI.setUnavailable(LibFunc::memset_pattern16);
74 // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
76 if (T.isMacOSXVersionLT(10, 5))
77 TLI.setUnavailable(LibFunc::memset_pattern16);
78 } else if (T.isiOS()) {
79 if (T.isOSVersionLT(3, 0))
80 TLI.setUnavailable(LibFunc::memset_pattern16);
82 TLI.setUnavailable(LibFunc::memset_pattern16);
85 if (!hasSinCosPiStret(T)) {
86 TLI.setUnavailable(LibFunc::sinpi);
87 TLI.setUnavailable(LibFunc::sinpif);
88 TLI.setUnavailable(LibFunc::cospi);
89 TLI.setUnavailable(LibFunc::cospif);
90 TLI.setUnavailable(LibFunc::sincospi_stret);
91 TLI.setUnavailable(LibFunc::sincospif_stret);
94 if (T.isMacOSX() && T.getArch() == Triple::x86 &&
95 !T.isMacOSXVersionLT(10, 7)) {
96 // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
97 // we don't care about) have two versions; on recent OSX, the one we want
98 // has a $UNIX2003 suffix. The two implementations are identical except
99 // for the return value in some edge cases. However, we don't want to
100 // generate code that depends on the old symbols.
101 TLI.setAvailableWithName(LibFunc::fwrite, "fwrite$UNIX2003");
102 TLI.setAvailableWithName(LibFunc::fputs, "fputs$UNIX2003");
105 // iprintf and friends are only available on XCore and TCE.
106 if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) {
107 TLI.setUnavailable(LibFunc::iprintf);
108 TLI.setUnavailable(LibFunc::siprintf);
109 TLI.setUnavailable(LibFunc::fiprintf);
112 if (T.isOSWindows() && !T.isOSCygMing()) {
113 // Win32 does not support long double
114 TLI.setUnavailable(LibFunc::acosl);
115 TLI.setUnavailable(LibFunc::asinl);
116 TLI.setUnavailable(LibFunc::atanl);
117 TLI.setUnavailable(LibFunc::atan2l);
118 TLI.setUnavailable(LibFunc::ceill);
119 TLI.setUnavailable(LibFunc::copysignl);
120 TLI.setUnavailable(LibFunc::cosl);
121 TLI.setUnavailable(LibFunc::coshl);
122 TLI.setUnavailable(LibFunc::expl);
123 TLI.setUnavailable(LibFunc::fabsf); // Win32 and Win64 both lack fabsf
124 TLI.setUnavailable(LibFunc::fabsl);
125 TLI.setUnavailable(LibFunc::floorl);
126 TLI.setUnavailable(LibFunc::fmaxl);
127 TLI.setUnavailable(LibFunc::fminl);
128 TLI.setUnavailable(LibFunc::fmodl);
129 TLI.setUnavailable(LibFunc::frexpl);
130 TLI.setUnavailable(LibFunc::ldexpf);
131 TLI.setUnavailable(LibFunc::ldexpl);
132 TLI.setUnavailable(LibFunc::logl);
133 TLI.setUnavailable(LibFunc::modfl);
134 TLI.setUnavailable(LibFunc::powl);
135 TLI.setUnavailable(LibFunc::sinl);
136 TLI.setUnavailable(LibFunc::sinhl);
137 TLI.setUnavailable(LibFunc::sqrtl);
138 TLI.setUnavailable(LibFunc::tanl);
139 TLI.setUnavailable(LibFunc::tanhl);
141 // Win32 only has C89 math
142 TLI.setUnavailable(LibFunc::acosh);
143 TLI.setUnavailable(LibFunc::acoshf);
144 TLI.setUnavailable(LibFunc::acoshl);
145 TLI.setUnavailable(LibFunc::asinh);
146 TLI.setUnavailable(LibFunc::asinhf);
147 TLI.setUnavailable(LibFunc::asinhl);
148 TLI.setUnavailable(LibFunc::atanh);
149 TLI.setUnavailable(LibFunc::atanhf);
150 TLI.setUnavailable(LibFunc::atanhl);
151 TLI.setUnavailable(LibFunc::cbrt);
152 TLI.setUnavailable(LibFunc::cbrtf);
153 TLI.setUnavailable(LibFunc::cbrtl);
154 TLI.setUnavailable(LibFunc::exp2);
155 TLI.setUnavailable(LibFunc::exp2f);
156 TLI.setUnavailable(LibFunc::exp2l);
157 TLI.setUnavailable(LibFunc::expm1);
158 TLI.setUnavailable(LibFunc::expm1f);
159 TLI.setUnavailable(LibFunc::expm1l);
160 TLI.setUnavailable(LibFunc::log2);
161 TLI.setUnavailable(LibFunc::log2f);
162 TLI.setUnavailable(LibFunc::log2l);
163 TLI.setUnavailable(LibFunc::log1p);
164 TLI.setUnavailable(LibFunc::log1pf);
165 TLI.setUnavailable(LibFunc::log1pl);
166 TLI.setUnavailable(LibFunc::logb);
167 TLI.setUnavailable(LibFunc::logbf);
168 TLI.setUnavailable(LibFunc::logbl);
169 TLI.setUnavailable(LibFunc::nearbyint);
170 TLI.setUnavailable(LibFunc::nearbyintf);
171 TLI.setUnavailable(LibFunc::nearbyintl);
172 TLI.setUnavailable(LibFunc::rint);
173 TLI.setUnavailable(LibFunc::rintf);
174 TLI.setUnavailable(LibFunc::rintl);
175 TLI.setUnavailable(LibFunc::round);
176 TLI.setUnavailable(LibFunc::roundf);
177 TLI.setUnavailable(LibFunc::roundl);
178 TLI.setUnavailable(LibFunc::trunc);
179 TLI.setUnavailable(LibFunc::truncf);
180 TLI.setUnavailable(LibFunc::truncl);
182 // Win32 provides some C99 math with mangled names
183 TLI.setAvailableWithName(LibFunc::copysign, "_copysign");
185 if (T.getArch() == Triple::x86) {
186 // Win32 on x86 implements single-precision math functions as macros
187 TLI.setUnavailable(LibFunc::acosf);
188 TLI.setUnavailable(LibFunc::asinf);
189 TLI.setUnavailable(LibFunc::atanf);
190 TLI.setUnavailable(LibFunc::atan2f);
191 TLI.setUnavailable(LibFunc::ceilf);
192 TLI.setUnavailable(LibFunc::copysignf);
193 TLI.setUnavailable(LibFunc::cosf);
194 TLI.setUnavailable(LibFunc::coshf);
195 TLI.setUnavailable(LibFunc::expf);
196 TLI.setUnavailable(LibFunc::floorf);
197 TLI.setUnavailable(LibFunc::fminf);
198 TLI.setUnavailable(LibFunc::fmaxf);
199 TLI.setUnavailable(LibFunc::fmodf);
200 TLI.setUnavailable(LibFunc::logf);
201 TLI.setUnavailable(LibFunc::powf);
202 TLI.setUnavailable(LibFunc::sinf);
203 TLI.setUnavailable(LibFunc::sinhf);
204 TLI.setUnavailable(LibFunc::sqrtf);
205 TLI.setUnavailable(LibFunc::tanf);
206 TLI.setUnavailable(LibFunc::tanhf);
209 // Win32 does *not* provide provide these functions, but they are
210 // generally available on POSIX-compliant systems:
211 TLI.setUnavailable(LibFunc::access);
212 TLI.setUnavailable(LibFunc::bcmp);
213 TLI.setUnavailable(LibFunc::bcopy);
214 TLI.setUnavailable(LibFunc::bzero);
215 TLI.setUnavailable(LibFunc::chmod);
216 TLI.setUnavailable(LibFunc::chown);
217 TLI.setUnavailable(LibFunc::closedir);
218 TLI.setUnavailable(LibFunc::ctermid);
219 TLI.setUnavailable(LibFunc::fdopen);
220 TLI.setUnavailable(LibFunc::ffs);
221 TLI.setUnavailable(LibFunc::fileno);
222 TLI.setUnavailable(LibFunc::flockfile);
223 TLI.setUnavailable(LibFunc::fseeko);
224 TLI.setUnavailable(LibFunc::fstat);
225 TLI.setUnavailable(LibFunc::fstatvfs);
226 TLI.setUnavailable(LibFunc::ftello);
227 TLI.setUnavailable(LibFunc::ftrylockfile);
228 TLI.setUnavailable(LibFunc::funlockfile);
229 TLI.setUnavailable(LibFunc::getc_unlocked);
230 TLI.setUnavailable(LibFunc::getitimer);
231 TLI.setUnavailable(LibFunc::getlogin_r);
232 TLI.setUnavailable(LibFunc::getpwnam);
233 TLI.setUnavailable(LibFunc::gettimeofday);
234 TLI.setUnavailable(LibFunc::htonl);
235 TLI.setUnavailable(LibFunc::htons);
236 TLI.setUnavailable(LibFunc::lchown);
237 TLI.setUnavailable(LibFunc::lstat);
238 TLI.setUnavailable(LibFunc::memccpy);
239 TLI.setUnavailable(LibFunc::mkdir);
240 TLI.setUnavailable(LibFunc::ntohl);
241 TLI.setUnavailable(LibFunc::ntohs);
242 TLI.setUnavailable(LibFunc::open);
243 TLI.setUnavailable(LibFunc::opendir);
244 TLI.setUnavailable(LibFunc::pclose);
245 TLI.setUnavailable(LibFunc::popen);
246 TLI.setUnavailable(LibFunc::pread);
247 TLI.setUnavailable(LibFunc::pwrite);
248 TLI.setUnavailable(LibFunc::read);
249 TLI.setUnavailable(LibFunc::readlink);
250 TLI.setUnavailable(LibFunc::realpath);
251 TLI.setUnavailable(LibFunc::rmdir);
252 TLI.setUnavailable(LibFunc::setitimer);
253 TLI.setUnavailable(LibFunc::stat);
254 TLI.setUnavailable(LibFunc::statvfs);
255 TLI.setUnavailable(LibFunc::stpcpy);
256 TLI.setUnavailable(LibFunc::stpncpy);
257 TLI.setUnavailable(LibFunc::strcasecmp);
258 TLI.setUnavailable(LibFunc::strncasecmp);
259 TLI.setUnavailable(LibFunc::times);
260 TLI.setUnavailable(LibFunc::uname);
261 TLI.setUnavailable(LibFunc::unlink);
262 TLI.setUnavailable(LibFunc::unsetenv);
263 TLI.setUnavailable(LibFunc::utime);
264 TLI.setUnavailable(LibFunc::utimes);
265 TLI.setUnavailable(LibFunc::write);
267 // Win32 does *not* provide provide these functions, but they are
269 TLI.setUnavailable(LibFunc::atoll);
270 TLI.setUnavailable(LibFunc::frexpf);
271 TLI.setUnavailable(LibFunc::llabs);
276 // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
277 // and their names are __exp10 and __exp10f. exp10l is not available on
279 TLI.setUnavailable(LibFunc::exp10l);
280 if (T.isMacOSXVersionLT(10, 9)) {
281 TLI.setUnavailable(LibFunc::exp10);
282 TLI.setUnavailable(LibFunc::exp10f);
284 TLI.setAvailableWithName(LibFunc::exp10, "__exp10");
285 TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f");
289 TLI.setUnavailable(LibFunc::exp10l);
290 if (T.isOSVersionLT(7, 0)) {
291 TLI.setUnavailable(LibFunc::exp10);
292 TLI.setUnavailable(LibFunc::exp10f);
294 TLI.setAvailableWithName(LibFunc::exp10, "__exp10");
295 TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f");
299 // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
300 // buggy prior to glibc version 2.18. Until this version is widely deployed
301 // or we have a reasonable detection strategy, we cannot use exp10 reliably
304 // Fall through to disable all of them.
306 TLI.setUnavailable(LibFunc::exp10);
307 TLI.setUnavailable(LibFunc::exp10f);
308 TLI.setUnavailable(LibFunc::exp10l);
311 // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
313 // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
314 // http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsl.c
315 // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
320 case Triple::FreeBSD:
324 TLI.setUnavailable(LibFunc::ffsl);
327 // ffsll is available on at least FreeBSD and Linux (GLIBC):
328 // http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsll.c
329 // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
331 case Triple::FreeBSD:
335 TLI.setUnavailable(LibFunc::ffsll);
338 // The following functions are available on at least Linux:
339 if (!T.isOSLinux()) {
340 TLI.setUnavailable(LibFunc::dunder_strdup);
341 TLI.setUnavailable(LibFunc::dunder_strtok_r);
342 TLI.setUnavailable(LibFunc::dunder_isoc99_scanf);
343 TLI.setUnavailable(LibFunc::dunder_isoc99_sscanf);
344 TLI.setUnavailable(LibFunc::under_IO_getc);
345 TLI.setUnavailable(LibFunc::under_IO_putc);
346 TLI.setUnavailable(LibFunc::memalign);
347 TLI.setUnavailable(LibFunc::fopen64);
348 TLI.setUnavailable(LibFunc::fseeko64);
349 TLI.setUnavailable(LibFunc::fstat64);
350 TLI.setUnavailable(LibFunc::fstatvfs64);
351 TLI.setUnavailable(LibFunc::ftello64);
352 TLI.setUnavailable(LibFunc::lstat64);
353 TLI.setUnavailable(LibFunc::open64);
354 TLI.setUnavailable(LibFunc::stat64);
355 TLI.setUnavailable(LibFunc::statvfs64);
356 TLI.setUnavailable(LibFunc::tmpfile64);
359 TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary);
362 TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
363 // Default to everything being available.
364 memset(AvailableArray, -1, sizeof(AvailableArray));
366 initialize(*this, Triple(), StandardNames);
369 TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
370 // Default to everything being available.
371 memset(AvailableArray, -1, sizeof(AvailableArray));
373 initialize(*this, T, StandardNames);
376 TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
377 : CustomNames(TLI.CustomNames) {
378 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
379 VectorDescs = TLI.VectorDescs;
380 ScalarDescs = TLI.ScalarDescs;
383 TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
384 : CustomNames(std::move(TLI.CustomNames)) {
385 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
387 VectorDescs = TLI.VectorDescs;
388 ScalarDescs = TLI.ScalarDescs;
391 TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl &TLI) {
392 CustomNames = TLI.CustomNames;
393 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
397 TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&TLI) {
398 CustomNames = std::move(TLI.CustomNames);
399 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
404 static StringRef sanitizeFunctionName(StringRef funcName) {
405 // Filter out empty names and names containing null bytes, those can't be in
407 if (funcName.empty() || funcName.find('\0') != StringRef::npos)
410 // Check for \01 prefix that is used to mangle __asm declarations and
411 // strip it if present.
412 return GlobalValue::getRealLinkageName(funcName);
415 bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
416 LibFunc::Func &F) const {
417 const char *const *Start = &StandardNames[0];
418 const char *const *End = &StandardNames[LibFunc::NumLibFuncs];
420 funcName = sanitizeFunctionName(funcName);
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) {
429 F = (LibFunc::Func)(I - Start);
435 void TargetLibraryInfoImpl::disableAllFunctions() {
436 memset(AvailableArray, 0, sizeof(AvailableArray));
439 static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
440 return std::strncmp(LHS.ScalarFnName, RHS.ScalarFnName,
441 std::strlen(RHS.ScalarFnName)) < 0;
444 static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
445 return std::strncmp(LHS.VectorFnName, RHS.VectorFnName,
446 std::strlen(RHS.VectorFnName)) < 0;
449 static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) {
450 return std::strncmp(LHS.ScalarFnName, S.data(), S.size()) < 0;
453 static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) {
454 return std::strncmp(LHS.VectorFnName, S.data(), S.size()) < 0;
457 void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
458 VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end());
459 std::sort(VectorDescs.begin(), VectorDescs.end(), compareByScalarFnName);
461 ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end());
462 std::sort(ScalarDescs.begin(), ScalarDescs.end(), compareByVectorFnName);
465 void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
466 enum VectorLibrary VecLib) {
469 const VecDesc VecFuncs[] = {
470 // Floating-Point Arithmetic and Auxiliary Functions
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},
478 // Exponential and Logarithmic Functions
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},
489 // Trigonometric Functions
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},
499 // Hyperbolic Functions
500 {"sinhf", "vsinhf", 4},
501 {"coshf", "vcoshf", 4},
502 {"tanhf", "vtanhf", 4},
503 {"asinhf", "vasinhf", 4},
504 {"acoshf", "vacoshf", 4},
505 {"atanhf", "vatanhf", 4},
507 addVectorizableFunctions(VecFuncs);
515 bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName) const {
516 funcName = sanitizeFunctionName(funcName);
517 if (funcName.empty())
520 std::vector<VecDesc>::const_iterator I = std::lower_bound(
521 VectorDescs.begin(), VectorDescs.end(), funcName,
522 compareWithScalarFnName);
523 return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName;
526 StringRef TargetLibraryInfoImpl::getVectorizedFunction(StringRef F,
528 F = sanitizeFunctionName(F);
531 std::vector<VecDesc>::const_iterator I = std::lower_bound(
532 VectorDescs.begin(), VectorDescs.end(), F, compareWithScalarFnName);
533 while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == F) {
534 if (I->VectorizationFactor == VF)
535 return I->VectorFnName;
541 StringRef TargetLibraryInfoImpl::getScalarizedFunction(StringRef F,
542 unsigned &VF) const {
543 F = sanitizeFunctionName(F);
547 std::vector<VecDesc>::const_iterator I = std::lower_bound(
548 ScalarDescs.begin(), ScalarDescs.end(), F, compareWithVectorFnName);
549 if (I == VectorDescs.end() || StringRef(I->VectorFnName) != F)
551 VF = I->VectorizationFactor;
552 return I->ScalarFnName;
555 TargetLibraryInfo TargetLibraryAnalysis::run(Module &M) {
557 return TargetLibraryInfo(*PresetInfoImpl);
559 return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
562 TargetLibraryInfo TargetLibraryAnalysis::run(Function &F) {
564 return TargetLibraryInfo(*PresetInfoImpl);
566 return TargetLibraryInfo(
567 lookupInfoImpl(Triple(F.getParent()->getTargetTriple())));
570 TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(Triple T) {
571 std::unique_ptr<TargetLibraryInfoImpl> &Impl =
572 Impls[T.normalize()];
574 Impl.reset(new TargetLibraryInfoImpl(T));
580 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
581 : ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
582 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
585 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
586 : ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
587 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
590 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
591 const TargetLibraryInfoImpl &TLIImpl)
592 : ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
593 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
596 char TargetLibraryAnalysis::PassID;
598 // Register the basic pass.
599 INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
600 "Target Library Information", false, true)
601 char TargetLibraryInfoWrapperPass::ID = 0;
603 void TargetLibraryInfoWrapperPass::anchor() {}