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;
117 setState(F, Unavailable);
122 setState(F, StandardName);
128 if (StandardNames[F] != Name) {
129 setState(F, CustomName);
130 CustomNames[
F] =
Name;
131 assert(CustomNames.find(F) != CustomNames.end());
133 setState(F, StandardName);
140 void disableAllFunctions();
148 void addVectorizableFunctionsFromVecLib(
enum VectorLibrary VecLib);
153 return !getVectorizedFunction(F, VF).empty();
158 bool isFunctionVectorizable(
StringRef F)
const;
167 return !getScalarizedFunction(F, VF).empty();
180 ShouldExtI32Param = Val;
187 ShouldExtI32Return = Val;
193 ShouldSignExtI32Param = Val;
198 unsigned getWCharSize(
const Module &M)
const;
248 return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable;
263 if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable)
267 case LibFunc_copysign:
case LibFunc_copysignf:
case LibFunc_copysignl:
268 case LibFunc_fabs:
case LibFunc_fabsf:
case LibFunc_fabsl:
269 case LibFunc_sin:
case LibFunc_sinf:
case LibFunc_sinl:
270 case LibFunc_cos:
case LibFunc_cosf:
case LibFunc_cosl:
271 case LibFunc_sqrt:
case LibFunc_sqrtf:
case LibFunc_sqrtl:
272 case LibFunc_sqrt_finite:
case LibFunc_sqrtf_finite:
273 case LibFunc_sqrtl_finite:
274 case LibFunc_fmax:
case LibFunc_fmaxf:
case LibFunc_fmaxl:
275 case LibFunc_fmin:
case LibFunc_fminf:
case LibFunc_fminl:
276 case LibFunc_floor:
case LibFunc_floorf:
case LibFunc_floorl:
277 case LibFunc_nearbyint:
case LibFunc_nearbyintf:
case LibFunc_nearbyintl:
278 case LibFunc_ceil:
case LibFunc_ceilf:
case LibFunc_ceill:
279 case LibFunc_rint:
case LibFunc_rintf:
case LibFunc_rintl:
280 case LibFunc_round:
case LibFunc_roundf:
case LibFunc_roundl:
281 case LibFunc_trunc:
case LibFunc_truncf:
case LibFunc_truncl:
282 case LibFunc_log2:
case LibFunc_log2f:
case LibFunc_log2l:
283 case LibFunc_exp2:
case LibFunc_exp2f:
case LibFunc_exp2l:
284 case LibFunc_memcmp:
case LibFunc_strcmp:
case LibFunc_strcpy:
285 case LibFunc_stpcpy:
case LibFunc_strlen:
case LibFunc_strnlen:
286 case LibFunc_memchr:
case LibFunc_mempcpy:
293 auto State = Impl->getState(F);
294 if (State == TargetLibraryInfoImpl::Unavailable)
296 if (State == TargetLibraryInfoImpl::StandardName)
297 return Impl->StandardNames[
F];
298 assert(State == TargetLibraryInfoImpl::CustomName);
299 return Impl->CustomNames.
find(F)->second;
306 if (Impl->ShouldExtI32Param)
308 if (Impl->ShouldSignExtI32Param)
317 if (Impl->ShouldExtI32Return)
360 : PresetInfoImpl(
std::move(PresetInfoImpl)) {}
380 virtual void anchor();
A parsed version of the target data layout string in and methods for querying it. ...
This class represents lattice values for constants.
void setShouldExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...
A Module instance is used to store all the information related to an LLVM module. ...
VectorLibrary
List of known vector-functions libraries.
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...
StringRef getName(LibFunc F) const
Implementation of the target library information.
TargetLibraryInfo & operator=(const TargetLibraryInfo &TLI)
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(const Function &FDecl, LibFunc &F) const
TargetLibraryInfo & operator=(TargetLibraryInfo &&TLI)
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
TargetLibraryAnalysis()
Default construct the library analysis.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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...
TargetLibraryInfo & getTLI()
No attributes have been set.
Class to represent function types.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
bool has(LibFunc F) const
Tests whether a library function is available.
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 ...
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
iterator find(const_arg_type_t< KeyT > Val)
A set of analyses that are preserved following a run of a transformation pass.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
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.
bool isFunctionVectorizable(StringRef F, unsigned VF) const
Module.h This file contains the declarations for the Module class.
Provides information about what library functions are available for the current target.
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
Return the name of the equivalent of F, vectorized with factor VF.
bool hasOptimizedCodeGen(LibFunc F) const
Tests if the function is both available and a candidate for optimized code generation.
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
const TargetLibraryInfo & getTLI() const
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
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...
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
bool isFunctionVectorizable(StringRef F) const
Establish a view to a call site for examination.
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
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.
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setAvailableWithName(LibFunc F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used...
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)
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...