gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rename_map.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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  * Authors: Kevin Lim
42  * Steve Reinhardt
43  */
44 
45 // Todo: Create destructor.
46 // Have it so that there's a more meaningful name given to the variable
47 // that marks the beginning of the FP registers.
48 
49 #ifndef __CPU_O3_RENAME_MAP_HH__
50 #define __CPU_O3_RENAME_MAP_HH__
51 
52 #include <iostream>
53 #include <utility>
54 #include <vector>
55 
56 #include "arch/types.hh"
57 #include "config/the_isa.hh"
58 #include "cpu/o3/free_list.hh"
59 #include "cpu/o3/regfile.hh"
60 #include "cpu/reg_class.hh"
61 
70 {
71  public:
72 
74 
75  private:
76 
79 
85 
94 
95  public:
96 
98 
100 
106  void init(unsigned size, SimpleFreeList *_freeList, RegIndex _zeroReg);
107 
115 
123  RenameInfo rename(RegIndex arch_reg);
124 
130  PhysRegIndex lookup(RegIndex arch_reg) const
131  {
132  assert(arch_reg < map.size());
133  return map[arch_reg];
134  }
135 
142  void setEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
143  {
144  map[arch_reg] = phys_reg;
145  }
146 
148  unsigned numFreeEntries() const { return freeList->numFreeRegs(); }
149 };
150 
151 
160 {
161  private:
162 
165 
168 
177 
180 
181  public:
183 
185 
187  UnifiedRenameMap() : regFile(nullptr) {};
188 
191 
193  void init(PhysRegFile *_regFile,
194  RegIndex _intZeroReg,
195  RegIndex _floatZeroReg,
196  UnifiedFreeList *freeList);
197 
207  RenameInfo rename(RegIndex arch_reg);
208 
214  {
215  RenameInfo info = intMap.rename(rel_arch_reg);
216  assert(regFile->isIntPhysReg(info.first));
217  return info;
218  }
219 
225  {
226  RenameInfo info = floatMap.rename(rel_arch_reg);
227  assert(regFile->isFloatPhysReg(info.first));
228  return info;
229  }
230 
236  {
237  RenameInfo info = ccMap.rename(rel_arch_reg);
238  assert(regFile->isCCPhysReg(info.first));
239  return info;
240  }
241 
247  {
248  // misc regs aren't really renamed, just remapped
249  PhysRegIndex phys_reg = lookupMisc(rel_arch_reg);
250  // Set the previous register to the same register; mainly it must be
251  // known that the prev reg was outside the range of normal registers
252  // so the free list can avoid adding it.
253  return RenameInfo(phys_reg, phys_reg);
254  }
255 
256 
264  PhysRegIndex lookup(RegIndex arch_reg) const;
265 
270  PhysRegIndex lookupInt(RegIndex rel_arch_reg) const
271  {
272  PhysRegIndex phys_reg = intMap.lookup(rel_arch_reg);
273  assert(regFile->isIntPhysReg(phys_reg));
274  return phys_reg;
275  }
276 
281  PhysRegIndex lookupFloat(RegIndex rel_arch_reg) const
282  {
283  PhysRegIndex phys_reg = floatMap.lookup(rel_arch_reg);
284  assert(regFile->isFloatPhysReg(phys_reg));
285  return phys_reg;
286  }
287 
292  PhysRegIndex lookupCC(RegIndex rel_arch_reg) const
293  {
294  PhysRegIndex phys_reg = ccMap.lookup(rel_arch_reg);
295  assert(regFile->isCCPhysReg(phys_reg));
296  return phys_reg;
297  }
298 
303  PhysRegIndex lookupMisc(RegIndex rel_arch_reg) const
304  {
305  // misc regs aren't really renamed, just given an index
306  // beyond the range of actual physical registers
307  PhysRegIndex phys_reg = rel_arch_reg + regFile->totalNumPhysRegs();
308  return phys_reg;
309  }
310 
319  void setEntry(RegIndex arch_reg, PhysRegIndex phys_reg);
320 
325  void setIntEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
326  {
327  assert(regFile->isIntPhysReg(phys_reg));
328  intMap.setEntry(arch_reg, phys_reg);
329  }
330 
335  void setFloatEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
336  {
337  assert(regFile->isFloatPhysReg(phys_reg));
338  floatMap.setEntry(arch_reg, phys_reg);
339  }
340 
345  void setCCEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
346  {
347  assert(regFile->isCCPhysReg(phys_reg));
348  ccMap.setEntry(arch_reg, phys_reg);
349  }
350 
357  unsigned numFreeEntries() const
358  {
359  return std::min(intMap.numFreeEntries(), floatMap.numFreeEntries());
360  }
361 
365  bool canRename(uint32_t intRegs, uint32_t floatRegs, uint32_t ccRegs) const
366  {
367  return intRegs <= intMap.numFreeEntries() &&
368  floatRegs <= floatMap.numFreeEntries() &&
369  ccRegs <= ccMap.numFreeEntries();
370  }
371 
372 };
373 
374 #endif //__CPU_O3_RENAME_MAP_HH__
PhysRegIndex lookup(RegIndex arch_reg) const
Look up the physical register mapped to an architectural register.
Definition: rename_map.cc:132
unsigned numFreeEntries() const
Return the minimum number of free entries across all of the register classes.
Definition: rename_map.hh:357
unsigned numFreeEntries() const
Return the number of free entries on the associated free list.
Definition: rename_map.hh:148
RenameInfo rename(RegIndex arch_reg)
Tell rename map to get a new free physical register to remap the specified architectural register...
Definition: rename_map.cc:107
STL pair class.
Definition: stl.hh:61
Simple physical register file class.
Definition: regfile.hh:51
RenameInfo renameFloat(RegIndex rel_arch_reg)
Perform rename() on a floating-point register, given a relative floating-point register index...
Definition: rename_map.hh:224
void setEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
Update rename map with a specific mapping.
Definition: rename_map.cc:156
SimpleRenameMap ccMap
The condition-code register rename map.
Definition: rename_map.hh:179
void setIntEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
Perform setEntry() on an integer register, given a relative integer register index.
Definition: rename_map.hh:325
SimpleRenameMap floatMap
The floating-point register rename map.
Definition: rename_map.hh:167
RenameInfo renameInt(RegIndex rel_arch_reg)
Perform rename() on an integer register, given a relative integer register index. ...
Definition: rename_map.hh:213
RenameInfo renameCC(RegIndex rel_arch_reg)
Perform rename() on a condition-code register, given a relative condition-code register index...
Definition: rename_map.hh:235
RegIndex zeroReg
The architectural index of the zero register.
Definition: rename_map.hh:93
unsigned numFreeRegs() const
Return the number of free registers on the list.
Definition: free_list.hh:75
std::vector< PhysRegIndex > map
The acutal arch-to-phys register map.
Definition: rename_map.hh:78
Free list for a single class of registers (e.g., integer or floating point).
Definition: free_list.hh:51
RenameInfo renameMisc(RegIndex rel_arch_reg)
Perform rename() on a misc register, given a relative misc register index.
Definition: rename_map.hh:246
TheISA::RegIndex RegIndex
Definition: rename_map.hh:182
PhysRegIndex lookupMisc(RegIndex rel_arch_reg) const
Perform lookup() on a misc register, given a relative misc register index.
Definition: rename_map.hh:303
uint8_t RegIndex
Definition: registers.hh:46
PhysRegIndex lookupFloat(RegIndex rel_arch_reg) const
Perform lookup() on a floating-point register, given a relative floating-point register index...
Definition: rename_map.hh:281
void setCCEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
Perform setEntry() on a condition-code register, given a relative condition-code register index...
Definition: rename_map.hh:345
PhysRegIndex lookupInt(RegIndex rel_arch_reg) const
Perform lookup() on an integer register, given a relative integer register index. ...
Definition: rename_map.hh:270
UnifiedRenameMap()
Default constructor.
Definition: rename_map.hh:187
bool canRename(uint32_t intRegs, uint32_t floatRegs, uint32_t ccRegs) const
Return whether there are enough registers to serve the request.
Definition: rename_map.hh:365
SimpleRenameMap intMap
The integer register rename map.
Definition: rename_map.hh:164
Unified register rename map for all classes of registers.
Definition: rename_map.hh:159
PhysRegIndex lookupCC(RegIndex rel_arch_reg) const
Perform lookup() on a condition-code register, given a relative condition-code register index...
Definition: rename_map.hh:292
PhysRegFile * regFile
The register file object is used only to distinguish integer from floating-point physical register in...
Definition: rename_map.hh:176
SimpleFreeList * freeList
Pointer to the free list from which new physical registers should be allocated in rename() ...
Definition: rename_map.hh:84
RenameInfo rename(RegIndex arch_reg)
Tell rename map to get a new free physical register to remap the specified architectural register...
Definition: rename_map.cc:61
bool isIntPhysReg(PhysRegIndex reg_idx) const
Definition: regfile.hh:134
void init(unsigned size, SimpleFreeList *_freeList, RegIndex _zeroReg)
Because we have an array of rename maps (one per thread) in the CPU, it's awkward to initialize this ...
Definition: rename_map.cc:49
TheISA::RegIndex RegIndex
Definition: rename_map.hh:73
FreeList class that simply holds the list of free integer and floating point registers.
Definition: free_list.hh:95
~UnifiedRenameMap()
Destructor.
Definition: rename_map.hh:190
int size()
Definition: pagetable.hh:146
void setEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
Update rename map with a specific mapping.
Definition: rename_map.hh:142
std::pair< PhysRegIndex, PhysRegIndex > RenameInfo
Pair of a physical register and a physical register.
Definition: rename_map.hh:114
unsigned totalNumPhysRegs() const
Definition: regfile.hh:128
short int PhysRegIndex
Definition: comm.hh:57
bool isFloatPhysReg(PhysRegIndex reg_idx) const
Definition: regfile.hh:143
PhysRegIndex lookup(RegIndex arch_reg) const
Look up the physical register mapped to an architectural register.
Definition: rename_map.hh:130
void setFloatEntry(RegIndex arch_reg, PhysRegIndex phys_reg)
Perform setEntry() on a floating-point register, given a relative floating-point register index...
Definition: rename_map.hh:335
bool isCCPhysReg(PhysRegIndex reg_idx)
Return true if the specified physical register index corresponds to a condition-code physical registe...
Definition: regfile.hh:152
SimpleRenameMap::RenameInfo RenameInfo
Definition: rename_map.hh:184
void init(PhysRegFile *_regFile, RegIndex _intZeroReg, RegIndex _floatZeroReg, UnifiedFreeList *freeList)
Initializes rename map with given parameters.
Definition: rename_map.cc:91
Register rename map for a single class of registers (e.g., integer or floating point).
Definition: rename_map.hh:69

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