10 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
11 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
22 template <
typename T>
class ArrayRef;
35 #define TLI_DEFINE_ENUM
36 #include "llvm/Analysis/TargetLibraryInfo.def"
54 bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param;
56 enum AvailabilityState {
62 AvailableArray[F/4] &= ~(3 << 2*(F&3));
63 AvailableArray[F/4] |= State << 2*(F&3);
66 return static_cast<AvailabilityState
>((AvailableArray[F/4] >> 2*(F&3)) & 3);
70 std::vector<VecDesc> VectorDescs;
73 std::vector<VecDesc> ScalarDescs;
77 bool isValidProtoForLibFunc(
const FunctionType &FTy,
LibFunc::Func F,
78 const DataLayout *DL)
const;
118 setState(F, Unavailable);
123 setState(F, StandardName);
129 if (StandardNames[F] != Name) {
130 setState(F, CustomName);
131 CustomNames[
F] =
Name;
134 setState(F, StandardName);
181 ShouldExtI32Param = Val;
188 ShouldExtI32Return = Val;
194 ShouldSignExtI32Param = Val;
238 return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable;
253 if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable)
257 case LibFunc::copysign:
case LibFunc::copysignf:
case LibFunc::copysignl:
258 case LibFunc::fabs:
case LibFunc::fabsf:
case LibFunc::fabsl:
259 case LibFunc::sin:
case LibFunc::sinf:
case LibFunc::sinl:
260 case LibFunc::cos:
case LibFunc::cosf:
case LibFunc::cosl:
261 case LibFunc::sqrt:
case LibFunc::sqrtf:
case LibFunc::sqrtl:
262 case LibFunc::sqrt_finite:
case LibFunc::sqrtf_finite:
263 case LibFunc::sqrtl_finite:
264 case LibFunc::fmax:
case LibFunc::fmaxf:
case LibFunc::fmaxl:
265 case LibFunc::fmin:
case LibFunc::fminf:
case LibFunc::fminl:
266 case LibFunc::floor:
case LibFunc::floorf:
case LibFunc::floorl:
267 case LibFunc::nearbyint:
case LibFunc::nearbyintf:
case LibFunc::nearbyintl:
268 case LibFunc::ceil:
case LibFunc::ceilf:
case LibFunc::ceill:
269 case LibFunc::rint:
case LibFunc::rintf:
case LibFunc::rintl:
271 case LibFunc::trunc:
case LibFunc::truncf:
case LibFunc::truncl:
272 case LibFunc::log2:
case LibFunc::log2f:
case LibFunc::log2l:
273 case LibFunc::exp2:
case LibFunc::exp2f:
case LibFunc::exp2l:
275 case LibFunc::stpcpy:
case LibFunc::strlen:
case LibFunc::strnlen:
276 case LibFunc::memchr:
case LibFunc::mempcpy:
283 auto State = Impl->getState(F);
284 if (State == TargetLibraryInfoImpl::Unavailable)
286 if (State == TargetLibraryInfoImpl::StandardName)
287 return Impl->StandardNames[
F];
288 assert(State == TargetLibraryInfoImpl::CustomName);
289 return Impl->CustomNames.
find(F)->second;
296 if (Impl->ShouldExtI32Param)
297 return Signed ? Attribute::SExt : Attribute::ZExt;
298 if (Impl->ShouldSignExtI32Param)
299 return Attribute::SExt;
307 if (Impl->ShouldExtI32Return)
308 return Signed ? Attribute::SExt : Attribute::ZExt;
345 : PresetInfoImpl(std::move(PresetInfoImpl)) {}
365 virtual void anchor();
bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const
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...
static uint64_t round(uint64_t Acc, uint64_t Input)
void disableAllFunctions()
Disables all builtins.
TargetLibraryInfoWrapperPass()
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.
TargetLibraryInfo & operator=(const TargetLibraryInfo &TLI)
void setAvailableWithName(LibFunc::Func F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with strcmp
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()
bool has(LibFunc::Func F) const
Tests whether a library function is available.
bool hasOptimizedCodeGen(LibFunc::Func F) const
Tests if the function is both available and a candidate for optimized code generation.
No attributes have been set.
void setUnavailable(LibFunc::Func F)
Forces a function to be marked as unavailable.
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
Searches for a particular function name.
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 setAvailable(LibFunc::Func F)
Forces a function to be marked as available.
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
Searches for a particular function name.
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...
A CRTP mix-in that provides informational APIs needed for analysis passes.
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.
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.
StringRef getName(LibFunc::Func F) const
bool isFunctionVectorizable(StringRef F, unsigned VF) 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...
iterator find(const KeyT &Val)
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())
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)
TargetLibraryInfo(const TargetLibraryInfoImpl &Impl)
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...
StringRef getVectorizedFunction(StringRef F, unsigned VF) const