gem5  v20.1.0.0
ras.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Regents of The University of Michigan
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_RAS_HH__
30 #define __CPU_PRED_RAS_HH__
31 
32 #include <vector>
33 
34 #include "arch/types.hh"
35 #include "base/types.hh"
36 #include "config/the_isa.hh"
37 
40 {
41  public:
46 
50  void init(unsigned numEntries);
51 
52  void reset();
53 
56  { return addrStack[tos]; }
57 
59  unsigned topIdx()
60  { return tos; }
61 
63  void push(const TheISA::PCState &return_addr);
64 
66  void pop();
67 
73  void restore(unsigned top_entry_idx, const TheISA::PCState &restored);
74 
75  bool empty() { return usedEntries == 0; }
76 
77  bool full() { return usedEntries == numEntries; }
78  private:
80  inline void incrTos()
81  { if (++tos == numEntries) tos = 0; }
82 
84  inline void decrTos()
85  { tos = (tos == 0 ? numEntries - 1 : tos - 1); }
86 
89 
91  unsigned numEntries;
92 
94  unsigned usedEntries;
95 
97  unsigned tos;
98 };
99 
100 #endif // __CPU_PRED_RAS_HH__
ReturnAddrStack::init
void init(unsigned numEntries)
Initializes RAS with a specified number of entries.
Definition: ras.cc:32
ReturnAddrStack::decrTos
void decrTos()
Decrements the top of stack index.
Definition: ras.hh:84
ReturnAddrStack::tos
unsigned tos
The top of stack index.
Definition: ras.hh:97
ReturnAddrStack::addrStack
std::vector< TheISA::PCState > addrStack
The RAS itself.
Definition: ras.hh:88
ReturnAddrStack::usedEntries
unsigned usedEntries
The number of used entries in the RAS.
Definition: ras.hh:94
ReturnAddrStack::empty
bool empty()
Definition: ras.hh:75
std::vector< TheISA::PCState >
ReturnAddrStack::topIdx
unsigned topIdx()
Returns the index of the top of the RAS.
Definition: ras.hh:59
ReturnAddrStack::reset
void reset()
Definition: ras.cc:40
ReturnAddrStack::restore
void restore(unsigned top_entry_idx, const TheISA::PCState &restored)
Changes index to the top of the RAS, and replaces the top address with a new target.
Definition: ras.cc:71
ReturnAddrStack::incrTos
void incrTos()
Increments the top of stack index.
Definition: ras.hh:80
ReturnAddrStack
Return address stack class, implements a simple RAS.
Definition: ras.hh:39
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
types.hh
ReturnAddrStack::numEntries
unsigned numEntries
The number of entries in the RAS.
Definition: ras.hh:91
ReturnAddrStack::ReturnAddrStack
ReturnAddrStack()
Creates a return address stack, but init() must be called prior to use.
Definition: ras.hh:45
ReturnAddrStack::push
void push(const TheISA::PCState &return_addr)
Pushes an address onto the RAS.
Definition: ras.cc:49
ReturnAddrStack::pop
void pop()
Pops the top address from the RAS.
Definition: ras.cc:61
ReturnAddrStack::top
TheISA::PCState top()
Returns the top address on the RAS.
Definition: ras.hh:55
ReturnAddrStack::full
bool full()
Definition: ras.hh:77

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17