gem5 v24.0.0.0
Loading...
Searching...
No Matches
rename_map.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2018,2019 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#include "cpu/o3/rename_map.hh"
43
44#include <vector>
45
46#include "cpu/o3/dyn_inst.hh"
47#include "cpu/reg_class.hh"
48#include "debug/Rename.hh"
49
50namespace gem5
51{
52
53namespace o3
54{
55
57{
58}
59
60
61void
62SimpleRenameMap::init(const RegClass &reg_class, SimpleFreeList *_freeList)
63{
64 assert(freeList == NULL);
65 assert(map.empty());
66
67 map.resize(reg_class.numRegs());
68 freeList = _freeList;
69}
70
73{
74 PhysRegIdPtr renamed_reg;
75 // Record the current physical register that is renamed to the
76 // requested architected register.
77 PhysRegIdPtr prev_reg = map[arch_reg.index()];
78
79 if (arch_reg.is(InvalidRegClass)) {
80 assert(prev_reg->is(InvalidRegClass));
81 renamed_reg = prev_reg;
82 } else if (prev_reg->getNumPinnedWrites() > 0) {
83 // Do not rename if the register is pinned
84 assert(arch_reg.getNumPinnedWrites() == 0); // Prevent pinning the
85 // same register twice
86 DPRINTF(Rename, "Renaming pinned reg, numPinnedWrites %d\n",
87 prev_reg->getNumPinnedWrites());
88 renamed_reg = prev_reg;
89 renamed_reg->decrNumPinnedWrites();
90 } else {
91 renamed_reg = freeList->getReg();
92 map[arch_reg.index()] = renamed_reg;
93 renamed_reg->setNumPinnedWrites(arch_reg.getNumPinnedWrites());
95 arch_reg.getNumPinnedWrites() + 1);
96 }
97
98 DPRINTF(Rename, "Renamed reg %d to physical reg %d (%d) old mapping was"
99 " %d (%d)\n",
100 arch_reg, renamed_reg->flatIndex(), renamed_reg->flatIndex(),
101 prev_reg->flatIndex(), prev_reg->flatIndex());
102
103 return RenameInfo(renamed_reg, prev_reg);
104}
105
106
107/**** UnifiedRenameMap methods ****/
108
109void
111 PhysRegFile *_regFile, UnifiedFreeList *freeList)
112{
113 regFile = _regFile;
114
115 for (int i = 0; i < renameMaps.size(); i++)
116 renameMaps[i].init(*regClasses.at(i), &(freeList->freeLists[i]));
117}
118
119bool
121{
122 for (int i = 0; i < renameMaps.size(); i++) {
123 if (inst->numDestRegs((RegClassType)i) >
124 renameMaps[i].numFreeEntries()) {
125 return false;
126 }
127 }
128 return true;
129}
130
131} // namespace o3
132} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
Physical register ID.
Definition reg_class.hh:415
int getNumPinnedWrites() const
Definition reg_class.hh:474
constexpr bool is(RegClassType reg_class) const
Definition reg_class.hh:275
const RegIndex & flatIndex() const
Flat index accessor.
Definition reg_class.hh:472
void decrNumPinnedWrites()
Definition reg_class.hh:489
void setNumPinnedWrites(int numWrites)
Definition reg_class.hh:477
void setNumPinnedWritesToComplete(int numWrites)
Definition reg_class.hh:501
constexpr size_t numRegs() const
Definition reg_class.hh:238
Register ID: describe an architectural register with its class and index.
Definition reg_class.hh:94
constexpr bool is(RegClassType reg_class) const
Definition reg_class.hh:275
constexpr RegIndex index() const
Index accessors.
Definition reg_class.hh:151
int getNumPinnedWrites() const
Definition reg_class.hh:162
Simple physical register file class.
Definition regfile.hh:66
Rename handles both single threaded and SMT rename.
Definition rename.hh:79
Free list for a single class of registers (e.g., integer or floating point).
Definition free_list.hh:72
PhysRegIdPtr getReg()
Get the next available register from the free list.
Definition free_list.hh:95
void init(const RegClass &reg_class, SimpleFreeList *_freeList)
Because we have an array of rename maps (one per thread) in the CPU, it's awkward to initialize this ...
Definition rename_map.cc:62
RenameInfo rename(const RegId &arch_reg)
Tell rename map to get a new free physical register to remap the specified architectural register.
Definition rename_map.cc:72
SimpleFreeList * freeList
Pointer to the free list from which new physical registers should be allocated in rename()
Definition rename_map.hh:86
std::pair< PhysRegIdPtr, PhysRegIdPtr > RenameInfo
Pair of a physical register and a physical register.
FreeList class that simply holds the list of free integer and floating point registers.
Definition free_list.hh:125
std::array< SimpleFreeList, CCRegClass+1 > freeLists
Definition free_list.hh:132
void init(const BaseISA::RegClasses &regClasses, PhysRegFile *_regFile, UnifiedFreeList *freeList)
Initializes rename map with given parameters.
PhysRegFile * regFile
The register file object is used only to get PhysRegIdPtr on MiscRegs, as they are stored in it.
bool canRename(DynInstPtr inst) const
Return whether there are enough registers to serve the request.
std::array< SimpleRenameMap, CCRegClass+1 > renameMaps
STL pair class.
Definition stl.hh:58
Bitfield< 7 > i
Definition misc_types.hh:67
const FlagsType init
This Stat is Initialized.
Definition info.hh:55
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
RegClassType
Enumerate the classes of registers.
Definition reg_class.hh:60
@ InvalidRegClass
Definition reg_class.hh:71

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0