gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dyn_inst.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 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  * Authors: Andrew Bardsley
38  */
39 
48 #ifndef __CPU_MINOR_DYN_INST_HH__
49 #define __CPU_MINOR_DYN_INST_HH__
50 
51 #include <iostream>
52 
53 #include "base/refcnt.hh"
54 #include "cpu/minor/buffers.hh"
55 #include "cpu/inst_seq.hh"
56 #include "cpu/static_inst.hh"
57 #include "cpu/timing_expr.hh"
58 #include "sim/faults.hh"
59 
60 namespace Minor
61 {
62 
64 
67 
70 class InstId
71 {
72  public:
75  static const InstSeqNum firstStreamSeqNum = 1;
77  static const InstSeqNum firstLineSeqNum = 1;
78  static const InstSeqNum firstFetchSeqNum = 1;
79  static const InstSeqNum firstExecSeqNum = 1;
80 
81  public:
84 
89 
93 
97 
101 
106 
107  public:
110  ThreadID thread_id = 0, InstSeqNum stream_seq_num = 0,
111  InstSeqNum prediction_seq_num = 0, InstSeqNum line_seq_num = 0,
112  InstSeqNum fetch_seq_num = 0, InstSeqNum exec_seq_num = 0) :
113  threadId(thread_id), streamSeqNum(stream_seq_num),
114  predictionSeqNum(prediction_seq_num), lineSeqNum(line_seq_num),
115  fetchSeqNum(fetch_seq_num), execSeqNum(exec_seq_num)
116  { }
117 
118  public:
119  /* Equal if the thread and last set sequence number matches */
120  bool
121  operator== (const InstId &rhs)
122  {
123  /* If any of fetch and exec sequence number are not set
124  * they need to be 0, so a straight comparison is still
125  * fine */
126  bool ret = (threadId == rhs.threadId &&
127  lineSeqNum == rhs.lineSeqNum &&
128  fetchSeqNum == rhs.fetchSeqNum &&
129  execSeqNum == rhs.execSeqNum);
130 
131  /* Stream and prediction *must* match if these are the same id */
132  if (ret) {
133  assert(streamSeqNum == rhs.streamSeqNum &&
135  }
136 
137  return ret;
138  }
139 };
140 
143 std::ostream &operator <<(std::ostream &os, const InstId &id);
144 
145 class MinorDynInst;
146 
151 std::ostream &operator <<(std::ostream &os, const MinorDynInst &inst);
152 
157 class MinorDynInst : public RefCounted
158 {
159  private:
163 
164  public:
166 
168 
171 
174 
177 
181 
185 
188 
192  unsigned int fuIndex;
193 
195  bool inLSQ;
196 
199 
204 
210 
214 
218 
222  TheISA::RegIndex flatDestRegIdx[TheISA::MaxInstDestRegs];
223 
226 
227  public:
228  MinorDynInst(InstId id_ = InstId(), Fault fault_ = NoFault) :
229  staticInst(NULL), id(id_), traceData(NULL),
230  pc(TheISA::PCState(0)), fault(fault_),
231  triedToPredict(false), predictedTaken(false),
232  fuIndex(0), inLSQ(false), inStoreBuffer(false),
233  canEarlyIssue(false),
236  ea(0)
237  { }
238 
239  public:
241  bool isBubble() const { return id.fetchSeqNum == 0; }
242 
244  static MinorDynInstPtr bubble() { return bubbleInst; }
245 
247  bool isFault() const { return fault != NoFault; }
248 
250  bool isInst() const { return !isBubble() && !isFault(); }
251 
253  bool isMemRef() const { return isInst() && staticInst->isMemRef(); }
254 
257  bool isNoCostInst() const;
258 
261  bool isLastOpInInst() const;
262 
264  static void init();
265 
268  void minorTraceInst(const Named &named_object) const;
269 
271  void reportData(std::ostream &os) const;
272 
273  ~MinorDynInst();
274 };
275 
277 std::ostream &operator <<(std::ostream &os, const MinorDynInst &inst);
278 
279 }
280 
281 #endif /* __CPU_MINOR_DYN_INST_HH__ */
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:63
decltype(nullptr) constexpr NoFault
Definition: types.hh:189
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
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:99
bool triedToPredict
Tried to predict the destination of this inst (if a control instruction or a sys call) ...
Definition: dyn_inst.hh:180
static const InstSeqNum firstPredictionSeqNum
Definition: dyn_inst.hh:76
bool canEarlyIssue
Can this instruction be executed out of order.
Definition: dyn_inst.hh:203
Addr ea
Effective address as set by ExecContext::setEA.
Definition: dyn_inst.hh:225
void reportData(std::ostream &os) const
ReportIF interface.
Definition: dyn_inst.cc:105
Fault fault
This is actually a fault masquerading as an instruction.
Definition: dyn_inst.hh:176
Cycles minimumCommitCycle
Once issued, extraCommitDelay becomes minimumCommitCycle to account for delay in absolute time...
Definition: dyn_inst.hh:217
RefCountingPtr< MinorDynInst > MinorDynInstPtr
MinorDynInsts are currently reference counted.
Definition: dyn_inst.hh:63
bool isBubble() const
The BubbleIF interface.
Definition: dyn_inst.hh:241
TheISA::RegIndex flatDestRegIdx[TheISA::MaxInstDestRegs]
Flat register indices so that, when clearing the scoreboard, we have the same register indices as whe...
Definition: dyn_inst.hh:222
unsigned int fuIndex
Fields only set during execution.
Definition: dyn_inst.hh:192
Id for lines and instructions.
Definition: dyn_inst.hh:70
MinorDynInst(InstId id_=InstId(), Fault fault_=NoFault)
Definition: dyn_inst.hh:228
Bitfield< 17 > os
Definition: misc.hh:804
bool isMemRef() const
Definition: static_inst.hh:132
bool predictedTaken
This instruction was predicted to change control flow and the following instructions will have a newe...
Definition: dyn_inst.hh:184
InstSeqNum execSeqNum
'Execute' sequence number.
Definition: dyn_inst.hh:105
InstSeqNum predictionSeqNum
The predicted qualifier to stream, attached by Fetch2 as a consequence of branch prediction.
Definition: dyn_inst.hh:92
InstSeqNum fetchSeqNum
Fetch sequence number.
Definition: dyn_inst.hh:100
TimingExpr * extraCommitDelayExpr
Definition: dyn_inst.hh:213
Definition: trace.hh:140
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:171
bool isMemRef() const
Is this a real mem ref instruction.
Definition: dyn_inst.hh:253
static const InstSeqNum firstExecSeqNum
Definition: dyn_inst.hh:79
Cycles extraCommitDelay
Extra delay at the end of the pipeline.
Definition: dyn_inst.hh:212
Classes for managing reference counted objects.
uint8_t RegIndex
Definition: registers.hh:46
static const InstSeqNum firstFetchSeqNum
Definition: dyn_inst.hh:78
TheISA::PCState predictedTarget
Predicted branch target.
Definition: dyn_inst.hh:187
InstSeqNum instToWaitFor
execSeqNum of the latest inst on which this inst depends.
Definition: dyn_inst.hh:209
bool isInst() const
Is this a real instruction.
Definition: dyn_inst.hh:250
uint64_t InstSeqNum
Definition: inst_seq.hh:40
Derive from RefCounted if you want to enable reference counting of this class.
Definition: refcnt.hh:45
static void init()
Initialise the class.
Definition: dyn_inst.cc:81
static MinorDynInstPtr bubbleInst
A prototypical bubble instruction.
Definition: dyn_inst.hh:162
Classes for buffer, queue and FIFO behaviour.
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:109
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
bool isFault() const
Is this a fault rather than instruction.
Definition: dyn_inst.hh:247
InstSeqNum streamSeqNum
The 'stream' this instruction belongs to.
Definition: dyn_inst.hh:88
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
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:92
Dynamic instruction for Minor.
Definition: dyn_inst.hh:157
TheISA::PCState pc
The fetch address of this instruction.
Definition: dyn_inst.hh:173
bool inStoreBuffer
The instruction has been sent to the store buffer.
Definition: dyn_inst.hh:198
bool inLSQ
This instruction is in the LSQ, not a functional unit.
Definition: dyn_inst.hh:195
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:244
bool operator==(const InstId &rhs)
Definition: dyn_inst.hh:121
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
InstSeqNum lineSeqNum
Line sequence number.
Definition: dyn_inst.hh:96
StaticInstPtr staticInst
Definition: dyn_inst.hh:165
static const InstSeqNum firstLineSeqNum
Definition: dyn_inst.hh:77
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
ThreadID threadId
The thread to which this line/instruction belongs.
Definition: dyn_inst.hh:83
Trace::InstRecord * traceData
Trace information for this instruction's execution.
Definition: dyn_inst.hh:170
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:75

Generated on Fri Jun 9 2017 13:03:42 for gem5 by doxygen 1.8.6