gem5 v24.0.0.0
Loading...
Searching...
No Matches
regfile.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2018 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 * Copyright (c) 2004-2005 The Regents of The University of Michigan
15 * Copyright (c) 2013 Advanced Micro Devices, Inc.
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
42#ifndef __CPU_O3_REGFILE_HH__
43#define __CPU_O3_REGFILE_HH__
44
45#include <cstring>
46#include <vector>
47
48#include "arch/generic/isa.hh"
49#include "base/trace.hh"
50#include "cpu/o3/comm.hh"
51#include "cpu/regfile.hh"
52#include "debug/IEW.hh"
53
54namespace gem5
55{
56
57namespace o3
58{
59
60class UnifiedFreeList;
61
66{
67 private:
68
70 public:
71 using IdRange = std::pair<PhysIds::iterator,
72 PhysIds::iterator>;
73 private:
77
81
85
89
93
97
101
104
109
114
119
124
129
134
139
141 unsigned totalNumRegs;
142
143 public:
148 PhysRegFile(unsigned _numPhysicalIntRegs,
149 unsigned _numPhysicalFloatRegs,
150 unsigned _numPhysicalVecRegs,
151 unsigned _numPhysicalVecPredRegs,
152 unsigned _numPhysicalMatRegs,
153 unsigned _numPhysicalCCRegs,
154 const BaseISA::RegClasses &classes);
155
160
162 void initFreeList(UnifiedFreeList *freeList);
163
165 unsigned totalNumPhysRegs() const { return totalNumRegs; }
166
169 return &miscRegIds[reg_idx];
170 }
171
172 RegVal
173 getReg(PhysRegIdPtr phys_reg) const
174 {
175 const RegClassType type = phys_reg->classValue();
176 const RegIndex idx = phys_reg->index();
177
178 RegVal val;
179 switch (type) {
180 case IntRegClass:
181 val = intRegFile.reg(idx);
182 DPRINTF(IEW, "RegFile: Access to int register %i, has data %#x\n",
183 idx, val);
184 return val;
185 case FloatRegClass:
186 val = floatRegFile.reg(idx);
187 DPRINTF(IEW, "RegFile: Access to float register %i has data %#x\n",
188 idx, val);
189 return val;
190 case VecElemClass:
192 DPRINTF(IEW, "RegFile: Access to vector element register %i "
193 "has data %#x\n", idx, val);
194 return val;
195 case CCRegClass:
196 val = ccRegFile.reg(idx);
197 DPRINTF(IEW, "RegFile: Access to cc register %i has data %#x\n",
198 idx, val);
199 return val;
200 default:
201 panic("Unsupported register class type %d.", type);
202 }
203 }
204
205 void
206 getReg(PhysRegIdPtr phys_reg, void *val) const
207 {
208 const RegClassType type = phys_reg->classValue();
209 const RegIndex idx = phys_reg->index();
210
211 switch (type) {
212 case IntRegClass:
213 *(RegVal *)val = getReg(phys_reg);
214 break;
215 case FloatRegClass:
216 *(RegVal *)val = getReg(phys_reg);
217 break;
218 case VecRegClass:
219 vectorRegFile.get(idx, val);
220 DPRINTF(IEW, "RegFile: Access to vector register %i, has "
221 "data %s\n", idx, vectorRegFile.regClass.valString(val));
222 break;
223 case VecElemClass:
224 *(RegVal *)val = getReg(phys_reg);
225 break;
226 case VecPredRegClass:
227 vecPredRegFile.get(idx, val);
228 DPRINTF(IEW, "RegFile: Access to predicate register %i, has "
229 "data %s\n", idx, vecPredRegFile.regClass.valString(val));
230 break;
231 case MatRegClass:
232 matRegFile.get(idx, val);
233 DPRINTF(IEW, "RegFile: Access to matrix register %i, has "
234 "data %s\n", idx, matRegFile.regClass.valString(val));
235 break;
236 case CCRegClass:
237 *(RegVal *)val = getReg(phys_reg);
238 break;
239 default:
240 panic("Unrecognized register class type %d.", type);
241 }
242 }
243
244 void *
246 {
247 const RegClassType type = phys_reg->classValue();
248 const RegIndex idx = phys_reg->index();
249
250 switch (type) {
251 case VecRegClass:
252 return vectorRegFile.ptr(idx);
253 case VecPredRegClass:
254 return vecPredRegFile.ptr(idx);
255 case MatRegClass:
256 return matRegFile.ptr(idx);
257 default:
258 panic("Unrecognized register class type %d.", type);
259 }
260 }
261
262 void
264 {
265 const RegClassType type = phys_reg->classValue();
266 const RegIndex idx = phys_reg->index();
267
268 switch (type) {
269 case InvalidRegClass:
270 break;
271 case IntRegClass:
272 intRegFile.reg(idx) = val;
273 DPRINTF(IEW, "RegFile: Setting int register %i to %#x\n",
274 idx, val);
275 break;
276 case FloatRegClass:
277 floatRegFile.reg(idx) = val;
278 DPRINTF(IEW, "RegFile: Setting float register %i to %#x\n",
279 idx, val);
280 break;
281 case VecElemClass:
283 DPRINTF(IEW, "RegFile: Setting vector element register %i to "
284 "%#x\n", idx, val);
285 break;
286 case CCRegClass:
287 ccRegFile.reg(idx) = val;
288 DPRINTF(IEW, "RegFile: Setting cc register %i to %#x\n",
289 idx, val);
290 break;
291 default:
292 panic("Unsupported register class type %d.", type);
293 }
294 }
295
296 void
297 setReg(PhysRegIdPtr phys_reg, const void *val)
298 {
299 const RegClassType type = phys_reg->classValue();
300 const RegIndex idx = phys_reg->index();
301
302 switch (type) {
303 case IntRegClass:
304 setReg(phys_reg, *(RegVal *)val);
305 break;
306 case FloatRegClass:
307 setReg(phys_reg, *(RegVal *)val);
308 break;
309 case VecRegClass:
310 DPRINTF(IEW, "RegFile: Setting vector register %i to %s\n",
312 vectorRegFile.set(idx, val);
313 break;
314 case VecElemClass:
315 setReg(phys_reg, *(RegVal *)val);
316 break;
317 case VecPredRegClass:
318 DPRINTF(IEW, "RegFile: Setting predicate register %i to %s\n",
320 vecPredRegFile.set(idx, val);
321 break;
322 case MatRegClass:
323 DPRINTF(IEW, "RegFile: Setting matrix register %i to %s\n",
325 matRegFile.set(idx, val);
326 break;
327 case CCRegClass:
328 setReg(phys_reg, *(RegVal *)val);
329 break;
330 default:
331 panic("Unrecognized register class type %d.", type);
332 }
333 }
334};
335
336} // namespace o3
337} // namespace gem5
338
339#endif //__CPU_O3_REGFILE_HH__
#define DPRINTF(x,...)
Definition trace.hh:210
Physical register ID.
Definition reg_class.hh:415
constexpr RegClassType classValue() const
Definition reg_class.hh:280
constexpr RegIndex index() const
Visible RegId methods.
Definition reg_class.hh:151
std::string valString(const void *val) const
Definition reg_class.hh:246
void set(size_t idx, const void *val)
Definition regfile.hh:99
void get(size_t idx, void *val) const
Definition regfile.hh:93
void * ptr(size_t idx)
Definition regfile.hh:81
Reg & reg(size_t idx)
Definition regfile.hh:66
const RegClass & regClass
Definition regfile.hh:50
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition iew.hh:88
Simple physical register file class.
Definition regfile.hh:66
void setReg(PhysRegIdPtr phys_reg, const void *val)
Definition regfile.hh:297
RegFile ccRegFile
Condition-code register file.
Definition regfile.hh:99
std::vector< PhysRegId > vecElemIds
Definition regfile.hh:88
RegVal getReg(PhysRegIdPtr phys_reg) const
Definition regfile.hh:173
std::vector< PhysRegId > ccRegIds
Definition regfile.hh:100
std::vector< PhysRegId > miscRegIds
Misc Reg Ids.
Definition regfile.hh:103
PhysRegIdPtr getMiscRegId(RegIndex reg_idx)
Gets a misc register PhysRegIdPtr.
Definition regfile.hh:168
unsigned totalNumRegs
Total number of physical registers.
Definition regfile.hh:141
unsigned numPhysicalVecRegs
Number of physical vector registers.
Definition regfile.hh:118
unsigned numPhysicalCCRegs
Number of physical CC registers.
Definition regfile.hh:138
unsigned numPhysicalMatRegs
Number of physical matrix registers.
Definition regfile.hh:133
unsigned numPhysicalVecPredRegs
Number of physical predicate registers.
Definition regfile.hh:128
RegFile vectorRegFile
Vector register file.
Definition regfile.hh:83
~PhysRegFile()
Destructor to free resources.
Definition regfile.hh:159
PhysRegFile(unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs, unsigned _numPhysicalVecRegs, unsigned _numPhysicalVecPredRegs, unsigned _numPhysicalMatRegs, unsigned _numPhysicalCCRegs, const BaseISA::RegClasses &classes)
Constructs a physical register file with the specified amount of integer and floating point registers...
Definition regfile.cc:52
RegFile vectorElemRegFile
Vector element register file.
Definition regfile.hh:87
std::vector< PhysRegId > floatRegIds
Definition regfile.hh:80
RegFile matRegFile
Matrix register file.
Definition regfile.hh:95
std::vector< PhysRegId > vecRegIds
Definition regfile.hh:84
RegFile vecPredRegFile
Predicate register file.
Definition regfile.hh:91
RegFile intRegFile
Integer register file.
Definition regfile.hh:75
RegFile floatRegFile
Floating point register file.
Definition regfile.hh:79
unsigned totalNumPhysRegs() const
Definition regfile.hh:165
unsigned numPhysicalVecElemRegs
Number of physical vector element registers.
Definition regfile.hh:123
unsigned numPhysicalFloatRegs
Number of physical floating point registers.
Definition regfile.hh:113
std::vector< PhysRegId > matRegIds
Definition regfile.hh:96
void * getWritableReg(PhysRegIdPtr phys_reg)
Definition regfile.hh:245
std::vector< PhysRegId > intRegIds
Definition regfile.hh:76
std::vector< PhysRegId > vecPredRegIds
Definition regfile.hh:92
void getReg(PhysRegIdPtr phys_reg, void *val) const
Definition regfile.hh:206
unsigned numPhysicalIntRegs
Number of physical general purpose registers.
Definition regfile.hh:108
void setReg(PhysRegIdPtr phys_reg, RegVal val)
Definition regfile.hh:263
void initFreeList(UnifiedFreeList *freeList)
Initialize the free list.
Definition regfile.cc:145
FreeList class that simply holds the list of free integer and floating point registers.
Definition free_list.hh:125
STL pair class.
Definition stl.hh:58
STL vector class.
Definition stl.hh:37
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 63 > val
Definition misc.hh:804
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint16_t RegIndex
Definition types.hh:176
uint64_t RegVal
Definition types.hh:173
RegClassType
Enumerate the classes of registers.
Definition reg_class.hh:60
@ VecPredRegClass
Definition reg_class.hh:67
@ MatRegClass
Matrix Register.
Definition reg_class.hh:68
@ FloatRegClass
Floating-point register.
Definition reg_class.hh:62
@ CCRegClass
Condition-code register.
Definition reg_class.hh:69
@ VecRegClass
Vector Register.
Definition reg_class.hh:64
@ IntRegClass
Integer register.
Definition reg_class.hh:61
@ InvalidRegClass
Definition reg_class.hh:71
@ VecElemClass
Vector Register Native Elem lane.
Definition reg_class.hh:66

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0