LLVM 17.0.0git
TargetLibraryInfo.h
Go to the documentation of this file.
1//===-- TargetLibraryInfo.h - Library information ---------------*- C++ -*-===//
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#ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
10#define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
11
12#include "llvm/ADT/BitVector.h"
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/Triple.h"
15#include "llvm/IR/InstrTypes.h"
16#include "llvm/IR/PassManager.h"
17#include "llvm/Pass.h"
18#include <optional>
19
20namespace llvm {
21
22template <typename T> class ArrayRef;
23class Function;
24class Module;
25class Triple;
26
27/// Describes a possible vectorization of a function.
28/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
29/// by a factor 'VectorizationFactor'.
30struct VecDesc {
34};
35
36 enum LibFunc : unsigned {
37#define TLI_DEFINE_ENUM
38#include "llvm/Analysis/TargetLibraryInfo.def"
39
42 };
43
44/// Implementation of the target library information.
45///
46/// This class constructs tables that hold the target library information and
47/// make it available. However, it is somewhat expensive to compute and only
48/// depends on the triple. So users typically interact with the \c
49/// TargetLibraryInfo wrapper below.
51 friend class TargetLibraryInfo;
52
53 unsigned char AvailableArray[(NumLibFuncs+3)/4];
55 static StringLiteral const StandardNames[NumLibFuncs];
56 bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param, ShouldSignExtI32Return;
57 unsigned SizeOfInt;
58
59 enum AvailabilityState {
60 StandardName = 3, // (memset to all ones)
61 CustomName = 1,
62 Unavailable = 0 // (memset to all zeros)
63 };
64 void setState(LibFunc F, AvailabilityState State) {
65 AvailableArray[F/4] &= ~(3 << 2*(F&3));
66 AvailableArray[F/4] |= State << 2*(F&3);
67 }
68 AvailabilityState getState(LibFunc F) const {
69 return static_cast<AvailabilityState>((AvailableArray[F/4] >> 2*(F&3)) & 3);
70 }
71
72 /// Vectorization descriptors - sorted by ScalarFnName.
73 std::vector<VecDesc> VectorDescs;
74 /// Scalarization descriptors - same content as VectorDescs but sorted based
75 /// on VectorFnName rather than ScalarFnName.
76 std::vector<VecDesc> ScalarDescs;
77
78 /// Return true if the function type FTy is valid for the library function
79 /// F, regardless of whether the function is available.
80 bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F,
81 const Module &M) const;
82
83public:
84 /// List of known vector-functions libraries.
85 ///
86 /// The vector-functions library defines, which functions are vectorizable
87 /// and with which factor. The library can be specified by either frontend,
88 /// or a commandline option, and then used by
89 /// addVectorizableFunctionsFromVecLib for filling up the tables of
90 /// vectorizable functions.
92 NoLibrary, // Don't use any vector library.
93 Accelerate, // Use Accelerate framework.
94 DarwinLibSystemM, // Use Darwin's libsystem_m.
95 LIBMVEC_X86, // GLIBC Vector Math library.
96 MASSV, // IBM MASS vector library.
97 SVML, // Intel short vector math library.
98 SLEEFGNUABI // SLEEF - SIMD Library for Evaluating Elementary Functions.
99 };
100
102 explicit TargetLibraryInfoImpl(const Triple &T);
103
104 // Provide value semantics.
109
110 /// Searches for a particular function name.
111 ///
112 /// If it is one of the known library functions, return true and set F to the
113 /// corresponding value.
114 bool getLibFunc(StringRef funcName, LibFunc &F) const;
115
116 /// Searches for a particular function name, also checking that its type is
117 /// valid for the library function matching that name.
118 ///
119 /// If it is one of the known library functions, return true and set F to the
120 /// corresponding value.
121 ///
122 /// FDecl is assumed to have a parent Module when using this function.
123 bool getLibFunc(const Function &FDecl, LibFunc &F) const;
124
125 /// Forces a function to be marked as unavailable.
127 setState(F, Unavailable);
128 }
129
130 /// Forces a function to be marked as available.
132 setState(F, StandardName);
133 }
134
135 /// Forces a function to be marked as available and provide an alternate name
136 /// that must be used.
138 if (StandardNames[F] != Name) {
139 setState(F, CustomName);
140 CustomNames[F] = std::string(Name);
141 assert(CustomNames.find(F) != CustomNames.end());
142 } else {
143 setState(F, StandardName);
144 }
145 }
146
147 /// Disables all builtins.
148 ///
149 /// This can be used for options like -fno-builtin.
150 void disableAllFunctions();
151
152 /// Add a set of scalar -> vector mappings, queryable via
153 /// getVectorizedFunction and getScalarizedFunction.
155
156 /// Calls addVectorizableFunctions with a known preset of functions for the
157 /// given vector library.
159 const llvm::Triple &TargetTriple);
160
161 /// Return true if the function F has a vector equivalent with vectorization
162 /// factor VF.
164 return !getVectorizedFunction(F, VF).empty();
165 }
166
167 /// Return true if the function F has a vector equivalent with any
168 /// vectorization factor.
170
171 /// Return the name of the equivalent of F, vectorized with factor VF. If no
172 /// such mapping exists, return the empty string.
174
175 /// Set to true iff i32 parameters to library functions should have signext
176 /// or zeroext attributes if they correspond to C-level int or unsigned int,
177 /// respectively.
178 void setShouldExtI32Param(bool Val) {
179 ShouldExtI32Param = Val;
180 }
181
182 /// Set to true iff i32 results from library functions should have signext
183 /// or zeroext attributes if they correspond to C-level int or unsigned int,
184 /// respectively.
185 void setShouldExtI32Return(bool Val) {
186 ShouldExtI32Return = Val;
187 }
188
189 /// Set to true iff i32 parameters to library functions should have signext
190 /// attribute if they correspond to C-level int or unsigned int.
192 ShouldSignExtI32Param = Val;
193 }
194
195 /// Set to true iff i32 results from library functions should have signext
196 /// attribute if they correspond to C-level int or unsigned int.
198 ShouldSignExtI32Return = Val;
199 }
200
201 /// Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
202 /// This queries the 'wchar_size' metadata.
203 unsigned getWCharSize(const Module &M) const;
204
205 /// Returns the size of the size_t type in bits.
206 unsigned getSizeTSize(const Module &M) const;
207
208 /// Get size of a C-level int or unsigned int, in bits.
209 unsigned getIntSize() const {
210 return SizeOfInt;
211 }
212
213 /// Initialize the C-level size of an integer.
214 void setIntSize(unsigned Bits) {
215 SizeOfInt = Bits;
216 }
217
218 /// Returns the largest vectorization factor used in the list of
219 /// vector functions.
220 void getWidestVF(StringRef ScalarF, ElementCount &FixedVF,
221 ElementCount &Scalable) const;
222
223 /// Returns true if call site / callee has cdecl-compatible calling
224 /// conventions.
225 static bool isCallingConvCCompatible(CallBase *CI);
227};
228
229/// Provides information about what library functions are available for
230/// the current target.
231///
232/// This both allows optimizations to handle them specially and frontends to
233/// disable such optimizations through -fno-builtin etc.
237
238 /// The global (module level) TLI info.
239 const TargetLibraryInfoImpl *Impl;
240
241 /// Support for -fno-builtin* options as function attributes, overrides
242 /// information in global TargetLibraryInfoImpl.
243 BitVector OverrideAsUnavailable;
244
245public:
247 std::optional<const Function *> F = std::nullopt)
248 : Impl(&Impl), OverrideAsUnavailable(NumLibFuncs) {
249 if (!F)
250 return;
251 if ((*F)->hasFnAttribute("no-builtins"))
253 else {
254 // Disable individual libc/libm calls in TargetLibraryInfo.
255 LibFunc LF;
256 AttributeSet FnAttrs = (*F)->getAttributes().getFnAttrs();
257 for (const Attribute &Attr : FnAttrs) {
258 if (!Attr.isStringAttribute())
259 continue;
260 auto AttrStr = Attr.getKindAsString();
261 if (!AttrStr.consume_front("no-builtin-"))
262 continue;
263 if (getLibFunc(AttrStr, LF))
264 setUnavailable(LF);
265 }
266 }
267 }
268
269 // Provide value semantics.
272 : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
275 Impl = TLI.Impl;
276 OverrideAsUnavailable = TLI.OverrideAsUnavailable;
277 return *this;
278 }
279
280 /// Determine whether a callee with the given TLI can be inlined into
281 /// caller with this TLI, based on 'nobuiltin' attributes. When requested,
282 /// allow inlining into a caller with a superset of the callee's nobuiltin
283 /// attributes, which is conservatively correct.
285 bool AllowCallerSuperset) const {
286 if (!AllowCallerSuperset)
287 return OverrideAsUnavailable == CalleeTLI.OverrideAsUnavailable;
288 BitVector B = OverrideAsUnavailable;
289 B |= CalleeTLI.OverrideAsUnavailable;
290 // We can inline if the union of the caller and callee's nobuiltin
291 // attributes is no stricter than the caller's nobuiltin attributes.
292 return B == OverrideAsUnavailable;
293 }
294
295 /// Return true if the function type FTy is valid for the library function
296 /// F, regardless of whether the function is available.
298 const Module &M) const {
299 return Impl->isValidProtoForLibFunc(FTy, F, M);
300 }
301
302 /// Searches for a particular function name.
303 ///
304 /// If it is one of the known library functions, return true and set F to the
305 /// corresponding value.
306 bool getLibFunc(StringRef funcName, LibFunc &F) const {
307 return Impl->getLibFunc(funcName, F);
308 }
309
310 bool getLibFunc(const Function &FDecl, LibFunc &F) const {
311 return Impl->getLibFunc(FDecl, F);
312 }
313
314 /// If a callbase does not have the 'nobuiltin' attribute, return if the
315 /// called function is a known library function and set F to that function.
316 bool getLibFunc(const CallBase &CB, LibFunc &F) const {
317 return !CB.isNoBuiltin() && CB.getCalledFunction() &&
319 }
320
321 /// Disables all builtins.
322 ///
323 /// This can be used for options like -fno-builtin.
325 OverrideAsUnavailable.set();
326 }
327
328 /// Forces a function to be marked as unavailable.
330 OverrideAsUnavailable.set(F);
331 }
332
333 TargetLibraryInfoImpl::AvailabilityState getState(LibFunc F) const {
334 if (OverrideAsUnavailable[F])
335 return TargetLibraryInfoImpl::Unavailable;
336 return Impl->getState(F);
337 }
338
339 /// Tests whether a library function is available.
340 bool has(LibFunc F) const {
341 return getState(F) != TargetLibraryInfoImpl::Unavailable;
342 }
344 return Impl->isFunctionVectorizable(F, VF);
345 }
347 return Impl->isFunctionVectorizable(F);
348 }
350 return Impl->getVectorizedFunction(F, VF);
351 }
352
353 /// Tests if the function is both available and a candidate for optimized code
354 /// generation.
356 if (getState(F) == TargetLibraryInfoImpl::Unavailable)
357 return false;
358 switch (F) {
359 default: break;
360 case LibFunc_copysign: case LibFunc_copysignf: case LibFunc_copysignl:
361 case LibFunc_fabs: case LibFunc_fabsf: case LibFunc_fabsl:
362 case LibFunc_sin: case LibFunc_sinf: case LibFunc_sinl:
363 case LibFunc_cos: case LibFunc_cosf: case LibFunc_cosl:
364 case LibFunc_sqrt: case LibFunc_sqrtf: case LibFunc_sqrtl:
365 case LibFunc_sqrt_finite: case LibFunc_sqrtf_finite:
366 case LibFunc_sqrtl_finite:
367 case LibFunc_fmax: case LibFunc_fmaxf: case LibFunc_fmaxl:
368 case LibFunc_fmin: case LibFunc_fminf: case LibFunc_fminl:
369 case LibFunc_floor: case LibFunc_floorf: case LibFunc_floorl:
370 case LibFunc_nearbyint: case LibFunc_nearbyintf: case LibFunc_nearbyintl:
371 case LibFunc_ceil: case LibFunc_ceilf: case LibFunc_ceill:
372 case LibFunc_rint: case LibFunc_rintf: case LibFunc_rintl:
373 case LibFunc_round: case LibFunc_roundf: case LibFunc_roundl:
374 case LibFunc_trunc: case LibFunc_truncf: case LibFunc_truncl:
375 case LibFunc_log2: case LibFunc_log2f: case LibFunc_log2l:
376 case LibFunc_exp2: case LibFunc_exp2f: case LibFunc_exp2l:
377 case LibFunc_memcpy: case LibFunc_memset: case LibFunc_memmove:
378 case LibFunc_memcmp: case LibFunc_bcmp: case LibFunc_strcmp:
379 case LibFunc_strcpy: case LibFunc_stpcpy: case LibFunc_strlen:
380 case LibFunc_strnlen: case LibFunc_memchr: case LibFunc_mempcpy:
381 return true;
382 }
383 return false;
384 }
385
387 auto State = getState(F);
388 if (State == TargetLibraryInfoImpl::Unavailable)
389 return StringRef();
390 if (State == TargetLibraryInfoImpl::StandardName)
391 return Impl->StandardNames[F];
392 assert(State == TargetLibraryInfoImpl::CustomName);
393 return Impl->CustomNames.find(F)->second;
394 }
395
396 static void initExtensionsForTriple(bool &ShouldExtI32Param,
397 bool &ShouldExtI32Return,
398 bool &ShouldSignExtI32Param,
399 bool &ShouldSignExtI32Return,
400 const Triple &T) {
401 ShouldExtI32Param = ShouldExtI32Return = false;
402 ShouldSignExtI32Param = ShouldSignExtI32Return = false;
403
404 // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
405 // returns corresponding to C-level ints and unsigned ints.
406 if (T.isPPC64() || T.getArch() == Triple::sparcv9 ||
407 T.getArch() == Triple::systemz) {
408 ShouldExtI32Param = true;
409 ShouldExtI32Return = true;
410 }
411 // Mips and riscv64, on the other hand, needs signext on i32 parameters
412 // corresponding to both signed and unsigned ints.
413 if (T.isMIPS() || T.isRISCV64()) {
414 ShouldSignExtI32Param = true;
415 }
416 // riscv64 needs signext on i32 returns corresponding to both signed and
417 // unsigned ints.
418 if (T.isRISCV64()) {
419 ShouldSignExtI32Return = true;
420 }
421 }
422
423 /// Returns extension attribute kind to be used for i32 parameters
424 /// corresponding to C-level int or unsigned int. May be zeroext, signext,
425 /// or none.
426private:
427 static Attribute::AttrKind getExtAttrForI32Param(bool ShouldExtI32Param_,
428 bool ShouldSignExtI32Param_,
429 bool Signed = true) {
430 if (ShouldExtI32Param_)
431 return Signed ? Attribute::SExt : Attribute::ZExt;
432 if (ShouldSignExtI32Param_)
433 return Attribute::SExt;
434 return Attribute::None;
435 }
436
437public:
439 bool Signed = true) {
440 bool ShouldExtI32Param, ShouldExtI32Return;
441 bool ShouldSignExtI32Param, ShouldSignExtI32Return;
442 initExtensionsForTriple(ShouldExtI32Param, ShouldExtI32Return,
443 ShouldSignExtI32Param, ShouldSignExtI32Return, T);
444 return getExtAttrForI32Param(ShouldExtI32Param, ShouldSignExtI32Param,
445 Signed);
446 }
447
449 return getExtAttrForI32Param(Impl->ShouldExtI32Param,
450 Impl->ShouldSignExtI32Param, Signed);
451 }
452
453 /// Returns extension attribute kind to be used for i32 return values
454 /// corresponding to C-level int or unsigned int. May be zeroext, signext,
455 /// or none.
456private:
457 static Attribute::AttrKind getExtAttrForI32Return(bool ShouldExtI32Return_,
458 bool ShouldSignExtI32Return_,
459 bool Signed) {
460 if (ShouldExtI32Return_)
461 return Signed ? Attribute::SExt : Attribute::ZExt;
462 if (ShouldSignExtI32Return_)
463 return Attribute::SExt;
464 return Attribute::None;
465 }
466
467public:
469 bool Signed = true) {
470 bool ShouldExtI32Param, ShouldExtI32Return;
471 bool ShouldSignExtI32Param, ShouldSignExtI32Return;
472 initExtensionsForTriple(ShouldExtI32Param, ShouldExtI32Return,
473 ShouldSignExtI32Param, ShouldSignExtI32Return, T);
474 return getExtAttrForI32Return(ShouldExtI32Return, ShouldSignExtI32Return,
475 Signed);
476 }
477
479 return getExtAttrForI32Return(Impl->ShouldExtI32Return,
480 Impl->ShouldSignExtI32Return, Signed);
481 }
482
483 // Helper to create an AttributeList for args (and ret val) which all have
484 // the same signedness. Attributes in AL may be passed in to include them
485 // as well in the returned AttributeList.
487 bool Signed, bool Ret = false,
488 AttributeList AL = AttributeList()) const {
489 if (auto AK = getExtAttrForI32Param(Signed))
490 for (auto ArgNo : ArgNos)
491 AL = AL.addParamAttribute(*C, ArgNo, AK);
492 if (Ret)
493 if (auto AK = getExtAttrForI32Return(Signed))
494 AL = AL.addRetAttribute(*C, AK);
495 return AL;
496 }
497
498 /// \copydoc TargetLibraryInfoImpl::getWCharSize()
499 unsigned getWCharSize(const Module &M) const {
500 return Impl->getWCharSize(M);
501 }
502
503 /// \copydoc TargetLibraryInfoImpl::getSizeTSize()
504 unsigned getSizeTSize(const Module &M) const { return Impl->getSizeTSize(M); }
505
506 /// \copydoc TargetLibraryInfoImpl::getIntSize()
507 unsigned getIntSize() const {
508 return Impl->getIntSize();
509 }
510
511 /// Handle invalidation from the pass manager.
512 ///
513 /// If we try to invalidate this info, just return false. It cannot become
514 /// invalid even if the module or function changes.
517 return false;
518 }
521 return false;
522 }
523 /// Returns the largest vectorization factor used in the list of
524 /// vector functions.
525 void getWidestVF(StringRef ScalarF, ElementCount &FixedVF,
526 ElementCount &ScalableVF) const {
527 Impl->getWidestVF(ScalarF, FixedVF, ScalableVF);
528 }
529
530 /// Check if the function "F" is listed in a library known to LLVM.
532 return this->isFunctionVectorizable(F);
533 }
534};
535
536/// Analysis pass providing the \c TargetLibraryInfo.
537///
538/// Note that this pass's result cannot be invalidated, it is immutable for the
539/// life of the module.
540class TargetLibraryAnalysis : public AnalysisInfoMixin<TargetLibraryAnalysis> {
541public:
543
544 /// Default construct the library analysis.
545 ///
546 /// This will use the module's triple to construct the library info for that
547 /// module.
549
550 /// Construct a library analysis with baseline Module-level info.
551 ///
552 /// This will be supplemented with Function-specific info in the Result.
554 : BaselineInfoImpl(std::move(BaselineInfoImpl)) {}
555
557
558private:
560 static AnalysisKey Key;
561
562 std::optional<TargetLibraryInfoImpl> BaselineInfoImpl;
563};
564
567 std::optional<TargetLibraryInfo> TLI;
568
569 virtual void anchor();
570
571public:
572 static char ID;
574 explicit TargetLibraryInfoWrapperPass(const Triple &T);
576
579 TLI = TLA.run(F, DummyFAM);
580 return *TLI;
581 }
582};
583
584} // end namespace llvm
585
586#endif
This header is deprecated in favour of llvm/TargetParser/Triple.h.
amdgpu Simplify well known AMD library false FunctionCallee Callee
This file implements the BitVector class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ATTRIBUTE_UNUSED
Definition: Compiler.h:172
This file defines the DenseMap class.
std::string Name
AvailabilityState
Definition: GVN.cpp:799
@ Unavailable
We know the block is not fully available. This is a fixpoint.
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:661
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:86
@ None
No attributes have been set.
Definition: Attributes.h:88
BitVector & set()
Definition: BitVector.h:344
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1184
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Definition: InstrTypes.h:1858
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1406
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
Class to represent function types.
Definition: DerivedTypes.h:103
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:279
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:841
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
Analysis pass providing the TargetLibraryInfo.
TargetLibraryAnalysis()=default
Default construct the library analysis.
TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)
TargetLibraryAnalysis(TargetLibraryInfoImpl BaselineInfoImpl)
Construct a library analysis with baseline Module-level info.
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...
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)
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Return the name of the equivalent of F, vectorized with factor VF.
void disableAllFunctions()
Disables all builtins.
VectorLibrary
List of known vector-functions libraries.
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
void setAvailable(LibFunc F)
Forces a function to be marked as available.
TargetLibraryInfo & getTLI(const Function &F)
Provides information about what library functions are available for the current target.
AttributeList getAttrList(LLVMContext *C, ArrayRef< unsigned > ArgNos, bool Signed, bool Ret=false, AttributeList AL=AttributeList()) const
TargetLibraryInfo & operator=(TargetLibraryInfo &&TLI)
static Attribute::AttrKind getExtAttrForI32Param(const Triple &T, bool Signed=true)
bool areInlineCompatible(const TargetLibraryInfo &CalleeTLI, bool AllowCallerSuperset) const
Determine whether a callee with the given TLI can be inlined into caller with this TLI,...
bool getLibFunc(const CallBase &CB, LibFunc &F) const
If a callbase does not have the 'nobuiltin' attribute, return if the called function is a known libra...
bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
Handle invalidation from the pass manager.
TargetLibraryInfo(TargetLibraryInfo &&TLI)
bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F, const Module &M) const
Return true if the function type FTy is valid for the library function F, regardless of whether the f...
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
bool hasOptimizedCodeGen(LibFunc F) const
Tests if the function is both available and a candidate for optimized code generation.
Attribute::AttrKind getExtAttrForI32Return(bool Signed=true) const
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
bool isKnownVectorFunctionInLibrary(StringRef F) const
Check if the function "F" is listed in a library known to LLVM.
bool isFunctionVectorizable(StringRef F) const
bool has(LibFunc F) const
Tests whether a library function is available.
unsigned getSizeTSize(const Module &M) const
Returns the size of the size_t type in bits.
TargetLibraryInfoImpl::AvailabilityState getState(LibFunc F) const
TargetLibraryInfo & operator=(const TargetLibraryInfo &TLI)=default
void disableAllFunctions() LLVM_ATTRIBUTE_UNUSED
Disables all builtins.
TargetLibraryInfo(const TargetLibraryInfo &TLI)=default
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &ScalableVF) const
Returns the largest vectorization factor used in the list of vector functions.
void setUnavailable(LibFunc F) LLVM_ATTRIBUTE_UNUSED
Forces a function to be marked as unavailable.
TargetLibraryInfo(const TargetLibraryInfoImpl &Impl, std::optional< const Function * > F=std::nullopt)
static Attribute::AttrKind getExtAttrForI32Return(const Triple &T, bool Signed=true)
bool getLibFunc(const Function &FDecl, LibFunc &F) const
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
static void initExtensionsForTriple(bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)
StringRef getName(LibFunc F) const
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ArrayRef(const T &OneElt) -> ArrayRef< T >
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:1862
Definition: BitVector.h:851
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:394
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
Describes a possible vectorization of a function.
StringRef VectorFnName
ElementCount VectorizationFactor
StringRef ScalarFnName