mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-17 20:29:31 +00:00
consolidate DenseMapInfo implementations, and add one for std::pair.
Patch contributed by m-s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5f0cfa299d
commit
2dba6a1bdb
@ -43,6 +43,48 @@ struct DenseMapInfo<T*> {
|
|||||||
static bool isPod() { return true; }
|
static bool isPod() { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Provide DenseMapInfo for unsigned ints.
|
||||||
|
template<> struct DenseMapInfo<uint32_t> {
|
||||||
|
static inline uint32_t getEmptyKey() { return ~0; }
|
||||||
|
static inline uint32_t getTombstoneKey() { return ~0 - 1; }
|
||||||
|
static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
|
||||||
|
static bool isPod() { return true; }
|
||||||
|
static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
|
||||||
|
return LHS == RHS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Provide DenseMapInfo for all pairs whose members have info.
|
||||||
|
template<typename T, typename U>
|
||||||
|
struct DenseMapInfo<std::pair<T, U> > {
|
||||||
|
typedef std::pair<T, U> Pair;
|
||||||
|
typedef DenseMapInfo<T> FirstInfo;
|
||||||
|
typedef DenseMapInfo<U> SecondInfo;
|
||||||
|
|
||||||
|
static inline Pair getEmptyKey() {
|
||||||
|
return std::make_pair(FirstInfo::getEmptyKey(),
|
||||||
|
SecondInfo::getEmptyKey());
|
||||||
|
}
|
||||||
|
static inline Pair getTombstoneKey() {
|
||||||
|
return std::make_pair(FirstInfo::getTombstoneKey(),
|
||||||
|
SecondInfo::getEmptyKey()); }
|
||||||
|
static unsigned getHashValue(const Pair& PairVal) {
|
||||||
|
uint64_t key = (uint64_t)FirstInfo::getHashValue(PairVal.first) << 32
|
||||||
|
| (uint64_t)SecondInfo::getHashValue(PairVal.second);
|
||||||
|
key += ~(key << 32);
|
||||||
|
key ^= (key >> 22);
|
||||||
|
key += ~(key << 13);
|
||||||
|
key ^= (key >> 8);
|
||||||
|
key += (key << 3);
|
||||||
|
key ^= (key >> 15);
|
||||||
|
key += ~(key << 27);
|
||||||
|
key ^= (key >> 31);
|
||||||
|
return (unsigned)key;
|
||||||
|
}
|
||||||
|
static bool isEqual(const Pair& LHS, const Pair& RHS) { return LHS == RHS; }
|
||||||
|
static bool isPod() { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
template<typename KeyT, typename ValueT,
|
template<typename KeyT, typename ValueT,
|
||||||
typename KeyInfoT = DenseMapInfo<KeyT>,
|
typename KeyInfoT = DenseMapInfo<KeyT>,
|
||||||
typename ValueInfoT = DenseMapInfo<ValueT> >
|
typename ValueInfoT = DenseMapInfo<ValueT> >
|
||||||
|
@ -55,20 +55,6 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Provide DenseMapInfo for unsigned.
|
|
||||||
template<>
|
|
||||||
struct DenseMapInfo<unsigned> {
|
|
||||||
static inline unsigned getEmptyKey() { return (unsigned)-1; }
|
|
||||||
static inline unsigned getTombstoneKey() { return (unsigned)-2; }
|
|
||||||
static unsigned getHashValue(const unsigned Val) {
|
|
||||||
return Val * 37;
|
|
||||||
}
|
|
||||||
static bool isEqual(const unsigned LHS, const unsigned RHS) {
|
|
||||||
return LHS == RHS;
|
|
||||||
}
|
|
||||||
static bool isPod() { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class LiveIntervals : public MachineFunctionPass {
|
class LiveIntervals : public MachineFunctionPass {
|
||||||
MachineFunction* mf_;
|
MachineFunction* mf_;
|
||||||
MachineRegisterInfo* mri_;
|
MachineRegisterInfo* mri_;
|
||||||
|
@ -561,18 +561,6 @@ static bool precedes(MachineBasicBlock::iterator A,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
template<> struct DenseMapInfo<uint32_t> {
|
|
||||||
static inline uint32_t getEmptyKey() { return ~0; }
|
|
||||||
static inline uint32_t getTombstoneKey() { return ~0 - 1; }
|
|
||||||
static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
|
|
||||||
static bool isPod() { return true; }
|
|
||||||
static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
|
|
||||||
return LHS == RHS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ComputeLocalLiveness - Computes liveness of registers within a basic
|
/// ComputeLocalLiveness - Computes liveness of registers within a basic
|
||||||
/// block, setting the killed/dead flags as appropriate.
|
/// block, setting the killed/dead flags as appropriate.
|
||||||
void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) {
|
void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) {
|
||||||
|
@ -682,18 +682,6 @@ void ValueTable::erase(Value* V) {
|
|||||||
// GVN Pass
|
// GVN Pass
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
template<> struct DenseMapInfo<uint32_t> {
|
|
||||||
static inline uint32_t getEmptyKey() { return ~0; }
|
|
||||||
static inline uint32_t getTombstoneKey() { return ~0 - 1; }
|
|
||||||
static unsigned getHashValue(const uint32_t& Val) { return Val * 37; }
|
|
||||||
static bool isPod() { return true; }
|
|
||||||
static bool isEqual(const uint32_t& LHS, const uint32_t& RHS) {
|
|
||||||
return LHS == RHS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct VISIBILITY_HIDDEN ValueNumberScope {
|
struct VISIBILITY_HIDDEN ValueNumberScope {
|
||||||
ValueNumberScope* parent;
|
ValueNumberScope* parent;
|
||||||
|
Loading…
Reference in New Issue
Block a user