mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Switch the TableGen record's string-based DenseMap key to use the new
hashing infrastructure. I wonder why we don't just use StringMap here, and I may revisit the issue if I have time, but for now I'm just trying to consolidate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152023 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/FoldingSet.h"
|
#include "llvm/ADT/FoldingSet.h"
|
||||||
|
#include "llvm/ADT/Hashing.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
@ -29,6 +30,8 @@ using namespace llvm;
|
|||||||
// std::string wrapper for DenseMap purposes
|
// std::string wrapper for DenseMap purposes
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
/// TableGenStringKey - This is a wrapper for std::string suitable for
|
/// TableGenStringKey - This is a wrapper for std::string suitable for
|
||||||
/// using as a key to a DenseMap. Because there isn't a particularly
|
/// using as a key to a DenseMap. Because there isn't a particularly
|
||||||
/// good way to indicate tombstone or empty keys for strings, we want
|
/// good way to indicate tombstone or empty keys for strings, we want
|
||||||
@ -43,14 +46,16 @@ public:
|
|||||||
TableGenStringKey(const char *str) : data(str) {}
|
TableGenStringKey(const char *str) : data(str) {}
|
||||||
|
|
||||||
const std::string &str() const { return data; }
|
const std::string &str() const { return data; }
|
||||||
|
|
||||||
|
friend hash_code hash_value(const TableGenStringKey &Value) {
|
||||||
|
using llvm::hash_value;
|
||||||
|
return hash_value(Value.str());
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::string data;
|
std::string data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialize DenseMapInfo for TableGenStringKey.
|
/// Specialize DenseMapInfo for TableGenStringKey.
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
template<> struct DenseMapInfo<TableGenStringKey> {
|
template<> struct DenseMapInfo<TableGenStringKey> {
|
||||||
static inline TableGenStringKey getEmptyKey() {
|
static inline TableGenStringKey getEmptyKey() {
|
||||||
TableGenStringKey Empty("<<<EMPTY KEY>>>");
|
TableGenStringKey Empty("<<<EMPTY KEY>>>");
|
||||||
@ -61,7 +66,8 @@ template<> struct DenseMapInfo<TableGenStringKey> {
|
|||||||
return Tombstone;
|
return Tombstone;
|
||||||
}
|
}
|
||||||
static unsigned getHashValue(const TableGenStringKey& Val) {
|
static unsigned getHashValue(const TableGenStringKey& Val) {
|
||||||
return HashString(Val.str());
|
using llvm::hash_value;
|
||||||
|
return hash_value(Val);
|
||||||
}
|
}
|
||||||
static bool isEqual(const TableGenStringKey& LHS,
|
static bool isEqual(const TableGenStringKey& LHS,
|
||||||
const TableGenStringKey& RHS) {
|
const TableGenStringKey& RHS) {
|
||||||
@ -69,7 +75,7 @@ template<> struct DenseMapInfo<TableGenStringKey> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace llvm
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Type implementations
|
// Type implementations
|
||||||
|
Reference in New Issue
Block a user