blob: fef17988e4b9490ff66fda9bfb1245322b7a5f8b [file] [log] [blame]
Nikhil Raj7dcc6972021-04-30 15:44:24 +01001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <memory>
9#include <stdint.h>
10
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000011namespace arm
Nikhil Raj7dcc6972021-04-30 15:44:24 +010012{
13
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000014namespace pipe
Nikhil Raj7dcc6972021-04-30 15:44:24 +010015{
16
17static constexpr uint64_t MIN_STATIC_GUID = 1llu << 63;
18
19class ProfilingGuid
20{
21public:
22 ProfilingGuid() : m_Guid(0) {}
23
24 ProfilingGuid(uint64_t guid) : m_Guid(guid) {}
25
26 operator uint64_t() const { return m_Guid; }
27
28 bool operator==(const ProfilingGuid& other) const
29 {
30 return m_Guid == other.m_Guid;
31 }
32
33 bool operator!=(const ProfilingGuid& other) const
34 {
35 return m_Guid != other.m_Guid;
36 }
37
38 bool operator<(const ProfilingGuid& other) const
39 {
40 return m_Guid < other.m_Guid;
41 }
42
43 bool operator<=(const ProfilingGuid& other) const
44 {
45 return m_Guid <= other.m_Guid;
46 }
47
48 bool operator>(const ProfilingGuid& other) const
49 {
50 return m_Guid > other.m_Guid;
51 }
52
53 bool operator>=(const ProfilingGuid& other) const
54 {
55 return m_Guid >= other.m_Guid;
56 }
57
58 protected:
59 uint64_t m_Guid;
60};
61
62/// Strongly typed guids to distinguish between those generated at runtime, and those that are statically defined.
63struct ProfilingDynamicGuid : public ProfilingGuid
64{
65 using ProfilingGuid::ProfilingGuid;
66};
67
68struct ProfilingStaticGuid : public ProfilingGuid
69{
70 using ProfilingGuid::ProfilingGuid;
71};
72
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000073} // namespace pipe
Nikhil Raj7dcc6972021-04-30 15:44:24 +010074
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000075} // namespace arm
Nikhil Raj7dcc6972021-04-30 15:44:24 +010076
77
78
79namespace std
80{
81/// make ProfilingGuid hashable
82template <>
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000083struct hash<arm::pipe::ProfilingGuid>
Nikhil Raj7dcc6972021-04-30 15:44:24 +010084{
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000085 std::size_t operator()(arm::pipe::ProfilingGuid const& guid) const noexcept
Nikhil Raj7dcc6972021-04-30 15:44:24 +010086 {
87 return hash<uint64_t>()(uint64_t(guid));
88 }
89};
90
91/// make ProfilingDynamicGuid hashable
92template <>
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000093struct hash<arm::pipe::ProfilingDynamicGuid>
Nikhil Raj7dcc6972021-04-30 15:44:24 +010094{
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000095 std::size_t operator()(arm::pipe::ProfilingDynamicGuid const& guid) const noexcept
Nikhil Raj7dcc6972021-04-30 15:44:24 +010096 {
97 return hash<uint64_t>()(uint64_t(guid));
98 }
99};
100
101/// make ProfilingStaticGuid hashable
102template <>
Cathal Corbett5aa9fd72022-02-25 15:33:28 +0000103struct hash<arm::pipe::ProfilingStaticGuid>
Nikhil Raj7dcc6972021-04-30 15:44:24 +0100104{
Cathal Corbett5aa9fd72022-02-25 15:33:28 +0000105 std::size_t operator()(arm::pipe::ProfilingStaticGuid const& guid) const noexcept
Nikhil Raj7dcc6972021-04-30 15:44:24 +0100106 {
107 return hash<uint64_t>()(uint64_t(guid));
108 }
109};
110
111} // namespace std