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/IR/InstrTypes.h"
15#include "llvm/IR/PassManager.h"
16#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 bool Masked;
35};
36
37 enum LibFunc : unsigned {
38#define TLI_DEFINE_ENUM
39#include "llvm/Analysis/TargetLibraryInfo.def"
40
43 };
44
45/// Implementation of the target library information.
46///
47/// This class constructs tables that hold the target library information and
48/// make it available. However, it is somewhat expensive to compute and only
49/// depends on the triple. So users typically interact with the \c
50/// TargetLibraryInfo wrapper below.
52 friend class TargetLibraryInfo;
53
54 unsigned char AvailableArray[(NumLibFuncs+3)/4];
56 static StringLiteral const StandardNames[NumLibFuncs];
57 bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param, ShouldSignExtI32Return;
58 unsigned SizeOfInt;
59
60 enum AvailabilityState {
61 StandardName = 3, // (memset to all ones)
62 CustomName = 1,
63 Unavailable = 0 // (memset to all zeros)
64 };
65 void setState(LibFunc F, AvailabilityState State) {
66 AvailableArray[F/4] &= ~(3 << 2*(F&3));
67 AvailableArray[F/4] |= State << 2*(F&3);
68 }
69 AvailabilityState getState(LibFunc F) const {
70 return static_cast<AvailabilityState>((AvailableArray[F/4] >> 2*(F&3)) & 3);
71 }
72
73 /// Vectorization descriptors - sorted by ScalarFnName.
74 std::vector<VecDesc> VectorDescs;
75 /// Scalarization descriptors - same content as VectorDescs but sorted based
76 /// on VectorFnName rather than ScalarFnName.
77 std::vector<VecDesc> ScalarDescs;
78
79 /// Return true if the function type FTy is valid for the library function
80 /// F, regardless of whether the function is available.
81 bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F,
82 const Module &M) const;
83
84public:
85 /// List of known vector-functions libraries.
86 ///
87 /// The vector-functions library defines, which functions are vectorizable
88 /// and with which factor. The library can be specified by either frontend,
89 /// or a commandline option, and then used by
90 /// addVectorizableFunctionsFromVecLib for filling up the tables of
91 /// vectorizable functions.
93 NoLibrary, // Don't use any vector library.
94 Accelerate, // Use Accelerate framework.
95 DarwinLibSystemM, // Use Darwin's libsystem_m.
96 LIBMVEC_X86, // GLIBC Vector Math library.
97 MASSV, // IBM MASS vector library.
98 SVML, // Intel short vector math library.
99 SLEEFGNUABI // SLEEF - SIMD Library for Evaluating Elementary Functions.
100 };
101
103 explicit TargetLibraryInfoImpl(const Triple &T);
104
105 // Provide value semantics.
110
111 /// Searches for a particular function name.
112 ///
113 /// If it is one of the known library functions, return true and set F to the
114 /// corresponding value.
115 bool getLibFunc(StringRef funcName, LibFunc &F) const;
116
117 /// Searches for a particular function name, also checking that its type is
118 /// valid for the library function matching that name.
119 ///
120 /// If it is one of the known library functions, return true and set F to the
121 /// corresponding value.
122 ///
123 /// FDecl is assumed to have a parent Module when using this function.
124 bool getLibFunc(const Function &FDecl, LibFunc &F) const;
125
126 /// Forces a function to be marked as unavailable.
128 setState(F, Unavailable);
129 }
130
131 /// Forces a function to be marked as available.
133 setState(F, StandardName);
134 }
135
136 /// Forces a function to be marked as available and provide an alternate name
137 /// that must be used.
139 if (StandardNames[F] != Name) {
140 setState(F, CustomName);
141 CustomNames[F] = std::string(Name);
142 assert(CustomNames.contains(F));
143 } else {
144 setState(F, StandardName);
145 }
146 }
147
148 /// Disables all builtins.
149 ///
150 /// This can be used for options like -fno-builtin.
151 void disableAllFunctions();
152
153 /// Add a set of scalar -> vector mappings, queryable via
154 /// getVectorizedFunction and getScalarizedFunction.
156
157 /// Calls addVectorizableFunctions with a known preset of functions for the
158 /// given vector library.
160 const llvm::Triple &TargetTriple);
161
162 /// Return true if the function F has a vector equivalent with vectorization
163 /// factor VF.
165 return !(getVectorizedFunction(F, VF, false).empty() &&
166 getVectorizedFunction(F, VF, true).empty());
167 }
168
169 /// Return true if the function F has a vector equivalent with any
170 /// vectorization factor.
172
173 /// Return the name of the equivalent of F, vectorized with factor VF. If no
174 /// such mapping exists, return the empty string.
176 bool Masked) const;
177
178 /// Set to true iff i32 parameters to library functions should have signext
179 /// or zeroext attributes if they correspond to C-level int or unsigned int,
180 /// respectively.
181 void setShouldExtI32Param(bool Val) {
182 ShouldExtI32Param = Val;
183 }
184
185 /// Set to true iff i32 results from library functions should have signext
186 /// or zeroext attributes if they correspond to C-level int or unsigned int,
187 /// respectively.
188 void setShouldExtI32Return(bool Val) {
189 ShouldExtI32Return = Val;
190 }
191
192 /// Set to true iff i32 parameters to library functions should have signext
193 /// attribute if they correspond to C-level int or unsigned int.
195 ShouldSignExtI32Param = Val;
196 }
197
198 /// Set to true iff i32 results from library functions should have signext
199 /// attribute if they correspond to C-level int or unsigned int.
201 ShouldSignExtI32Return = Val;
202 }
203
204 /// Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
205 /// This queries the 'wchar_size' metadata.
206 unsigned getWCharSize(const Module &M) const;
207
208 /// Returns the size of the size_t type in bits.
209 unsigned getSizeTSize(const Module &M) const;
210
211 /// Get size of a C-level int or unsigned int, in bits.
212 unsigned getIntSize() const {
213 return SizeOfInt;
214 }
215
216 /// Initialize the C-level size of an integer.
217 void setIntSize(unsigned Bits) {
218 SizeOfInt = Bits;
219 }
220
221 /// Returns the largest vectorization factor used in the list of
222 /// vector functions.
223 void getWidestVF(StringRef ScalarF, ElementCount &FixedVF,
224 ElementCount &Scalable) const;
225
226 /// Returns true if call site / callee has cdecl-compatible calling
227 /// conventions.
228 static bool isCallingConvCCompatible(CallBase *CI);
230};
231
232/// Provides information about what library functions are available for
233/// the current target.
234///
235/// This both allows optimizations to handle them specially and frontends to
236/// disable such optimizations through -fno-builtin etc.
240
241 /// The global (module level) TLI info.
242 const TargetLibraryInfoImpl *Impl;
243
244 /// Support for -fno-builtin* options as function attributes, overrides
245 /// information in global TargetLibraryInfoImpl.
246 BitVector OverrideAsUnavailable;
247
248public:
250 std::optional<const Function *> F = std::nullopt)
251 : Impl(&Impl), OverrideAsUnavailable(NumLibFuncs) {
252 if (!F)
253 return;
254 if ((*F)->hasFnAttribute("no-builtins"))
256 else {
257 // Disable individual libc/libm calls in TargetLibraryInfo.
258 LibFunc LF;
259 AttributeSet FnAttrs = (*F)->getAttributes().getFnAttrs();
260 for (const Attribute &Attr : FnAttrs) {
261 if (!Attr.isStringAttribute())
262 continue;
263 auto AttrStr = Attr.getKindAsString();
264 if (!AttrStr.consume_front("no-builtin-"))
265 continue;
266 if (getLibFunc(AttrStr, LF))
267 setUnavailable(LF);
268 }
269 }
270 }
271
272 // Provide value semantics.
275 : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
278 Impl = TLI.Impl;
279 OverrideAsUnavailable = TLI.OverrideAsUnavailable;
280 return *this;
281 }
282
283 /// Determine whether a callee with the given TLI can be inlined into
284 /// caller with this TLI, based on 'nobuiltin' attributes. When requested,
285 /// allow inlining into a caller with a superset of the callee's nobuiltin
286 /// attributes, which is conservatively correct.
288 bool AllowCallerSuperset) const {
289 if (!AllowCallerSuperset)
290 return OverrideAsUnavailable == CalleeTLI.OverrideAsUnavailable;
291 BitVector B = OverrideAsUnavailable;
292 B |= CalleeTLI.OverrideAsUnavailable;
293 // We can inline if the union of the caller and callee's nobuiltin
294 // attributes is no stricter than the caller's nobuiltin attributes.
295 return B == OverrideAsUnavailable;
296 }
297
298 /// Return true if the function type FTy is valid for the library function
299 /// F, regardless of whether the function is available.
301 const Module &M) const {
302 return Impl->isValidProtoForLibFunc(FTy, F, M);
303 }
304
305 /// Searches for a particular function name.
306 ///
307 /// If it is one of the known library functions, return true and set F to the
308 /// corresponding value.
309 bool getLibFunc(StringRef funcName, LibFunc &F) const {
310 return Impl->getLibFunc(funcName, F);
311 }
312
313 bool getLibFunc(const Function &FDecl, LibFunc &F) const {
314 return Impl->getLibFunc(FDecl, F);
315 }
316
317 /// If a callbase does not have the 'nobuiltin' attribute, return if the
318 /// called function is a known library function and set F to that function.
319 bool getLibFunc(const CallBase &CB, LibFunc &F) const {
320 return !CB.isNoBuiltin() && CB.getCalledFunction() &&
322 }
323
324 /// Disables all builtins.
325 ///
326 /// This can be used for options like -fno-builtin.
328 OverrideAsUnavailable.set();
329 }
330
331 /// Forces a function to be marked as unavailable.
333 OverrideAsUnavailable.set(F);
334 }
335
336 TargetLibraryInfoImpl::AvailabilityState getState(LibFunc F) const {
337 if (OverrideAsUnavailable[F])
338 return TargetLibraryInfoImpl::Unavailable;
339 return Impl->getState(F);
340 }
341
342 /// Tests whether a library function is available.
343 bool has(LibFunc F) const {
344 return getState(F) != TargetLibraryInfoImpl::Unavailable;
345 }
347 return Impl->isFunctionVectorizable(F, VF);
348 }
350 return Impl->isFunctionVectorizable(F);
351 }
353 bool Masked = false) const {
354 return Impl->getVectorizedFunction(F, VF, Masked);
355 }
356
357 /// Tests if the function is both available and a candidate for optimized code
358 /// generation.
360 if (getState(F) == TargetLibraryInfoImpl::Unavailable)
361 return false;
362 switch (F) {
363 default: break;
364 case LibFunc_copysign: case LibFunc_copysignf: case LibFunc_copysignl:
365 case LibFunc_fabs: case LibFunc_fabsf: case LibFunc_fabsl:
366 case LibFunc_sin: case LibFunc_sinf: case LibFunc_sinl:
367 case LibFunc_cos: case LibFunc_cosf: case LibFunc_cosl:
368 case LibFunc_sqrt: case LibFunc_sqrtf: case LibFunc_sqrtl:
369 case LibFunc_sqrt_finite: case LibFunc_sqrtf_finite:
370 case LibFunc_sqrtl_finite:
371 case LibFunc_fmax: case LibFunc_fmaxf: case LibFunc_fmaxl:
372 case LibFunc_fmin: case LibFunc_fminf: case LibFunc_fminl:
373 case LibFunc_floor: case LibFunc_floorf: case LibFunc_floorl:
374 case LibFunc_nearbyint: case LibFunc_nearbyintf: case LibFunc_nearbyintl:
375 case LibFunc_ceil: case LibFunc_ceilf: case LibFunc_ceill:
376 case LibFunc_rint: case LibFunc_rintf: case LibFunc_rintl:
377 case LibFunc_round: case LibFunc_roundf: case LibFunc_roundl:
378 case LibFunc_trunc: case LibFunc_truncf: case LibFunc_truncl:
379 case LibFunc_log2: case LibFunc_log2f: case LibFunc_log2l:
380 case LibFunc_exp2: case LibFunc_exp2f: case LibFunc_exp2l:
381 case LibFunc_memcpy: case LibFunc_memset: case LibFunc_memmove:
382 case LibFunc_memcmp: case LibFunc_bcmp: case LibFunc_strcmp:
383 case LibFunc_strcpy: case LibFunc_stpcpy: case LibFunc_strlen:
384 case LibFunc_strnlen: case LibFunc_memchr: case LibFunc_mempcpy:
385 return true;
386 }
387 return false;
388 }
389
391 auto State = getState(F);
392 if (State == TargetLibraryInfoImpl::Unavailable)
393 return StringRef();
394 if (State == TargetLibraryInfoImpl::StandardName)
395 return Impl->StandardNames[F];
396 assert(State == TargetLibraryInfoImpl::CustomName);
397 return Impl->CustomNames.find(F)->second;
398 }
399
400 static void initExtensionsForTriple(bool &ShouldExtI32Param,
401 bool &ShouldExtI32Return,
402 bool &ShouldSignExtI32Param,
403 bool &ShouldSignExtI32Return,
404 const Triple &T) {
405 ShouldExtI32Param = ShouldExtI32Return = false;
406 ShouldSignExtI32Param = ShouldSignExtI32Return = false;
407
408 // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
409 // returns corresponding to C-level ints and unsigned ints.
410 if (T.isPPC64() || T.getArch() == Triple::sparcv9 ||
411 T.getArch() == Triple::systemz) {
412 ShouldExtI32Param = true;
413 ShouldExtI32Return = true;
414 }
415 // Mips and riscv64, on the other hand, needs signext on i32 parameters
416 // corresponding to both signed and unsigned ints.
417 if (T.isMIPS() || T.isRISCV64()) {
418 ShouldSignExtI32Param = true;
419 }
420 // riscv64 needs signext on i32 returns corresponding to both signed and
421 // unsigned ints.
422 if (T.isRISCV64()) {
423 ShouldSignExtI32Return = true;
424 }
425 }
426
427 /// Returns extension attribute kind to be used for i32 parameters
428 /// corresponding to C-level int or unsigned int. May be zeroext, signext,
429 /// or none.
430private:
431 static Attribute::AttrKind getExtAttrForI32Param(bool ShouldExtI32Param_,
432 bool ShouldSignExtI32Param_,
433 bool Signed = true) {
434 if (ShouldExtI32Param_)
435 return Signed ? Attribute::SExt : Attribute::ZExt;
436 if (ShouldSignExtI32Param_)
437 return Attribute::SExt;
438 return Attribute::None;
439 }
440
441public:
443 bool Signed = true) {
444 bool ShouldExtI32Param, ShouldExtI32Return;
445 bool ShouldSignExtI32Param, ShouldSignExtI32Return;
446 initExtensionsForTriple(ShouldExtI32Param, ShouldExtI32Return,
447 ShouldSignExtI32Param, ShouldSignExtI32Return, T);
448 return getExtAttrForI32Param(ShouldExtI32Param, ShouldSignExtI32Param,
449 Signed);
450 }
451
453 return getExtAttrForI32Param(Impl->ShouldExtI32Param,
454 Impl->ShouldSignExtI32Param, Signed);
455 }
456
457 /// Returns extension attribute kind to be used for i32 return values
458 /// corresponding to C-level int or unsigned int. May be zeroext, signext,
459 /// or none.
460private:
461 static Attribute::AttrKind getExtAttrForI32Return(bool ShouldExtI32Return_,
462 bool ShouldSignExtI32Return_,
463 bool Signed) {
464 if (ShouldExtI32Return_)
465 return Signed ? Attribute::SExt : Attribute::ZExt;
466 if (ShouldSignExtI32Return_)
467 return Attribute::SExt;
468 return Attribute::None;
469 }
470
471public:
473 bool Signed = true) {
474 bool ShouldExtI32Param, ShouldExtI32Return;
475 bool ShouldSignExtI32Param, ShouldSignExtI32Return;
476 initExtensionsForTriple(ShouldExtI32Param, ShouldExtI32Return,
477 ShouldSignExtI32Param, ShouldSignExtI32Return, T);
478 return getExtAttrForI32Return(ShouldExtI32Return, ShouldSignExtI32Return,
479 Signed);
480 }
481
483 return getExtAttrForI32Return(Impl->ShouldExtI32Return,
484 Impl->ShouldSignExtI32Return, Signed);
485 }
486
487 // Helper to create an AttributeList for args (and ret val) which all have
488 // the same signedness. Attributes in AL may be passed in to include them
489 // as well in the returned AttributeList.
491 bool Signed, bool Ret = false,
492 AttributeList AL = AttributeList()) const {
493 if (auto AK = getExtAttrForI32Param(Signed))
494 for (auto ArgNo : ArgNos)
495 AL = AL.addParamAttribute(*C, ArgNo, AK);
496 if (Ret)
497 if (auto AK = getExtAttrForI32Return(Signed))
498 AL = AL.addRetAttribute(*C, AK);
499 return AL;
500 }
501
502 /// \copydoc TargetLibraryInfoImpl::getWCharSize()
503 unsigned getWCharSize(const Module &M) const {
504 return Impl->getWCharSize(M);
505 }
506
507 /// \copydoc TargetLibraryInfoImpl::getSizeTSize()
508 unsigned getSizeTSize(const Module &M) const { return Impl->getSizeTSize(M); }
509
510 /// \copydoc TargetLibraryInfoImpl::getIntSize()
511 unsigned getIntSize() const {
512 return Impl->getIntSize();
513 }
514
515 /// Handle invalidation from the pass manager.
516 ///
517 /// If we try to invalidate this info, just return false. It cannot become
518 /// invalid even if the module or function changes.
521 return false;
522 }
525 return false;
526 }
527 /// Returns the largest vectorization factor used in the list of
528 /// vector functions.
529 void getWidestVF(StringRef ScalarF, ElementCount &FixedVF,
530 ElementCount &ScalableVF) const {
531 Impl->getWidestVF(ScalarF, FixedVF, ScalableVF);
532 }
533
534 /// Check if the function "F" is listed in a library known to LLVM.
536 return this->isFunctionVectorizable(F);
537 }
538};
539
540/// Analysis pass providing the \c TargetLibraryInfo.
541///
542/// Note that this pass's result cannot be invalidated, it is immutable for the
543/// life of the module.
544class TargetLibraryAnalysis : public AnalysisInfoMixin<TargetLibraryAnalysis> {
545public:
547
548 /// Default construct the library analysis.
549 ///
550 /// This will use the module's triple to construct the library info for that
551 /// module.
553
554 /// Construct a library analysis with baseline Module-level info.
555 ///
556 /// This will be supplemented with Function-specific info in the Result.
558 : BaselineInfoImpl(std::move(BaselineInfoImpl)) {}
559
561
562private:
564 static AnalysisKey Key;
565
566 std::optional<TargetLibraryInfoImpl> BaselineInfoImpl;
567};
568
571 std::optional<TargetLibraryInfo> TLI;
572
573 virtual void anchor();
574
575public:
576 static char ID;
578 explicit TargetLibraryInfoWrapperPass(const Triple &T);
580
583 TLI = TLA.run(F, DummyFAM);
584 return *TLI;
585 }
586};
587
588} // end namespace llvm
589
590#endif
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:805
@ 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:87
@ None
No attributes have been set.
Definition: Attributes.h:89
BitVector & set()
Definition: BitVector.h:351
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1190
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Definition: InstrTypes.h:1877
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1412
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:155
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:282
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:851
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)
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.
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.
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 getVectorizedFunction(StringRef F, const ElementCount &VF, bool Masked=false) const
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:1946
Definition: BitVector.h:858
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