2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // Todo: Create destructor.
30 // Have it so that there's a more meaningful name given to the variable
31 // that marks the beginning of the FP registers.
33 #ifndef __CPU_O3_CPU_RENAME_MAP_HH__
34 #define __CPU_O3_CPU_RENAME_MAP_HH__
40 #include "cpu/o3/free_list.hh"
42 #include "arch/isa_traits.hh"
47 typedef TheISA::RegIndex RegIndex;
50 * Pair of a logical register and a physical register. Tells the
51 * previous mapping of a logical register to a physical register.
52 * Used to roll back the rename map to a previous state.
54 typedef std::pair<RegIndex, PhysRegIndex> UnmapInfo;
57 * Pair of a physical register and a physical register. Used to
58 * return the physical register that a logical register has been
59 * renamed to, and the previous physical register that the same
60 * logical register was previously mapped to.
62 typedef std::pair<PhysRegIndex, PhysRegIndex> RenameInfo;
66 SimpleRenameMap(unsigned _numLogicalIntRegs,
67 unsigned _numPhysicalIntRegs,
68 unsigned _numLogicalFloatRegs,
69 unsigned _numPhysicalFloatRegs,
70 unsigned _numMiscRegs,
72 RegIndex _floatZeroReg);
77 void setFreeList(SimpleFreeList *fl_ptr);
79 //Tell rename map to get a free physical register for a given
80 //architected register. Not sure it should have a return value,
81 //but perhaps it should have some sort of fault in case there are
83 RenameInfo rename(RegIndex arch_reg);
85 PhysRegIndex lookup(RegIndex phys_reg);
87 bool isReady(PhysRegIndex arch_reg);
90 * Marks the given register as ready, meaning that its value has been
91 * calculated and written to the register file.
92 * @param ready_reg The index of the physical register that is now ready.
94 void markAsReady(PhysRegIndex ready_reg);
96 void setEntry(RegIndex arch_reg, PhysRegIndex renamed_reg);
98 void squash(std::vector<RegIndex> freed_regs,
99 std::vector<UnmapInfo> unmaps);
101 int numFreeEntries();
104 /** Number of logical integer registers. */
105 int numLogicalIntRegs;
107 /** Number of physical integer registers. */
108 int numPhysicalIntRegs;
110 /** Number of logical floating point registers. */
111 int numLogicalFloatRegs;
113 /** Number of physical floating point registers. */
114 int numPhysicalFloatRegs;
116 /** Number of miscellaneous registers. */
119 /** Number of logical integer + float registers. */
122 /** Number of physical integer + float registers. */
125 /** The integer zero register. This implementation assumes it is always
126 * zero and never can be anything else.
130 /** The floating point zero register. This implementation assumes it is
131 * always zero and never can be anything else.
133 RegIndex floatZeroReg;
138 PhysRegIndex physical_reg;
142 : physical_reg(0), valid(false)
146 /** Integer rename map. */
147 RenameEntry *intRenameMap;
149 /** Floating point rename map. */
150 RenameEntry *floatRenameMap;
152 /** Free list interface. */
153 SimpleFreeList *freeList;
155 // Might want to make all these scoreboards into one large scoreboard.
157 /** Scoreboard of physical integer registers, saying whether or not they
160 std::vector<bool> intScoreboard;
162 /** Scoreboard of physical floating registers, saying whether or not they
165 std::vector<bool> floatScoreboard;
167 /** Scoreboard of miscellaneous registers, saying whether or not they
170 std::vector<bool> miscScoreboard;
173 #endif //__CPU_O3_CPU_RENAME_MAP_HH__