gem5  v20.1.0.0
dyn_inst.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014,2018 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
46 #ifndef __CPU_MINOR_DYN_INST_HH__
47 #define __CPU_MINOR_DYN_INST_HH__
48 
49 #include <iostream>
50 
51 #include "base/refcnt.hh"
52 #include "cpu/minor/buffers.hh"
53 #include "cpu/inst_seq.hh"
54 #include "cpu/static_inst.hh"
55 #include "cpu/timing_expr.hh"
56 #include "sim/faults.hh"
57 
58 namespace Minor
59 {
60 
62 
65 
68 class InstId
69 {
70  public:
73  static const InstSeqNum firstStreamSeqNum = 1;
75  static const InstSeqNum firstLineSeqNum = 1;
76  static const InstSeqNum firstFetchSeqNum = 1;
77  static const InstSeqNum firstExecSeqNum = 1;
78 
79  public:
82 
87 
91 
95 
99 
104 
105  public:
108  ThreadID thread_id = 0, InstSeqNum stream_seq_num = 0,
109  InstSeqNum prediction_seq_num = 0, InstSeqNum line_seq_num = 0,
110  InstSeqNum fetch_seq_num = 0, InstSeqNum exec_seq_num = 0) :
111  threadId(thread_id), streamSeqNum(stream_seq_num),
112  predictionSeqNum(prediction_seq_num), lineSeqNum(line_seq_num),
113  fetchSeqNum(fetch_seq_num), execSeqNum(exec_seq_num)
114  { }
115 
116  public:
117  /* Equal if the thread and last set sequence number matches */
118  bool
119  operator== (const InstId &rhs)
120  {
121  /* If any of fetch and exec sequence number are not set
122  * they need to be 0, so a straight comparison is still
123  * fine */
124  bool ret = (threadId == rhs.threadId &&
125  lineSeqNum == rhs.lineSeqNum &&
126  fetchSeqNum == rhs.fetchSeqNum &&
127  execSeqNum == rhs.execSeqNum);
128 
129  /* Stream and prediction *must* match if these are the same id */
130  if (ret) {
131  assert(streamSeqNum == rhs.streamSeqNum &&
133  }
134 
135  return ret;
136  }
137 };
138 
141 std::ostream &operator <<(std::ostream &os, const InstId &id);
142 
143 class MinorDynInst;
144 
149 std::ostream &operator <<(std::ostream &os, const MinorDynInst &inst);
150 
155 class MinorDynInst : public RefCounted
156 {
157  private:
161 
162  public:
164 
166 
169 
172 
175 
179 
183 
186 
190  unsigned int fuIndex;
191 
193  bool inLSQ;
194 
197 
200 
205 
207  bool predicate;
208 
212 
218 
222 
226 
230  RegId flatDestRegIdx[TheISA::MaxInstDestRegs];
231 
232  public:
233  MinorDynInst(InstId id_ = InstId(), Fault fault_ = NoFault) :
234  staticInst(NULL), id(id_), traceData(NULL),
235  pc(TheISA::PCState(0)), fault(fault_),
236  triedToPredict(false), predictedTaken(false),
237  fuIndex(0), inLSQ(false), translationFault(NoFault),
238  inStoreBuffer(false), canEarlyIssue(false), predicate(true),
241  { }
242 
243  public:
245  bool isBubble() const { return id.fetchSeqNum == 0; }
246 
248  static MinorDynInstPtr bubble() { return bubbleInst; }
249 
251  bool isFault() const { return fault != NoFault; }
252 
254  bool isInst() const { return !isBubble() && !isFault(); }
255 
257  bool isMemRef() const { return isInst() && staticInst->isMemRef(); }
258 
261  bool isNoCostInst() const;
262 
265  bool isLastOpInInst() const;
266 
268  static void init();
269 
272  void minorTraceInst(const Named &named_object) const;
273 
275  void reportData(std::ostream &os) const;
276 
277  bool readPredicate() const { return predicate; }
278 
279  void setPredicate(bool val) { predicate = val; }
280 
281  bool readMemAccPredicate() const { return memAccPredicate; }
282 
284 
285  ~MinorDynInst();
286 };
287 
289 std::ostream &operator <<(std::ostream &os, const MinorDynInst &inst);
290 
291 }
292 
293 #endif /* __CPU_MINOR_DYN_INST_HH__ */
refcnt.hh
Minor::MinorDynInst::predictedTaken
bool predictedTaken
This instruction was predicted to change control flow and the following instructions will have a newe...
Definition: dyn_inst.hh:182
Minor::MinorDynInst::readMemAccPredicate
bool readMemAccPredicate() const
Definition: dyn_inst.hh:281
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
StaticInst::isMemRef
bool isMemRef() const
Definition: static_inst.hh:160
Minor::MinorDynInst::flatDestRegIdx
RegId flatDestRegIdx[TheISA::MaxInstDestRegs]
Flat register indices so that, when clearing the scoreboard, we have the same register indices as whe...
Definition: dyn_inst.hh:230
Minor::InstId::firstLineSeqNum
static const InstSeqNum firstLineSeqNum
Definition: dyn_inst.hh:75
Minor::MinorDynInst::isMemRef
bool isMemRef() const
Is this a real mem ref instruction.
Definition: dyn_inst.hh:257
Minor::MinorDynInst::minimumCommitCycle
Cycles minimumCommitCycle
Once issued, extraCommitDelay becomes minimumCommitCycle to account for delay in absolute time.
Definition: dyn_inst.hh:225
Minor::MinorDynInst::bubbleInst
static MinorDynInstPtr bubbleInst
A prototypical bubble instruction.
Definition: dyn_inst.hh:160
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Minor::MinorDynInst::fuIndex
unsigned int fuIndex
Fields only set during execution.
Definition: dyn_inst.hh:190
Minor::MinorDynInst::triedToPredict
bool triedToPredict
Tried to predict the destination of this inst (if a control instruction or a sys call)
Definition: dyn_inst.hh:178
Minor::MinorDynInst::isNoCostInst
bool isNoCostInst() const
Is this an instruction that can be executed ‘for free’ and needn't spend time in an FU.
Definition: dyn_inst.cc:97
TheISA
Definition: decode_cache.hh:37
Minor::InstId::execSeqNum
InstSeqNum execSeqNum
'Execute' sequence number.
Definition: dyn_inst.hh:103
timing_expr.hh
Trace::InstRecord
Definition: insttracer.hh:55
Minor::InstId::firstStreamSeqNum
static const InstSeqNum firstStreamSeqNum
First sequence numbers to use in initialisation of the pipeline and to be expected on the first line/...
Definition: dyn_inst.hh:73
Minor::MinorDynInst::inLSQ
bool inLSQ
This instruction is in the LSQ, not a functional unit.
Definition: dyn_inst.hh:193
Minor::InstId::firstExecSeqNum
static const InstSeqNum firstExecSeqNum
Definition: dyn_inst.hh:77
TimingExpr
Definition: timing_expr.hh:88
faults.hh
Minor::InstId::firstFetchSeqNum
static const InstSeqNum firstFetchSeqNum
Definition: dyn_inst.hh:76
Minor::MinorDynInst::readPredicate
bool readPredicate() const
Definition: dyn_inst.hh:277
Minor
Definition: activity.cc:44
RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:75
Minor::MinorDynInst::predicate
bool predicate
Flag controlling conditional execution of the instruction.
Definition: dyn_inst.hh:207
inst_seq.hh
Minor::InstId::streamSeqNum
InstSeqNum streamSeqNum
The 'stream' this instruction belongs to.
Definition: dyn_inst.hh:86
Minor::MinorDynInst::bubble
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:248
Minor::MinorDynInst
Dynamic instruction for Minor.
Definition: dyn_inst.hh:155
Minor::MinorDynInst::init
static void init()
Initialise the class.
Definition: dyn_inst.cc:79
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
Minor::MinorDynInst::extraCommitDelayExpr
TimingExpr * extraCommitDelayExpr
Definition: dyn_inst.hh:221
Minor::MinorDynInst::traceData
Trace::InstRecord * traceData
Trace information for this instruction's execution.
Definition: dyn_inst.hh:168
Minor::InstId::operator==
bool operator==(const InstId &rhs)
Definition: dyn_inst.hh:119
Minor::InstId::lineSeqNum
InstSeqNum lineSeqNum
Line sequence number.
Definition: dyn_inst.hh:94
static_inst.hh
Minor::MinorDynInst::id
InstId id
Definition: dyn_inst.hh:165
Minor::InstId::threadId
ThreadID threadId
The thread to which this line/instruction belongs.
Definition: dyn_inst.hh:81
Minor::InstId::fetchSeqNum
InstSeqNum fetchSeqNum
Fetch sequence number.
Definition: dyn_inst.hh:98
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
Minor::MinorDynInst::isInst
bool isInst() const
Is this a real instruction.
Definition: dyn_inst.hh:254
Minor::MinorDynInst::isFault
bool isFault() const
Is this a fault rather than instruction.
Definition: dyn_inst.hh:251
Minor::MinorDynInst::inStoreBuffer
bool inStoreBuffer
The instruction has been sent to the store buffer.
Definition: dyn_inst.hh:199
Minor::MinorDynInstPtr
RefCountingPtr< MinorDynInst > MinorDynInstPtr
MinorDynInsts are currently reference counted.
Definition: dyn_inst.hh:61
Minor::InstId::InstId
InstId(ThreadID thread_id=0, InstSeqNum stream_seq_num=0, InstSeqNum prediction_seq_num=0, InstSeqNum line_seq_num=0, InstSeqNum fetch_seq_num=0, InstSeqNum exec_seq_num=0)
Very boring default constructor.
Definition: dyn_inst.hh:107
Named
Definition: trace.hh:147
Minor::InstId::firstPredictionSeqNum
static const InstSeqNum firstPredictionSeqNum
Definition: dyn_inst.hh:74
Minor::MinorDynInst::minorTraceInst
void minorTraceInst(const Named &named_object) const
Print (possibly verbose) instruction information for MinorTrace using the given Named object's name.
Definition: dyn_inst.cc:181
Minor::operator<<
std::ostream & operator<<(std::ostream &os, const InstId &id)
Print this id in the usual slash-separated format expected by MinorTrace.
Definition: dyn_inst.cc:61
Minor::MinorDynInst::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: dyn_inst.cc:103
RefCounted
Derive from RefCounted if you want to enable reference counting of this class.
Definition: refcnt.hh:57
Minor::MinorDynInst::predictedTarget
TheISA::PCState predictedTarget
Predicted branch target.
Definition: dyn_inst.hh:185
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
Minor::MinorDynInst::setMemAccPredicate
void setMemAccPredicate(bool val)
Definition: dyn_inst.hh:283
Minor::MinorDynInst::MinorDynInst
MinorDynInst(InstId id_=InstId(), Fault fault_=NoFault)
Definition: dyn_inst.hh:233
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Minor::MinorDynInst::translationFault
Fault translationFault
Translation fault in case of a mem ref.
Definition: dyn_inst.hh:196
Minor::MinorDynInst::isLastOpInInst
bool isLastOpInInst() const
Assuming this is not a fault, is this instruction either a whole instruction or the last microop from...
Definition: dyn_inst.cc:90
Minor::MinorDynInst::pc
TheISA::PCState pc
The fetch address of this instruction.
Definition: dyn_inst.hh:171
buffers.hh
Minor::MinorDynInst::isBubble
bool isBubble() const
The BubbleIF interface.
Definition: dyn_inst.hh:245
RefCountingPtr< MinorDynInst >
Minor::MinorDynInst::memAccPredicate
bool memAccPredicate
Flag controlling conditional execution of the memory access associated with the instruction (only mea...
Definition: dyn_inst.hh:211
Minor::InstId::predictionSeqNum
InstSeqNum predictionSeqNum
The predicted qualifier to stream, attached by Fetch2 as a consequence of branch prediction.
Definition: dyn_inst.hh:90
Minor::MinorDynInst::extraCommitDelay
Cycles extraCommitDelay
Extra delay at the end of the pipeline.
Definition: dyn_inst.hh:220
Minor::MinorDynInst::staticInst
StaticInstPtr staticInst
Definition: dyn_inst.hh:163
Minor::MinorDynInst::fault
Fault fault
This is actually a fault masquerading as an instruction.
Definition: dyn_inst.hh:174
Minor::MinorDynInst::~MinorDynInst
~MinorDynInst()
Definition: dyn_inst.cc:238
Minor::MinorDynInst::instToWaitFor
InstSeqNum instToWaitFor
execSeqNum of the latest inst on which this inst depends.
Definition: dyn_inst.hh:217
Minor::MinorDynInst::setPredicate
void setPredicate(bool val)
Definition: dyn_inst.hh:279
Minor::InstId
Id for lines and instructions.
Definition: dyn_inst.hh:68
Minor::MinorDynInst::canEarlyIssue
bool canEarlyIssue
Can this instruction be executed out of order.
Definition: dyn_inst.hh:204

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