gem5  v21.1.0.2
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 <vector>
46 
47 #include "arch/generic/isa.hh"
48 #include "arch/vecregs.hh"
49 #include "base/trace.hh"
50 #include "config/the_isa.hh"
51 #include "cpu/o3/comm.hh"
52 #include "debug/IEW.hh"
53 #include "enums/VecRegRenameMode.hh"
54 
55 namespace gem5
56 {
57 
58 namespace o3
59 {
60 
61 class UnifiedFreeList;
62 
67 {
68  private:
69 
71  using VecMode = enums::VecRegRenameMode;
72  public:
73  using IdRange = std::pair<PhysIds::iterator,
74  PhysIds::iterator>;
75  private:
80 
84 
89 
93 
97 
100 
105 
110 
115 
120 
125 
130 
132  unsigned totalNumRegs;
133 
136 
137  public:
142  PhysRegFile(unsigned _numPhysicalIntRegs,
143  unsigned _numPhysicalFloatRegs,
144  unsigned _numPhysicalVecRegs,
145  unsigned _numPhysicalVecPredRegs,
146  unsigned _numPhysicalCCRegs,
147  const BaseISA::RegClasses &regClasses,
148  VecMode vmode
149  );
150 
155 
157  void initFreeList(UnifiedFreeList *freeList);
158 
160  unsigned numIntPhysRegs() const { return numPhysicalIntRegs; }
161 
163  unsigned numFloatPhysRegs() const { return numPhysicalFloatRegs; }
165  unsigned numVecPhysRegs() const { return numPhysicalVecRegs; }
167  unsigned numPredPhysRegs() const { return numPhysicalVecPredRegs; }
168 
170  unsigned numVecElemPhysRegs() const { return numPhysicalVecElemRegs; }
171 
173  unsigned numCCPhysRegs() const { return numPhysicalCCRegs; }
174 
176  unsigned totalNumPhysRegs() const { return totalNumRegs; }
177 
180  return &miscRegIds[reg_idx];
181  }
182 
184  RegVal
185  readIntReg(PhysRegIdPtr phys_reg) const
186  {
187  assert(phys_reg->is(IntRegClass));
188 
189  DPRINTF(IEW, "RegFile: Access to int register %i, has data "
190  "%#x\n", phys_reg->index(), intRegFile[phys_reg->index()]);
191  return intRegFile[phys_reg->index()];
192  }
193 
194  RegVal
195  readFloatReg(PhysRegIdPtr phys_reg) const
196  {
197  assert(phys_reg->is(FloatRegClass));
198 
199  RegVal floatRegBits = floatRegFile[phys_reg->index()];
200 
201  DPRINTF(IEW, "RegFile: Access to float register %i as int, "
202  "has data %#x\n", phys_reg->index(), floatRegBits);
203 
204  return floatRegBits;
205  }
206 
209  readVecReg(PhysRegIdPtr phys_reg) const
210  {
211  assert(phys_reg->is(VecRegClass));
212 
213  DPRINTF(IEW, "RegFile: Access to vector register %i, has "
214  "data %s\n", int(phys_reg->index()),
215  vectorRegFile[phys_reg->index()]);
216 
217  return vectorRegFile[phys_reg->index()];
218  }
219 
223  {
224  /* const_cast for not duplicating code above. */
225  return const_cast<TheISA::VecRegContainer&>(readVecReg(phys_reg));
226  }
227 
229  const TheISA::VecElem &
230  readVecElem(PhysRegIdPtr phys_reg) const
231  {
232  assert(phys_reg->is(VecElemClass));
233  auto ret = vectorRegFile[phys_reg->index()].as<TheISA::VecElem>();
234  const TheISA::VecElem& val = ret[phys_reg->elemIndex()];
235  DPRINTF(IEW, "RegFile: Access to element %d of vector register %i,"
236  " has data %#x\n", phys_reg->elemIndex(),
237  int(phys_reg->index()), val);
238 
239  return val;
240  }
241 
244  readVecPredReg(PhysRegIdPtr phys_reg) const
245  {
246  assert(phys_reg->is(VecPredRegClass));
247 
248  DPRINTF(IEW, "RegFile: Access to predicate register %i, has "
249  "data %s\n", int(phys_reg->index()),
250  vecPredRegFile[phys_reg->index()]);
251 
252  return vecPredRegFile[phys_reg->index()];
253  }
254 
257  {
258  /* const_cast for not duplicating code above. */
259  return const_cast<TheISA::VecPredRegContainer&>(
260  readVecPredReg(phys_reg));
261  }
262 
264  RegVal
266  {
267  assert(phys_reg->is(CCRegClass));
268 
269  DPRINTF(IEW, "RegFile: Access to cc register %i, has "
270  "data %#x\n", phys_reg->index(),
271  ccRegFile[phys_reg->index()]);
272 
273  return ccRegFile[phys_reg->index()];
274  }
275 
277  void
279  {
280  assert(phys_reg->is(IntRegClass));
281 
282  DPRINTF(IEW, "RegFile: Setting int register %i to %#x\n",
283  phys_reg->index(), val);
284 
285  if (phys_reg->index() != zeroReg.index())
286  intRegFile[phys_reg->index()] = val;
287  }
288 
289  void
291  {
292  assert(phys_reg->is(FloatRegClass));
293 
294  DPRINTF(IEW, "RegFile: Setting float register %i to %#x\n",
295  phys_reg->index(), (uint64_t)val);
296 
297  floatRegFile[phys_reg->index()] = val;
298  }
299 
301  void
303  {
304  assert(phys_reg->is(VecRegClass));
305 
306  DPRINTF(IEW, "RegFile: Setting vector register %i to %s\n",
307  int(phys_reg->index()), val);
308 
309  vectorRegFile[phys_reg->index()] = val;
310  }
311 
313  void
315  {
316  assert(phys_reg->is(VecElemClass));
317 
318  DPRINTF(IEW, "RegFile: Setting element %d of vector register %i to"
319  " %#x\n", phys_reg->elemIndex(), int(phys_reg->index()), val);
320 
321  vectorRegFile[phys_reg->index()].as<TheISA::VecElem>()[
322  phys_reg->elemIndex()] = val;
323  }
324 
326  void
329  {
330  assert(phys_reg->is(VecPredRegClass));
331 
332  DPRINTF(IEW, "RegFile: Setting predicate register %i to %s\n",
333  int(phys_reg->index()), val);
334 
335  vecPredRegFile[phys_reg->index()] = val;
336  }
337 
339  void
341  {
342  assert(phys_reg->is(CCRegClass));
343 
344  DPRINTF(IEW, "RegFile: Setting cc register %i to %#x\n",
345  phys_reg->index(), (uint64_t)val);
346 
347  ccRegFile[phys_reg->index()] = val;
348  }
349 
354 
361 
368 };
369 
370 } // namespace o3
371 } // namespace gem5
372 
373 #endif //__CPU_O3_REGFILE_HH__
gem5::o3::PhysRegFile::setCCReg
void setCCReg(PhysRegIdPtr phys_reg, RegVal val)
Sets a condition-code register to the given value.
Definition: regfile.hh:340
gem5::VecElemClass
@ VecElemClass
Vector Register Native Elem lane.
Definition: reg_class.hh:62
gem5::o3::PhysRegFile::getWritableVecReg
TheISA::VecRegContainer & getWritableVecReg(PhysRegIdPtr phys_reg)
Reads a vector register for modification.
Definition: regfile.hh:222
gem5::CCRegClass
@ CCRegClass
Condition-code register.
Definition: reg_class.hh:64
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::o3::PhysRegFile::readVecReg
const TheISA::VecRegContainer & readVecReg(PhysRegIdPtr phys_reg) const
Reads a vector register.
Definition: regfile.hh:209
gem5::RegClass
RegClass
Enumerate the classes of registers.
Definition: reg_class.hh:55
gem5::ArmISA::VecPredRegContainer
VecPredReg::Container VecPredRegContainer
Definition: vec.hh:68
gem5::o3::PhysRegFile::numPhysicalVecElemRegs
unsigned numPhysicalVecElemRegs
Number of physical vector element registers.
Definition: regfile.hh:119
gem5::o3::PhysRegFile::readVecElem
const TheISA::VecElem & readVecElem(PhysRegIdPtr phys_reg) const
Reads a vector element.
Definition: regfile.hh:230
gem5::o3::PhysRegFile::zeroReg
RegId zeroReg
Definition: regfile.hh:79
gem5::o3::PhysRegFile::PhysRegFile
PhysRegFile(unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs, unsigned _numPhysicalVecRegs, unsigned _numPhysicalVecPredRegs, unsigned _numPhysicalCCRegs, const BaseISA::RegClasses &regClasses, VecMode vmode)
Constructs a physical register file with the specified amount of integer and floating point registers...
Definition: regfile.cc:54
gem5::o3::PhysRegFile::setVecPredReg
void setVecPredReg(PhysRegIdPtr phys_reg, const TheISA::VecPredRegContainer &val)
Sets a predicate register to the given value.
Definition: regfile.hh:327
gem5::o3::PhysRegFile::numIntPhysRegs
unsigned numIntPhysRegs() const
Definition: regfile.hh:160
gem5::o3::PhysRegFile::readFloatReg
RegVal readFloatReg(PhysRegIdPtr phys_reg) const
Definition: regfile.hh:195
gem5::o3::PhysRegFile::intRegFile
std::vector< RegVal > intRegFile
Integer register file.
Definition: regfile.hh:77
gem5::o3::PhysRegFile::readIntReg
RegVal readIntReg(PhysRegIdPtr phys_reg) const
Reads an integer register.
Definition: regfile.hh:185
gem5::o3::PhysRegFile::numFloatPhysRegs
unsigned numFloatPhysRegs() const
Definition: regfile.hh:163
gem5::FloatRegClass
@ FloatRegClass
Floating-point register.
Definition: reg_class.hh:58
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:775
gem5::o3::UnifiedFreeList
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:122
gem5::VecPredRegClass
@ VecPredRegClass
Definition: reg_class.hh:63
gem5::o3::PhysRegFile::ccRegIds
std::vector< PhysRegId > ccRegIds
Definition: regfile.hh:96
std::vector
STL vector class.
Definition: stl.hh:37
gem5::o3::PhysRegFile::getRegIds
IdRange getRegIds(RegClass cls)
Get the PhysRegIds of the elems of all vector registers.
Definition: regfile.cc:200
gem5::o3::PhysRegFile::getWritableVecPredReg
TheISA::VecPredRegContainer & getWritableVecPredReg(PhysRegIdPtr phys_reg)
Definition: regfile.hh:256
gem5::RegId::index
RegIndex index() const
Index accessors.
Definition: reg_class.hh:154
gem5::o3::PhysRegFile::setVecElem
void setVecElem(PhysRegIdPtr phys_reg, const TheISA::VecElem val)
Sets a vector register to the given value.
Definition: regfile.hh:314
gem5::o3::PhysRegFile::getTrueId
PhysRegIdPtr getTrueId(PhysRegIdPtr reg)
Get the true physical register id.
Definition: regfile.cc:225
gem5::o3::PhysRegFile::numPhysicalVecRegs
unsigned numPhysicalVecRegs
Number of physical vector registers.
Definition: regfile.hh:114
gem5::o3::PhysRegFile::numCCPhysRegs
unsigned numCCPhysRegs() const
Definition: regfile.hh:173
gem5::o3::PhysRegFile::floatRegIds
std::vector< PhysRegId > floatRegIds
Definition: regfile.hh:83
comm.hh
gem5::o3::PhysRegFile::miscRegIds
std::vector< PhysRegId > miscRegIds
Misc Reg Ids.
Definition: regfile.hh:99
gem5::o3::PhysRegFile::vecElemIds
std::vector< PhysRegId > vecElemIds
Definition: regfile.hh:88
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::o3::PhysRegFile
Simple physical register file class.
Definition: regfile.hh:66
gem5::o3::PhysRegFile::numPredPhysRegs
unsigned numPredPhysRegs() const
Definition: regfile.hh:167
gem5::o3::IEW
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition: iew.hh:87
gem5::o3::PhysRegFile::vecRegIds
std::vector< PhysRegId > vecRegIds
Definition: regfile.hh:87
gem5::ArmISA::VecRegContainer
gem5::VecRegContainer< NumVecElemPerVecReg *sizeof(VecElem)> VecRegContainer
Definition: vec.hh:62
gem5::o3::PhysRegFile::IdRange
std::pair< PhysIds::iterator, PhysIds::iterator > IdRange
Definition: regfile.hh:74
gem5::o3::PhysRegFile::vecMode
VecMode vecMode
Mode in which vector registers are addressed.
Definition: regfile.hh:135
std::pair
STL pair class.
Definition: stl.hh:58
gem5::o3::PhysRegFile::intRegIds
std::vector< PhysRegId > intRegIds
Definition: regfile.hh:78
gem5::o3::PhysRegFile::vecPredRegFile
std::vector< TheISA::VecPredRegContainer > vecPredRegFile
Predicate register file.
Definition: regfile.hh:91
gem5::o3::PhysRegFile::vectorRegFile
std::vector< TheISA::VecRegContainer > vectorRegFile
Vector register file.
Definition: regfile.hh:86
gem5::o3::PhysRegFile::numPhysicalIntRegs
unsigned numPhysicalIntRegs
Number of physical general purpose registers.
Definition: regfile.hh:104
gem5::o3::PhysRegFile::numVecPhysRegs
unsigned numVecPhysRegs() const
Definition: regfile.hh:165
gem5::o3::PhysRegFile::~PhysRegFile
~PhysRegFile()
Destructor to free resources.
Definition: regfile.hh:154
gem5::X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:92
gem5::o3::PhysRegFile::numPhysicalVecPredRegs
unsigned numPhysicalVecPredRegs
Number of physical predicate registers.
Definition: regfile.hh:124
isa.hh
gem5::o3::PhysRegFile::getRegElemIds
IdRange getRegElemIds(PhysRegIdPtr reg)
Get the PhysRegIds of the elems of a vector register.
Definition: regfile.cc:189
gem5::VecRegClass
@ VecRegClass
Vector Register.
Definition: reg_class.hh:60
gem5::PhysRegId::elemIndex
RegIndex elemIndex() const
Elem accessor.
Definition: reg_class.hh:178
gem5::ArmISA::VecElem
uint32_t VecElem
Definition: vec.hh:60
gem5::o3::PhysRegFile::getMiscRegId
PhysRegIdPtr getMiscRegId(RegIndex reg_idx)
Gets a misc register PhysRegIdPtr.
Definition: regfile.hh:179
gem5::o3::PhysRegFile::floatRegFile
std::vector< RegVal > floatRegFile
Floating point register file.
Definition: regfile.hh:82
gem5::o3::PhysRegFile::totalNumRegs
unsigned totalNumRegs
Total number of physical registers.
Definition: regfile.hh:132
gem5::o3::PhysRegFile::numPhysicalCCRegs
unsigned numPhysicalCCRegs
Number of physical CC registers.
Definition: regfile.hh:129
gem5::o3::PhysRegFile::readVecPredReg
const TheISA::VecPredRegContainer & readVecPredReg(PhysRegIdPtr phys_reg) const
Reads a predicate register.
Definition: regfile.hh:244
gem5::o3::PhysRegFile::initFreeList
void initFreeList(UnifiedFreeList *freeList)
Initialize the free list.
Definition: regfile.cc:135
gem5::o3::PhysRegFile::vecPredRegIds
std::vector< PhysRegId > vecPredRegIds
Definition: regfile.hh:92
gem5::o3::PhysRegFile::VecMode
enums::VecRegRenameMode VecMode
Definition: regfile.hh:71
gem5::PhysRegId
Physical register ID.
Definition: reg_class.hh:198
gem5::o3::PhysRegFile::setFloatReg
void setFloatReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: regfile.hh:290
gem5::o3::PhysRegFile::setIntReg
void setIntReg(PhysRegIdPtr phys_reg, RegVal val)
Sets an integer register to the given value.
Definition: regfile.hh:278
gem5::o3::PhysRegFile::ccRegFile
std::vector< RegVal > ccRegFile
Condition-code register file.
Definition: regfile.hh:95
trace.hh
gem5::o3::PhysRegFile::numPhysicalFloatRegs
unsigned numPhysicalFloatRegs
Number of physical floating point registers.
Definition: regfile.hh:109
gem5::PhysRegId::is
bool is(RegClass reg_class) const
Definition: reg_class.hh:150
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
gem5::o3::PhysRegFile::setVecReg
void setVecReg(PhysRegIdPtr phys_reg, const TheISA::VecRegContainer &val)
Sets a vector register to the given value.
Definition: regfile.hh:302
gem5::IntRegClass
@ IntRegClass
Integer register.
Definition: reg_class.hh:57
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::o3::PhysRegFile::readCCReg
RegVal readCCReg(PhysRegIdPtr phys_reg)
Reads a condition-code register.
Definition: regfile.hh:265
gem5::PhysRegId::index
RegIndex index() const
Visible RegId methods.
Definition: reg_class.hh:154
gem5::o3::PhysRegFile::numVecElemPhysRegs
unsigned numVecElemPhysRegs() const
Definition: regfile.hh:170
gem5::RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:88
gem5::o3::PhysRegFile::totalNumPhysRegs
unsigned totalNumPhysRegs() const
Definition: regfile.hh:176

Generated on Tue Sep 21 2021 12:25:05 for gem5 by doxygen 1.8.17