gem5  v20.1.0.0
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/types.hh"
48 #include "base/trace.hh"
49 #include "config/the_isa.hh"
50 #include "cpu/o3/comm.hh"
51 #include "debug/IEW.hh"
52 #include "enums/VecRegRenameMode.hh"
53 
54 class UnifiedFreeList;
55 
60 {
61  private:
62 
66  using VecMode = Enums::VecRegRenameMode;
68  public:
69  using IdRange = std::pair<PhysIds::iterator,
70  PhysIds::iterator>;
71  private:
73 
77 
81 
86 
90 
94 
97 
102 
107 
112 
117 
122 
127 
129  unsigned totalNumRegs;
130 
133 
134  public:
139  PhysRegFile(unsigned _numPhysicalIntRegs,
140  unsigned _numPhysicalFloatRegs,
141  unsigned _numPhysicalVecRegs,
142  unsigned _numPhysicalVecPredRegs,
143  unsigned _numPhysicalCCRegs,
144  VecMode vmode
145  );
146 
151 
153  void initFreeList(UnifiedFreeList *freeList);
154 
156  unsigned numIntPhysRegs() const { return numPhysicalIntRegs; }
157 
159  unsigned numFloatPhysRegs() const { return numPhysicalFloatRegs; }
161  unsigned numVecPhysRegs() const { return numPhysicalVecRegs; }
163  unsigned numPredPhysRegs() const { return numPhysicalVecPredRegs; }
164 
166  unsigned numVecElemPhysRegs() const { return numPhysicalVecElemRegs; }
167 
169  unsigned numCCPhysRegs() const { return numPhysicalCCRegs; }
170 
172  unsigned totalNumPhysRegs() const { return totalNumRegs; }
173 
176  return &miscRegIds[reg_idx];
177  }
178 
180  RegVal
181  readIntReg(PhysRegIdPtr phys_reg) const
182  {
183  assert(phys_reg->isIntPhysReg());
184 
185  DPRINTF(IEW, "RegFile: Access to int register %i, has data "
186  "%#x\n", phys_reg->index(), intRegFile[phys_reg->index()]);
187  return intRegFile[phys_reg->index()];
188  }
189 
190  RegVal
191  readFloatReg(PhysRegIdPtr phys_reg) const
192  {
193  assert(phys_reg->isFloatPhysReg());
194 
195  RegVal floatRegBits = floatRegFile[phys_reg->index()];
196 
197  DPRINTF(IEW, "RegFile: Access to float register %i as int, "
198  "has data %#x\n", phys_reg->index(), floatRegBits);
199 
200  return floatRegBits;
201  }
202 
204  const VecRegContainer &
205  readVecReg(PhysRegIdPtr phys_reg) const
206  {
207  assert(phys_reg->isVectorPhysReg());
208 
209  DPRINTF(IEW, "RegFile: Access to vector register %i, has "
210  "data %s\n", int(phys_reg->index()),
211  vectorRegFile[phys_reg->index()].print());
212 
213  return vectorRegFile[phys_reg->index()];
214  }
215 
219  {
220  /* const_cast for not duplicating code above. */
221  return const_cast<VecRegContainer&>(readVecReg(phys_reg));
222  }
223 
225  template <typename VecElem, int LaneIdx>
227  readVecLane(PhysRegIdPtr phys_reg) const
228  {
229  return readVecReg(phys_reg).laneView<VecElem, LaneIdx>();
230  }
231 
233  template <typename VecElem>
235  readVecLane(PhysRegIdPtr phys_reg) const
236  {
237  return readVecReg(phys_reg).laneView<VecElem>(phys_reg->elemIndex());
238  }
239 
241  template <typename LD>
242  void
243  setVecLane(PhysRegIdPtr phys_reg, const LD& val)
244  {
245  assert(phys_reg->isVectorPhysReg());
246 
247  DPRINTF(IEW, "RegFile: Setting vector register %i[%d] to %lx\n",
248  int(phys_reg->index()), phys_reg->elemIndex(), val);
249 
250  vectorRegFile[phys_reg->index()].laneView<typename LD::UnderlyingType>(
251  phys_reg->elemIndex()) = val;
252  }
253 
255  const VecElem &
256  readVecElem(PhysRegIdPtr phys_reg) const
257  {
258  assert(phys_reg->isVectorPhysElem());
259  auto ret = vectorRegFile[phys_reg->index()].as<VecElem>();
260  const VecElem& val = ret[phys_reg->elemIndex()];
261  DPRINTF(IEW, "RegFile: Access to element %d of vector register %i,"
262  " has data %#x\n", phys_reg->elemIndex(),
263  int(phys_reg->index()), val);
264 
265  return val;
266  }
267 
270  {
271  assert(phys_reg->isVecPredPhysReg());
272 
273  DPRINTF(IEW, "RegFile: Access to predicate register %i, has "
274  "data %s\n", int(phys_reg->index()),
275  vecPredRegFile[phys_reg->index()].print());
276 
277  return vecPredRegFile[phys_reg->index()];
278  }
279 
281  {
282  /* const_cast for not duplicating code above. */
283  return const_cast<VecPredRegContainer&>(readVecPredReg(phys_reg));
284  }
285 
287  RegVal
289  {
290  assert(phys_reg->isCCPhysReg());
291 
292  DPRINTF(IEW, "RegFile: Access to cc register %i, has "
293  "data %#x\n", phys_reg->index(),
294  ccRegFile[phys_reg->index()]);
295 
296  return ccRegFile[phys_reg->index()];
297  }
298 
300  void
302  {
303  assert(phys_reg->isIntPhysReg());
304 
305  DPRINTF(IEW, "RegFile: Setting int register %i to %#x\n",
306  phys_reg->index(), val);
307 
308  if (!phys_reg->isZeroReg())
309  intRegFile[phys_reg->index()] = val;
310  }
311 
312  void
314  {
315  assert(phys_reg->isFloatPhysReg());
316 
317  DPRINTF(IEW, "RegFile: Setting float register %i to %#x\n",
318  phys_reg->index(), (uint64_t)val);
319 
320  if (!phys_reg->isZeroReg())
321  floatRegFile[phys_reg->index()] = val;
322  }
323 
325  void
327  {
328  assert(phys_reg->isVectorPhysReg());
329 
330  DPRINTF(IEW, "RegFile: Setting vector register %i to %s\n",
331  int(phys_reg->index()), val.print());
332 
333  vectorRegFile[phys_reg->index()] = val;
334  }
335 
337  void
339  {
340  assert(phys_reg->isVectorPhysElem());
341 
342  DPRINTF(IEW, "RegFile: Setting element %d of vector register %i to"
343  " %#x\n", phys_reg->elemIndex(), int(phys_reg->index()), val);
344 
345  vectorRegFile[phys_reg->index()].as<VecElem>()[phys_reg->elemIndex()] =
346  val;
347  }
348 
351  {
352  assert(phys_reg->isVecPredPhysReg());
353 
354  DPRINTF(IEW, "RegFile: Setting predicate register %i to %s\n",
355  int(phys_reg->index()), val.print());
356 
357  vecPredRegFile[phys_reg->index()] = val;
358  }
359 
361  void
363  {
364  assert(phys_reg->isCCPhysReg());
365 
366  DPRINTF(IEW, "RegFile: Setting cc register %i to %#x\n",
367  phys_reg->index(), (uint64_t)val);
368 
369  ccRegFile[phys_reg->index()] = val;
370  }
371 
376 
383 
390 };
391 
392 
393 #endif //__CPU_O3_REGFILE_HH__
PhysRegId::isFloatPhysReg
bool isFloatPhysReg() const
Definition: reg_class.hh:278
PhysRegFile::numPhysicalIntRegs
unsigned numPhysicalIntRegs
Number of physical general purpose registers.
Definition: regfile.hh:101
PhysRegFile::vecPredRegIds
std::vector< PhysRegId > vecPredRegIds
Definition: regfile.hh:89
PhysRegId::isVectorPhysElem
bool isVectorPhysElem() const
@Return true if it is a vector element physical register.
Definition: reg_class.hh:287
PhysRegFile::numVecElemPhysRegs
unsigned numVecElemPhysRegs() const
Definition: regfile.hh:166
PhysRegFile::readVecLane
VecLaneT< VecElem, true > readVecLane(PhysRegIdPtr phys_reg) const
Reads a vector register lane.
Definition: regfile.hh:227
VecPredRegContainer
Generic predicate register container.
Definition: vec_pred_reg.hh:47
ArmISA::VecRegContainer
VecReg::Container VecRegContainer
Definition: registers.hh:71
PhysRegFile::floatRegIds
std::vector< PhysRegId > floatRegIds
Definition: regfile.hh:80
PhysRegFile::readVecElem
const VecElem & readVecElem(PhysRegIdPtr phys_reg) const
Reads a vector element.
Definition: regfile.hh:256
PhysRegFile::vectorRegFile
std::vector< VecRegContainer > vectorRegFile
Vector register file.
Definition: regfile.hh:83
PhysRegFile::totalNumRegs
unsigned totalNumRegs
Total number of physical registers.
Definition: regfile.hh:129
PhysRegFile::ccRegIds
std::vector< PhysRegId > ccRegIds
Definition: regfile.hh:93
PhysRegId::elemIndex
const RegIndex & elemIndex() const
Elem accessor.
Definition: reg_class.hh:198
PhysRegId::isZeroReg
bool isZeroReg() const
Check if this is the zero register.
Definition: reg_class.hh:137
ArmISA::VecPredRegContainer
VecPredReg::Container VecPredRegContainer
Definition: registers.hh:77
PhysRegId::isVectorPhysReg
bool isVectorPhysReg() const
@Return true if it is a vector physical register.
Definition: reg_class.hh:284
PhysRegFile::ccRegFile
std::vector< RegVal > ccRegFile
Condition-code register file.
Definition: regfile.hh:92
PhysRegFile
Simple physical register file class.
Definition: regfile.hh:59
PhysRegFile::initFreeList
void initFreeList(UnifiedFreeList *freeList)
Initialize the free list.
Definition: regfile.cc:131
std::vector< PhysRegId >
PhysRegFile::getWritableVecReg
VecRegContainer & getWritableVecReg(PhysRegIdPtr phys_reg)
Reads a vector register for modification.
Definition: regfile.hh:218
PhysRegFile::VecMode
Enums::VecRegRenameMode VecMode
Definition: regfile.hh:66
PhysRegFile::readVecLane
VecLaneT< VecElem, true > readVecLane(PhysRegIdPtr phys_reg) const
Reads a vector register lane.
Definition: regfile.hh:235
PhysRegFile::getRegElemIds
IdRange getRegElemIds(PhysRegIdPtr reg)
Get the PhysRegIds of the elems of a vector register.
Definition: regfile.cc:184
X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:87
PhysRegFile::numPhysicalVecElemRegs
unsigned numPhysicalVecElemRegs
Number of physical vector element registers.
Definition: regfile.hh:116
PhysRegFile::intRegIds
std::vector< PhysRegId > intRegIds
Definition: regfile.hh:76
VecRegContainer::laneView
VecLaneT< VecElem, false > laneView()
View as the Nth lane of type VecElem.
Definition: vec_reg.hh:596
PhysRegFile::getMiscRegId
PhysRegIdPtr getMiscRegId(RegIndex reg_idx)
Gets a misc register PhysRegIdPtr.
Definition: regfile.hh:175
PhysRegFile::vecRegIds
std::vector< PhysRegId > vecRegIds
Definition: regfile.hh:84
PhysRegFile::~PhysRegFile
~PhysRegFile()
Destructor to free resources.
Definition: regfile.hh:150
PhysRegFile::setCCReg
void setCCReg(PhysRegIdPtr phys_reg, RegVal val)
Sets a condition-code register to the given value.
Definition: regfile.hh:362
PhysRegFile::numIntPhysRegs
unsigned numIntPhysRegs() const
Definition: regfile.hh:156
comm.hh
PhysRegId::index
const RegIndex & index() const
Visible RegId methods.
Definition: reg_class.hh:173
PhysRegFile::numCCPhysRegs
unsigned numCCPhysRegs() const
Definition: regfile.hh:169
ArmISA::VecElem
uint32_t VecElem
Definition: registers.hh:68
VecLaneT
Vector Lane abstraction Another view of a container.
Definition: vec_reg.hh:262
PhysRegFile::readIntReg
RegVal readIntReg(PhysRegIdPtr phys_reg) const
Reads an integer register.
Definition: regfile.hh:181
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
PhysRegFile::setFloatReg
void setFloatReg(PhysRegIdPtr phys_reg, RegVal val)
Definition: regfile.hh:313
PhysRegFile::PhysRegFile
PhysRegFile(unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs, unsigned _numPhysicalVecRegs, unsigned _numPhysicalVecPredRegs, unsigned _numPhysicalCCRegs, VecMode vmode)
Constructs a physical register file with the specified amount of integer and floating point registers...
Definition: regfile.cc:48
PhysRegFile::setVecPredReg
void setVecPredReg(PhysRegIdPtr phys_reg, const VecPredRegContainer &val)
Sets a predicate register to the given value.
Definition: regfile.hh:350
PhysRegFile::numPhysicalCCRegs
unsigned numPhysicalCCRegs
Number of physical CC registers.
Definition: regfile.hh:126
RegClass
RegClass
Enumerate the classes of registers.
Definition: reg_class.hh:52
ArmISA::NumVecElemPerVecReg
constexpr unsigned NumVecElemPerVecReg
Definition: registers.hh:66
UnifiedFreeList
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:115
PhysRegFile::NumVecElemPerVecReg
static constexpr auto NumVecElemPerVecReg
Definition: regfile.hh:72
PhysRegFile::readCCReg
RegVal readCCReg(PhysRegIdPtr phys_reg)
Reads a condition-code register.
Definition: regfile.hh:288
PhysRegFile::numFloatPhysRegs
unsigned numFloatPhysRegs() const
Definition: regfile.hh:159
PhysRegFile::numPredPhysRegs
unsigned numPredPhysRegs() const
Definition: regfile.hh:163
PhysRegId::isCCPhysReg
bool isCCPhysReg() const
@Return true if it is a condition-code physical register.
Definition: reg_class.hh:281
std::pair
STL pair class.
Definition: stl.hh:58
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
PhysRegFile::setVecReg
void setVecReg(PhysRegIdPtr phys_reg, const VecRegContainer &val)
Sets a vector register to the given value.
Definition: regfile.hh:326
PhysRegFile::vecMode
VecMode vecMode
Mode in which vector registers are addressed.
Definition: regfile.hh:132
PhysRegFile::readVecPredReg
const VecPredRegContainer & readVecPredReg(PhysRegIdPtr phys_reg) const
Reads a predicate register.
Definition: regfile.hh:269
PhysRegId::isIntPhysReg
bool isIntPhysReg() const
Definition: reg_class.hh:275
PhysRegFile::numPhysicalVecPredRegs
unsigned numPhysicalVecPredRegs
Number of physical predicate registers.
Definition: regfile.hh:121
PhysRegFile::setVecElem
void setVecElem(PhysRegIdPtr phys_reg, const VecElem val)
Sets a vector register to the given value.
Definition: regfile.hh:338
PhysRegFile::miscRegIds
std::vector< PhysRegId > miscRegIds
Misc Reg Ids.
Definition: regfile.hh:96
PhysRegFile::IdRange
std::pair< PhysIds::iterator, PhysIds::iterator > IdRange
Definition: regfile.hh:70
PhysRegFile::numPhysicalVecRegs
unsigned numPhysicalVecRegs
Number of physical vector registers.
Definition: regfile.hh:111
PhysRegFile::numVecPhysRegs
unsigned numVecPhysRegs() const
Definition: regfile.hh:161
RegIndex
uint16_t RegIndex
Definition: types.hh:52
PhysRegFile::totalNumPhysRegs
unsigned totalNumPhysRegs() const
Definition: regfile.hh:172
PhysRegFile::getTrueId
PhysRegIdPtr getTrueId(PhysRegIdPtr reg)
Get the true physical register id.
Definition: regfile.cc:220
PhysRegFile::intRegFile
std::vector< RegVal > intRegFile
Integer register file.
Definition: regfile.hh:75
PhysRegFile::numPhysicalFloatRegs
unsigned numPhysicalFloatRegs
Number of physical floating point registers.
Definition: regfile.hh:106
PhysRegFile::floatRegFile
std::vector< RegVal > floatRegFile
Floating point register file.
Definition: regfile.hh:79
PhysRegId
Physical register ID.
Definition: reg_class.hh:223
trace.hh
PhysRegFile::vecPredRegFile
std::vector< VecPredRegContainer > vecPredRegFile
Predicate register file.
Definition: regfile.hh:88
PhysRegFile::vecElemIds
std::vector< PhysRegId > vecElemIds
Definition: regfile.hh:85
PhysRegId::isVecPredPhysReg
bool isVecPredPhysReg() const
Definition: reg_class.hh:290
PhysRegFile::VecElem
TheISA::VecElem VecElem
Definition: regfile.hh:63
PhysRegFile::readFloatReg
RegVal readFloatReg(PhysRegIdPtr phys_reg) const
Definition: regfile.hh:191
PhysRegFile::setIntReg
void setIntReg(PhysRegIdPtr phys_reg, RegVal val)
Sets an integer register to the given value.
Definition: regfile.hh:301
PhysRegFile::getRegIds
IdRange getRegIds(RegClass cls)
Get the PhysRegIds of the elems of all vector registers.
Definition: regfile.cc:195
PhysRegFile::readVecReg
const VecRegContainer & readVecReg(PhysRegIdPtr phys_reg) const
Reads a vector register.
Definition: regfile.hh:205
RegVal
uint64_t RegVal
Definition: types.hh:168
PhysRegFile::getWritableVecPredReg
VecPredRegContainer & getWritableVecPredReg(PhysRegIdPtr phys_reg)
Definition: regfile.hh:280
VecRegContainer
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
Definition: vec_reg.hh:156
PhysRegFile::setVecLane
void setVecLane(PhysRegIdPtr phys_reg, const LD &val)
Get a vector register lane for modification.
Definition: regfile.hh:243

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17