gem5 v24.0.0.0
Loading...
Searching...
No Matches
pc_count_pair.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __PC_COUNT_PAIR_HH__
30#define __PC_COUNT_PAIR_HH__
31
32#include "base/types.hh"
33
34namespace gem5
35{
36
38{
39
40 private:
41
45 int count;
46
47 public:
48
50 explicit constexpr PcCountPair(Addr _pc, int _count) :
51 pc(_pc), count(_count) {}
52
54 PcCountPair() : pc(0), count(0) {}
55
57 constexpr Addr getPC() const { return pc; }
59 constexpr int getCount() const { return count; }
60
62 constexpr bool
63 operator>(const PcCountPair& cc) const
64 {
65 return count > cc.getCount();
66 }
67
69 constexpr bool
70 operator==(const PcCountPair& cc) const
71 {
72 return (pc == cc.getPC() && count == cc.getCount());
73 }
74
76 std::string
77 to_string() const
78 {
79 std::string s = "(" + std::to_string(pc)
80 + "," + std::to_string(count) + ")";
81 return s;
82 }
83
86 {
87 size_t operator()(const PcCountPair& item) const
88 {
89 size_t xHash = std::hash<int>()(item.pc);
90 size_t yHash = std::hash<int>()(item.count);
91 return xHash * 2 + yHash;
92 }
93 };
94
95};
96
97} // namespace gem5
98
99#endif // __PC_COUNT_PAIR_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
constexpr bool operator>(const PcCountPair &cc) const
Greater than comparison.
constexpr Addr getPC() const
Returns the Program Counter address.
std::string to_string() const
String format.
Addr pc
The Program Counter address.
PcCountPair()
Default constructor for parameter classes.
constexpr PcCountPair(Addr _pc, int _count)
Explicit constructor assigning the pc and count values.
constexpr int getCount() const
Returns the count of the Program.
int count
The count of the Program Counter address.
constexpr bool operator==(const PcCountPair &cc) const
Equal comparison.
Bitfield< 4 > s
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
Enable hashing for this parameter.
size_t operator()(const PcCountPair &item) const

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0