10 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
11 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
23 template <
typename T>
class ArrayRef;
35 #define TLI_DEFINE_ENUM
36 #include "llvm/Analysis/TargetLibraryInfo.def"
53 bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param;
55 enum AvailabilityState {
60 void setState(
LibFunc F, AvailabilityState State) {
61 AvailableArray[F/4] &= ~(3 << 2*(F&3));
62 AvailableArray[F/4] |= State << 2*(F&3);
64 AvailabilityState getState(
LibFunc F)
const {
65 return static_cast<AvailabilityState
>((AvailableArray[F/4] >> 2*(F&3)) & 3);
69 std::vector<VecDesc> VectorDescs;
72 std::vector<VecDesc> ScalarDescs;
76 bool isValidProtoForLibFunc(
const FunctionType &FTy,
LibFunc F,
77 const DataLayout *
DL)
const;
117 setState(F, Unavailable);
122 setState(F, StandardName);
128 if (StandardNames[F] != Name) {
129 setState(F, CustomName);
130 CustomNames[
F] =
Name;
133 setState(F, StandardName);
180 ShouldExtI32Param = Val;
187 ShouldExtI32Return = Val;
193 ShouldSignExtI32Param = Val;
252 return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable;
267 if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable)
271 case LibFunc_copysign:
case LibFunc_copysignf:
case LibFunc_copysignl:
272 case LibFunc_fabs:
case LibFunc_fabsf:
case LibFunc_fabsl:
273 case LibFunc_sin:
case LibFunc_sinf:
case LibFunc_sinl:
274 case LibFunc_cos:
case LibFunc_cosf:
case LibFunc_cosl:
275 case LibFunc_sqrt:
case LibFunc_sqrtf:
case LibFunc_sqrtl:
276 case LibFunc_sqrt_finite:
case LibFunc_sqrtf_finite:
277 case LibFunc_sqrtl_finite:
278 case LibFunc_fmax:
case LibFunc_fmaxf:
case LibFunc_fmaxl:
279 case LibFunc_fmin:
case LibFunc_fminf:
case LibFunc_fminl:
280 case LibFunc_floor:
case LibFunc_floorf:
case LibFunc_floorl:
281 case LibFunc_nearbyint:
case LibFunc_nearbyintf:
case LibFunc_nearbyintl:
282 case LibFunc_ceil:
case LibFunc_ceilf:
case LibFunc_ceill:
283 case LibFunc_rint:
case LibFunc_rintf:
case LibFunc_rintl:
284 case LibFunc_round:
case LibFunc_roundf:
case LibFunc_roundl:
285 case LibFunc_trunc:
case LibFunc_truncf:
case LibFunc_truncl:
286 case LibFunc_log2:
case LibFunc_log2f:
case LibFunc_log2l:
287 case LibFunc_exp2:
case LibFunc_exp2f:
case LibFunc_exp2l:
288 case LibFunc_memcmp:
case LibFunc_strcmp:
case LibFunc_strcpy:
289 case LibFunc_stpcpy:
case LibFunc_strlen:
case LibFunc_strnlen:
290 case LibFunc_memchr:
case LibFunc_mempcpy:
297 auto State = Impl->getState(F);
298 if (State == TargetLibraryInfoImpl::Unavailable)
300 if (State == TargetLibraryInfoImpl::StandardName)
301 return Impl->StandardNames[
F];
302 assert(State == TargetLibraryInfoImpl::CustomName);
303 return Impl->CustomNames.
find(F)->second;
310 if (Impl->ShouldExtI32Param)
311 return Signed ? Attribute::SExt : Attribute::ZExt;
312 if (Impl->ShouldSignExtI32Param)
313 return Attribute::SExt;
321 if (Impl->ShouldExtI32Return)
322 return Signed ? Attribute::SExt : Attribute::ZExt;
364 : PresetInfoImpl(std::move(PresetInfoImpl)) {}
384 virtual void anchor();
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...
A Module instance is used to store all the information related to an LLVM module. ...
VectorLibrary
List of known vector-functions libraries.
bool isFunctionVectorizable(StringRef F) const
TargetLibraryInfo(const TargetLibraryInfo &TLI)
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
void disableAllFunctions()
Disables all builtins.
TargetLibraryInfoWrapperPass()
static unsigned getTargetWCharSize(const Triple &T)
Returns size of the default wchar_t type on target T.
Implementation of the target library information.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
TargetLibraryInfo & operator=(const TargetLibraryInfo &TLI)
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
TargetLibraryInfo & operator=(TargetLibraryInfo &&TLI)
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
Return the name of the equivalent of F, vectorized with factor VF.
TargetLibraryAnalysis()
Default construct the library analysis.
TargetLibraryInfo & getTLI()
No attributes have been set.
const TargetLibraryInfo & getTLI() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
TargetLibraryInfo run(Module &M, ModuleAnalysisManager &)
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
iterator find(const_arg_type_t< KeyT > Val)
bool hasOptimizedCodeGen(LibFunc F) const
Tests if the function is both available and a candidate for optimized code generation.
A set of analyses that are preserved following a run of a transformation pass.
bool isFunctionScalarizable(StringRef F, unsigned &VF) const
Return true if the function F has a scalar equivalent, and set VF to be the vectorization factor...
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
A CRTP mix-in that provides informational APIs needed for analysis passes.
bool getLibFunc(ImmutableCallSite CS, LibFunc &F) const
If a callsite does not have the 'nobuiltin' attribute, return if the called function is a known libra...
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes.
Triple - Helper class for working with autoconf configuration names.
unsigned VectorizationFactor
ImmutablePass class - This class is used to provide information that does not need to be run...
Describes a possible vectorization of a function.
Module.h This file contains the declarations for the Module class.
Provides information about what library functions are available for the current target.
bool getLibFunc(const Function &FDecl, LibFunc &F) const
StringRef getScalarizedFunction(StringRef F, unsigned &VF) const
Return the name of the equivalent of F, scalarized.
TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib)
Calls addVectorizableFunctions with a known preset of functions for the given vector library...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
Establish a view to a call site for examination.
StringRef getName(LibFunc F) const
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...
API to communicate dependencies between analyses during invalidation.
TargetLibraryAnalysis(TargetLibraryInfoImpl PresetInfoImpl)
Construct a library analysis with preset info.
bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
Handle invalidation from the pass manager.
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
void setAvailableWithName(LibFunc F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used...
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes.
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
TargetLibraryInfo(TargetLibraryInfo &&TLI)
void setAvailable(LibFunc F)
Forces a function to be marked as available.
TargetLibraryInfo(const TargetLibraryInfoImpl &Impl)
A special type used by analysis passes to provide an address that identifies that particular analysis...
bool has(LibFunc F) const
Tests whether a library function is available.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
StringRef getVectorizedFunction(StringRef F, unsigned VF) const