arm_types: Specialize std::hash for LocationDescriptor (#14)

Same thing, but with the benefit of working with anything that uses
std::hash by default.
This commit is contained in:
Mat M 2016-09-03 07:48:47 -04:00 committed by Merry
parent 8c4df46580
commit 05b189bc26
2 changed files with 12 additions and 9 deletions

View file

@ -81,9 +81,9 @@ private:
Jit* jit_interface;
std::unordered_map<u64, CodePtr> unique_hash_to_code_ptr;
std::unordered_map<u64, std::vector<CodePtr>> patch_unique_hash_locations;
std::unordered_map<Arm::LocationDescriptor, BlockDescriptor, Arm::LocationDescriptorHash> basic_blocks;
std::unordered_map<Arm::LocationDescriptor, std::vector<CodePtr>, Arm::LocationDescriptorHash> patch_jg_locations;
std::unordered_map<Arm::LocationDescriptor, std::vector<CodePtr>, Arm::LocationDescriptorHash> patch_jmp_locations;
std::unordered_map<Arm::LocationDescriptor, BlockDescriptor> basic_blocks;
std::unordered_map<Arm::LocationDescriptor, std::vector<CodePtr>> patch_jg_locations;
std::unordered_map<Arm::LocationDescriptor, std::vector<CodePtr>> patch_jmp_locations;
};
} // namespace BackendX64

View file

@ -137,12 +137,6 @@ private:
Arm::FPSCR fpscr; ///< Floating point status control register.
};
struct LocationDescriptorHash {
size_t operator()(const LocationDescriptor& x) const {
return std::hash<u64>()(x.UniqueHash());
}
};
const char* CondToString(Cond cond, bool explicit_al = false);
const char* RegToString(Reg reg);
const char* ExtRegToString(ExtReg reg);
@ -183,3 +177,12 @@ inline ExtReg operator+(ExtReg reg, size_t number) {
} // namespace Arm
} // namespace Dynarmic
namespace std {
template <>
struct hash<Dynarmic::Arm::LocationDescriptor> {
size_t operator()(const Dynarmic::Arm::LocationDescriptor& x) const {
return std::hash<u64>()(x.UniqueHash());
}
};
} // namespace std