gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tarmac_record.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 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 
43 #ifndef __ARCH_ARM_TRACERS_TARMAC_RECORD_HH__
44 #define __ARCH_ARM_TRACERS_TARMAC_RECORD_HH__
45 
47 #include "base/printable.hh"
48 #include "config/the_isa.hh"
49 #include "cpu/reg_class.hh"
50 #include "cpu/static_inst.hh"
51 
52 namespace Trace {
53 
54 class TarmacContext;
55 
56 class TarmacTracer;
57 
66 std::string
68 
76 std::string
78 
90 {
91  public:
93  struct TraceInstEntry: public InstEntry, Printable
94  {
95  TraceInstEntry(const TarmacContext& tarmCtx, bool predicate);
96 
97  virtual void print(std::ostream& outs,
98  int verbosity = 0,
99  const std::string &prefix = "") const override;
100 
101  protected:
103  static uint64_t instCount;
104 
112  uint8_t instSize;
113  };
114 
117  {
118  public:
119  TraceRegEntry(const TarmacContext& tarmCtx, const RegId& reg);
120 
130  void update(const TarmacContext& tarmCtx);
131 
132  virtual void print(std::ostream& outs,
133  int verbosity = 0,
134  const std::string &prefix = "") const override;
135 
136  protected:
138  virtual void
139  updateMisc(const TarmacContext& tarmCtx, RegIndex regRelIdx);
140 
141  virtual void
142  updateCC(const TarmacContext& tarmCtx, RegIndex regRelIdx);
143 
144  virtual void
145  updateFloat(const TarmacContext& tarmCtx, RegIndex regRelIdx);
146 
147  virtual void
148  updateInt(const TarmacContext& tarmCtx, RegIndex regRelIdx);
149 
150  virtual void
151  updateVec(const TarmacContext& tarmCtx, RegIndex regRelIdx) {};
152 
153  virtual void
154  updatePred(const TarmacContext& tarmCtx, RegIndex regRelIdx) {};
155 
156  public:
158  bool regValid;
164  std::string regName;
165  };
166 
169  {
170  public:
171  TraceMemEntry(const TarmacContext& tarmCtx,
172  uint8_t _size, Addr _addr, uint64_t _data);
173 
174  virtual void print(std::ostream& outs,
175  int verbosity = 0,
176  const std::string &prefix = "") const override;
177 
178  protected:
181  };
182 
183  public:
184  TarmacTracerRecord(Tick _when, ThreadContext *_thread,
185  const StaticInstPtr _staticInst, ArmISA::PCState _pc,
186  TarmacTracer& _tracer,
187  const StaticInstPtr _macroStaticInst = NULL);
188 
189  virtual void dump() override;
190 
191  using InstPtr = std::unique_ptr<TraceInstEntry>;
192  using MemPtr = std::unique_ptr<TraceMemEntry>;
193  using RegPtr = std::unique_ptr<TraceRegEntry>;
194 
195  protected:
197  virtual void addInstEntry(std::vector<InstPtr>& queue,
198  const TarmacContext& ptr);
199 
201  virtual void addMemEntry(std::vector<MemPtr>& queue,
202  const TarmacContext& ptr);
203 
205  virtual void addRegEntry(std::vector<RegPtr>& queue,
206  const TarmacContext& ptr);
207 
208  protected:
210  template<typename RegEntry>
211  RegEntry
212  genRegister(const TarmacContext& tarmCtx, const RegId& reg)
213  {
214  RegEntry single_reg(tarmCtx, reg);
215  single_reg.update(tarmCtx);
216 
217  return single_reg;
218  }
219 
220  template<typename RegEntry>
221  void
223  {
224  // Find all CC Entries and move them at the end of the queue
225  auto it = std::remove_if(
226  queue.begin(), queue.end(),
227  [] (RegPtr& reg) ->bool { return (reg->regClass == CCRegClass); }
228  );
229 
230  if (it != queue.end()) {
231  // Remove all CC Entries.
232  queue.erase(it, queue.end());
233 
234  auto is_cpsr = [] (RegPtr& reg) ->bool
235  {
236  return (reg->regClass == MiscRegClass) &&
237  (reg->regRel == ArmISA::MISCREG_CPSR);
238  };
239 
240  // Looking for the presence of a CPSR register entry.
241  auto cpsr_it = std::find_if(
242  queue.begin(), queue.end(), is_cpsr
243  );
244 
245  // If CPSR entry not present, generate one
246  if (cpsr_it == queue.end()) {
248  queue.push_back(
249  m5::make_unique<RegEntry>(
250  genRegister<RegEntry>(tarmCtx, reg))
251  );
252  }
253  }
254  }
255 
257  template<typename Queue>
258  void flushQueues(Queue& queue);
259  template<typename Queue, typename... Args>
260  void flushQueues(Queue& queue, Args & ... args);
261 
262  protected:
265 };
266 
267 } // namespace Trace
268 
269 #endif // __ARCH_ARM_TRACERS_TARMAC_RECORD_HH__
TarmacTracer & tracer
Reference to tracer.
TraceInstEntry(const TarmacContext &tarmCtx, bool predicate)
Bitfield< 5, 3 > reg
Definition: types.hh:87
std::string regName
Register name to be printed.
ISetState
ARM instruction set state.
Definition: tarmac_base.hh:74
Tarmac Tracer: this tracer generates a new Tarmac Record for every instruction being executed in gem5...
bool predicate
is the predicate for execution this inst true or false (not execed)?
Definition: insttracer.hh:144
std::string opModeToStr(OperatingMode opMode)
Returns the string representation of the ARM Operating Mode (CPSR.M[3:0] field) according to the Tarm...
std::unique_ptr< TraceRegEntry > RegPtr
Control (misc) register.
Definition: reg_class.hh:61
This object type is encapsulating the informations needed by a Tarmac record to generate it&#39;s own ent...
RegClass
Enumerate the classes of registers.
Definition: reg_class.hh:52
bool loadAccess
True if memory access is a load.
TarmacTracerRecord(Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, ArmISA::PCState _pc, TarmacTracer &_tracer, const StaticInstPtr _macroStaticInst=NULL)
bool secureMode
True if instruction is executed in secure mode.
OperatingMode
Definition: types.hh:590
static uint64_t instCount
Number of instructions being traced.
uint8_t instSize
Instruction size: 16 for 16-bit Thumb Instruction 32 otherwise (ARM and BigThumb) ...
virtual void addMemEntry(std::vector< MemPtr > &queue, const TarmacContext &ptr)
Generates an Entry for every triggered memory access.
void flushQueues(Queue &queue)
Flush queues to the trace output.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
A high-level queue interface, to be used by both the MSHR queue and the write buffer.
Definition: queue.hh:66
RegIndex regRel
Register arch number.
virtual void updateVec(const TarmacContext &tarmCtx, RegIndex regRelIdx)
uint16_t RegIndex
Definition: types.hh:40
virtual void print(std::ostream &outs, int verbosity=0, const std::string &prefix="") const override
std::unique_ptr< TraceMemEntry > MemPtr
uint64_t Tick
Tick count type.
Definition: types.hh:61
bool regValid(Addr daddr)
Definition: sinicreg.hh:224
virtual void addRegEntry(std::vector< RegPtr > &queue, const TarmacContext &ptr)
Generate an Entry for every register being written.
Condition-code register.
Definition: reg_class.hh:60
RegEntry genRegister(const TarmacContext &tarmCtx, const RegId &reg)
Generate and update a register entry.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Abstract base class for objects which support being printed to a stream for debugging.
Definition: printable.hh:44
TarmacTracer Record: Record generated by the TarmacTracer for every executed instruction.
std::unique_ptr< TraceInstEntry > InstPtr
void mergeCCEntry(std::vector< RegPtr > &queue, const TarmacContext &tarmCtx)
TARMAC register trace record.
Definition: tarmac_base.hh:98
TARMAC memory access trace record (stores only).
Definition: tarmac_base.hh:117
std::string iSetStateToStr(TarmacBaseRecord::ISetState isetstate)
Returns the string representation of the instruction set being currently run according to the Tarmac ...
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:75
virtual void updatePred(const TarmacContext &tarmCtx, RegIndex regRelIdx)
virtual void dump() override
virtual void addInstEntry(std::vector< InstPtr > &queue, const TarmacContext &ptr)
Generates an Entry for the executed instruction.
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41

Generated on Thu May 28 2020 16:11:03 for gem5 by doxygen 1.8.13