Go to the documentation of this file.
24 "No vector functions library"),
26 "Accelerate framework"),
28 "Darwin_libsystem_m",
"Darwin libsystem_m"),
30 "GLIBC Vector Math library"),
32 "IBM MASS vector library"),
34 "Intel SVML library"),
36 "SIMD Library for Evaluating Elementary Functions")));
40 #define TLI_DEFINE_STRING
41 #include "llvm/Analysis/TargetLibraryInfo.def"
71 #define TLI_DEFINE_SIG
72 #include "llvm/Analysis/TargetLibraryInfo.def"
76 "Missing library function signatures");
87 if (
T.isMacOSX() &&
T.isMacOSXVersionLT(10, 9))
90 if (
T.isiOS() &&
T.isOSVersionLT(7, 0))
100 return TT.isGNUEnvironment() || TT.isMusl();
103 return TT.isOSFreeBSD() || TT.isOSSolaris();
127 for (
auto *Param : FuncTy->
params()) {
128 if (!Param->isPointerTy() && !Param->isIntegerTy())
145 F->getParent()->getTargetTriple(),
146 F->getFunctionType());
158 "TargetLibraryInfoImpl function names must be sorted");
173 bool ShouldExtI32Param, ShouldExtI32Return;
174 bool ShouldSignExtI32Param, ShouldSignExtI32Return;
176 ShouldExtI32Return, ShouldSignExtI32Param, ShouldSignExtI32Return,
T);
205 if (
T.isMacOSXVersionLT(10, 5)) {
210 }
else if (
T.isiOS()) {
211 if (
T.isOSVersionLT(3, 0)) {
216 }
else if (!
T.isWatchOS()) {
235 !
T.isMacOSXVersionLT(10, 7)) {
260 if (
T.isOSWindows() && !
T.isOSCygMing()) {
266 bool hasPartialC99 =
true;
267 if (
T.isKnownWindowsMSVCEnvironment()) {
269 hasPartialC99 = (
Version.getMajor() == 0 ||
Version.getMajor() >= 19);
275 bool hasPartialFloat = (isARM ||
279 if (!hasPartialFloat) {
332 if (!hasPartialC99) {
416 if (
T.isOSWindows() && !
T.isWindowsCygwinEnvironment()) {
453 if (
T.isOSMSVCRT()) {
517 if (
T.isMacOSXVersionLT(10, 9)) {
529 if (!
T.isWatchOS() &&
530 (
T.isOSVersionLT(7, 0) || (
T.isOSVersionLT(9, 0) &&
T.isX86()))) {
590 if (!
T.isOSFreeBSD()) {
598 if (!
T.isOSLinux() || !
T.isGNUEnvironment()) {
606 if (!
T.isAndroid() && !
T.isMusl())
670 if ((
T.isOSLinux() &&
T.isGNUEnvironment()) ||
671 (
T.isAndroid() && !
T.isAndroidVersionLT(28))) {
685 if (
T.isAndroid() &&
T.isAndroidVersionLT(21)) {
862 memset(AvailableArray, -1,
sizeof(AvailableArray));
869 memset(AvailableArray, -1,
sizeof(AvailableArray));
875 : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
876 ShouldExtI32Return(TLI.ShouldExtI32Return),
877 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
878 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
879 SizeOfInt(TLI.SizeOfInt) {
880 memcpy(AvailableArray, TLI.AvailableArray,
sizeof(AvailableArray));
881 VectorDescs = TLI.VectorDescs;
882 ScalarDescs = TLI.ScalarDescs;
886 : CustomNames(
std::
move(TLI.CustomNames)),
887 ShouldExtI32Param(TLI.ShouldExtI32Param),
888 ShouldExtI32Return(TLI.ShouldExtI32Return),
889 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
890 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
891 SizeOfInt(TLI.SizeOfInt) {
894 VectorDescs = TLI.VectorDescs;
895 ScalarDescs = TLI.ScalarDescs;
899 CustomNames = TLI.CustomNames;
900 ShouldExtI32Param = TLI.ShouldExtI32Param;
901 ShouldExtI32Return = TLI.ShouldExtI32Return;
902 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
903 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
904 SizeOfInt = TLI.SizeOfInt;
905 memcpy(AvailableArray, TLI.AvailableArray,
sizeof(AvailableArray));
910 CustomNames =
std::move(TLI.CustomNames);
911 ShouldExtI32Param = TLI.ShouldExtI32Param;
912 ShouldExtI32Return = TLI.ShouldExtI32Return;
913 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
914 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
915 SizeOfInt = TLI.SizeOfInt;
934 if (funcName.
empty())
937 const auto *Start =
std::begin(StandardNames);
938 const auto *End =
std::end(StandardNames);
940 if (
I != End && *
I == funcName) {
950 unsigned SizeTBits) {
996 bool TargetLibraryInfoImpl::isValidProtoForLibFunc(
const FunctionType &FTy,
1005 case LibFunc_cabsl: {
1017 else if (NumParams == 2)
1018 return ParamTy == RetTy && FTy.
getParamType(1) == RetTy;
1024 case LibFunc_sincospi_stret:
1025 case LibFunc_sincospif_stret: {
1031 if (
auto *Ty = dyn_cast<StructType>(RetTy)) {
1032 if (Ty->getNumElements() != 2)
1034 return (Ty->getElementType(0) == ParamTy &&
1035 Ty->getElementType(1) == ParamTy);
1038 if (
auto *Ty = dyn_cast<FixedVectorType>(RetTy)) {
1039 if (Ty->getNumElements() != 2)
1041 return Ty->getElementType() == ParamTy;
1060 for (
auto TyID : ProtoTypes) {
1061 if (Idx && TyID == Void)
1066 if (TyID ==
Ellip) {
1070 assert(Idx == ProtoTypes.size() - 1 || ProtoTypes[Idx + 1] == Void);
1075 assert(Idx != 0 &&
"Type ID 'Same' must not be first!");
1079 if (!Ty || !
matchType(TyID, Ty, IntBits, SizeTBits))
1084 if (Idx == NumParams) {
1108 assert(
M &&
"Expecting FDecl to be connected to a Module.");
1115 memset(AvailableArray, 0,
sizeof(AvailableArray));
1119 return LHS.ScalarFnName <
RHS.ScalarFnName;
1123 return LHS.VectorFnName <
RHS.VectorFnName;
1127 return LHS.ScalarFnName <
S;
1143 #define TLI_DEFINE_ACCELERATE_VECFUNCS
1144 #include "llvm/Analysis/VecFuncs.def"
1151 #define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
1152 #include "llvm/Analysis/VecFuncs.def"
1159 #define TLI_DEFINE_LIBMVEC_X86_VECFUNCS
1160 #include "llvm/Analysis/VecFuncs.def"
1167 #define TLI_DEFINE_MASSV_VECFUNCS
1168 #include "llvm/Analysis/VecFuncs.def"
1175 #define TLI_DEFINE_SVML_VECFUNCS
1176 #include "llvm/Analysis/VecFuncs.def"
1182 const VecDesc VecFuncs_VF2[] = {
1183 #define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
1184 #include "llvm/Analysis/VecFuncs.def"
1186 const VecDesc VecFuncs_VF4[] = {
1187 #define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
1188 #include "llvm/Analysis/VecFuncs.def"
1191 switch (TargetTriple.
getArch()) {
1209 if (funcName.
empty())
1212 std::vector<VecDesc>::const_iterator
I =
1214 return I != VectorDescs.end() &&
StringRef(
I->ScalarFnName) == funcName;
1223 std::vector<VecDesc>::const_iterator
I =
1225 while (
I != VectorDescs.end() &&
StringRef(
I->ScalarFnName) ==
F) {
1226 if (
I->VectorizationFactor == VF)
1227 return I->VectorFnName;
1235 if (!BaselineInfoImpl)
1242 if (
auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
1243 M.getModuleFlag(
"wchar_size")))
1244 return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
1261 return M.getDataLayout().getPointerSizeInBits(
AddressSpace);
1284 "Target Library Information",
false,
true)
1297 if (ScalarF.
empty())
1300 std::vector<VecDesc>::const_iterator
I =
1302 while (
I != VectorDescs.end() &&
StringRef(
I->ScalarFnName) == ScalarF) {
1304 I->VectorizationFactor.isScalable() ? &ScalableVF : &FixedVF;
1306 *VF =
I->VectorizationFactor;
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
bool isFunctionVarArg() const
Describes a possible vectorization of a function.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
void setAvailable(LibFunc F)
Forces a function to be marked as available.
This is an optimization pass for GlobalISel generic memory operations.
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
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
static constexpr ElementCount getScalable(ScalarTy MinVal)
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
bool isPointerTy() const
True if this is an instance of PointerType.
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS)
ImmutablePass class - This class is used to provide information that does not need to be run.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
static constexpr ElementCount getFixed(ScalarTy MinVal)
const_iterator end(StringRef path)
Get end iterator over path.
FunctionType * getFunctionType() const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
@ C
The default llvm calling convention, compatible with C.
TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
Implementation of the target library information.
static void initExtensionsForTriple(bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
unsigned getSizeTSize(const Module &M) const
Returns the size of the size_t type in bits.
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.
bool isArrayTy() const
True if this is an instance of ArrayType.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static cl::opt< TargetLibraryInfoImpl::VectorLibrary > ClVectorLibrary("vector-library", cl::Hidden, cl::desc("Vector functions library"), cl::init(TargetLibraryInfoImpl::NoLibrary), cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none", "No vector functions library"), clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate", "Accelerate framework"), clEnumValN(TargetLibraryInfoImpl::DarwinLibSystemM, "Darwin_libsystem_m", "Darwin libsystem_m"), clEnumValN(TargetLibraryInfoImpl::LIBMVEC_X86, "LIBMVEC-X86", "GLIBC Vector Math library"), clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV", "IBM MASS vector library"), clEnumValN(TargetLibraryInfoImpl::SVML, "SVML", "Intel SVML library"), clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi", "SIMD Library for Evaluating Elementary Functions")))
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Return the name of the equivalent of F, vectorized with factor VF.
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const
Returns the largest vectorization factor used in the list of vector functions.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)
ArrayRef< Type * > params() const
Represents a version number in the form major[.minor[.subminor[.build]]].
static const FuncProtoTy Signatures[]
ArchType getArch() const
Get the parsed architecture type of this triple.
CallingConv::ID getCallingConv() const
void setShouldSignExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext attribute if they correspond t...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
bool isIntegerTy() const
True if this is an instance of IntegerType.
void sort(IteratorTy Start, IteratorTy End)
constexpr bool empty() const
empty - Check if the string is empty.
Type * getArrayElementType() const
void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib, const llvm::Triple &TargetTriple)
Calls addVectorizableFunctions with a known preset of functions for the given vector library.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Module * getParent()
Get the module that this global value is contained inside of...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
@ ARM_AAPCS
ARM Architecture Procedure Calling Standard calling convention (aka EABI).
A special type used by analysis passes to provide an address that identifies that particular analysis...
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)
Type * getParamType(unsigned i) const
Parameter type accessors.
initializer< Ty > init(const Ty &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 ...
uint64_t getArrayNumElements() const
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
bool isVoidTy() const
Return true if this is 'void'.
A Module instance is used to store all the information related to an LLVM module.
static bool isCallingConvCCompatible(CallingConv::ID CC, StringRef TT, FunctionType *FuncTy)
static bool hasBcmp(const Triple &TT)
static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits, unsigned SizeTBits)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static bool hasSinCosPiStret(const Triple &T)
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
TargetLibraryInfoWrapperPass()
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
StringRef getName() const
Return a constant reference to the value's name.
void disableAllFunctions()
Disables all builtins.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
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 is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
FunctionType * getFunctionType() const
Returns the FunctionType for me.
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
@ ARM_APCS
ARM Procedure Calling Standard (obsolete, but still used on some targets).
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
bool isStructTy() const
True if this is an instance of StructType.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
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.
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)
static StringRef sanitizeFunctionName(StringRef funcName)
VectorLibrary
List of known vector-functions libraries.
Type * getReturnType() const
void setIntSize(unsigned Bits)
Initialize the C-level size of an integer.
std::array< FuncArgTypeID, 8 > FuncProtoTy
Class to represent function types.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.