15#ifndef LLVM_PROFILEDATA_FUNCTIONID_H
16#define LLVM_PROFILEDATA_FUNCTIONID_H
38 const char *Data =
nullptr;
48 static int compareMemory(
const char *Lhs,
const char *Rhs,
uint64_t Length) {
55 return ::memcmp(Lhs, Rhs, (
size_t)
Length);
63 : Data(Str.data()), LengthOrHashCode(Str.
size()) {
68 : LengthOrHashCode(HashCode) {
77 return LengthOrHashCode ==
Other.LengthOrHashCode &&
78 compareMemory(Data,
Other.Data, LengthOrHashCode) == 0;
86 auto Res = compareMemory(
87 Data,
Other.Data, std::min(LengthOrHashCode,
Other.LengthOrHashCode));
90 if (LengthOrHashCode ==
Other.LengthOrHashCode)
92 return LengthOrHashCode <
Other.LengthOrHashCode ? -1 : 1;
97 std::string
str()
const {
99 return std::string(Data, LengthOrHashCode);
100 if (LengthOrHashCode != 0)
101 return std::to_string(LengthOrHashCode);
102 return std::string();
110 return StringRef(Data, LengthOrHashCode);
111 assert(LengthOrHashCode == 0 &&
112 "Cannot convert MD5 FunctionId to StringRef");
126 return LengthOrHashCode;
129 bool empty()
const {
return LengthOrHashCode == 0; }
144 return LHS.compare(
RHS) < 0;
148 return LHS.compare(
RHS) <= 0;
152 return LHS.compare(
RHS) > 0;
156 return LHS.compare(
RHS) >= 0;
161 return OS <<
StringRef(Obj.Data, Obj.LengthOrHashCode);
162 if (Obj.LengthOrHashCode != 0)
163 return OS << Obj.LengthOrHashCode;
205template <>
struct hash<
llvm::sampleprof::FunctionId> {
This file defines DenseMapInfo traits for DenseMap.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
This class represents a function that is read from a sample profile.
FunctionId(StringRef Str)
Constructor from a StringRef.
StringRef stringRef() const
Convert to StringRef.
FunctionId(uint64_t HashCode)
Constructor from a hash code.
uint64_t getHashCode() const
Get hash code of this object.
bool isStringRef() const
Check if this object represents a StringRef, or a hash code.
friend raw_ostream & operator<<(raw_ostream &OS, const FunctionId &Obj)
int compare(const FunctionId &Other) const
Total order comparison.
bool equals(const FunctionId &Other) const
Check for equality.
std::string str() const
Convert to a string, usually for output purpose.
bool operator>(const FunctionId &LHS, const FunctionId &RHS)
bool operator<=(const FunctionId &LHS, const FunctionId &RHS)
bool operator<(const FunctionId &LHS, const FunctionId &RHS)
bool operator!=(const FunctionId &LHS, const FunctionId &RHS)
bool operator>=(const FunctionId &LHS, const FunctionId &RHS)
uint64_t MD5Hash(const FunctionId &Obj)
raw_ostream & operator<<(raw_ostream &OS, const FunctionId &Obj)
uint64_t hash_value(const FunctionId &Obj)
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
Implement std::hash so that hash_code can be used in STL containers.
static sampleprof::FunctionId getEmptyKey()
static sampleprof::FunctionId getTombstoneKey()
static bool isEqual(const sampleprof::FunctionId &LHS, const sampleprof::FunctionId &RHS)
static unsigned getHashValue(const sampleprof::FunctionId &Val)
An information struct used to provide DenseMap with the various necessary components for a given valu...
size_t operator()(const llvm::sampleprof::FunctionId &Val) const