gem5  v21.2.1.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 "config/the_isa.hh"
35 #include "cpu/inst_seq.hh"
36 #include "cpu/pred/indirect.hh"
37 #include "params/SimpleIndirectPredictor.hh"
38 
39 namespace gem5
40 {
41 
42 namespace branch_prediction
43 {
44 
46 {
47  public:
48  SimpleIndirectPredictor(const SimpleIndirectPredictorParams &params);
49 
50  bool lookup(Addr br_addr, PCStateBase& br_target, ThreadID tid);
51  void recordIndirect(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num,
52  ThreadID tid);
53  void commit(InstSeqNum seq_num, ThreadID tid, void * indirect_history);
54  void squash(InstSeqNum seq_num, ThreadID tid);
55  void recordTarget(InstSeqNum seq_num, void * indirect_history,
56  const PCStateBase& target, ThreadID tid);
57  void genIndirectInfo(ThreadID tid, void* & indirect_history);
58  void updateDirectionInfo(ThreadID tid, bool actually_taken);
59  void deleteIndirectInfo(ThreadID tid, void * indirect_history);
60  void changeDirectionPrediction(ThreadID tid, void * indirect_history,
61  bool actually_taken);
62 
63  private:
64  const bool hashGHR;
65  const bool hashTargets;
66  const unsigned numSets;
67  const unsigned numWays;
68  const unsigned tagBits;
69  const unsigned pathLength;
70  const unsigned instShift;
71  const unsigned ghrNumBits;
72  const unsigned ghrMask;
73 
74  struct IPredEntry
75  {
76  Addr tag = 0;
77  std::unique_ptr<PCStateBase> target;
78  };
79 
81 
82  Addr getSetIndex(Addr br_addr, unsigned ghr, ThreadID tid);
83  Addr getTag(Addr br_addr);
84 
85  struct HistoryEntry
86  {
87  HistoryEntry(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num)
88  : pcAddr(br_addr), targetAddr(tgt_addr), seqNum(seq_num) { }
92  };
93 
94 
95  struct ThreadInfo
96  {
98  unsigned headHistEntry = 0;
99  unsigned ghr = 0;
100  };
101 
103 };
104 
105 } // namespace branch_prediction
106 } // namespace gem5
107 
108 #endif // __CPU_PRED_INDIRECT_HH__
gem5::branch_prediction::SimpleIndirectPredictor::numSets
const unsigned numSets
Definition: simple_indirect.hh:66
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:70
gem5::branch_prediction::SimpleIndirectPredictor::hashTargets
const bool hashTargets
Definition: simple_indirect.hh:65
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry::seqNum
InstSeqNum seqNum
Definition: simple_indirect.hh:91
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:64
std::vector
STL vector class.
Definition: stl.hh:37
gem5::branch_prediction::SimpleIndirectPredictor::ghrMask
const unsigned ghrMask
Definition: simple_indirect.hh:72
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry
Definition: simple_indirect.hh:85
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:77
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo
Definition: simple_indirect.hh:95
gem5::branch_prediction::SimpleIndirectPredictor::numWays
const unsigned numWays
Definition: simple_indirect.hh:67
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo::ghr
unsigned ghr
Definition: simple_indirect.hh:99
indirect.hh
gem5::branch_prediction::SimpleIndirectPredictor::targetCache
std::vector< std::vector< IPredEntry > > targetCache
Definition: simple_indirect.hh:80
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:74
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:87
gem5::branch_prediction::SimpleIndirectPredictor::pathLength
const unsigned pathLength
Definition: simple_indirect.hh:69
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:97
gem5::branch_prediction::SimpleIndirectPredictor::HistoryEntry::pcAddr
Addr pcAddr
Definition: simple_indirect.hh:89
gem5::branch_prediction::SimpleIndirectPredictor::ThreadInfo::headHistEntry
unsigned headHistEntry
Definition: simple_indirect.hh:98
gem5::branch_prediction::IndirectPredictor
Definition: indirect.hh:44
gem5::branch_prediction::SimpleIndirectPredictor::tagBits
const unsigned tagBits
Definition: simple_indirect.hh:68
std::deque
STL deque class.
Definition: stl.hh:44
gem5::branch_prediction::SimpleIndirectPredictor::IPredEntry::tag
Addr tag
Definition: simple_indirect.hh:76
gem5::branch_prediction::SimpleIndirectPredictor
Definition: simple_indirect.hh:45
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::branch_prediction::SimpleIndirectPredictor::threadInfo
std::vector< ThreadInfo > threadInfo
Definition: simple_indirect.hh:102
gem5::PCStateBase
Definition: pcstate.hh:57
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
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:90
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:242
gem5::branch_prediction::SimpleIndirectPredictor::ghrNumBits
const unsigned ghrNumBits
Definition: simple_indirect.hh:71
gem5::branch_prediction::SimpleIndirectPredictor::SimpleIndirectPredictor
SimpleIndirectPredictor(const SimpleIndirectPredictorParams &params)
Definition: simple_indirect.cc:40

Generated on Tue Feb 8 2022 11:47:04 for gem5 by doxygen 1.8.17