gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
exec_context.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2014, 2016-2018, 2020-2021 ARM Limited
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2002-2005 The Regents of The University of Michigan
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
48 #ifndef __CPU_MINOR_EXEC_CONTEXT_HH__
49 #define __CPU_MINOR_EXEC_CONTEXT_HH__
50 
51 #include "cpu/exec_context.hh"
52 #include "cpu/minor/execute.hh"
53 #include "cpu/minor/pipeline.hh"
54 #include "cpu/base.hh"
55 #include "cpu/simple_thread.hh"
56 #include "mem/request.hh"
57 #include "debug/MinorExecute.hh"
58 
59 namespace gem5
60 {
61 
62 namespace minor
63 {
64 
65 /* Forward declaration of Execute */
66 class Execute;
67 
73 {
74  public:
76 
79 
82 
85 
87  MinorCPU &cpu_,
88  SimpleThread &thread_, Execute &execute_,
89  MinorDynInstPtr inst_) :
90  cpu(cpu_),
91  thread(thread_),
92  execute(execute_),
93  inst(inst_)
94  {
95  DPRINTF(MinorExecute, "ExecContext setting PC: %s\n", *inst->pc);
96  pcState(*inst->pc);
97  setPredicate(inst->readPredicate());
98  setMemAccPredicate(inst->readMemAccPredicate());
99  }
100 
102  {
103  inst->setPredicate(readPredicate());
104  inst->setMemAccPredicate(readMemAccPredicate());
105  }
106 
107  Fault
108  initiateMemRead(Addr addr, unsigned int size,
110  const std::vector<bool>& byte_enable) override
111  {
112  assert(byte_enable.size() == size);
113  return execute.getLSQ().pushRequest(inst, true /* load */, nullptr,
114  size, addr, flags, nullptr, nullptr, byte_enable);
115  }
116 
117  Fault
119  {
120  panic("ExecContext::initiateMemMgmtCmd() not implemented "
121  " on MinorCPU\n");
122  return NoFault;
123  }
124 
125  Fault
126  writeMem(uint8_t *data, unsigned int size, Addr addr,
127  Request::Flags flags, uint64_t *res,
128  const std::vector<bool>& byte_enable)
129  override
130  {
131  assert(byte_enable.size() == size);
132  return execute.getLSQ().pushRequest(inst, false /* store */, data,
133  size, addr, flags, res, nullptr, byte_enable);
134  }
135 
136  Fault
138  AtomicOpFunctorPtr amo_op) override
139  {
140  // AMO requests are pushed through the store path
141  return execute.getLSQ().pushRequest(inst, false /* amo */, nullptr,
142  size, addr, flags, nullptr, std::move(amo_op),
143  std::vector<bool>(size, true));
144  }
145 
146  RegVal
147  getRegOperand(const StaticInst *si, int idx) override
148  {
149  const RegId &reg = si->srcRegIdx(idx);
150  if (reg.is(InvalidRegClass))
151  return 0;
152  return thread.getReg(reg);
153  }
154 
155  void
156  getRegOperand(const StaticInst *si, int idx, void *val) override
157  {
158  thread.getReg(si->srcRegIdx(idx), val);
159  }
160 
161  void *
162  getWritableRegOperand(const StaticInst *si, int idx) override
163  {
164  return thread.getWritableReg(si->destRegIdx(idx));
165  }
166 
167  void
168  setRegOperand(const StaticInst *si, int idx, RegVal val) override
169  {
170  const RegId &reg = si->destRegIdx(idx);
171  if (reg.is(InvalidRegClass))
172  return;
173  thread.setReg(si->destRegIdx(idx), val);
174  }
175 
176  void
177  setRegOperand(const StaticInst *si, int idx, const void *val) override
178  {
179  thread.setReg(si->destRegIdx(idx), val);
180  }
181 
182  bool
183  readPredicate() const override
184  {
185  return thread.readPredicate();
186  }
187 
188  void
189  setPredicate(bool val) override
190  {
192  }
193 
194  bool
195  readMemAccPredicate() const override
196  {
197  return thread.readMemAccPredicate();
198  }
199 
200  void
201  setMemAccPredicate(bool val) override
202  {
204  }
205 
206  // hardware transactional memory
207  uint64_t
208  getHtmTransactionUid() const override
209  {
210  panic("ExecContext::getHtmTransactionUid() not"
211  "implemented on MinorCPU\n");
212  return 0;
213  }
214 
215  uint64_t
216  newHtmTransactionUid() const override
217  {
218  panic("ExecContext::newHtmTransactionUid() not"
219  "implemented on MinorCPU\n");
220  return 0;
221  }
222 
223  bool
224  inHtmTransactionalState() const override
225  {
226  // ExecContext::inHtmTransactionalState() not
227  // implemented on MinorCPU
228  return false;
229  }
230 
231  uint64_t
232  getHtmTransactionalDepth() const override
233  {
234  panic("ExecContext::getHtmTransactionalDepth() not"
235  "implemented on MinorCPU\n");
236  return 0;
237  }
238 
239  const PCStateBase &
240  pcState() const override
241  {
242  return thread.pcState();
243  }
244 
245  void
246  pcState(const PCStateBase &val) override
247  {
248  thread.pcState(val);
249  }
250 
251  RegVal
252  readMiscRegNoEffect(int misc_reg) const
253  {
254  return thread.readMiscRegNoEffect(misc_reg);
255  }
256 
257  RegVal
258  readMiscReg(int misc_reg) override
259  {
260  return thread.readMiscReg(misc_reg);
261  }
262 
263  void
264  setMiscReg(int misc_reg, RegVal val) override
265  {
266  thread.setMiscReg(misc_reg, val);
267  }
268 
269  RegVal
270  readMiscRegOperand(const StaticInst *si, int idx) override
271  {
272  const RegId& reg = si->srcRegIdx(idx);
273  assert(reg.is(MiscRegClass));
274  return thread.readMiscReg(reg.index());
275  }
276 
277  void
278  setMiscRegOperand(const StaticInst *si, int idx, RegVal val) override
279  {
280  const RegId& reg = si->destRegIdx(idx);
281  assert(reg.is(MiscRegClass));
282  return thread.setMiscReg(reg.index(), val);
283  }
284 
285  ThreadContext *tcBase() const override { return thread.getTC(); }
286 
287  /* @todo, should make stCondFailures persistent somewhere */
288  unsigned int readStCondFailures() const override { return 0; }
289  void setStCondFailures(unsigned int st_cond_failures) override {}
290 
292  /* ISA-specific (or at least currently ISA singleton) functions */
293 
294  /* X86: TLB twiddling */
295  void
296  demapPage(Addr vaddr, uint64_t asn) override
297  {
298  thread.getMMUPtr()->demapPage(vaddr, asn);
299  }
300 
301  BaseCPU *getCpuPtr() { return &cpu; }
302 
303  public:
304  // monitor/mwait funtions
305  void
306  armMonitor(Addr address) override
307  {
308  getCpuPtr()->armMonitor(inst->id.threadId, address);
309  }
310 
311  bool
312  mwait(PacketPtr pkt) override
313  {
314  return getCpuPtr()->mwait(inst->id.threadId, pkt);
315  }
316 
317  void
319  {
320  return getCpuPtr()->mwaitAtomic(inst->id.threadId, tc, thread.mmu);
321  }
322 
324  getAddrMonitor() override
325  {
326  return getCpuPtr()->getCpuAddrMonitor(inst->id.threadId);
327  }
328 };
329 
330 } // namespace minor
331 } // namespace gem5
332 
333 #endif /* __CPU_MINOR_EXEC_CONTEXT_HH__ */
gem5::minor::ExecContext::mwait
bool mwait(PacketPtr pkt) override
Definition: exec_context.hh:312
gem5::SimpleThread::readMiscReg
RegVal readMiscReg(RegIndex misc_reg) override
Definition: simple_thread.hh:275
gem5::minor::ExecContext::getRegOperand
void getRegOperand(const StaticInst *si, int idx, void *val) override
Definition: exec_context.hh:156
gem5::minor::ExecContext::initiateMemMgmtCmd
Fault initiateMemMgmtCmd(Request::Flags flags) override
Initiate a memory management command with no valid address.
Definition: exec_context.hh:118
gem5::minor::ExecContext::inHtmTransactionalState
bool inHtmTransactionalState() const override
Definition: exec_context.hh:224
gem5::SimpleThread::getWritableReg
void * getWritableReg(const RegId &arch_reg) override
Definition: simple_thread.hh:345
gem5::BaseCPU::armMonitor
void armMonitor(ThreadID tid, Addr address)
Definition: base.cc:242
gem5::NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:253
gem5::SimpleThread::getReg
RegVal getReg(const RegId &arch_reg) const override
Definition: simple_thread.hh:313
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::BaseCPU::mwaitAtomic
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseMMU *mmu)
Definition: base.cc:277
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::minor::ExecContext::getWritableRegOperand
void * getWritableRegOperand(const StaticInst *si, int idx) override
Definition: exec_context.hh:162
gem5::minor::ExecContext::readMiscRegNoEffect
RegVal readMiscRegNoEffect(int misc_reg) const
Definition: exec_context.hh:252
gem5::minor::ExecContext::readMiscReg
RegVal readMiscReg(int misc_reg) override
Reads a miscellaneous register, handling any architectural side effects due to reading that register.
Definition: exec_context.hh:258
gem5::minor::ExecContext::armMonitor
void armMonitor(Addr address) override
Definition: exec_context.hh:306
gem5::InvalidRegClass
@ InvalidRegClass
Definition: reg_class.hh:70
gem5::minor::ExecContext::readPredicate
bool readPredicate() const override
Definition: exec_context.hh:183
gem5::minor::ExecContext::setRegOperand
void setRegOperand(const StaticInst *si, int idx, const void *val) override
Definition: exec_context.hh:177
gem5::minor::ExecContext::thread
SimpleThread & thread
ThreadState object, provides all the architectural state.
Definition: exec_context.hh:78
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:776
gem5::minor::ExecContext::writeMem
Fault writeMem(uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable) override
For atomic-mode contexts, perform an atomic memory write operation.
Definition: exec_context.hh:126
gem5::SimpleThread::setMiscReg
void setMiscReg(RegIndex misc_reg, RegVal val) override
Definition: simple_thread.hh:287
minor
gem5::SimpleThread::getMMUPtr
BaseMMU * getMMUPtr() override
Definition: simple_thread.hh:205
gem5::MinorCPU
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:84
gem5::minor::ExecContext::initiateMemAMO
Fault initiateMemAMO(Addr addr, unsigned int size, Request::Flags flags, AtomicOpFunctorPtr amo_op) override
For timing-mode contexts, initiate an atomic AMO (atomic read-modify-write memory operation)
Definition: exec_context.hh:137
gem5::minor::ExecContext::newHtmTransactionUid
uint64_t newHtmTransactionUid() const override
Definition: exec_context.hh:216
std::vector< bool >
gem5::minor::ExecContext::setMemAccPredicate
void setMemAccPredicate(bool val) override
Definition: exec_context.hh:201
gem5::minor::ExecContext::ExecContext
ExecContext(MinorCPU &cpu_, SimpleThread &thread_, Execute &execute_, MinorDynInstPtr inst_)
Definition: exec_context.hh:86
gem5::SimpleThread::setReg
void setReg(const RegId &arch_reg, RegVal val) override
Definition: simple_thread.hh:355
gem5::minor::ExecContext::mwaitAtomic
void mwaitAtomic(ThreadContext *tc) override
Definition: exec_context.hh:318
gem5::SimpleThread
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
Definition: simple_thread.hh:93
request.hh
gem5::minor::ExecContext::contextId
ContextID contextId()
Definition: exec_context.hh:291
gem5::minor::ExecContext::getCpuPtr
BaseCPU * getCpuPtr()
Definition: exec_context.hh:301
execute.hh
gem5::minor::ExecContext::initiateMemRead
Fault initiateMemRead(Addr addr, unsigned int size, Request::Flags flags, const std::vector< bool > &byte_enable) override
Initiate a timing memory read operation.
Definition: exec_context.hh:108
gem5::RefCountingPtr< MinorDynInst >
gem5::AddressMonitor
Definition: base.hh:70
gem5::minor::ExecContext::readMiscRegOperand
RegVal readMiscRegOperand(const StaticInst *si, int idx) override
Definition: exec_context.hh:270
gem5::minor::Execute::getLSQ
LSQ & getLSQ()
To allow ExecContext to find the LSQ.
Definition: execute.hh:337
gem5::SimpleThread::mmu
BaseMMU * mmu
Definition: simple_thread.hh:130
gem5::SimpleThread::readMemAccPredicate
bool readMemAccPredicate()
Definition: simple_thread.hh:295
gem5::Flags< FlagsType >
gem5::minor::ExecContext::setStCondFailures
void setStCondFailures(unsigned int st_cond_failures) override
Sets the number of consecutive store conditional failures.
Definition: exec_context.hh:289
gem5::minor::ExecContext::cpu
MinorCPU & cpu
Definition: exec_context.hh:75
gem5::StaticInst
Base, ISA-independent static instruction class.
Definition: static_inst.hh:87
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
gem5::minor::ExecContext::pcState
void pcState(const PCStateBase &val) override
Definition: exec_context.hh:246
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
gem5::SimpleThread::readPredicate
bool readPredicate() const
Definition: simple_thread.hh:265
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:210
gem5::SimpleThread::readMiscRegNoEffect
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
Definition: simple_thread.hh:269
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::minor::ExecContext::pcState
const PCStateBase & pcState() const override
Definition: exec_context.hh:240
gem5::SimpleThread::setMemAccPredicate
void setMemAccPredicate(bool val)
Definition: simple_thread.hh:301
pipeline.hh
gem5::BaseMMU::demapPage
void demapPage(Addr vaddr, uint64_t asn)
Definition: mmu.cc:97
gem5::minor::ExecContext::~ExecContext
~ExecContext()
Definition: exec_context.hh:101
gem5::BaseCPU
Definition: base.hh:104
flags
uint8_t flags
Definition: helpers.cc:66
gem5::minor::ExecContext::inst
MinorDynInstPtr inst
Instruction for the benefit of memory operations and for PC.
Definition: exec_context.hh:84
gem5::minor::ExecContext::setRegOperand
void setRegOperand(const StaticInst *si, int idx, RegVal val) override
Definition: exec_context.hh:168
gem5::SimpleThread::pcState
const PCStateBase & pcState() const override
Definition: simple_thread.hh:256
gem5::ArmISA::si
Bitfield< 6 > si
Definition: misc_types.hh:914
gem5::BaseCPU::getCpuAddrMonitor
AddressMonitor * getCpuAddrMonitor(ThreadID tid)
Definition: base.hh:656
gem5::minor::ExecContext::setPredicate
void setPredicate(bool val) override
Definition: exec_context.hh:189
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::minor::ExecContext::readMemAccPredicate
bool readMemAccPredicate() const override
Definition: exec_context.hh:195
gem5::minor::ExecContext::readStCondFailures
unsigned int readStCondFailures() const override
Returns the number of consecutive store conditional failures.
Definition: exec_context.hh:288
gem5::SimpleThread::contextId
ContextID contextId() const override
Definition: simple_thread.hh:202
gem5::X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:92
gem5::SimpleThread::getTC
ThreadContext * getTC()
Returns the pointer to this SimpleThread's ThreadContext.
Definition: simple_thread.hh:165
gem5::minor::ExecContext
ExecContext bears the exec_context interface for Minor.
Definition: exec_context.hh:72
gem5::minor::ExecContext::execute
Execute & execute
The execute stage so we can peek at its contents.
Definition: exec_context.hh:81
gem5::minor::ExecContext::getRegOperand
RegVal getRegOperand(const StaticInst *si, int idx) override
Definition: exec_context.hh:147
gem5::minor::ExecContext::setMiscReg
void setMiscReg(int misc_reg, RegVal val) override
Sets a miscellaneous register, handling any architectural side effects due to writing that register.
Definition: exec_context.hh:264
simple_thread.hh
gem5::minor::ExecContext::demapPage
void demapPage(Addr vaddr, uint64_t asn) override
Invalidate a page in the DTLB and ITLB.
Definition: exec_context.hh:296
base.hh
gem5::MiscRegClass
@ MiscRegClass
Control (misc) register.
Definition: reg_class.hh:69
gem5::minor::Execute
Execute stage.
Definition: execute.hh:67
gem5::ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
exec_context.hh
gem5::ExecContext
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:71
gem5::minor::ExecContext::getHtmTransactionalDepth
uint64_t getHtmTransactionalDepth() const override
Definition: exec_context.hh:232
gem5::minor::ExecContext::getAddrMonitor
AddressMonitor * getAddrMonitor() override
Definition: exec_context.hh:324
gem5::BaseCPU::mwait
bool mwait(ThreadID tid, PacketPtr pkt)
Definition: base.cc:254
gem5::MipsISA::vaddr
vaddr
Definition: pra_constants.hh:278
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::minor::LSQ::pushRequest
Fault pushRequest(MinorDynInstPtr inst, bool isLoad, uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, AtomicOpFunctorPtr amo_op, const std::vector< bool > &byte_enable=std::vector< bool >())
Single interface for readMem/writeMem/amoMem to issue requests into the LSQ.
Definition: lsq.cc:1583
gem5::AtomicOpFunctorPtr
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition: amo.hh:269
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::minor::ExecContext::setMiscRegOperand
void setMiscRegOperand(const StaticInst *si, int idx, RegVal val) override
Definition: exec_context.hh:278
gem5::SimpleThread::setPredicate
void setPredicate(bool val)
Definition: simple_thread.hh:266
gem5::RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:92
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::minor::ExecContext::getHtmTransactionUid
uint64_t getHtmTransactionUid() const override
Definition: exec_context.hh:208
gem5::minor::ExecContext::tcBase
ThreadContext * tcBase() const override
Returns a pointer to the ThreadContext.
Definition: exec_context.hh:285

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