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