27 for (
size_t I = 0;
I < Length; ++
I) {
29 unsigned char RHC =
toLower(RHS[I]);
31 return LHC < RHC ? -1 : 1;
40 if (Length == RHS.Length)
42 return Length < RHS.Length ? -1 : 1;
47 return Length >= Prefix.Length &&
53 return Length >= Suffix.Length &&
64 for (
size_t I = 0,
E = std::min(Length, RHS.Length);
I !=
E; ++
I) {
70 for (J = I + 1; J !=
E + 1; ++J) {
71 bool ld = J < Length &&
isDigit(Data[J]);
72 bool rd = J < RHS.Length &&
isDigit(RHS.Data[J]);
79 if (
int Res = compareMemory(Data + I, RHS.Data + I, J - I))
80 return Res < 0 ? -1 : 1;
85 if (Data[I] != RHS.Data[I])
86 return (
unsigned char)Data[
I] < (
unsigned char)RHS.Data[I] ? -1 : 1;
88 if (Length == RHS.Length)
90 return Length < RHS.Length ? -1 : 1;
95 bool AllowReplacements,
96 unsigned MaxEditDistance)
const {
100 AllowReplacements, MaxEditDistance);
108 std::string Result(
size(),
char());
116 std::string Result(
size(),
char());
136 const char *Start = Data +
From;
139 const char *Needle = Str.
data();
140 size_t N = Str.
size();
146 const char *Ptr = (
const char *)::memchr(Start, Needle[0], Size);
147 return Ptr ==
nullptr ?
npos : Ptr - Data;
150 const char *Stop = Start + (Size - N + 1);
153 if (Size < 16 || N > 255) {
158 }
while (Start < Stop);
163 uint8_t BadCharSkip[256];
164 std::memset(BadCharSkip, N, 256);
165 for (
unsigned i = 0; i != N-1; ++i)
166 BadCharSkip[(uint8_t)Str[i]] = N-1-i;
169 uint8_t Last = Start[N - 1];
175 Start += BadCharSkip[Last];
176 }
while (Start < Stop);
193 From = std::min(From, Length);
208 size_t N = Str.
size();
211 for (
size_t i = Length - N + 1,
e = 0; i !=
e;) {
220 size_t N = Str.
size();
223 for (
size_t i = Length - N + 1,
e = 0; i !=
e;) {
237 std::bitset<1 << CHAR_BIT> CharBits;
239 CharBits.set((
unsigned char)Chars[i]);
241 for (
size_type i = std::min(From, Length),
e = Length; i !=
e; ++i)
242 if (CharBits.test((
unsigned char)Data[i]))
250 for (
size_type i = std::min(From, Length),
e = Length; i !=
e; ++i)
262 std::bitset<1 << CHAR_BIT> CharBits;
264 CharBits.set((
unsigned char)Chars[i]);
266 for (
size_type i = std::min(From, Length),
e = Length; i !=
e; ++i)
267 if (!CharBits.test((
unsigned char)Data[i]))
278 std::bitset<1 << CHAR_BIT> CharBits;
280 CharBits.set((
unsigned char)Chars[i]);
282 for (
size_type i = std::min(From, Length) - 1,
e = -1; i !=
e; --i)
283 if (CharBits.test((
unsigned char)Data[i]))
291 for (
size_type i = std::min(From, Length) - 1,
e = -1; i !=
e; --i)
303 std::bitset<1 << CHAR_BIT> CharBits;
305 CharBits.set((
unsigned char)Chars[i]);
307 for (
size_type i = std::min(From, Length) - 1,
e = -1; i !=
e; --i)
308 if (!CharBits.test((
unsigned char)Data[i]))
315 bool KeepEmpty)
const {
322 while (MaxSplit-- != 0) {
323 size_t Idx = S.
find(Separator);
328 if (KeepEmpty || Idx > 0)
336 if (KeepEmpty || !S.
empty())
341 int MaxSplit,
bool KeepEmpty)
const {
348 while (MaxSplit-- != 0) {
349 size_t Idx = S.
find(Separator);
354 if (KeepEmpty || Idx > 0)
362 if (KeepEmpty || !S.
empty())
374 size_t N = Str.
size();
377 for (
size_t i = 0,
e = Length - N + 1; i !=
e; ++i)
402 if (Str[0] ==
'0' && Str.
size() > 1 &&
isDigit(Str[1])) {
411 unsigned long long &Result) {
417 if (Str.
empty())
return true;
422 while (!Str2.
empty()) {
424 if (Str2[0] >=
'0' && Str2[0] <=
'9')
425 CharVal = Str2[0] -
'0';
426 else if (Str2[0] >=
'a' && Str2[0] <=
'z')
427 CharVal = Str2[0] -
'a' + 10;
428 else if (Str2[0] >=
'A' && Str2[0] <=
'Z')
429 CharVal = Str2[0] -
'A' + 10;
435 if (CharVal >= Radix)
439 unsigned long long PrevResult = Result;
440 Result = Result * Radix + CharVal;
443 if (Result / Radix < PrevResult)
460 unsigned long long ULLVal;
466 (
long long)ULLVal < 0)
478 (
long long)-ULLVal > 0)
489 unsigned long long &Result) {
515 assert(Radix > 1 && Radix <= 36);
518 if (Str.
empty())
return true;
527 Result =
APInt(64, 0);
532 unsigned Log2Radix = 0;
533 while ((1U << Log2Radix) < Radix) Log2Radix++;
534 bool IsPowerOf2Radix = ((1U << Log2Radix) == Radix);
536 unsigned BitWidth = Log2Radix * Str.
size();
540 Result = Result.
zext(BitWidth);
542 APInt RadixAP, CharAP;
543 if (!IsPowerOf2Radix) {
545 RadixAP =
APInt(BitWidth, Radix);
546 CharAP =
APInt(BitWidth, 0);
551 while (!Str.
empty()) {
553 if (Str[0] >=
'0' && Str[0] <=
'9')
554 CharVal = Str[0]-
'0';
555 else if (Str[0] >=
'a' && Str[0] <=
'z')
556 CharVal = Str[0]-
'a'+10;
557 else if (Str[0] >=
'A' && Str[0] <=
'Z')
558 CharVal = Str[0]-
'A'+10;
564 if (CharVal >= Radix)
568 if (IsPowerOf2Radix) {
569 Result <<= Log2Radix;
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
This class represents lattice values for constants.
unsigned ComputeEditDistance(ArrayRef< T > FromArray, ArrayRef< T > ToArray, bool AllowReplacements=true, unsigned MaxEditDistance=0)
Determine the edit distance between two sequences.
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
#define LLVM_UNLIKELY(EXPR)
bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
void push_back(const T &Elt)
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
APInt zext(unsigned width) const
Zero extend to a new width.
LLVM_NODISCARD size_t find_last_of(char C, size_t From=npos) const
Find the last character in the string that is C, or npos if not found.
LLVM_NODISCARD bool endswith_lower(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
LLVM_NODISCARD unsigned edit_distance(StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
Determine the edit distance between this string and another string.
unsigned getBitWidth() const
Return the number of bits in the APInt.
opStatus convertFromString(StringRef, roundingMode)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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 size_t count(char C) const
Return the number of occurrences of C in the string.
LLVM_NODISCARD StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
This file implements a class to represent arbitrary precision integral constant values and operations...
LLVM_NODISCARD size_t size() const
size - Get the string size.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
LLVM_NODISCARD std::string upper() const
Convert the given ASCII string to uppercase.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
double convertToDouble() const
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
LLVM_NODISCARD size_t rfind_lower(char C, size_t From=npos) const
Search for the last character C in the string, ignoring case.
static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length)
char toLower(char x)
Returns the corresponding lowercase character if x is uppercase.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD int compare_lower(StringRef RHS) const
compare_lower - Compare two strings, ignoring case.
BlockVerifier::State From
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsDouble(double &Result, bool AllowInexact=true) const
Parse the current string as an IEEE double-precision floating point value.
LLVM_NODISCARD size_t find_lower(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
LLVM_NODISCARD size_t find_last_not_of(char C, size_t From=npos) const
Find the last character in the string that is not C, or npos if not found.
static unsigned GetAutoSenseRadix(StringRef &Str)
Class for arbitrary precision integers.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
An opaque object representing a hash code.
LLVM_NODISCARD int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
opStatus
IEEE-754R 7: Default exception handling.
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
Merge contiguous icmps into a memcmp
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
LLVM_NODISCARD size_t find_if(function_ref< bool(char)> F, size_t From=0) const
Search for the first character satisfying the predicate F.
LLVM_NODISCARD std::string lower() const
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
char toUpper(char x)
Returns the corresponding uppercase character if x is lowercase.
LLVM_NODISCARD char front() const
front - Get the first character in the string.
StringRef - Represent a constant reference to a string, i.e.
bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)