rename_map.hh (2670:9107b8bd08cd) rename_map.hh (2674:6d4afef73a20)
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 *
28 * Authors: Kevin Lim
29 */
30
31// Todo: Create destructor.
32// Have it so that there's a more meaningful name given to the variable
33// that marks the beginning of the FP registers.
34
35#ifndef __CPU_O3_RENAME_MAP_HH__
36#define __CPU_O3_RENAME_MAP_HH__
37
38#include <iostream>
39#include <utility>
40#include <vector>
41
42#include "cpu/o3/free_list.hh"
43//For RegIndex
44#include "arch/isa_traits.hh"
45
46class SimpleRenameMap
47{
48 protected:
49 typedef TheISA::RegIndex RegIndex;
50 public:
51 /**
52 * Pair of a logical register and a physical register. Tells the
53 * previous mapping of a logical register to a physical register.
54 * Used to roll back the rename map to a previous state.
55 */
56 typedef std::pair<RegIndex, PhysRegIndex> UnmapInfo;
57
58 /**
59 * Pair of a physical register and a physical register. Used to
60 * return the physical register that a logical register has been
61 * renamed to, and the previous physical register that the same
62 * logical register was previously mapped to.
63 */
64 typedef std::pair<PhysRegIndex, PhysRegIndex> RenameInfo;
65
66 public:
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 *
28 * Authors: Kevin Lim
29 */
30
31// Todo: Create destructor.
32// Have it so that there's a more meaningful name given to the variable
33// that marks the beginning of the FP registers.
34
35#ifndef __CPU_O3_RENAME_MAP_HH__
36#define __CPU_O3_RENAME_MAP_HH__
37
38#include <iostream>
39#include <utility>
40#include <vector>
41
42#include "cpu/o3/free_list.hh"
43//For RegIndex
44#include "arch/isa_traits.hh"
45
46class SimpleRenameMap
47{
48 protected:
49 typedef TheISA::RegIndex RegIndex;
50 public:
51 /**
52 * Pair of a logical register and a physical register. Tells the
53 * previous mapping of a logical register to a physical register.
54 * Used to roll back the rename map to a previous state.
55 */
56 typedef std::pair<RegIndex, PhysRegIndex> UnmapInfo;
57
58 /**
59 * Pair of a physical register and a physical register. Used to
60 * return the physical register that a logical register has been
61 * renamed to, and the previous physical register that the same
62 * logical register was previously mapped to.
63 */
64 typedef std::pair<PhysRegIndex, PhysRegIndex> RenameInfo;
65
66 public:
67 //Constructor
68 SimpleRenameMap() {};
67 /** Default constructor. init() must be called prior to use. */
68 SimpleRenameMap() {};
69
70 /** Destructor. */
71 ~SimpleRenameMap();
72
69
70 /** Destructor. */
71 ~SimpleRenameMap();
72
73 /** Initializes rename map with given parameters. */
73 void init(unsigned _numLogicalIntRegs,
74 unsigned _numPhysicalIntRegs,
75 PhysRegIndex &_int_reg_start,
76
77 unsigned _numLogicalFloatRegs,
78 unsigned _numPhysicalFloatRegs,
79 PhysRegIndex &_float_reg_start,
80
81 unsigned _numMiscRegs,
82
83 RegIndex _intZeroReg,
84 RegIndex _floatZeroReg,
85
86 int id,
87 bool bindRegs);
88
74 void init(unsigned _numLogicalIntRegs,
75 unsigned _numPhysicalIntRegs,
76 PhysRegIndex &_int_reg_start,
77
78 unsigned _numLogicalFloatRegs,
79 unsigned _numPhysicalFloatRegs,
80 PhysRegIndex &_float_reg_start,
81
82 unsigned _numMiscRegs,
83
84 RegIndex _intZeroReg,
85 RegIndex _floatZeroReg,
86
87 int id,
88 bool bindRegs);
89
90 /** Sets the free list used with this rename map. */
89 void setFreeList(SimpleFreeList *fl_ptr);
90
91 //Tell rename map to get a free physical register for a given
92 //architected register. Not sure it should have a return value,
93 //but perhaps it should have some sort of fault in case there are
94 //no free registers.
95 RenameInfo rename(RegIndex arch_reg);
96
97 PhysRegIndex lookup(RegIndex phys_reg);
98
99 /**
100 * Marks the given register as ready, meaning that its value has been
101 * calculated and written to the register file.
102 * @param ready_reg The index of the physical register that is now ready.
103 */
104 void setEntry(RegIndex arch_reg, PhysRegIndex renamed_reg);
105
106 int numFreeEntries();
107
108 private:
109 /** Rename Map ID */
110 int id;
111
112 /** Number of logical integer registers. */
113 int numLogicalIntRegs;
114
115 /** Number of physical integer registers. */
116 int numPhysicalIntRegs;
117
118 /** Number of logical floating point registers. */
119 int numLogicalFloatRegs;
120
121 /** Number of physical floating point registers. */
122 int numPhysicalFloatRegs;
123
124 /** Number of miscellaneous registers. */
125 int numMiscRegs;
126
127 /** Number of logical integer + float registers. */
128 int numLogicalRegs;
129
130 /** Number of physical integer + float registers. */
131 int numPhysicalRegs;
132
133 /** The integer zero register. This implementation assumes it is always
134 * zero and never can be anything else.
135 */
136 RegIndex intZeroReg;
137
138 /** The floating point zero register. This implementation assumes it is
139 * always zero and never can be anything else.
140 */
141 RegIndex floatZeroReg;
142
143 class RenameEntry
144 {
145 public:
146 PhysRegIndex physical_reg;
147 bool valid;
148
149 RenameEntry()
150 : physical_reg(0), valid(false)
151 { }
152 };
153
91 void setFreeList(SimpleFreeList *fl_ptr);
92
93 //Tell rename map to get a free physical register for a given
94 //architected register. Not sure it should have a return value,
95 //but perhaps it should have some sort of fault in case there are
96 //no free registers.
97 RenameInfo rename(RegIndex arch_reg);
98
99 PhysRegIndex lookup(RegIndex phys_reg);
100
101 /**
102 * Marks the given register as ready, meaning that its value has been
103 * calculated and written to the register file.
104 * @param ready_reg The index of the physical register that is now ready.
105 */
106 void setEntry(RegIndex arch_reg, PhysRegIndex renamed_reg);
107
108 int numFreeEntries();
109
110 private:
111 /** Rename Map ID */
112 int id;
113
114 /** Number of logical integer registers. */
115 int numLogicalIntRegs;
116
117 /** Number of physical integer registers. */
118 int numPhysicalIntRegs;
119
120 /** Number of logical floating point registers. */
121 int numLogicalFloatRegs;
122
123 /** Number of physical floating point registers. */
124 int numPhysicalFloatRegs;
125
126 /** Number of miscellaneous registers. */
127 int numMiscRegs;
128
129 /** Number of logical integer + float registers. */
130 int numLogicalRegs;
131
132 /** Number of physical integer + float registers. */
133 int numPhysicalRegs;
134
135 /** The integer zero register. This implementation assumes it is always
136 * zero and never can be anything else.
137 */
138 RegIndex intZeroReg;
139
140 /** The floating point zero register. This implementation assumes it is
141 * always zero and never can be anything else.
142 */
143 RegIndex floatZeroReg;
144
145 class RenameEntry
146 {
147 public:
148 PhysRegIndex physical_reg;
149 bool valid;
150
151 RenameEntry()
152 : physical_reg(0), valid(false)
153 { }
154 };
155
154 //Change this to private
155 private:
156 /** Integer rename map. */
157 std::vector<RenameEntry> intRenameMap;
158
159 /** Floating point rename map. */
160 std::vector<RenameEntry> floatRenameMap;
161
162 private:
163 /** Free list interface. */
164 SimpleFreeList *freeList;
165};
166
167#endif //__CPU_O3_RENAME_MAP_HH__
156 private:
157 /** Integer rename map. */
158 std::vector<RenameEntry> intRenameMap;
159
160 /** Floating point rename map. */
161 std::vector<RenameEntry> floatRenameMap;
162
163 private:
164 /** Free list interface. */
165 SimpleFreeList *freeList;
166};
167
168#endif //__CPU_O3_RENAME_MAP_HH__