10 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
11 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
34 #define TLI_DEFINE_ENUM
35 #include "llvm/Analysis/TargetLibraryInfo.def"
54 enum AvailabilityState {
60 AvailableArray[F/4] &= ~(3 << 2*(F&3));
61 AvailableArray[F/4] |= State << 2*(F&3);
64 return static_cast<AvailabilityState
>((AvailableArray[F/4] >> 2*(F&3)) & 3);
68 std::vector<VecDesc> VectorDescs;
71 std::vector<VecDesc> ScalarDescs;
103 setState(F, Unavailable);
108 setState(F, StandardName);
114 if (StandardNames[F] != Name) {
115 setState(F, CustomName);
116 CustomNames[
F] =
Name;
117 assert(CustomNames.
find(F) != CustomNames.
end());
119 setState(F, StandardName);
200 return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable;
215 if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable)
219 case LibFunc::copysign:
case LibFunc::copysignf:
case LibFunc::copysignl:
220 case LibFunc::fabs:
case LibFunc::fabsf:
case LibFunc::fabsl:
221 case LibFunc::sin:
case LibFunc::sinf:
case LibFunc::sinl:
222 case LibFunc::cos:
case LibFunc::cosf:
case LibFunc::cosl:
223 case LibFunc::sqrt:
case LibFunc::sqrtf:
case LibFunc::sqrtl:
224 case LibFunc::sqrt_finite:
case LibFunc::sqrtf_finite:
225 case LibFunc::sqrtl_finite:
226 case LibFunc::fmax:
case LibFunc::fmaxf:
case LibFunc::fmaxl:
227 case LibFunc::fmin:
case LibFunc::fminf:
case LibFunc::fminl:
228 case LibFunc::floor:
case LibFunc::floorf:
case LibFunc::floorl:
229 case LibFunc::nearbyint:
case LibFunc::nearbyintf:
case LibFunc::nearbyintl:
230 case LibFunc::ceil:
case LibFunc::ceilf:
case LibFunc::ceill:
231 case LibFunc::rint:
case LibFunc::rintf:
case LibFunc::rintl:
232 case LibFunc::round:
case LibFunc::roundf:
case LibFunc::roundl:
233 case LibFunc::trunc:
case LibFunc::truncf:
case LibFunc::truncl:
234 case LibFunc::log2:
case LibFunc::log2f:
case LibFunc::log2l:
235 case LibFunc::exp2:
case LibFunc::exp2f:
case LibFunc::exp2l:
236 case LibFunc::memcmp:
case LibFunc::strcmp:
case LibFunc::strcpy:
237 case LibFunc::stpcpy:
case LibFunc::strlen:
case LibFunc::strnlen:
238 case LibFunc::memchr:
245 auto State = Impl->getState(F);
246 if (State == TargetLibraryInfoImpl::Unavailable)
248 if (State == TargetLibraryInfoImpl::StandardName)
249 return Impl->StandardNames[
F];
250 assert(State == TargetLibraryInfoImpl::CustomName);
251 return Impl->CustomNames.
find(F)->second;
270 static void *
ID() {
return (
void *)&PassID; }
283 : PresetInfoImpl(std::move(PresetInfoImpl)) {}
287 : PresetInfoImpl(std::move(Arg.PresetInfoImpl)), Impls(std::move(Arg.Impls)) {}
289 PresetInfoImpl = std::move(RHS.PresetInfoImpl);
290 Impls = std::move(RHS.Impls);
314 virtual void anchor();
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
addVectorizableFunctions - Add a set of scalar -> vector mappings, queryable via getVectorizedFunctio...
A Module instance is used to store all the information related to an LLVM module. ...
VectorLibrary
List of known vector-functions libraries.
static void * ID()
Opaque, unique identifier for this analysis pass.
bool isFunctionVectorizable(StringRef F) const
TargetLibraryInfo(const TargetLibraryInfo &TLI)
void disableAllFunctions()
Disables all builtins.
TargetLibraryInfoWrapperPass()
static StringRef name()
Provide access to a name for this pass for debugging purposes.
Implementation of the target library information.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
isFunctionVectorizable - Return true if the function F has a vector equivalent with vectorization fac...
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...
TargetLibraryInfo & operator=(TargetLibraryInfo &&TLI)
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
getVectorizedFunction - 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.
TargetLibraryInfo run(Module &M)
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)...
TargetLibraryAnalysis & operator=(TargetLibraryAnalysis &&RHS)
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.
An abstract set of preserved analyses following a transformation pass run.
bool isFunctionScalarizable(StringRef F, unsigned &VF) const
isFunctionScalarizable - Return true if the function F has a scalar equivalent, and set VF to be the ...
const char * VectorFnName
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...
VecDesc - 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
getScalarizedFunction - 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...
const char * ScalarFnName
StringRef getName(LibFunc::Func F) const
bool isFunctionVectorizable(StringRef F, unsigned VF) const
iterator find(const KeyT &Val)
TargetLibraryAnalysis(TargetLibraryInfoImpl PresetInfoImpl)
Construct a library analysis with preset info.
Analysis pass providing the TargetLibraryInfo.
TargetLibraryAnalysis(TargetLibraryAnalysis &&Arg)
bool invalidate(Module &, const PreservedAnalyses &)
Handle invalidation from the pass manager.
StringRef - Represent a constant reference to a string, i.e.
TargetLibraryInfo(TargetLibraryInfo &&TLI)
TargetLibraryInfo(const TargetLibraryInfoImpl &Impl)
bool empty() const
empty - Check if the string is empty.
StringRef getVectorizedFunction(StringRef F, unsigned VF) const