gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
54 namespace gem5
55 {
56 
57 namespace o3
58 {
59 
60 class 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:
191  val = vectorElemRegFile.reg(idx);
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:
282  vectorElemRegFile.reg(idx) = val;
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__
gem5::RegFile::ptr
void * ptr(size_t idx)
Definition: regfile.hh:81
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::o3::PhysRegFile::numPhysicalVecElemRegs
unsigned numPhysicalVecElemRegs
Number of physical vector element registers.
Definition: regfile.hh:123
gem5::o3::PhysRegFile::vectorElemRegFile
RegFile vectorElemRegFile
Vector element register file.
Definition: regfile.hh:87
gem5::VecElemClass
@ VecElemClass
Vector Register Native Elem lane.
Definition: reg_class.hh:65
gem5::InvalidRegClass
@ InvalidRegClass
Definition: reg_class.hh:70
gem5::o3::PhysRegFile::ccRegFile
RegFile ccRegFile
Condition-code register file.
Definition: regfile.hh:99
gem5::CCRegClass
@ CCRegClass
Condition-code register.
Definition: reg_class.hh:68
gem5::o3::PhysRegFile::getWritableReg
void * getWritableReg(PhysRegIdPtr phys_reg)
Definition: regfile.hh:245
gem5::o3::PhysRegFile::numPhysicalMatRegs
unsigned numPhysicalMatRegs
Number of physical matrix registers.
Definition: regfile.hh:133
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:776
gem5::RegFile::get
void get(size_t idx, void *val) const
Definition: regfile.hh:93
gem5::RegClass::valString
std::string valString(const void *val) const
Definition: reg_class.hh:245
gem5::o3::PhysRegFile::setReg
void setReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: regfile.hh:263
gem5::o3::UnifiedFreeList
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:124
gem5::o3::PhysRegFile::ccRegIds
std::vector< PhysRegId > ccRegIds
Definition: regfile.hh:100
std::vector
STL vector class.
Definition: stl.hh:37
gem5::VecPredRegClass
@ VecPredRegClass
Definition: reg_class.hh:66
gem5::o3::PhysRegFile::numPhysicalVecRegs
unsigned numPhysicalVecRegs
Number of physical vector registers.
Definition: regfile.hh:118
gem5::o3::PhysRegFile::floatRegIds
std::vector< PhysRegId > floatRegIds
Definition: regfile.hh:80
comm.hh
gem5::FloatRegClass
@ FloatRegClass
Floating-point register.
Definition: reg_class.hh:61
gem5::o3::PhysRegFile::miscRegIds
std::vector< PhysRegId > miscRegIds
Misc Reg Ids.
Definition: regfile.hh:103
gem5::o3::PhysRegFile::vecElemIds
std::vector< PhysRegId > vecElemIds
Definition: regfile.hh:88
gem5::MatRegClass
@ MatRegClass
Matrix Register.
Definition: reg_class.hh:67
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:210
gem5::o3::PhysRegFile::matRegFile
RegFile matRegFile
Matrix register file.
Definition: regfile.hh:95
gem5::RegFile
Definition: regfile.hh:41
gem5::o3::PhysRegFile::setReg
void setReg(PhysRegIdPtr phys_reg, const void *val)
Definition: regfile.hh:297
gem5::o3::PhysRegFile
Simple physical register file class.
Definition: regfile.hh:65
gem5::o3::PhysRegFile::getReg
RegVal getReg(PhysRegIdPtr phys_reg) const
Definition: regfile.hh:173
gem5::o3::IEW
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition: iew.hh:87
gem5::X86ISA::type
type
Definition: misc.hh:734
gem5::o3::PhysRegFile::vectorRegFile
RegFile vectorRegFile
Vector register file.
Definition: regfile.hh:83
gem5::o3::PhysRegFile::vecRegIds
std::vector< PhysRegId > vecRegIds
Definition: regfile.hh:84
gem5::RegFile::reg
Reg & reg(size_t idx)
Definition: regfile.hh:66
gem5::RegFile::regClass
const RegClass & regClass
Definition: regfile.hh:50
std::pair
STL pair class.
Definition: stl.hh:58
gem5::o3::PhysRegFile::intRegIds
std::vector< PhysRegId > intRegIds
Definition: regfile.hh:76
regfile.hh
gem5::o3::PhysRegFile::numPhysicalIntRegs
unsigned numPhysicalIntRegs
Number of physical general purpose registers.
Definition: regfile.hh:108
gem5::o3::PhysRegFile::PhysRegFile
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
gem5::o3::PhysRegFile::~PhysRegFile
~PhysRegFile()
Destructor to free resources.
Definition: regfile.hh:159
gem5::o3::PhysRegFile::numPhysicalVecPredRegs
unsigned numPhysicalVecPredRegs
Number of physical predicate registers.
Definition: regfile.hh:128
gem5::o3::PhysRegFile::getReg
void getReg(PhysRegIdPtr phys_reg, void *val) const
Definition: regfile.hh:206
gem5::IntRegClass
@ IntRegClass
Integer register.
Definition: reg_class.hh:60
isa.hh
gem5::RegClassType
RegClassType
Enumerate the classes of registers.
Definition: reg_class.hh:58
gem5::o3::PhysRegFile::getMiscRegId
PhysRegIdPtr getMiscRegId(RegIndex reg_idx)
Gets a misc register PhysRegIdPtr.
Definition: regfile.hh:168
gem5::o3::PhysRegFile::totalNumRegs
unsigned totalNumRegs
Total number of physical registers.
Definition: regfile.hh:141
gem5::o3::PhysRegFile::numPhysicalCCRegs
unsigned numPhysicalCCRegs
Number of physical CC registers.
Definition: regfile.hh:138
gem5::o3::PhysRegFile::initFreeList
void initFreeList(UnifiedFreeList *freeList)
Initialize the free list.
Definition: regfile.cc:145
gem5::o3::PhysRegFile::vecPredRegIds
std::vector< PhysRegId > vecPredRegIds
Definition: regfile.hh:92
gem5::RegFile::set
void set(size_t idx, const void *val)
Definition: regfile.hh:99
gem5::PhysRegId
Physical register ID.
Definition: reg_class.hh:393
gem5::PhysRegId::index
constexpr RegIndex index() const
Visible RegId methods.
Definition: reg_class.hh:150
trace.hh
gem5::o3::PhysRegFile::numPhysicalFloatRegs
unsigned numPhysicalFloatRegs
Number of physical floating point registers.
Definition: regfile.hh:113
gem5::VecRegClass
@ VecRegClass
Vector Register.
Definition: reg_class.hh:63
gem5::o3::PhysRegFile::vecPredRegFile
RegFile vecPredRegFile
Predicate register file.
Definition: regfile.hh:91
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
gem5::o3::PhysRegFile::floatRegFile
RegFile floatRegFile
Floating point register file.
Definition: regfile.hh:79
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::o3::PhysRegFile::matRegIds
std::vector< PhysRegId > matRegIds
Definition: regfile.hh:96
gem5::PhysRegId::classValue
constexpr RegClassType classValue() const
Definition: reg_class.hh:274
gem5::o3::PhysRegFile::intRegFile
RegFile intRegFile
Integer register file.
Definition: regfile.hh:75
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::o3::PhysRegFile::totalNumPhysRegs
unsigned totalNumPhysRegs() const
Definition: regfile.hh:165

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