gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
regfile.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Regents of The University of Michigan
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Authors: Kevin Lim
30  * Gabe Black
31  */
32 
33 #ifndef __CPU_O3_REGFILE_HH__
34 #define __CPU_O3_REGFILE_HH__
35 
36 #include <vector>
37 
38 #include "arch/isa_traits.hh"
39 #include "arch/kernel_stats.hh"
40 #include "arch/types.hh"
41 #include "base/trace.hh"
42 #include "config/the_isa.hh"
43 #include "cpu/o3/comm.hh"
44 #include "debug/IEW.hh"
45 
46 class UnifiedFreeList;
47 
52 {
53  private:
54 
59 
60  typedef union {
63  } PhysFloatReg;
64 
67 
70 
73 
89 
94  unsigned baseCCRegIndex;
95 
97  unsigned totalNumRegs;
98 
99  public:
104  PhysRegFile(unsigned _numPhysicalIntRegs,
105  unsigned _numPhysicalFloatRegs,
106  unsigned _numPhysicalCCRegs);
107 
112 
114  void initFreeList(UnifiedFreeList *freeList);
115 
117  unsigned numIntPhysRegs() const { return baseFloatRegIndex; }
118 
120  unsigned numFloatPhysRegs() const
121  { return baseCCRegIndex - baseFloatRegIndex; }
122 
124  unsigned numCCPhysRegs() const
125  { return totalNumRegs - baseCCRegIndex; }
126 
128  unsigned totalNumPhysRegs() const { return totalNumRegs; }
129 
134  bool isIntPhysReg(PhysRegIndex reg_idx) const
135  {
136  return 0 <= reg_idx && reg_idx < baseFloatRegIndex;
137  }
138 
143  bool isFloatPhysReg(PhysRegIndex reg_idx) const
144  {
145  return (baseFloatRegIndex <= reg_idx && reg_idx < baseCCRegIndex);
146  }
147 
152  bool isCCPhysReg(PhysRegIndex reg_idx)
153  {
154  return (baseCCRegIndex <= reg_idx && reg_idx < totalNumRegs);
155  }
156 
158  uint64_t readIntReg(PhysRegIndex reg_idx) const
159  {
160  assert(isIntPhysReg(reg_idx));
161 
162  DPRINTF(IEW, "RegFile: Access to int register %i, has data "
163  "%#x\n", int(reg_idx), intRegFile[reg_idx]);
164  return intRegFile[reg_idx];
165  }
166 
169  {
170  assert(isFloatPhysReg(reg_idx));
171 
172  // Remove the base Float reg dependency.
173  PhysRegIndex reg_offset = reg_idx - baseFloatRegIndex;
174 
175  DPRINTF(IEW, "RegFile: Access to float register %i, has "
176  "data %#x\n", int(reg_idx), floatRegFile[reg_offset].q);
177 
178  return floatRegFile[reg_offset].d;
179  }
180 
182  {
183  assert(isFloatPhysReg(reg_idx));
184 
185  // Remove the base Float reg dependency.
186  PhysRegIndex reg_offset = reg_idx - baseFloatRegIndex;
187 
188  FloatRegBits floatRegBits = floatRegFile[reg_offset].q;
189 
190  DPRINTF(IEW, "RegFile: Access to float register %i as int, "
191  "has data %#x\n", int(reg_idx), (uint64_t)floatRegBits);
192 
193  return floatRegBits;
194  }
195 
198  {
199  assert(isCCPhysReg(reg_idx));
200 
201  // Remove the base CC reg dependency.
202  PhysRegIndex reg_offset = reg_idx - baseCCRegIndex;
203 
204  DPRINTF(IEW, "RegFile: Access to cc register %i, has "
205  "data %#x\n", int(reg_idx), ccRegFile[reg_offset]);
206 
207  return ccRegFile[reg_offset];
208  }
209 
211  void setIntReg(PhysRegIndex reg_idx, uint64_t val)
212  {
213  assert(isIntPhysReg(reg_idx));
214 
215  DPRINTF(IEW, "RegFile: Setting int register %i to %#x\n",
216  int(reg_idx), val);
217 
218  if (reg_idx != TheISA::ZeroReg)
219  intRegFile[reg_idx] = val;
220  }
221 
224  {
225  assert(isFloatPhysReg(reg_idx));
226 
227  // Remove the base Float reg dependency.
228  PhysRegIndex reg_offset = reg_idx - baseFloatRegIndex;
229 
230  DPRINTF(IEW, "RegFile: Setting float register %i to %#x\n",
231  int(reg_idx), (uint64_t)val);
232 
233 #if THE_ISA == ALPHA_ISA
234  if (reg_offset != TheISA::ZeroReg)
235 #endif
236  floatRegFile[reg_offset].d = val;
237  }
238 
240  {
241  assert(isFloatPhysReg(reg_idx));
242 
243  // Remove the base Float reg dependency.
244  PhysRegIndex reg_offset = reg_idx - baseFloatRegIndex;
245 
246  DPRINTF(IEW, "RegFile: Setting float register %i to %#x\n",
247  int(reg_idx), (uint64_t)val);
248 
249  floatRegFile[reg_offset].q = val;
250  }
251 
254  {
255  assert(isCCPhysReg(reg_idx));
256 
257  // Remove the base CC reg dependency.
258  PhysRegIndex reg_offset = reg_idx - baseCCRegIndex;
259 
260  DPRINTF(IEW, "RegFile: Setting cc register %i to %#x\n",
261  int(reg_idx), (uint64_t)val);
262 
263  ccRegFile[reg_offset] = val;
264  }
265 };
266 
267 
268 #endif //__CPU_O3_REGFILE_HH__
#define DPRINTF(x,...)
Definition: trace.hh:212
void setCCReg(PhysRegIndex reg_idx, CCReg val)
Sets a condition-code register to the given value.
Definition: regfile.hh:253
uint8_t CCReg
Definition: registers.hh:57
Simple physical register file class.
Definition: regfile.hh:51
FloatReg readFloatReg(PhysRegIndex reg_idx) const
Reads a floating point register (double precision).
Definition: regfile.hh:168
unsigned totalNumRegs
Total number of physical registers.
Definition: regfile.hh:97
unsigned baseFloatRegIndex
The first floating-point physical register index.
Definition: regfile.hh:88
std::vector< PhysFloatReg > floatRegFile
Floating point register file.
Definition: regfile.hh:69
Bitfield< 63 > val
Definition: misc.hh:770
CCReg readCCReg(PhysRegIndex reg_idx)
Reads a condition-code register.
Definition: regfile.hh:197
void initFreeList(UnifiedFreeList *freeList)
Initialize the free list.
Definition: regfile.cc:60
uint64_t FloatRegBits
Definition: registers.hh:51
TheISA::FloatReg FloatReg
Definition: regfile.hh:56
Bitfield< 27 > q
Definition: miscregs.hh:1367
const RegIndex ZeroReg
Definition: registers.hh:77
PhysRegFile(unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs, unsigned _numPhysicalCCRegs)
Constructs a physical register file with the specified amount of integer and floating point registers...
Definition: regfile.cc:38
void setFloatRegBits(PhysRegIndex reg_idx, FloatRegBits val)
Definition: regfile.hh:239
~PhysRegFile()
Destructor to free resources.
Definition: regfile.hh:111
unsigned numFloatPhysRegs() const
Definition: regfile.hh:120
unsigned baseCCRegIndex
The first condition-code physical register index.
Definition: regfile.hh:94
TheISA::IntReg IntReg
Definition: regfile.hh:55
double FloatReg
Definition: registers.hh:50
unsigned numCCPhysRegs() const
Definition: regfile.hh:124
bool isIntPhysReg(PhysRegIndex reg_idx) const
Definition: regfile.hh:134
void setIntReg(PhysRegIndex reg_idx, uint64_t val)
Sets an integer register to the given value.
Definition: regfile.hh:211
uint64_t IntReg
Definition: registers.hh:47
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:95
std::vector< CCReg > ccRegFile
Condition-code register file.
Definition: regfile.hh:72
std::vector< IntReg > intRegFile
Integer register file.
Definition: regfile.hh:66
void setFloatReg(PhysRegIndex reg_idx, FloatReg val)
Sets a double precision floating point register to the given value.
Definition: regfile.hh:223
unsigned numIntPhysRegs() const
Definition: regfile.hh:117
unsigned totalNumPhysRegs() const
Definition: regfile.hh:128
short int PhysRegIndex
Definition: comm.hh:57
bool isFloatPhysReg(PhysRegIndex reg_idx) const
Definition: regfile.hh:143
FloatRegBits readFloatRegBits(PhysRegIndex reg_idx) const
Definition: regfile.hh:181
TheISA::CCReg CCReg
Definition: regfile.hh:58
TheISA::FloatRegBits FloatRegBits
Definition: regfile.hh:57
bool isCCPhysReg(PhysRegIndex reg_idx)
Return true if the specified physical register index corresponds to a condition-code physical registe...
Definition: regfile.hh:152
uint64_t readIntReg(PhysRegIndex reg_idx) const
Reads an integer register.
Definition: regfile.hh:158

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6