gem5  v22.1.0.0
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 
46 #include <memory>
47 
48 #include "arch/arm/regs/misc.hh"
50 #include "base/printable.hh"
51 #include "cpu/reg_class.hh"
52 #include "cpu/static_inst.hh"
53 
54 namespace gem5
55 {
56 
57 namespace trace {
58 
59 class TarmacContext;
60 
61 class TarmacTracer;
62 
71 std::string
73 
81 std::string
83 
95 {
96  public:
99  {
100  TraceInstEntry(const TarmacContext& tarmCtx, bool predicate);
101 
102  virtual void print(std::ostream& outs,
103  int verbosity = 0,
104  const std::string &prefix = "") const override;
105 
106  protected:
108  static uint64_t instCount;
109 
117  uint8_t instSize;
118  };
119 
122  {
123  public:
124  TraceRegEntry(const TarmacContext& tarmCtx, const RegId& reg);
125 
135  void update(const TarmacContext& tarmCtx);
136 
137  virtual void print(std::ostream& outs,
138  int verbosity = 0,
139  const std::string &prefix = "") const override;
140 
141  protected:
143  virtual void updateMisc(const TarmacContext& tarmCtx);
144  virtual void updateCC(const TarmacContext& tarmCtx);
145  virtual void updateFloat(const TarmacContext& tarmCtx);
146  virtual void updateInt(const TarmacContext& tarmCtx);
147  virtual void updateVec(const TarmacContext& tarmCtx) {};
148  virtual void updatePred(const TarmacContext& tarmCtx) {};
149 
150  public:
152  bool regValid;
156  std::string regName;
157  };
158 
161  {
162  public:
163  TraceMemEntry(const TarmacContext& tarmCtx,
164  uint8_t _size, Addr _addr, uint64_t _data);
165 
166  virtual void print(std::ostream& outs,
167  int verbosity = 0,
168  const std::string &prefix = "") const override;
169 
170  protected:
173  };
174 
175  public:
176  TarmacTracerRecord(Tick _when, ThreadContext *_thread,
177  const StaticInstPtr _staticInst, const PCStateBase &_pc,
178  TarmacTracer& _tracer,
179  const StaticInstPtr _macroStaticInst = NULL);
180 
181  virtual void dump() override;
182 
183  using InstPtr = std::unique_ptr<TraceInstEntry>;
184  using MemPtr = std::unique_ptr<TraceMemEntry>;
185  using RegPtr = std::unique_ptr<TraceRegEntry>;
186 
187  protected:
189  virtual void addInstEntry(std::vector<InstPtr>& queue,
190  const TarmacContext& ptr);
191 
193  virtual void addMemEntry(std::vector<MemPtr>& queue,
194  const TarmacContext& ptr);
195 
197  virtual void addRegEntry(std::vector<RegPtr>& queue,
198  const TarmacContext& ptr);
199 
200  protected:
202  template<typename RegEntry>
203  RegEntry
204  genRegister(const TarmacContext& tarmCtx, const RegId& reg)
205  {
206  RegEntry single_reg(tarmCtx, reg);
207  single_reg.update(tarmCtx);
208 
209  return single_reg;
210  }
211 
212  template<typename RegEntry>
213  void
215  {
216  // Find all CC Entries and move them at the end of the queue
217  auto it = std::remove_if(
218  queue.begin(), queue.end(),
219  [] (RegPtr& reg) ->bool {
220  return (reg->regId.classValue() == CCRegClass);
221  }
222  );
223 
224  if (it != queue.end()) {
225  // Remove all CC Entries.
226  queue.erase(it, queue.end());
227 
228  auto is_cpsr = [] (RegPtr& reg) ->bool
229  {
230  return (reg->regId.classValue()== MiscRegClass) &&
231  (reg->regId.index() == ArmISA::MISCREG_CPSR);
232  };
233 
234  // Looking for the presence of a CPSR register entry.
235  auto cpsr_it = std::find_if(
236  queue.begin(), queue.end(), is_cpsr
237  );
238 
239  // If CPSR entry not present, generate one
240  if (cpsr_it == queue.end()) {
242  queue.push_back(
243  std::make_unique<RegEntry>(
244  genRegister<RegEntry>(tarmCtx, reg))
245  );
246  }
247  }
248  }
249 
251  template<typename Queue>
252  void flushQueues(Queue& queue);
253  template<typename Queue, typename... Args>
254  void flushQueues(Queue& queue, Args & ... args);
255 
256  protected:
259 };
260 
261 } // namespace trace
262 } // namespace gem5
263 
264 #endif // __ARCH_ARM_TRACERS_TARMAC_RECORD_HH__
Abstract base class for objects which support being printed to a stream for debugging.
Definition: printable.hh:48
A high-level queue interface, to be used by both the MSHR queue and the write buffer.
Definition: queue.hh:71
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:91
ThreadContext is the external interface to all thread state for anything outside of the CPU.
bool predicate
is the predicate for execution this inst true or false (not execed)?
Definition: insttracer.hh:150
ISetState
ARM instruction set state.
Definition: tarmac_base.hh:78
This object type is encapsulating the informations needed by a Tarmac record to generate it's own ent...
TarmacTracer Record: Record generated by the TarmacTracer for every executed instruction.
std::unique_ptr< TraceRegEntry > RegPtr
virtual void addInstEntry(std::vector< InstPtr > &queue, const TarmacContext &ptr)
Generates an Entry for the executed instruction.
void mergeCCEntry(std::vector< RegPtr > &queue, const TarmacContext &tarmCtx)
RegEntry genRegister(const TarmacContext &tarmCtx, const RegId &reg)
Generate and update a register entry.
std::unique_ptr< TraceMemEntry > MemPtr
virtual void addRegEntry(std::vector< RegPtr > &queue, const TarmacContext &ptr)
Generate an Entry for every register being written.
virtual void dump() override
TarmacTracerRecord(Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, const PCStateBase &_pc, TarmacTracer &_tracer, const StaticInstPtr _macroStaticInst=NULL)
void flushQueues(Queue &queue)
Flush queues to the trace output.
virtual void addMemEntry(std::vector< MemPtr > &queue, const TarmacContext &ptr)
Generates an Entry for every triggered memory access.
TarmacTracer & tracer
Reference to tracer.
std::unique_ptr< TraceInstEntry > InstPtr
Tarmac Tracer: this tracer generates a new Tarmac Record for every instruction being executed in gem5...
@ MISCREG_CPSR
Definition: misc.hh:65
constexpr RegClass miscRegClass
Definition: misc.hh:2726
Bitfield< 5, 3 > reg
Definition: types.hh:92
std::string iSetStateToStr(TarmacBaseRecord::ISetState isetstate)
Returns the string representation of the instruction set being currently run according to the Tarmac ...
std::string opModeToStr(OperatingMode opMode)
Returns the string representation of the ARM Operating Mode (CPSR.M[3:0] field) according to the Tarm...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t Tick
Tick count type.
Definition: types.hh:58
@ MiscRegClass
Control (misc) register.
Definition: reg_class.hh:68
TARMAC instruction trace record.
Definition: tarmac_base.hh:86
TARMAC memory access trace record (stores only).
Definition: tarmac_base.hh:123
TARMAC register trace record.
Definition: tarmac_base.hh:103
bool secureMode
True if instruction is executed in secure mode.
virtual void print(std::ostream &outs, int verbosity=0, const std::string &prefix="") const override
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)
TraceInstEntry(const TarmacContext &tarmCtx, bool predicate)
TraceMemEntry(const TarmacContext &tarmCtx, uint8_t _size, Addr _addr, uint64_t _data)
virtual void print(std::ostream &outs, int verbosity=0, const std::string &prefix="") const override
bool loadAccess
True if memory access is a load.
void update(const TarmacContext &tarmCtx)
This updates the register entry using the update table.
bool regValid
True if register entry is valid.
virtual void updateCC(const TarmacContext &tarmCtx)
virtual void updatePred(const TarmacContext &tarmCtx)
virtual void updateFloat(const TarmacContext &tarmCtx)
virtual void print(std::ostream &outs, int verbosity=0, const std::string &prefix="") const override
virtual void updateMisc(const TarmacContext &tarmCtx)
Register update functions.
virtual void updateVec(const TarmacContext &tarmCtx)
TraceRegEntry(const TarmacContext &tarmCtx, const RegId &reg)
std::string regName
Register name to be printed.
virtual void updateInt(const TarmacContext &tarmCtx)

Generated on Wed Dec 21 2022 10:22:27 for gem5 by doxygen 1.9.1