LLVM  16.0.0git
TargetLibraryInfo.cpp
Go to the documentation of this file.
1 //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the TargetLibraryInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/InitializePasses.h"
18 using namespace llvm;
19 
21  "vector-library", cl::Hidden, cl::desc("Vector functions library"),
24  "No vector functions library"),
26  "Accelerate framework"),
28  "Darwin_libsystem_m", "Darwin libsystem_m"),
30  "GLIBC Vector Math library"),
32  "IBM MASS vector library"),
34  "Intel SVML library")));
35 
36 StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
37  {
38 #define TLI_DEFINE_STRING
39 #include "llvm/Analysis/TargetLibraryInfo.def"
40 };
41 
42 // Recognized types of library function arguments and return types.
43 enum FuncArgTypeID : char {
44  Void = 0, // Must be zero.
45  Bool, // 8 bits on all targets
46  Int16,
47  Int32,
48  Int,
49  IntPlus, // Int or bigger.
50  Long, // Either 32 or 64 bits.
51  IntX, // Any integer type.
52  Int64,
53  LLong, // 64 bits on all targets.
54  SizeT, // size_t.
55  SSizeT, // POSIX ssize_t.
56  Flt, // IEEE float.
57  Dbl, // IEEE double.
58  LDbl, // Any floating type (TODO: tighten this up).
59  Floating, // Any floating type.
60  Ptr, // Any pointer type.
61  Struct, // Any struct type.
62  Ellip, // The ellipsis (...).
63  Same, // Same argument type as the previous one.
64 };
65 
66 typedef std::array<FuncArgTypeID, 8> FuncProtoTy;
67 
68 static const FuncProtoTy Signatures[] = {
69 #define TLI_DEFINE_SIG
70 #include "llvm/Analysis/TargetLibraryInfo.def"
71 };
72 
73 static_assert(sizeof Signatures / sizeof *Signatures == LibFunc::NumLibFuncs,
74  "Missing library function signatures");
75 
76 static bool hasSinCosPiStret(const Triple &T) {
77  // Only Darwin variants have _stret versions of combined trig functions.
78  if (!T.isOSDarwin())
79  return false;
80 
81  // The ABI is rather complicated on x86, so don't do anything special there.
82  if (T.getArch() == Triple::x86)
83  return false;
84 
85  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9))
86  return false;
87 
88  if (T.isiOS() && T.isOSVersionLT(7, 0))
89  return false;
90 
91  return true;
92 }
93 
94 static bool hasBcmp(const Triple &TT) {
95  // Posix removed support from bcmp() in 2001, but the glibc and several
96  // implementations of the libc still have it.
97  if (TT.isOSLinux())
98  return TT.isGNUEnvironment() || TT.isMusl();
99  // Both NetBSD and OpenBSD are planning to remove the function. Windows does
100  // not have it.
101  return TT.isOSFreeBSD() || TT.isOSSolaris();
102 }
103 
105  FunctionType *FuncTy) {
106  switch (CC) {
107  default:
108  return false;
110  return true;
114 
115  // The iOS ABI diverges from the standard in some cases, so for now don't
116  // try to simplify those calls.
117  if (Triple(TT).isiOS())
118  return false;
119 
120  if (!FuncTy->getReturnType()->isPointerTy() &&
121  !FuncTy->getReturnType()->isIntegerTy() &&
122  !FuncTy->getReturnType()->isVoidTy())
123  return false;
124 
125  for (auto *Param : FuncTy->params()) {
126  if (!Param->isPointerTy() && !Param->isIntegerTy())
127  return false;
128  }
129  return true;
130  }
131  }
132  return false;
133 }
134 
137  CI->getModule()->getTargetTriple(),
138  CI->getFunctionType());
139 }
140 
142  return ::isCallingConvCCompatible(F->getCallingConv(),
143  F->getParent()->getTargetTriple(),
144  F->getFunctionType());
145 }
146 
147 /// Initialize the set of available library functions based on the specified
148 /// target triple. This should be carefully written so that a missing target
149 /// triple gets a sane set of defaults.
150 static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
151  ArrayRef<StringLiteral> StandardNames) {
152  // Verify that the StandardNames array is in alphabetical order.
153  assert(
154  llvm::is_sorted(StandardNames,
155  [](StringRef LHS, StringRef RHS) { return LHS < RHS; }) &&
156  "TargetLibraryInfoImpl function names must be sorted");
157 
158  // Set IO unlocked variants as unavailable
159  // Set them as available per system below
160  TLI.setUnavailable(LibFunc_getc_unlocked);
161  TLI.setUnavailable(LibFunc_getchar_unlocked);
162  TLI.setUnavailable(LibFunc_putc_unlocked);
163  TLI.setUnavailable(LibFunc_putchar_unlocked);
164  TLI.setUnavailable(LibFunc_fputc_unlocked);
165  TLI.setUnavailable(LibFunc_fgetc_unlocked);
166  TLI.setUnavailable(LibFunc_fread_unlocked);
167  TLI.setUnavailable(LibFunc_fwrite_unlocked);
168  TLI.setUnavailable(LibFunc_fputs_unlocked);
169  TLI.setUnavailable(LibFunc_fgets_unlocked);
170 
171  bool ShouldExtI32Param = false, ShouldExtI32Return = false,
172  ShouldSignExtI32Param = false;
173  // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
174  // returns corresponding to C-level ints and unsigned ints.
175  if (T.isPPC64() || T.getArch() == Triple::sparcv9 ||
176  T.getArch() == Triple::systemz) {
177  ShouldExtI32Param = true;
178  ShouldExtI32Return = true;
179  }
180  // Mips, on the other hand, needs signext on i32 parameters corresponding
181  // to both signed and unsigned ints.
182  if (T.isMIPS()) {
183  ShouldSignExtI32Param = true;
184  }
185  TLI.setShouldExtI32Param(ShouldExtI32Param);
186  TLI.setShouldExtI32Return(ShouldExtI32Return);
187  TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
188 
189  // Let's assume by default that the size of int is 32 bits, unless the target
190  // is a 16-bit architecture because then it most likely is 16 bits. If that
191  // isn't true for a target those defaults should be overridden below.
192  TLI.setIntSize(T.isArch16Bit() ? 16 : 32);
193 
194  // There is really no runtime library on AMDGPU, apart from
195  // __kmpc_alloc/free_shared.
196  if (T.isAMDGPU()) {
197  TLI.disableAllFunctions();
198  TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
199  TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
200  return;
201  }
202 
203  // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and
204  // later. All versions of watchOS support it.
205  if (T.isMacOSX()) {
206  // available IO unlocked variants on Mac OS X
207  TLI.setAvailable(LibFunc_getc_unlocked);
208  TLI.setAvailable(LibFunc_getchar_unlocked);
209  TLI.setAvailable(LibFunc_putc_unlocked);
210  TLI.setAvailable(LibFunc_putchar_unlocked);
211 
212  if (T.isMacOSXVersionLT(10, 5)) {
213  TLI.setUnavailable(LibFunc_memset_pattern4);
214  TLI.setUnavailable(LibFunc_memset_pattern8);
215  TLI.setUnavailable(LibFunc_memset_pattern16);
216  }
217  } else if (T.isiOS()) {
218  if (T.isOSVersionLT(3, 0)) {
219  TLI.setUnavailable(LibFunc_memset_pattern4);
220  TLI.setUnavailable(LibFunc_memset_pattern8);
221  TLI.setUnavailable(LibFunc_memset_pattern16);
222  }
223  } else if (!T.isWatchOS()) {
224  TLI.setUnavailable(LibFunc_memset_pattern4);
225  TLI.setUnavailable(LibFunc_memset_pattern8);
226  TLI.setUnavailable(LibFunc_memset_pattern16);
227  }
228 
229  if (!hasSinCosPiStret(T)) {
230  TLI.setUnavailable(LibFunc_sinpi);
231  TLI.setUnavailable(LibFunc_sinpif);
232  TLI.setUnavailable(LibFunc_cospi);
233  TLI.setUnavailable(LibFunc_cospif);
234  TLI.setUnavailable(LibFunc_sincospi_stret);
235  TLI.setUnavailable(LibFunc_sincospif_stret);
236  }
237 
238  if (!hasBcmp(T))
239  TLI.setUnavailable(LibFunc_bcmp);
240 
241  if (T.isMacOSX() && T.getArch() == Triple::x86 &&
242  !T.isMacOSXVersionLT(10, 7)) {
243  // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
244  // we don't care about) have two versions; on recent OSX, the one we want
245  // has a $UNIX2003 suffix. The two implementations are identical except
246  // for the return value in some edge cases. However, we don't want to
247  // generate code that depends on the old symbols.
248  TLI.setAvailableWithName(LibFunc_fwrite, "fwrite$UNIX2003");
249  TLI.setAvailableWithName(LibFunc_fputs, "fputs$UNIX2003");
250  }
251 
252  // iprintf and friends are only available on XCore, TCE, and Emscripten.
253  if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce &&
254  T.getOS() != Triple::Emscripten) {
255  TLI.setUnavailable(LibFunc_iprintf);
256  TLI.setUnavailable(LibFunc_siprintf);
257  TLI.setUnavailable(LibFunc_fiprintf);
258  }
259 
260  // __small_printf and friends are only available on Emscripten.
261  if (T.getOS() != Triple::Emscripten) {
262  TLI.setUnavailable(LibFunc_small_printf);
263  TLI.setUnavailable(LibFunc_small_sprintf);
264  TLI.setUnavailable(LibFunc_small_fprintf);
265  }
266 
267  if (T.isOSWindows() && !T.isOSCygMing()) {
268  // XXX: The earliest documentation available at the moment is for VS2015/VC19:
269  // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015
270  // XXX: In order to use an MSVCRT older than VC19,
271  // the specific library version must be explicit in the target triple,
272  // e.g., x86_64-pc-windows-msvc18.
273  bool hasPartialC99 = true;
274  if (T.isKnownWindowsMSVCEnvironment()) {
275  VersionTuple Version = T.getEnvironmentVersion();
276  hasPartialC99 = (Version.getMajor() == 0 || Version.getMajor() >= 19);
277  }
278 
279  // Latest targets support C89 math functions, in part.
280  bool isARM = (T.getArch() == Triple::aarch64 ||
281  T.getArch() == Triple::arm);
282  bool hasPartialFloat = (isARM ||
283  T.getArch() == Triple::x86_64);
284 
285  // Win32 does not support float C89 math functions, in general.
286  if (!hasPartialFloat) {
287  TLI.setUnavailable(LibFunc_acosf);
288  TLI.setUnavailable(LibFunc_asinf);
289  TLI.setUnavailable(LibFunc_atan2f);
290  TLI.setUnavailable(LibFunc_atanf);
291  TLI.setUnavailable(LibFunc_ceilf);
292  TLI.setUnavailable(LibFunc_cosf);
293  TLI.setUnavailable(LibFunc_coshf);
294  TLI.setUnavailable(LibFunc_expf);
295  TLI.setUnavailable(LibFunc_floorf);
296  TLI.setUnavailable(LibFunc_fmodf);
297  TLI.setUnavailable(LibFunc_log10f);
298  TLI.setUnavailable(LibFunc_logf);
299  TLI.setUnavailable(LibFunc_modff);
300  TLI.setUnavailable(LibFunc_powf);
301  TLI.setUnavailable(LibFunc_remainderf);
302  TLI.setUnavailable(LibFunc_sinf);
303  TLI.setUnavailable(LibFunc_sinhf);
304  TLI.setUnavailable(LibFunc_sqrtf);
305  TLI.setUnavailable(LibFunc_tanf);
306  TLI.setUnavailable(LibFunc_tanhf);
307  }
308  if (!isARM)
309  TLI.setUnavailable(LibFunc_fabsf);
310  TLI.setUnavailable(LibFunc_frexpf);
311  TLI.setUnavailable(LibFunc_ldexpf);
312 
313  // Win32 does not support long double C89 math functions.
314  TLI.setUnavailable(LibFunc_acosl);
315  TLI.setUnavailable(LibFunc_asinl);
316  TLI.setUnavailable(LibFunc_atan2l);
317  TLI.setUnavailable(LibFunc_atanl);
318  TLI.setUnavailable(LibFunc_ceill);
319  TLI.setUnavailable(LibFunc_cosl);
320  TLI.setUnavailable(LibFunc_coshl);
321  TLI.setUnavailable(LibFunc_expl);
322  TLI.setUnavailable(LibFunc_fabsl);
323  TLI.setUnavailable(LibFunc_floorl);
324  TLI.setUnavailable(LibFunc_fmodl);
325  TLI.setUnavailable(LibFunc_frexpl);
326  TLI.setUnavailable(LibFunc_ldexpl);
327  TLI.setUnavailable(LibFunc_log10l);
328  TLI.setUnavailable(LibFunc_logl);
329  TLI.setUnavailable(LibFunc_modfl);
330  TLI.setUnavailable(LibFunc_powl);
331  TLI.setUnavailable(LibFunc_remainderl);
332  TLI.setUnavailable(LibFunc_sinl);
333  TLI.setUnavailable(LibFunc_sinhl);
334  TLI.setUnavailable(LibFunc_sqrtl);
335  TLI.setUnavailable(LibFunc_tanl);
336  TLI.setUnavailable(LibFunc_tanhl);
337 
338  // Win32 does not fully support C99 math functions.
339  if (!hasPartialC99) {
340  TLI.setUnavailable(LibFunc_acosh);
341  TLI.setUnavailable(LibFunc_acoshf);
342  TLI.setUnavailable(LibFunc_asinh);
343  TLI.setUnavailable(LibFunc_asinhf);
344  TLI.setUnavailable(LibFunc_atanh);
345  TLI.setUnavailable(LibFunc_atanhf);
346  TLI.setAvailableWithName(LibFunc_cabs, "_cabs");
347  TLI.setUnavailable(LibFunc_cabsf);
348  TLI.setUnavailable(LibFunc_cbrt);
349  TLI.setUnavailable(LibFunc_cbrtf);
350  TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
351  TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf");
352  TLI.setUnavailable(LibFunc_exp2);
353  TLI.setUnavailable(LibFunc_exp2f);
354  TLI.setUnavailable(LibFunc_expm1);
355  TLI.setUnavailable(LibFunc_expm1f);
356  TLI.setUnavailable(LibFunc_fmax);
357  TLI.setUnavailable(LibFunc_fmaxf);
358  TLI.setUnavailable(LibFunc_fmin);
359  TLI.setUnavailable(LibFunc_fminf);
360  TLI.setUnavailable(LibFunc_log1p);
361  TLI.setUnavailable(LibFunc_log1pf);
362  TLI.setUnavailable(LibFunc_log2);
363  TLI.setUnavailable(LibFunc_log2f);
364  TLI.setAvailableWithName(LibFunc_logb, "_logb");
365  if (hasPartialFloat)
366  TLI.setAvailableWithName(LibFunc_logbf, "_logbf");
367  else
368  TLI.setUnavailable(LibFunc_logbf);
369  TLI.setUnavailable(LibFunc_rint);
370  TLI.setUnavailable(LibFunc_rintf);
371  TLI.setUnavailable(LibFunc_round);
372  TLI.setUnavailable(LibFunc_roundf);
373  TLI.setUnavailable(LibFunc_trunc);
374  TLI.setUnavailable(LibFunc_truncf);
375  }
376 
377  // Win32 does not support long double C99 math functions.
378  TLI.setUnavailable(LibFunc_acoshl);
379  TLI.setUnavailable(LibFunc_asinhl);
380  TLI.setUnavailable(LibFunc_atanhl);
381  TLI.setUnavailable(LibFunc_cabsl);
382  TLI.setUnavailable(LibFunc_cbrtl);
383  TLI.setUnavailable(LibFunc_copysignl);
384  TLI.setUnavailable(LibFunc_exp2l);
385  TLI.setUnavailable(LibFunc_expm1l);
386  TLI.setUnavailable(LibFunc_fmaxl);
387  TLI.setUnavailable(LibFunc_fminl);
388  TLI.setUnavailable(LibFunc_log1pl);
389  TLI.setUnavailable(LibFunc_log2l);
390  TLI.setUnavailable(LibFunc_logbl);
391  TLI.setUnavailable(LibFunc_nearbyintl);
392  TLI.setUnavailable(LibFunc_rintl);
393  TLI.setUnavailable(LibFunc_roundl);
394  TLI.setUnavailable(LibFunc_truncl);
395 
396  // Win32 does not support these functions, but
397  // they are generally available on POSIX-compliant systems.
398  TLI.setUnavailable(LibFunc_access);
399  TLI.setUnavailable(LibFunc_chmod);
400  TLI.setUnavailable(LibFunc_closedir);
401  TLI.setUnavailable(LibFunc_fdopen);
402  TLI.setUnavailable(LibFunc_fileno);
403  TLI.setUnavailable(LibFunc_fseeko);
404  TLI.setUnavailable(LibFunc_fstat);
405  TLI.setUnavailable(LibFunc_ftello);
406  TLI.setUnavailable(LibFunc_gettimeofday);
407  TLI.setUnavailable(LibFunc_memccpy);
408  TLI.setUnavailable(LibFunc_mkdir);
409  TLI.setUnavailable(LibFunc_open);
410  TLI.setUnavailable(LibFunc_opendir);
411  TLI.setUnavailable(LibFunc_pclose);
412  TLI.setUnavailable(LibFunc_popen);
413  TLI.setUnavailable(LibFunc_read);
414  TLI.setUnavailable(LibFunc_rmdir);
415  TLI.setUnavailable(LibFunc_stat);
416  TLI.setUnavailable(LibFunc_strcasecmp);
417  TLI.setUnavailable(LibFunc_strncasecmp);
418  TLI.setUnavailable(LibFunc_unlink);
419  TLI.setUnavailable(LibFunc_utime);
420  TLI.setUnavailable(LibFunc_write);
421  }
422 
423  if (T.isOSWindows() && !T.isWindowsCygwinEnvironment()) {
424  // These functions aren't available in either MSVC or MinGW environments.
425  TLI.setUnavailable(LibFunc_bcmp);
426  TLI.setUnavailable(LibFunc_bcopy);
427  TLI.setUnavailable(LibFunc_bzero);
428  TLI.setUnavailable(LibFunc_chown);
429  TLI.setUnavailable(LibFunc_ctermid);
430  TLI.setUnavailable(LibFunc_ffs);
431  TLI.setUnavailable(LibFunc_flockfile);
432  TLI.setUnavailable(LibFunc_fstatvfs);
433  TLI.setUnavailable(LibFunc_ftrylockfile);
434  TLI.setUnavailable(LibFunc_funlockfile);
435  TLI.setUnavailable(LibFunc_getitimer);
436  TLI.setUnavailable(LibFunc_getlogin_r);
437  TLI.setUnavailable(LibFunc_getpwnam);
438  TLI.setUnavailable(LibFunc_htonl);
439  TLI.setUnavailable(LibFunc_htons);
440  TLI.setUnavailable(LibFunc_lchown);
441  TLI.setUnavailable(LibFunc_lstat);
442  TLI.setUnavailable(LibFunc_memrchr);
443  TLI.setUnavailable(LibFunc_ntohl);
444  TLI.setUnavailable(LibFunc_ntohs);
445  TLI.setUnavailable(LibFunc_pread);
446  TLI.setUnavailable(LibFunc_pwrite);
447  TLI.setUnavailable(LibFunc_readlink);
448  TLI.setUnavailable(LibFunc_realpath);
449  TLI.setUnavailable(LibFunc_setitimer);
450  TLI.setUnavailable(LibFunc_statvfs);
451  TLI.setUnavailable(LibFunc_stpcpy);
452  TLI.setUnavailable(LibFunc_stpncpy);
453  TLI.setUnavailable(LibFunc_times);
454  TLI.setUnavailable(LibFunc_uname);
455  TLI.setUnavailable(LibFunc_unsetenv);
456  TLI.setUnavailable(LibFunc_utimes);
457  }
458 
459  // Pick just one set of new/delete variants.
460  if (T.isOSMSVCRT()) {
461  // MSVC, doesn't have the Itanium new/delete.
462  TLI.setUnavailable(LibFunc_ZdaPv);
463  TLI.setUnavailable(LibFunc_ZdaPvRKSt9nothrow_t);
464  TLI.setUnavailable(LibFunc_ZdaPvSt11align_val_t);
465  TLI.setUnavailable(LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t);
466  TLI.setUnavailable(LibFunc_ZdaPvj);
467  TLI.setUnavailable(LibFunc_ZdaPvjSt11align_val_t);
468  TLI.setUnavailable(LibFunc_ZdaPvm);
469  TLI.setUnavailable(LibFunc_ZdaPvmSt11align_val_t);
470  TLI.setUnavailable(LibFunc_ZdlPv);
471  TLI.setUnavailable(LibFunc_ZdlPvRKSt9nothrow_t);
472  TLI.setUnavailable(LibFunc_ZdlPvSt11align_val_t);
473  TLI.setUnavailable(LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t);
474  TLI.setUnavailable(LibFunc_ZdlPvj);
475  TLI.setUnavailable(LibFunc_ZdlPvjSt11align_val_t);
476  TLI.setUnavailable(LibFunc_ZdlPvm);
477  TLI.setUnavailable(LibFunc_ZdlPvmSt11align_val_t);
478  TLI.setUnavailable(LibFunc_Znaj);
479  TLI.setUnavailable(LibFunc_ZnajRKSt9nothrow_t);
480  TLI.setUnavailable(LibFunc_ZnajSt11align_val_t);
481  TLI.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t);
482  TLI.setUnavailable(LibFunc_Znam);
483  TLI.setUnavailable(LibFunc_ZnamRKSt9nothrow_t);
484  TLI.setUnavailable(LibFunc_ZnamSt11align_val_t);
485  TLI.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t);
486  TLI.setUnavailable(LibFunc_Znwj);
487  TLI.setUnavailable(LibFunc_ZnwjRKSt9nothrow_t);
488  TLI.setUnavailable(LibFunc_ZnwjSt11align_val_t);
489  TLI.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t);
490  TLI.setUnavailable(LibFunc_Znwm);
491  TLI.setUnavailable(LibFunc_ZnwmRKSt9nothrow_t);
492  TLI.setUnavailable(LibFunc_ZnwmSt11align_val_t);
493  TLI.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t);
494  } else {
495  // Not MSVC, assume it's Itanium.
496  TLI.setUnavailable(LibFunc_msvc_new_int);
497  TLI.setUnavailable(LibFunc_msvc_new_int_nothrow);
498  TLI.setUnavailable(LibFunc_msvc_new_longlong);
499  TLI.setUnavailable(LibFunc_msvc_new_longlong_nothrow);
500  TLI.setUnavailable(LibFunc_msvc_delete_ptr32);
501  TLI.setUnavailable(LibFunc_msvc_delete_ptr32_nothrow);
502  TLI.setUnavailable(LibFunc_msvc_delete_ptr32_int);
503  TLI.setUnavailable(LibFunc_msvc_delete_ptr64);
504  TLI.setUnavailable(LibFunc_msvc_delete_ptr64_nothrow);
505  TLI.setUnavailable(LibFunc_msvc_delete_ptr64_longlong);
506  TLI.setUnavailable(LibFunc_msvc_new_array_int);
507  TLI.setUnavailable(LibFunc_msvc_new_array_int_nothrow);
508  TLI.setUnavailable(LibFunc_msvc_new_array_longlong);
509  TLI.setUnavailable(LibFunc_msvc_new_array_longlong_nothrow);
510  TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32);
511  TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32_nothrow);
512  TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32_int);
513  TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64);
514  TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64_nothrow);
515  TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64_longlong);
516  }
517 
518  switch (T.getOS()) {
519  case Triple::MacOSX:
520  // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
521  // and their names are __exp10 and __exp10f. exp10l is not available on
522  // OS X or iOS.
523  TLI.setUnavailable(LibFunc_exp10l);
524  if (T.isMacOSXVersionLT(10, 9)) {
525  TLI.setUnavailable(LibFunc_exp10);
526  TLI.setUnavailable(LibFunc_exp10f);
527  } else {
528  TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
529  TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
530  }
531  break;
532  case Triple::IOS:
533  case Triple::TvOS:
534  case Triple::WatchOS:
535  TLI.setUnavailable(LibFunc_exp10l);
536  if (!T.isWatchOS() &&
537  (T.isOSVersionLT(7, 0) || (T.isOSVersionLT(9, 0) && T.isX86()))) {
538  TLI.setUnavailable(LibFunc_exp10);
539  TLI.setUnavailable(LibFunc_exp10f);
540  } else {
541  TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
542  TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
543  }
544  break;
545  case Triple::Linux:
546  // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
547  // buggy prior to glibc version 2.18. Until this version is widely deployed
548  // or we have a reasonable detection strategy, we cannot use exp10 reliably
549  // on Linux.
550  //
551  // Fall through to disable all of them.
552  [[fallthrough]];
553  default:
554  TLI.setUnavailable(LibFunc_exp10);
555  TLI.setUnavailable(LibFunc_exp10f);
556  TLI.setUnavailable(LibFunc_exp10l);
557  }
558 
559  // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
560  // Linux (GLIBC):
561  // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
562  // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
563  // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
564  switch (T.getOS()) {
565  case Triple::Darwin:
566  case Triple::MacOSX:
567  case Triple::IOS:
568  case Triple::TvOS:
569  case Triple::WatchOS:
570  case Triple::FreeBSD:
571  case Triple::Linux:
572  break;
573  default:
574  TLI.setUnavailable(LibFunc_ffsl);
575  }
576 
577  // ffsll is available on at least FreeBSD and Linux (GLIBC):
578  // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
579  // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
580  switch (T.getOS()) {
581  case Triple::Darwin:
582  case Triple::MacOSX:
583  case Triple::IOS:
584  case Triple::TvOS:
585  case Triple::WatchOS:
586  case Triple::FreeBSD:
587  case Triple::Linux:
588  break;
589  default:
590  TLI.setUnavailable(LibFunc_ffsll);
591  }
592 
593  // The following functions are available on at least FreeBSD:
594  // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
595  // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
596  // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
597  if (!T.isOSFreeBSD()) {
598  TLI.setUnavailable(LibFunc_fls);
599  TLI.setUnavailable(LibFunc_flsl);
600  TLI.setUnavailable(LibFunc_flsll);
601  }
602 
603  // The following functions are only available on GNU/Linux (using glibc).
604  // Linux variants without glibc (eg: bionic, musl) may have some subset.
605  if (!T.isOSLinux() || !T.isGNUEnvironment()) {
606  TLI.setUnavailable(LibFunc_dunder_strdup);
607  TLI.setUnavailable(LibFunc_dunder_strtok_r);
608  TLI.setUnavailable(LibFunc_dunder_isoc99_scanf);
609  TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf);
610  TLI.setUnavailable(LibFunc_under_IO_getc);
611  TLI.setUnavailable(LibFunc_under_IO_putc);
612  // But, Android and musl have memalign.
613  if (!T.isAndroid() && !T.isMusl())
614  TLI.setUnavailable(LibFunc_memalign);
615  TLI.setUnavailable(LibFunc_fopen64);
616  TLI.setUnavailable(LibFunc_fseeko64);
617  TLI.setUnavailable(LibFunc_fstat64);
618  TLI.setUnavailable(LibFunc_fstatvfs64);
619  TLI.setUnavailable(LibFunc_ftello64);
620  TLI.setUnavailable(LibFunc_lstat64);
621  TLI.setUnavailable(LibFunc_open64);
622  TLI.setUnavailable(LibFunc_stat64);
623  TLI.setUnavailable(LibFunc_statvfs64);
624  TLI.setUnavailable(LibFunc_tmpfile64);
625 
626  // Relaxed math functions are included in math-finite.h on Linux (GLIBC).
627  // Note that math-finite.h is no longer supported by top-of-tree GLIBC,
628  // so we keep these functions around just so that they're recognized by
629  // the ConstantFolder.
630  TLI.setUnavailable(LibFunc_acos_finite);
631  TLI.setUnavailable(LibFunc_acosf_finite);
632  TLI.setUnavailable(LibFunc_acosl_finite);
633  TLI.setUnavailable(LibFunc_acosh_finite);
634  TLI.setUnavailable(LibFunc_acoshf_finite);
635  TLI.setUnavailable(LibFunc_acoshl_finite);
636  TLI.setUnavailable(LibFunc_asin_finite);
637  TLI.setUnavailable(LibFunc_asinf_finite);
638  TLI.setUnavailable(LibFunc_asinl_finite);
639  TLI.setUnavailable(LibFunc_atan2_finite);
640  TLI.setUnavailable(LibFunc_atan2f_finite);
641  TLI.setUnavailable(LibFunc_atan2l_finite);
642  TLI.setUnavailable(LibFunc_atanh_finite);
643  TLI.setUnavailable(LibFunc_atanhf_finite);
644  TLI.setUnavailable(LibFunc_atanhl_finite);
645  TLI.setUnavailable(LibFunc_cosh_finite);
646  TLI.setUnavailable(LibFunc_coshf_finite);
647  TLI.setUnavailable(LibFunc_coshl_finite);
648  TLI.setUnavailable(LibFunc_exp10_finite);
649  TLI.setUnavailable(LibFunc_exp10f_finite);
650  TLI.setUnavailable(LibFunc_exp10l_finite);
651  TLI.setUnavailable(LibFunc_exp2_finite);
652  TLI.setUnavailable(LibFunc_exp2f_finite);
653  TLI.setUnavailable(LibFunc_exp2l_finite);
654  TLI.setUnavailable(LibFunc_exp_finite);
655  TLI.setUnavailable(LibFunc_expf_finite);
656  TLI.setUnavailable(LibFunc_expl_finite);
657  TLI.setUnavailable(LibFunc_log10_finite);
658  TLI.setUnavailable(LibFunc_log10f_finite);
659  TLI.setUnavailable(LibFunc_log10l_finite);
660  TLI.setUnavailable(LibFunc_log2_finite);
661  TLI.setUnavailable(LibFunc_log2f_finite);
662  TLI.setUnavailable(LibFunc_log2l_finite);
663  TLI.setUnavailable(LibFunc_log_finite);
664  TLI.setUnavailable(LibFunc_logf_finite);
665  TLI.setUnavailable(LibFunc_logl_finite);
666  TLI.setUnavailable(LibFunc_pow_finite);
667  TLI.setUnavailable(LibFunc_powf_finite);
668  TLI.setUnavailable(LibFunc_powl_finite);
669  TLI.setUnavailable(LibFunc_sinh_finite);
670  TLI.setUnavailable(LibFunc_sinhf_finite);
671  TLI.setUnavailable(LibFunc_sinhl_finite);
672  TLI.setUnavailable(LibFunc_sqrt_finite);
673  TLI.setUnavailable(LibFunc_sqrtf_finite);
674  TLI.setUnavailable(LibFunc_sqrtl_finite);
675  }
676 
677  if ((T.isOSLinux() && T.isGNUEnvironment()) ||
678  (T.isAndroid() && !T.isAndroidVersionLT(28))) {
679  // available IO unlocked variants on GNU/Linux and Android P or later
680  TLI.setAvailable(LibFunc_getc_unlocked);
681  TLI.setAvailable(LibFunc_getchar_unlocked);
682  TLI.setAvailable(LibFunc_putc_unlocked);
683  TLI.setAvailable(LibFunc_putchar_unlocked);
684  TLI.setAvailable(LibFunc_fputc_unlocked);
685  TLI.setAvailable(LibFunc_fgetc_unlocked);
686  TLI.setAvailable(LibFunc_fread_unlocked);
687  TLI.setAvailable(LibFunc_fwrite_unlocked);
688  TLI.setAvailable(LibFunc_fputs_unlocked);
689  TLI.setAvailable(LibFunc_fgets_unlocked);
690  }
691 
692  if (T.isAndroid() && T.isAndroidVersionLT(21)) {
693  TLI.setUnavailable(LibFunc_stpcpy);
694  TLI.setUnavailable(LibFunc_stpncpy);
695  }
696 
697  if (T.isPS()) {
698  // PS4/PS5 do have memalign.
699  TLI.setAvailable(LibFunc_memalign);
700 
701  // PS4/PS5 do not have new/delete with "unsigned int" size parameter;
702  // they only have the "unsigned long" versions.
703  TLI.setUnavailable(LibFunc_ZdaPvj);
704  TLI.setUnavailable(LibFunc_ZdaPvjSt11align_val_t);
705  TLI.setUnavailable(LibFunc_ZdlPvj);
706  TLI.setUnavailable(LibFunc_ZdlPvjSt11align_val_t);
707  TLI.setUnavailable(LibFunc_Znaj);
708  TLI.setUnavailable(LibFunc_ZnajRKSt9nothrow_t);
709  TLI.setUnavailable(LibFunc_ZnajSt11align_val_t);
710  TLI.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t);
711  TLI.setUnavailable(LibFunc_Znwj);
712  TLI.setUnavailable(LibFunc_ZnwjRKSt9nothrow_t);
713  TLI.setUnavailable(LibFunc_ZnwjSt11align_val_t);
714  TLI.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t);
715 
716  // None of the *_chk functions.
717  TLI.setUnavailable(LibFunc_memccpy_chk);
718  TLI.setUnavailable(LibFunc_memcpy_chk);
719  TLI.setUnavailable(LibFunc_memmove_chk);
720  TLI.setUnavailable(LibFunc_mempcpy_chk);
721  TLI.setUnavailable(LibFunc_memset_chk);
722  TLI.setUnavailable(LibFunc_snprintf_chk);
723  TLI.setUnavailable(LibFunc_sprintf_chk);
724  TLI.setUnavailable(LibFunc_stpcpy_chk);
725  TLI.setUnavailable(LibFunc_stpncpy_chk);
726  TLI.setUnavailable(LibFunc_strcat_chk);
727  TLI.setUnavailable(LibFunc_strcpy_chk);
728  TLI.setUnavailable(LibFunc_strlcat_chk);
729  TLI.setUnavailable(LibFunc_strlcpy_chk);
730  TLI.setUnavailable(LibFunc_strlen_chk);
731  TLI.setUnavailable(LibFunc_strncat_chk);
732  TLI.setUnavailable(LibFunc_strncpy_chk);
733  TLI.setUnavailable(LibFunc_vsnprintf_chk);
734  TLI.setUnavailable(LibFunc_vsprintf_chk);
735 
736  // Various Posix system functions.
737  TLI.setUnavailable(LibFunc_access);
738  TLI.setUnavailable(LibFunc_chmod);
739  TLI.setUnavailable(LibFunc_chown);
740  TLI.setUnavailable(LibFunc_closedir);
741  TLI.setUnavailable(LibFunc_ctermid);
742  TLI.setUnavailable(LibFunc_execl);
743  TLI.setUnavailable(LibFunc_execle);
744  TLI.setUnavailable(LibFunc_execlp);
745  TLI.setUnavailable(LibFunc_execv);
746  TLI.setUnavailable(LibFunc_execvP);
747  TLI.setUnavailable(LibFunc_execve);
748  TLI.setUnavailable(LibFunc_execvp);
749  TLI.setUnavailable(LibFunc_execvpe);
750  TLI.setUnavailable(LibFunc_fork);
751  TLI.setUnavailable(LibFunc_fstat);
752  TLI.setUnavailable(LibFunc_fstatvfs);
753  TLI.setUnavailable(LibFunc_getenv);
754  TLI.setUnavailable(LibFunc_getitimer);
755  TLI.setUnavailable(LibFunc_getlogin_r);
756  TLI.setUnavailable(LibFunc_getpwnam);
757  TLI.setUnavailable(LibFunc_gettimeofday);
758  TLI.setUnavailable(LibFunc_lchown);
759  TLI.setUnavailable(LibFunc_lstat);
760  TLI.setUnavailable(LibFunc_mkdir);
761  TLI.setUnavailable(LibFunc_open);
762  TLI.setUnavailable(LibFunc_opendir);
763  TLI.setUnavailable(LibFunc_pclose);
764  TLI.setUnavailable(LibFunc_popen);
765  TLI.setUnavailable(LibFunc_pread);
766  TLI.setUnavailable(LibFunc_pwrite);
767  TLI.setUnavailable(LibFunc_read);
768  TLI.setUnavailable(LibFunc_readlink);
769  TLI.setUnavailable(LibFunc_realpath);
770  TLI.setUnavailable(LibFunc_rename);
771  TLI.setUnavailable(LibFunc_rmdir);
772  TLI.setUnavailable(LibFunc_setitimer);
773  TLI.setUnavailable(LibFunc_stat);
774  TLI.setUnavailable(LibFunc_statvfs);
775  TLI.setUnavailable(LibFunc_system);
776  TLI.setUnavailable(LibFunc_times);
777  TLI.setUnavailable(LibFunc_tmpfile);
778  TLI.setUnavailable(LibFunc_unlink);
779  TLI.setUnavailable(LibFunc_uname);
780  TLI.setUnavailable(LibFunc_unsetenv);
781  TLI.setUnavailable(LibFunc_utime);
782  TLI.setUnavailable(LibFunc_utimes);
783  TLI.setUnavailable(LibFunc_valloc);
784  TLI.setUnavailable(LibFunc_write);
785 
786  // Miscellaneous other functions not provided.
787  TLI.setUnavailable(LibFunc_atomic_load);
788  TLI.setUnavailable(LibFunc_atomic_store);
789  TLI.setUnavailable(LibFunc___kmpc_alloc_shared);
790  TLI.setUnavailable(LibFunc___kmpc_free_shared);
791  TLI.setUnavailable(LibFunc_dunder_strndup);
792  TLI.setUnavailable(LibFunc_bcmp);
793  TLI.setUnavailable(LibFunc_bcopy);
794  TLI.setUnavailable(LibFunc_bzero);
795  TLI.setUnavailable(LibFunc_cabs);
796  TLI.setUnavailable(LibFunc_cabsf);
797  TLI.setUnavailable(LibFunc_cabsl);
798  TLI.setUnavailable(LibFunc_ffs);
799  TLI.setUnavailable(LibFunc_flockfile);
800  TLI.setUnavailable(LibFunc_fseeko);
801  TLI.setUnavailable(LibFunc_ftello);
802  TLI.setUnavailable(LibFunc_ftrylockfile);
803  TLI.setUnavailable(LibFunc_funlockfile);
804  TLI.setUnavailable(LibFunc_htonl);
805  TLI.setUnavailable(LibFunc_htons);
806  TLI.setUnavailable(LibFunc_isascii);
807  TLI.setUnavailable(LibFunc_memccpy);
808  TLI.setUnavailable(LibFunc_mempcpy);
809  TLI.setUnavailable(LibFunc_memrchr);
810  TLI.setUnavailable(LibFunc_ntohl);
811  TLI.setUnavailable(LibFunc_ntohs);
812  TLI.setUnavailable(LibFunc_reallocf);
813  TLI.setUnavailable(LibFunc_roundeven);
814  TLI.setUnavailable(LibFunc_roundevenf);
815  TLI.setUnavailable(LibFunc_roundevenl);
816  TLI.setUnavailable(LibFunc_stpcpy);
817  TLI.setUnavailable(LibFunc_stpncpy);
818  TLI.setUnavailable(LibFunc_strlcat);
819  TLI.setUnavailable(LibFunc_strlcpy);
820  TLI.setUnavailable(LibFunc_strndup);
821  TLI.setUnavailable(LibFunc_strnlen);
822  TLI.setUnavailable(LibFunc_toascii);
823  }
824 
825  // As currently implemented in clang, NVPTX code has no standard library to
826  // speak of. Headers provide a standard-ish library implementation, but many
827  // of the signatures are wrong -- for example, many libm functions are not
828  // extern "C".
829  //
830  // libdevice, an IR library provided by nvidia, is linked in by the front-end,
831  // but only used functions are provided to llvm. Moreover, most of the
832  // functions in libdevice don't map precisely to standard library functions.
833  //
834  // FIXME: Having no standard library prevents e.g. many fastmath
835  // optimizations, so this situation should be fixed.
836  if (T.isNVPTX()) {
837  TLI.disableAllFunctions();
838  TLI.setAvailable(LibFunc_nvvm_reflect);
839  TLI.setAvailable(llvm::LibFunc_malloc);
840  TLI.setAvailable(llvm::LibFunc_free);
841 
842  // TODO: We could enable the following two according to [0] but we haven't
843  // done an evaluation wrt. the performance implications.
844  // [0]
845  // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#dynamic-global-memory-allocation-and-operations
846  //
847  // TLI.setAvailable(llvm::LibFunc_memcpy);
848  // TLI.setAvailable(llvm::LibFunc_memset);
849 
850  TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
851  TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
852  } else {
853  TLI.setUnavailable(LibFunc_nvvm_reflect);
854  }
855 
856  // These vec_malloc/free routines are only available on AIX.
857  if (!T.isOSAIX()) {
858  TLI.setUnavailable(LibFunc_vec_calloc);
859  TLI.setUnavailable(LibFunc_vec_malloc);
860  TLI.setUnavailable(LibFunc_vec_realloc);
861  TLI.setUnavailable(LibFunc_vec_free);
862  }
863 
865 }
866 
868  // Default to everything being available.
869  memset(AvailableArray, -1, sizeof(AvailableArray));
870 
871  initialize(*this, Triple(), StandardNames);
872 }
873 
875  // Default to everything being available.
876  memset(AvailableArray, -1, sizeof(AvailableArray));
877 
878  initialize(*this, T, StandardNames);
879 }
880 
882  : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
883  ShouldExtI32Return(TLI.ShouldExtI32Return),
884  ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
885  SizeOfInt(TLI.SizeOfInt) {
886  memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
887  VectorDescs = TLI.VectorDescs;
888  ScalarDescs = TLI.ScalarDescs;
889 }
890 
892  : CustomNames(std::move(TLI.CustomNames)),
893  ShouldExtI32Param(TLI.ShouldExtI32Param),
894  ShouldExtI32Return(TLI.ShouldExtI32Return),
895  ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
896  SizeOfInt(TLI.SizeOfInt) {
897  std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
898  AvailableArray);
899  VectorDescs = TLI.VectorDescs;
900  ScalarDescs = TLI.ScalarDescs;
901 }
902 
904  CustomNames = TLI.CustomNames;
905  ShouldExtI32Param = TLI.ShouldExtI32Param;
906  ShouldExtI32Return = TLI.ShouldExtI32Return;
907  ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
908  SizeOfInt = TLI.SizeOfInt;
909  memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
910  return *this;
911 }
912 
914  CustomNames = std::move(TLI.CustomNames);
915  ShouldExtI32Param = TLI.ShouldExtI32Param;
916  ShouldExtI32Return = TLI.ShouldExtI32Return;
917  ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
918  SizeOfInt = TLI.SizeOfInt;
919  std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
920  AvailableArray);
921  return *this;
922 }
923 
925  // Filter out empty names and names containing null bytes, those can't be in
926  // our table.
927  if (funcName.empty() || funcName.contains('\0'))
928  return StringRef();
929 
930  // Check for \01 prefix that is used to mangle __asm declarations and
931  // strip it if present.
932  return GlobalValue::dropLLVMManglingEscape(funcName);
933 }
934 
936  funcName = sanitizeFunctionName(funcName);
937  if (funcName.empty())
938  return false;
939 
940  const auto *Start = std::begin(StandardNames);
941  const auto *End = std::end(StandardNames);
942  const auto *I = std::lower_bound(Start, End, funcName);
943  if (I != End && *I == funcName) {
944  F = (LibFunc)(I - Start);
945  return true;
946  }
947  return false;
948 }
949 
950 // Return true if ArgTy matches Ty.
951 
952 static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits,
953  unsigned SizeTBits) {
954  switch (ArgTy) {
955  case Void:
956  return Ty->isVoidTy();
957  case Bool:
958  return Ty->isIntegerTy(8);
959  case Int16:
960  return Ty->isIntegerTy(16);
961  case Int32:
962  return Ty->isIntegerTy(32);
963  case Int:
964  return Ty->isIntegerTy(IntBits);
965  case IntPlus:
966  return Ty->isIntegerTy() && Ty->getPrimitiveSizeInBits() >= IntBits;
967  case IntX:
968  return Ty->isIntegerTy();
969  case Long:
970  // TODO: Figure out and use long size.
971  return Ty->isIntegerTy() && Ty->getPrimitiveSizeInBits() >= IntBits;
972  case Int64:
973  return Ty->isIntegerTy(64);
974  case LLong:
975  return Ty->isIntegerTy(64);
976  case SizeT:
977  case SSizeT:
978  return Ty->isIntegerTy(SizeTBits);
979  case Flt:
980  return Ty->isFloatTy();
981  case Dbl:
982  return Ty->isDoubleTy();
983  // TODO: Tighten this up.
984  case LDbl:
985  return Ty->isFloatingPointTy();
986  case Floating:
987  return Ty->isFloatingPointTy();
988  case Ptr:
989  return Ty->isPointerTy();
990  case Struct:
991  return Ty->isStructTy();
992  default:
993  break;
994  }
995 
996  llvm_unreachable("Invalid type");
997 }
998 
999 bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
1000  LibFunc F,
1001  const Module &M) const {
1002  unsigned NumParams = FTy.getNumParams();
1003 
1004  switch (F) {
1005  // Special handling for <complex.h> functions:
1006  case LibFunc_cabs:
1007  case LibFunc_cabsf:
1008  case LibFunc_cabsl: {
1009  Type *RetTy = FTy.getReturnType();
1010  if (!RetTy->isFloatingPointTy())
1011  return false;
1012 
1013  Type *ParamTy = FTy.getParamType(0);
1014  // NOTE: These prototypes are target specific and currently support
1015  // "complex" passed as an array or discrete real & imaginary parameters.
1016  // Add other calling conventions to enable libcall optimizations.
1017  if (NumParams == 1)
1018  return (ParamTy->isArrayTy() && ParamTy->getArrayNumElements() == 2 &&
1019  ParamTy->getArrayElementType() == RetTy);
1020  else if (NumParams == 2)
1021  return ParamTy == RetTy && FTy.getParamType(1) == RetTy;
1022 
1023  return false;
1024  }
1025  // Special handling for the sincospi functions that return either
1026  // a struct or vector:
1027  case LibFunc_sincospi_stret:
1028  case LibFunc_sincospif_stret: {
1029  if (NumParams != 1)
1030  return false;
1031 
1032  Type *RetTy = FTy.getReturnType();
1033  Type *ParamTy = FTy.getParamType(0);
1034  if (auto *Ty = dyn_cast<StructType>(RetTy)) {
1035  if (Ty->getNumElements() != 2)
1036  return false;
1037  return (Ty->getElementType(0) == ParamTy &&
1038  Ty->getElementType(1) == ParamTy);
1039  }
1040 
1041  if (auto *Ty = dyn_cast<FixedVectorType>(RetTy)) {
1042  if (Ty->getNumElements() != 2)
1043  return false;
1044  return Ty->getElementType() == ParamTy;
1045  }
1046 
1047  return false;
1048  }
1049 
1050  default:
1051  break;
1052  }
1053 
1054  // FIXME: There is no guarantee that sizeof(size_t) is equal to
1055  // sizeof(int*) for every target. So the assumption used here to derive
1056  // the SizeTBits based on the size of an integer pointer in address space
1057  // zero isn't always valid.
1058  unsigned IntBits = getIntSize();
1059  unsigned SizeTBits = M.getDataLayout().getPointerSizeInBits(/*AddrSpace=*/0);
1060  unsigned Idx = 0;
1061 
1062  // Iterate over the type ids in the function prototype, matching each
1063  // against the function's type FTy, starting with its return type.
1064  // Return true if both match in number and kind, inclduing the ellipsis.
1065  Type *Ty = FTy.getReturnType(), *LastTy = Ty;
1066  const auto &ProtoTypes = Signatures[F];
1067  for (auto TyID : ProtoTypes) {
1068  if (Idx && TyID == Void)
1069  // Except in the first position where it designates the function's
1070  // return type Void ends the argument list.
1071  break;
1072 
1073  if (TyID == Ellip) {
1074  // The ellipsis ends the protoype list but is not a part of FTy's
1075  // argument list. Except when it's last it must be followed by
1076  // Void.
1077  assert(Idx == ProtoTypes.size() - 1 || ProtoTypes[Idx + 1] == Void);
1078  return FTy.isFunctionVarArg();
1079  }
1080 
1081  if (TyID == Same) {
1082  assert(Idx != 0 && "Type ID 'Same' must not be first!");
1083  if (Ty != LastTy)
1084  return false;
1085  } else {
1086  if (!Ty || !matchType(TyID, Ty, IntBits, SizeTBits))
1087  return false;
1088  LastTy = Ty;
1089  }
1090 
1091  if (Idx == NumParams) {
1092  // There's at least one and at most two more type ids than there are
1093  // arguments in FTy's argument list.
1094  Ty = nullptr;
1095  ++Idx;
1096  continue;
1097  }
1098 
1099  Ty = FTy.getParamType(Idx++);
1100  }
1101 
1102  // Return success only if all entries on both lists have been processed
1103  // and the function is not a variadic one.
1104  return Idx == NumParams + 1 && !FTy.isFunctionVarArg();
1105 }
1106 
1108  LibFunc &F) const {
1109  // Intrinsics don't overlap w/libcalls; if our module has a large number of
1110  // intrinsics, this ends up being an interesting compile time win since we
1111  // avoid string normalization and comparison.
1112  if (FDecl.isIntrinsic()) return false;
1113 
1114  const Module *M = FDecl.getParent();
1115  assert(M && "Expecting FDecl to be connected to a Module.");
1116 
1117  return getLibFunc(FDecl.getName(), F) &&
1118  isValidProtoForLibFunc(*FDecl.getFunctionType(), F, *M);
1119 }
1120 
1122  memset(AvailableArray, 0, sizeof(AvailableArray));
1123 }
1124 
1125 static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
1126  return LHS.ScalarFnName < RHS.ScalarFnName;
1127 }
1128 
1129 static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
1130  return LHS.VectorFnName < RHS.VectorFnName;
1131 }
1132 
1134  return LHS.ScalarFnName < S;
1135 }
1136 
1138  llvm::append_range(VectorDescs, Fns);
1139  llvm::sort(VectorDescs, compareByScalarFnName);
1140 
1141  llvm::append_range(ScalarDescs, Fns);
1142  llvm::sort(ScalarDescs, compareByVectorFnName);
1143 }
1144 
1146  enum VectorLibrary VecLib) {
1147  switch (VecLib) {
1148  case Accelerate: {
1149  const VecDesc VecFuncs[] = {
1150  #define TLI_DEFINE_ACCELERATE_VECFUNCS
1151  #include "llvm/Analysis/VecFuncs.def"
1152  };
1153  addVectorizableFunctions(VecFuncs);
1154  break;
1155  }
1156  case DarwinLibSystemM: {
1157  const VecDesc VecFuncs[] = {
1158  #define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
1159  #include "llvm/Analysis/VecFuncs.def"
1160  };
1161  addVectorizableFunctions(VecFuncs);
1162  break;
1163  }
1164  case LIBMVEC_X86: {
1165  const VecDesc VecFuncs[] = {
1166  #define TLI_DEFINE_LIBMVEC_X86_VECFUNCS
1167  #include "llvm/Analysis/VecFuncs.def"
1168  };
1169  addVectorizableFunctions(VecFuncs);
1170  break;
1171  }
1172  case MASSV: {
1173  const VecDesc VecFuncs[] = {
1174  #define TLI_DEFINE_MASSV_VECFUNCS
1175  #include "llvm/Analysis/VecFuncs.def"
1176  };
1177  addVectorizableFunctions(VecFuncs);
1178  break;
1179  }
1180  case SVML: {
1181  const VecDesc VecFuncs[] = {
1182  #define TLI_DEFINE_SVML_VECFUNCS
1183  #include "llvm/Analysis/VecFuncs.def"
1184  };
1185  addVectorizableFunctions(VecFuncs);
1186  break;
1187  }
1188  case NoLibrary:
1189  break;
1190  }
1191 }
1192 
1194  funcName = sanitizeFunctionName(funcName);
1195  if (funcName.empty())
1196  return false;
1197 
1198  std::vector<VecDesc>::const_iterator I =
1199  llvm::lower_bound(VectorDescs, funcName, compareWithScalarFnName);
1200  return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName;
1201 }
1202 
1203 StringRef
1205  const ElementCount &VF) const {
1207  if (F.empty())
1208  return F;
1209  std::vector<VecDesc>::const_iterator I =
1211  while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == F) {
1212  if (I->VectorizationFactor == VF)
1213  return I->VectorFnName;
1214  ++I;
1215  }
1216  return StringRef();
1217 }
1218 
1221  if (!BaselineInfoImpl)
1222  BaselineInfoImpl =
1223  TargetLibraryInfoImpl(Triple(F.getParent()->getTargetTriple()));
1224  return TargetLibraryInfo(*BaselineInfoImpl, &F);
1225 }
1226 
1228  if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
1229  M.getModuleFlag("wchar_size")))
1230  return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
1231  return 0;
1232 }
1233 
1237 }
1238 
1242 }
1243 
1245  const TargetLibraryInfoImpl &TLIImpl)
1246  : ImmutablePass(ID), TLA(TLIImpl) {
1248 }
1249 
1250 AnalysisKey TargetLibraryAnalysis::Key;
1251 
1252 // Register the basic pass.
1254  "Target Library Information", false, true)
1256 
1257 void TargetLibraryInfoWrapperPass::anchor() {}
1258 
1260  ElementCount &FixedVF,
1261  ElementCount &ScalableVF) const {
1262  ScalarF = sanitizeFunctionName(ScalarF);
1263  // Use '0' here because a type of the form <vscale x 1 x ElTy> is not the
1264  // same as a scalar.
1265  ScalableVF = ElementCount::getScalable(0);
1266  FixedVF = ElementCount::getFixed(1);
1267  if (ScalarF.empty())
1268  return;
1269 
1270  std::vector<VecDesc>::const_iterator I =
1271  llvm::lower_bound(VectorDescs, ScalarF, compareWithScalarFnName);
1272  while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == ScalarF) {
1273  ElementCount *VF =
1274  I->VectorizationFactor.isScalable() ? &ScalableVF : &FixedVF;
1275  if (ElementCount::isKnownGT(I->VectorizationFactor, *VF))
1276  *VF = I->VectorizationFactor;
1277  ++I;
1278  }
1279 }
llvm::TargetLibraryInfoImpl::setShouldSignExtI32Param
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
Definition: TargetLibraryInfo.h:188
llvm::Type::isFunctionVarArg
bool isFunctionVarArg() const
Definition: DerivedTypes.h:149
llvm::VecDesc
Describes a possible vectorization of a function.
Definition: TargetLibraryInfo.h:29
llvm::Function::isIntrinsic
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
Definition: Function.h:210
llvm::TargetLibraryInfoImpl::setAvailable
void setAvailable(LibFunc F)
Forces a function to be marked as available.
Definition: TargetLibraryInfo.h:129
llvm::TargetLibraryInfoImpl::SVML
@ SVML
Definition: TargetLibraryInfo.h:96
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:65
llvm::TargetLibraryInfoImpl::getIntSize
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
Definition: TargetLibraryInfo.h:197
llvm::LinearPolySize< ElementCount >::isKnownGT
static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS)
Definition: TypeSize.h:334
llvm::Type::isPointerTy
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:223
compareByVectorFnName
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS)
Definition: TargetLibraryInfo.cpp:1129
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:279
llvm::ElementCount
Definition: TypeSize.h:404
llvm::GlobalValue::dropLLVMManglingEscape
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Definition: GlobalValue.h:554
T
llvm::Function
Definition: Function.h:60
llvm::lower_bound
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1727
llvm::Triple::Darwin
@ Darwin
Definition: Triple.h:187
llvm::Triple::x86
@ x86
Definition: Triple.h:85
LDbl
@ LDbl
Definition: TargetLibraryInfo.cpp:58
llvm::TargetLibraryInfoImpl::MASSV
@ MASSV
Definition: TargetLibraryInfo.h:95
llvm::Triple::IOS
@ IOS
Definition: Triple.h:191
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
Dbl
@ Dbl
Definition: TargetLibraryInfo.cpp:57
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:86
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:235
llvm::CallBase::getFunctionType
FunctionType * getFunctionType() const
Definition: InstrTypes.h:1254
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:226
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
llvm::TargetLibraryInfoImpl::operator=
TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
Definition: TargetLibraryInfo.cpp:903
llvm::TargetLibraryInfoImpl
Implementation of the target library information.
Definition: TargetLibraryInfo.h:49
llvm::FunctionType::getNumParams
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Definition: DerivedTypes.h:139
initialize
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
Definition: TargetLibraryInfo.cpp:150
IntX
@ IntX
Definition: TargetLibraryInfo.cpp:51
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::Type::isFloatingPointTy
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
Definition: Type.h:168
llvm::TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib
void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib)
Calls addVectorizableFunctions with a known preset of functions for the given vector library.
Definition: TargetLibraryInfo.cpp:1145
llvm::Triple::WatchOS
@ WatchOS
Definition: Triple.h:213
llvm::initializeTargetLibraryInfoWrapperPassPass
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
LLong
@ LLong
Definition: TargetLibraryInfo.cpp:53
llvm::TargetLibraryInfoImpl::isFunctionVectorizable
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
Definition: TargetLibraryInfo.h:160
F
#define F(x, y, z)
Definition: MD5.cpp:55
SSizeT
@ SSizeT
Definition: TargetLibraryInfo.cpp:55
llvm::TargetLibraryInfoImpl::setAvailableWithName
void setAvailableWithName(LibFunc F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used.
Definition: TargetLibraryInfo.h:135
CommandLine.h
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::Type::isArrayTy
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition: Type.h:220
llvm::StringLiteral
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:842
llvm::Triple::FreeBSD
@ FreeBSD
Definition: Triple.h:189
llvm::Triple::sparcv9
@ sparcv9
Definition: Triple.h:78
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
Constants.h
llvm::TargetLibraryInfoImpl::getVectorizedFunction
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Return the name of the equivalent of F, vectorized with factor VF.
Definition: TargetLibraryInfo.cpp:1204
llvm::Triple::TvOS
@ TvOS
Definition: Triple.h:212
llvm::TargetLibraryInfoImpl::getWidestVF
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const
Returns the largest vectorization factor used in the list of vector functions.
Definition: TargetLibraryInfo.cpp:1259
llvm::LibFunc
LibFunc
Definition: TargetLibraryInfo.h:35
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:37
Param
Value * Param
Definition: NVPTXLowerArgs.cpp:165
llvm::Triple::Emscripten
@ Emscripten
Definition: Triple.h:221
llvm::TargetLibraryAnalysis::run
TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)
Definition: TargetLibraryInfo.cpp:1219
TargetLibraryInfo.h
llvm::Triple::xcore
@ xcore
Definition: Triple.h:87
llvm::FunctionType::params
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:130
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1056
Signatures
static const FuncProtoTy Signatures[]
Definition: TargetLibraryInfo.cpp:68
Long
@ Long
Definition: TargetLibraryInfo.cpp:50
Flt
@ Flt
Definition: TargetLibraryInfo.cpp:56
llvm::CallBase::getCallingConv
CallingConv::ID getCallingConv() const
Definition: InstrTypes.h:1455
llvm::LinearPolySize< ElementCount >::getFixed
static ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:283
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Int
@ Int
Definition: TargetLibraryInfo.cpp:48
llvm::Type::isIntegerTy
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:196
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1538
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::Type::getArrayElementType
Type * getArrayElementType() const
Definition: Type.h:370
llvm::cl::opt
Definition: CommandLine.h:1399
llvm::Triple::MacOSX
@ MacOSX
Definition: Triple.h:195
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:692
llvm::TargetLibraryInfoWrapperPass
Definition: TargetLibraryInfo.h:468
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:644
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::CallingConv::ARM_AAPCS
@ ARM_AAPCS
ARM Architecture Procedure Calling Standard calling convention (aka EABI).
Definition: CallingConv.h:108
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::Triple::Linux
@ Linux
Definition: Triple.h:193
I
#define I(x, y, z)
Definition: MD5.cpp:58
compareByScalarFnName
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)
Definition: TargetLibraryInfo.cpp:1125
llvm::FunctionType::getParamType
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:135
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:439
Ellip
@ Ellip
Definition: TargetLibraryInfo.cpp:62
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SizeT
@ SizeT
Definition: TargetLibraryInfo.cpp:54
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1666
llvm::TargetLibraryInfoImpl::setShouldExtI32Return
void setShouldExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...
Definition: TargetLibraryInfo.h:182
llvm::Type::getArrayNumElements
uint64_t getArrayNumElements() const
Definition: DerivedTypes.h:384
llvm::TargetLibraryInfoImpl::addVectorizableFunctions
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...
Definition: TargetLibraryInfo.cpp:1137
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
llvm::Type::isVoidTy
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
isCallingConvCCompatible
static bool isCallingConvCCompatible(CallingConv::ID CC, StringRef TT, FunctionType *FuncTy)
Definition: TargetLibraryInfo.cpp:104
hasBcmp
static bool hasBcmp(const Triple &TT)
Definition: TargetLibraryInfo.cpp:94
llvm::TargetLibraryInfoImpl::Accelerate
@ Accelerate
Definition: TargetLibraryInfo.h:92
Triple.h
matchType
static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits, unsigned SizeTBits)
Definition: TargetLibraryInfo.cpp:952
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::Triple::arm
@ arm
Definition: Triple.h:49
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
hasSinCosPiStret
static bool hasSinCosPiStret(const Triple &T)
Definition: TargetLibraryInfo.cpp:76
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1818
llvm::TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass
TargetLibraryInfoWrapperPass()
Definition: TargetLibraryInfo.cpp:1234
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:667
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
CC
auto CC
Definition: RISCVRedundantCopyElimination.cpp:79
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
llvm::TargetLibraryInfoImpl::disableAllFunctions
void disableAllFunctions()
Disables all builtins.
Definition: TargetLibraryInfo.cpp:1121
std
Definition: BitVector.h:851
llvm::Type::isFloatTy
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
ClVectorLibrary
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_X86, "LIBMVEC-X86", "GLIBC Vector Math library"), clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV", "IBM MASS vector library"), clEnumValN(TargetLibraryInfoImpl::SVML, "SVML", "Intel SVML library")))
IntPlus
@ IntPlus
Definition: TargetLibraryInfo.cpp:49
llvm::CallingConv::ARM_AAPCS_VFP
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
Definition: CallingConv.h:111
FuncArgTypeID
FuncArgTypeID
Definition: TargetLibraryInfo.cpp:43
llvm::TargetLibraryInfoImpl::setUnavailable
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
Definition: TargetLibraryInfo.h:124
llvm::LinearPolySize< ElementCount >::getScalable
static ElementCount getScalable(ScalarTy MinVal)
Definition: TypeSize.h:286
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:222
llvm::is_sorted
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
Definition: STLExtras.h:1688
llvm::Type::isDoubleTy
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
llvm::TargetLibraryInfoImpl::setShouldExtI32Param
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
Definition: TargetLibraryInfo.h:175
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:175
llvm::TargetLibraryInfoImpl::LIBMVEC_X86
@ LIBMVEC_X86
Definition: TargetLibraryInfo.h:94
Same
@ Same
Definition: TargetLibraryInfo.cpp:63
llvm::Triple::systemz
@ systemz
Definition: Triple.h:80
llvm::TargetLibraryInfoImpl::getWCharSize
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
Definition: TargetLibraryInfo.cpp:1227
llvm::CallingConv::ARM_APCS
@ ARM_APCS
ARM Procedure Calling Standard (obsolete, but still used on some targets).
Definition: CallingConv.h:104
llvm::StringRef::contains
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:415
llvm::TargetLibraryInfoImpl::getLibFunc
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
Definition: TargetLibraryInfo.cpp:935
llvm::Type::isStructTy
bool isStructTy() const
True if this is an instance of StructType.
Definition: Type.h:217
Floating
@ Floating
Definition: TargetLibraryInfo.cpp:59
llvm::Module::getTargetTriple
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:258
llvm::TargetLibraryInfoImpl::NoLibrary
@ NoLibrary
Definition: TargetLibraryInfo.h:91
Struct
@ Struct
Definition: TargetLibraryInfo.cpp:61
llvm::NumLibFuncs
@ NumLibFuncs
Definition: TargetLibraryInfo.h:39
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1174
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::TargetLibraryInfoImpl::isCallingConvCCompatible
static bool isCallingConvCCompatible(CallBase *CI)
Returns true if call site / callee has cdecl-compatible calling conventions.
Definition: TargetLibraryInfo.cpp:135
compareWithScalarFnName
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)
Definition: TargetLibraryInfo.cpp:1133
sanitizeFunctionName
static StringRef sanitizeFunctionName(StringRef funcName)
Definition: TargetLibraryInfo.cpp:924
llvm::cl::desc
Definition: CommandLine.h:412
llvm::TargetLibraryInfoImpl::VectorLibrary
VectorLibrary
List of known vector-functions libraries.
Definition: TargetLibraryInfo.h:90
llvm::TargetLibraryInfoImpl::TargetLibraryInfoImpl
TargetLibraryInfoImpl()
Definition: TargetLibraryInfo.cpp:867
InitializePasses.h
llvm::FunctionType::getReturnType
Type * getReturnType() const
Definition: DerivedTypes.h:124
llvm::Triple::tce
@ tce
Definition: Triple.h:81
llvm::TargetLibraryInfoImpl::setIntSize
void setIntSize(unsigned Bits)
Initialize the C-level size of an integer.
Definition: TargetLibraryInfo.h:202
Void
@ Void
Definition: TargetLibraryInfo.cpp:44
FuncProtoTy
std::array< FuncArgTypeID, 8 > FuncProtoTy
Definition: TargetLibraryInfo.cpp:66
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:51
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::Type::getPrimitiveSizeInBits
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition: Type.cpp:164
llvm::TargetLibraryInfoImpl::DarwinLibSystemM
@ DarwinLibSystemM
Definition: TargetLibraryInfo.h:93