Go to the documentation of this file.
9 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
10 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
21 template <
typename T>
class ArrayRef;
36 #define TLI_DEFINE_ENUM
37 #include "llvm/Analysis/TargetLibraryInfo.def"
55 bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param;
58 enum AvailabilityState {
64 AvailableArray[
F/4] &= ~(3 << 2*(
F&3));
65 AvailableArray[
F/4] |= State << 2*(
F&3);
72 std::vector<VecDesc> VectorDescs;
75 std::vector<VecDesc> ScalarDescs;
130 setState(
F, StandardName);
136 if (StandardNames[
F] !=
Name) {
137 setState(
F, CustomName);
138 CustomNames[
F] = std::string(
Name);
139 assert(CustomNames.find(
F) != CustomNames.end());
141 setState(
F, StandardName);
176 ShouldExtI32Param = Val;
183 ShouldExtI32Return = Val;
189 ShouldSignExtI32Param = Val;
236 : Impl(&Impl), OverrideAsUnavailable(
NumLibFuncs) {
239 if ((*F)->hasFnAttribute(
"no-builtins"))
244 AttributeSet FnAttrs = (*F)->getAttributes().getFnAttrs();
246 if (!Attr.isStringAttribute())
248 auto AttrStr = Attr.getKindAsString();
249 if (!AttrStr.consume_front(
"no-builtin-"))
260 : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
264 OverrideAsUnavailable = TLI.OverrideAsUnavailable;
273 bool AllowCallerSuperset)
const {
274 if (!AllowCallerSuperset)
275 return OverrideAsUnavailable == CalleeTLI.OverrideAsUnavailable;
277 B |= CalleeTLI.OverrideAsUnavailable;
280 return B == OverrideAsUnavailable;
287 return Impl->isValidProtoForLibFunc(FTy,
F,
M);
313 OverrideAsUnavailable.
set();
318 OverrideAsUnavailable.
set(
F);
322 if (OverrideAsUnavailable[
F])
323 return TargetLibraryInfoImpl::Unavailable;
324 return Impl->getState(
F);
329 return getState(
F) != TargetLibraryInfoImpl::Unavailable;
344 if (
getState(
F) == TargetLibraryInfoImpl::Unavailable)
348 case LibFunc_copysign:
case LibFunc_copysignf:
case LibFunc_copysignl:
349 case LibFunc_fabs:
case LibFunc_fabsf:
case LibFunc_fabsl:
350 case LibFunc_sin:
case LibFunc_sinf:
case LibFunc_sinl:
351 case LibFunc_cos:
case LibFunc_cosf:
case LibFunc_cosl:
352 case LibFunc_sqrt:
case LibFunc_sqrtf:
case LibFunc_sqrtl:
353 case LibFunc_sqrt_finite:
case LibFunc_sqrtf_finite:
354 case LibFunc_sqrtl_finite:
355 case LibFunc_fmax:
case LibFunc_fmaxf:
case LibFunc_fmaxl:
356 case LibFunc_fmin:
case LibFunc_fminf:
case LibFunc_fminl:
357 case LibFunc_floor:
case LibFunc_floorf:
case LibFunc_floorl:
358 case LibFunc_nearbyint:
case LibFunc_nearbyintf:
case LibFunc_nearbyintl:
359 case LibFunc_ceil:
case LibFunc_ceilf:
case LibFunc_ceill:
360 case LibFunc_rint:
case LibFunc_rintf:
case LibFunc_rintl:
361 case LibFunc_round:
case LibFunc_roundf:
case LibFunc_roundl:
362 case LibFunc_trunc:
case LibFunc_truncf:
case LibFunc_truncl:
363 case LibFunc_log2:
case LibFunc_log2f:
case LibFunc_log2l:
364 case LibFunc_exp2:
case LibFunc_exp2f:
case LibFunc_exp2l:
365 case LibFunc_memcpy:
case LibFunc_memset:
case LibFunc_memmove:
366 case LibFunc_memcmp:
case LibFunc_bcmp:
case LibFunc_strcmp:
367 case LibFunc_strcpy:
case LibFunc_stpcpy:
case LibFunc_strlen:
368 case LibFunc_strnlen:
case LibFunc_memchr:
case LibFunc_mempcpy:
376 if (State == TargetLibraryInfoImpl::Unavailable)
378 if (State == TargetLibraryInfoImpl::StandardName)
379 return Impl->StandardNames[
F];
380 assert(State == TargetLibraryInfoImpl::CustomName);
381 return Impl->CustomNames.
find(
F)->second;
388 if (Impl->ShouldExtI32Param)
389 return Signed ? Attribute::SExt : Attribute::ZExt;
390 if (Impl->ShouldSignExtI32Param)
391 return Attribute::SExt;
399 if (Impl->ShouldExtI32Return)
400 return Signed ? Attribute::SExt : Attribute::ZExt;
457 : BaselineInfoImpl(
std::
move(BaselineInfoImpl)) {}
472 virtual void anchor();
482 TLI = TLA.
run(
F, DummyFAM);
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
A set of analyses that are preserved following a run of a transformation pass.
bool getLibFunc(const Function &FDecl, LibFunc &F) const
Describes a possible vectorization of a function.
void setAvailable(LibFunc F)
Forces a function to be marked as available.
This is an optimization pass for GlobalISel generic memory operations.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
ImmutablePass class - This class is used to provide information that does not need to be run.
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...
TargetLibraryInfo(const TargetLibraryInfoImpl &Impl, Optional< const Function * > F=None)
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
Triple - Helper class for working with autoconf configuration names.
TargetLibraryInfo(TargetLibraryInfo &&TLI)
void disableAllFunctions() LLVM_ATTRIBUTE_UNUSED
Disables all builtins.
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
Implementation of the target library information.
#define LLVM_ATTRIBUTE_UNUSED
void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib)
Calls addVectorizableFunctions with a known preset of functions for the given vector library.
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
void setAvailableWithName(LibFunc F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used.
Attribute::AttrKind getExtAttrForI32Return(bool Signed=true) const
Returns extension attribute kind to be used for i32 return values corresponding to C-level int or uns...
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Return the name of the equivalent of F, vectorized with factor VF.
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const
Returns the largest vectorization factor used in the list of vector functions.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
TargetLibraryInfo & operator=(TargetLibraryInfo &&TLI)
TargetLibraryInfoImpl::AvailabilityState getState(LibFunc F) const
TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
StringRef getName(LibFunc F) const
API to communicate dependencies between analyses during invalidation.
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
bool areInlineCompatible(const TargetLibraryInfo &CalleeTLI, bool AllowCallerSuperset) const
Determine whether a callee with the given TLI can be inlined into caller with this TLI,...
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
@ None
No attributes have been set.
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
A special type used by analysis passes to provide an address that identifies that particular analysis...
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
Handle invalidation from the pass manager.
TargetLibraryAnalysis()=default
Default construct the library analysis.
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void setShouldExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...
@ Unavailable
We know the block is not fully available. This is a fixpoint.
bool has(LibFunc F) const
Tests whether a library function is available.
bool isKnownVectorFunctionInLibrary(StringRef F) const
Check if the function "F" is listed in a library known to LLVM.
A Module instance is used to store all the information related to an LLVM module.
A CRTP mix-in that provides informational APIs needed for analysis passes.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
TargetLibraryAnalysis(TargetLibraryInfoImpl BaselineInfoImpl)
Construct a library analysis with baseline Module-level info.
StringRef - Represent a constant reference to a string, i.e.
TargetLibraryInfo & operator=(const TargetLibraryInfo &TLI)=default
TargetLibraryInfoWrapperPass()
Machine Check Debug Module
TargetLibraryInfo & getTLI(const Function &F)
amdgpu Simplify well known AMD library false FunctionCallee Callee
void disableAllFunctions()
Disables all builtins.
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
Provides information about what library functions are available for the current target.
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...
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
bool isFunctionVectorizable(StringRef F) const
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.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &ScalableVF) const
Returns the largest vectorization factor used in the list of vector functions.
A container for analyses that lazily runs them and caches their results.
static bool isCallingConvCCompatible(CallBase *CI)
Returns true if call site / callee has cdecl-compatible calling conventions.
bool hasOptimizedCodeGen(LibFunc F) const
Tests if the function is both available and a candidate for optimized code generation.
ElementCount VectorizationFactor
void setUnavailable(LibFunc F) LLVM_ATTRIBUTE_UNUSED
Forces a function to be marked as unavailable.
VectorLibrary
List of known vector-functions libraries.
void setIntSize(unsigned Bits)
Initialize the C-level size of an integer.
Analysis pass providing the TargetLibraryInfo.
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Class to represent function types.