gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
54namespace gem5
55{
56
57namespace trace {
58
59class TarmacContext;
60
61class TarmacTracer;
62
71std::string
73
81std::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
120 std::string disassemble;
121 };
122
125 {
126 public:
127 TraceRegEntry(const TarmacContext& tarmCtx, const RegId& reg);
128
138 void update(const TarmacContext& tarmCtx);
139
140 virtual void print(std::ostream& outs,
141 int verbosity = 0,
142 const std::string &prefix = "") const override;
143
144 protected:
146 virtual void updateMisc(const TarmacContext& tarmCtx);
147 virtual void updateCC(const TarmacContext& tarmCtx);
148 virtual void updateFloat(const TarmacContext& tarmCtx);
149 virtual void updateInt(const TarmacContext& tarmCtx);
150 virtual void updateVec(const TarmacContext& tarmCtx) {};
151 virtual void updatePred(const TarmacContext& tarmCtx) {};
152
153 public:
159 std::string regName;
160 };
161
164 {
165 public:
166 TraceMemEntry(const TarmacContext& tarmCtx,
167 uint8_t _size, Addr _addr, uint64_t _data);
168
169 virtual void print(std::ostream& outs,
170 int verbosity = 0,
171 const std::string &prefix = "") const override;
172
173 protected:
176 };
177
178 public:
179 TarmacTracerRecord(Tick _when, ThreadContext *_thread,
180 const StaticInstPtr _staticInst, const PCStateBase &_pc,
181 TarmacTracer& _tracer,
182 const StaticInstPtr _macroStaticInst = NULL);
183
184 virtual void dump() override;
185
186 using InstPtr = std::unique_ptr<TraceInstEntry>;
187 using MemPtr = std::unique_ptr<TraceMemEntry>;
188 using RegPtr = std::unique_ptr<TraceRegEntry>;
189
190 protected:
192 virtual void addInstEntry(std::vector<InstPtr>& queue,
193 const TarmacContext& ptr);
194
196 virtual void addMemEntry(std::vector<MemPtr>& queue,
197 const TarmacContext& ptr);
198
200 virtual void addRegEntry(std::vector<RegPtr>& queue,
201 const TarmacContext& ptr);
202
203 protected:
205 template<typename RegEntry>
207 genRegister(const TarmacContext& tarmCtx, const RegId& reg)
208 {
209 RegEntry single_reg(tarmCtx, reg);
210 single_reg.update(tarmCtx);
211
212 return single_reg;
213 }
214
215 template<typename RegEntry>
216 void
218 {
219 // Find all CC Entries and move them at the end of the queue
220 auto it = std::remove_if(
221 queue.begin(), queue.end(),
222 [] (RegPtr& reg) ->bool {
223 return (reg->regId.classValue() == CCRegClass);
224 }
225 );
226
227 if (it != queue.end()) {
228 // Remove all CC Entries.
229 queue.erase(it, queue.end());
230
231 auto is_cpsr = [] (RegPtr& reg) ->bool
232 {
233 return (reg->regId.classValue()== MiscRegClass) &&
234 (reg->regId.index() == ArmISA::MISCREG_CPSR);
235 };
236
237 // Looking for the presence of a CPSR register entry.
238 auto cpsr_it = std::find_if(
239 queue.begin(), queue.end(), is_cpsr
240 );
241
242 // If CPSR entry not present, generate one
243 if (cpsr_it == queue.end()) {
245 queue.push_back(
246 std::make_unique<RegEntry>(
247 genRegister<RegEntry>(tarmCtx, reg))
248 );
249 }
250 }
251 }
252
254 template<typename Queue>
255 void flushQueues(Queue& queue);
256 template<typename Queue, typename... Args>
257 void flushQueues(Queue& queue, Args & ... args);
258
259 protected:
262};
263
264} // namespace trace
265} // namespace gem5
266
267#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:94
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)?
ISetState
ARM instruction set state.
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...
STL vector class.
Definition stl.hh:37
@ MISCREG_CPSR
Definition misc.hh:67
constexpr RegClass miscRegClass
Definition misc.hh:2937
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...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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:70
TARMAC instruction trace record.
TARMAC memory access trace record (stores only).
TARMAC register trace record.
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
std::string disassemble
Instruction disassembly.
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 Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0