gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
simple_indirect.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 ARM Limited
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 __CPU_PRED_INDIRECT_HH__
30 #define __CPU_PRED_INDIRECT_HH__
31 
32 #include <deque>
33 
34 #include "cpu/inst_seq.hh"
35 #include "cpu/pred/indirect.hh"
36 #include "params/SimpleIndirectPredictor.hh"
37 
38 namespace gem5
39 {
40 
41 namespace branch_prediction
42 {
43 
45 {
46  public:
47  SimpleIndirectPredictor(const SimpleIndirectPredictorParams &params);
48 
49  bool lookup(Addr br_addr, PCStateBase& br_target, ThreadID tid);
50  void recordIndirect(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num,
51  ThreadID tid);
52  void commit(InstSeqNum seq_num, ThreadID tid, void * indirect_history);
53  void squash(InstSeqNum seq_num, ThreadID tid);
54  void recordTarget(InstSeqNum seq_num, void * indirect_history,
55  const PCStateBase& target, ThreadID tid);
56  void genIndirectInfo(ThreadID tid, void* & indirect_history);
57  void updateDirectionInfo(ThreadID tid, bool actually_taken);
58  void deleteIndirectInfo(ThreadID tid, void * indirect_history);
59  void changeDirectionPrediction(ThreadID tid, void * indirect_history,
60  bool actually_taken);
61 
62  private:
63  const bool hashGHR;
64  const bool hashTargets;
65  const unsigned numSets;
66  const unsigned numWays;
67  const unsigned tagBits;
68  const unsigned pathLength;
69  const unsigned instShift;
70  const unsigned ghrNumBits;
71  const unsigned ghrMask;
72 
73  struct IPredEntry
74  {
75  Addr tag = 0;
76  std::unique_ptr<PCStateBase> target;
77  };
78 
80 
81  Addr getSetIndex(Addr br_addr, unsigned ghr, ThreadID tid);
82  Addr getTag(Addr br_addr);
83 
84  struct HistoryEntry
85  {
86  HistoryEntry(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num)
87  : pcAddr(br_addr), targetAddr(tgt_addr), seqNum(seq_num) { }
91  };
92 
93 
94  struct ThreadInfo
95  {
97  unsigned headHistEntry = 0;
98  unsigned ghr = 0;
99  };
100 
102 };
103 
104 } // namespace branch_prediction
105 } // namespace gem5
106 
107 #endif // __CPU_PRED_INDIRECT_HH__
gem5::branch_prediction::SimpleIndirectPredictor::numSets
const unsigned numSets
Definition: simple_indirect.hh:65
gem5::branch_prediction::SimpleIndirectPredictor::getTag
Addr getTag(Addr br_addr)
Definition: simple_indirect.cc:240
gem5::branch_prediction::SimpleIndirectPredictor::updateDirectionInfo
void updateDirectionInfo(ThreadID tid, bool actually_taken)
Definition: simple_indirect.cc:78
gem5::branch_prediction::SimpleIndirectPredictor::instShift
const unsigned instShift
Definition: simple_indirect.hh:69
gem5::branch_prediction::SimpleIndirectPredictor::hashTargets
const bool hashTargets
Definition: simple_indirect.hh:64
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry::seqNum
InstSeqNum seqNum
Definition: simple_indirect.hh:90
gem5::branch_prediction::SimpleIndirectPredictor::genIndirectInfo
void genIndirectInfo(ThreadID tid, void *&indirect_history)
Definition: simple_indirect.cc:68
gem5::branch_prediction::SimpleIndirectPredictor::hashGHR
const bool hashGHR
Definition: simple_indirect.hh:63
std::vector
STL vector class.
Definition: stl.hh:37
gem5::branch_prediction::SimpleIndirectPredictor::ghrMask
const unsigned ghrMask
Definition: simple_indirect.hh:71
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry
Definition: simple_indirect.hh:84
inst_seq.hh
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::branch_prediction::SimpleIndirectPredictor::deleteIndirectInfo
void deleteIndirectInfo(ThreadID tid, void *indirect_history)
Definition: simple_indirect.cc:171
gem5::branch_prediction::SimpleIndirectPredictor::changeDirectionPrediction
void changeDirectionPrediction(ThreadID tid, void *indirect_history, bool actually_taken)
Definition: simple_indirect.cc:87
gem5::branch_prediction::SimpleIndirectPredictor::IPredEntry::target
std::unique_ptr< PCStateBase > target
Definition: simple_indirect.hh:76
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo
Definition: simple_indirect.hh:94
gem5::branch_prediction::SimpleIndirectPredictor::numWays
const unsigned numWays
Definition: simple_indirect.hh:66
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo::ghr
unsigned ghr
Definition: simple_indirect.hh:98
indirect.hh
gem5::branch_prediction::SimpleIndirectPredictor::targetCache
std::vector< std::vector< IPredEntry > > targetCache
Definition: simple_indirect.hh:79
gem5::branch_prediction::SimpleIndirectPredictor::getSetIndex
Addr getSetIndex(Addr br_addr, unsigned ghr, ThreadID tid)
Definition: simple_indirect.cc:220
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::branch_prediction::SimpleIndirectPredictor::IPredEntry
Definition: simple_indirect.hh:73
gem5::branch_prediction::SimpleIndirectPredictor::commit
void commit(InstSeqNum seq_num, ThreadID tid, void *indirect_history)
Definition: simple_indirect.cc:129
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry::HistoryEntry
HistoryEntry(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num)
Definition: simple_indirect.hh:86
gem5::branch_prediction::SimpleIndirectPredictor::pathLength
const unsigned pathLength
Definition: simple_indirect.hh:68
gem5::branch_prediction::SimpleIndirectPredictor::squash
void squash(InstSeqNum seq_num, ThreadID tid)
Definition: simple_indirect.cc:152
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo::pathHist
std::deque< HistoryEntry > pathHist
Definition: simple_indirect.hh:96
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry::pcAddr
Addr pcAddr
Definition: simple_indirect.hh:88
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo::headHistEntry
unsigned headHistEntry
Definition: simple_indirect.hh:97
gem5::branch_prediction::IndirectPredictor
Definition: indirect.hh:43
gem5::branch_prediction::SimpleIndirectPredictor::tagBits
const unsigned tagBits
Definition: simple_indirect.hh:67
std::deque
STL deque class.
Definition: stl.hh:44
gem5::branch_prediction::SimpleIndirectPredictor::IPredEntry::tag
Addr tag
Definition: simple_indirect.hh:75
gem5::branch_prediction::SimpleIndirectPredictor
Definition: simple_indirect.hh:44
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::branch_prediction::SimpleIndirectPredictor::threadInfo
std::vector< ThreadInfo > threadInfo
Definition: simple_indirect.hh:101
gem5::PCStateBase
Definition: pcstate.hh:57
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::branch_prediction::SimpleIndirectPredictor::recordIndirect
void recordIndirect(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num, ThreadID tid)
Definition: simple_indirect.cc:120
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry::targetAddr
Addr targetAddr
Definition: simple_indirect.hh:89
gem5::branch_prediction::SimpleIndirectPredictor::lookup
bool lookup(Addr br_addr, PCStateBase &br_target, ThreadID tid)
Definition: simple_indirect.cc:96
gem5::branch_prediction::SimpleIndirectPredictor::recordTarget
void recordTarget(InstSeqNum seq_num, void *indirect_history, const PCStateBase &target, ThreadID tid)
Definition: simple_indirect.cc:181
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
gem5::branch_prediction::SimpleIndirectPredictor::ghrNumBits
const unsigned ghrNumBits
Definition: simple_indirect.hh:70
gem5::branch_prediction::SimpleIndirectPredictor::SimpleIndirectPredictor
SimpleIndirectPredictor(const SimpleIndirectPredictorParams &params)
Definition: simple_indirect.cc:40

Generated on Sun Jul 30 2023 01:56:53 for gem5 by doxygen 1.8.17