1 /* This file is part of the dynarmic project.
2  * Copyright (c) 2016 MerryMage
3  * SPDX-License-Identifier: 0BSD
4  */
5 
6 #pragma once
7 
8 #include <functional>
9 #include <iosfwd>
10 
11 #include "common/common_types.h"
12 
13 namespace Dynarmic::IR {
14 
15 class LocationDescriptor {
16 public:
LocationDescriptor(u64 value)17     explicit LocationDescriptor(u64 value) : value(value) {}
18 
19     bool operator == (const LocationDescriptor& o) const {
20         return value == o.Value();
21     }
22 
23     bool operator != (const LocationDescriptor& o) const {
24         return !operator==(o);
25     }
26 
Value()27     u64 Value() const { return value; }
28 
29 private:
30     u64 value;
31 };
32 
33 std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor);
34 
35 inline bool operator<(const LocationDescriptor& x, const LocationDescriptor& y) noexcept {
36     return x.Value() < y.Value();
37 }
38 
39 } // namespace Dynarmic::IR
40 
41 namespace std {
42 template <>
43 struct less<Dynarmic::IR::LocationDescriptor> {
44     bool operator()(const Dynarmic::IR::LocationDescriptor& x, const Dynarmic::IR::LocationDescriptor& y) const noexcept {
45         return x < y;
46     }
47 };
48 template <>
49 struct hash<Dynarmic::IR::LocationDescriptor> {
50     size_t operator()(const Dynarmic::IR::LocationDescriptor& x) const noexcept {
51         return std::hash<u64>()(x.Value());
52     }
53 };
54 } // namespace std
55