28 if (MangledName.
empty())
133 Ret = tryParseLinearTokenWithRuntimeStep(ParseString, PKind, StepOrPos,
"ls");
138 Ret = tryParseLinearTokenWithRuntimeStep(ParseString, PKind, StepOrPos,
"Rs");
143 Ret = tryParseLinearTokenWithRuntimeStep(ParseString, PKind, StepOrPos,
"Ls");
148 Ret = tryParseLinearTokenWithRuntimeStep(ParseString, PKind, StepOrPos,
"Us");
195 if (tryParseCompileTimeLinearToken(ParseString, PKind, StepOrPos,
"l") ==
200 if (tryParseCompileTimeLinearToken(ParseString, PKind, StepOrPos,
"R") ==
205 if (tryParseCompileTimeLinearToken(ParseString, PKind, StepOrPos,
"L") ==
210 if (tryParseCompileTimeLinearToken(ParseString, PKind, StepOrPos,
"U") ==
240 tryParseLinearWithRuntimeStep(ParseString, PKind, StepOrPos);
242 return HasLinearRuntime;
244 const ParseRet HasLinearCompileTime =
245 tryParseLinearWithCompileTimeStep(ParseString, PKind, StepOrPos);
247 return HasLinearCompileTime;
270 Alignment =
Align(Val);
280 bool verifyAllVectorsHaveSameWidth(
FunctionType *Signature) {
282 if (
auto *RetTy = dyn_cast<VectorType>(Signature->
getReturnType()))
284 for (
auto *Ty : Signature->
params())
285 if (
auto *VTy = dyn_cast<VectorType>(Ty))
288 if (VecTys.
size() <= 1)
291 assert(VecTys.
size() > 1 &&
"Invalid number of elements.");
304 assert(verifyAllVectorsHaveSameWidth(Signature) &&
305 "Invalid vector signature.");
307 if (
auto *RetTy = dyn_cast<VectorType>(Signature->
getReturnType()))
308 return RetTy->getElementCount();
309 for (
auto *Ty : Signature->
params())
310 if (
auto *VTy = dyn_cast<VectorType>(Ty))
321 const StringRef OriginalName = MangledName;
334 if (tryParseISA(MangledName, ISA) != ParseRet::OK)
339 if (tryParseMask(MangledName, IsMasked) != ParseRet::OK)
345 if (tryParseVLEN(MangledName, VF, IsScalable) != ParseRet::OK)
352 const unsigned ParameterPos = Parameters.
size();
355 ParamFound = tryParseParameter(MangledName, PKind, StepOrPos);
361 if (ParamFound == ParseRet::OK) {
364 const ParseRet AlignFound = tryParseAlign(MangledName, Alignment);
370 Parameters.
push_back({ParameterPos, PKind, StepOrPos, Alignment});
372 }
while (ParamFound == ParseRet::OK);
376 if (Parameters.
empty())
389 if (ScalarName.
empty())
393 MangledName = MangledName.
ltrim(ScalarName);
399 VectorName = MangledName;
401 if (VectorName.
empty())
413 const unsigned Pos = Parameters.
size();
426 assert(NGlobalPreds < 2 &&
"Cannot have more than one global predicate.");
429 "The global predicate must be the last parameter");
439 const Function *
F = M.getFunction(VectorName);
444 const ElementCount EC = getECFromSignature(
F->getFunctionType());
445 VF = EC.getKnownMinValue();
454 if (!M.getFunction(VectorName))
457 const VFShape Shape({VF, IsScalable, Parameters});
458 return VFInfo({Shape, std::string(ScalarName), std::string(VectorName), ISA});
480 " that have a textual representation in the mangled name" 481 " of the Vector Function ABI");
LLVM_NODISCARD StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module.
LLVM_NODISCARD bool empty() const
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
void push_back(const T &Elt)
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Contains the information about the kind of vectorization available.
LLVM_NODISCARD StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
static constexpr char const * _LLVM_
LLVM Internal VFABI ISA token for vector functions.
Holds the VFShape for a specific scalar to vector function mapping.
StringSwitch & Case(StringLiteral S, T Value)
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LLVM_NODISCARD R Default(T Value)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
std::enable_if_t< std::numeric_limits< T >::is_signed, bool > consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD StringRef take_while(function_ref< bool(char)> F) const
Return the longest prefix of 'this' such that every character in the prefix satisfies the given predi...
Class to represent function types.
VFISAKind
Describes the type of Instruction Set Architecture.
A switch()-like statement whose cases are string literals.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Encapsulates information needed to describe a parameter.
ArrayRef< Type * > params() const
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Type * getReturnType() const
Base class of all SIMD vector types.
VFParamKind
Describes the type of Parameters.
ParseRet
Utilities for the Vector Function ABI name parser.
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
VFParamKind getVFParamKindFromString(const StringRef Token)
Retrieve the VFParamKind from a string token.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
auto drop_begin(T &&RangeOrContainer, size_t N)
Return a range covering RangeOrContainer with the first N elements excluded.
StringRef - Represent a constant reference to a string, i.e.
Optional< VFInfo > tryDemangleForVFABI(StringRef MangledName, const Module &M)
Function to construct a VFInfo out of a mangled names in the following format:
static ElementCount getFixed(ScalarTy MinVal)