Deleted Added
sdiff udiff text old ( 2654:9559cfa91b9d ) new ( 2665:a124942bacb8 )
full compact
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

--- 8 unchanged lines hidden (view full) ---

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#include "base/trace.hh"
32#include "cpu/o3/store_set.hh"
33
34StoreSet::StoreSet(int _SSIT_size, int _LFST_size)
35 : SSIT_size(_SSIT_size), LFST_size(_LFST_size)
36{
37 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n");
38 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n",
39 SSIT_size, LFST_size);
40
41 SSIT = new SSID[SSIT_size];
42
43 validSSIT.resize(SSIT_size);
44
45 for (int i = 0; i < SSIT_size; ++i)
46 validSSIT[i] = false;
47
48 LFST = new InstSeqNum[LFST_size];
49
50 validLFST.resize(LFST_size);
51
52 SSCounters = new int[LFST_size];
53
54 for (int i = 0; i < LFST_size; ++i)
55 {
56 validLFST[i] = false;
57 SSCounters[i] = 0;
58 }
59
60 index_mask = SSIT_size - 1;
61
62 offset_bits = 2;
63}
64
65void
66StoreSet::violation(Addr store_PC, Addr load_PC)
67{
68 int load_index = calcIndex(load_PC);
69 int store_index = calcIndex(store_PC);
70
71 assert(load_index < SSIT_size && store_index < SSIT_size);
72
73 bool valid_load_SSID = validSSIT[load_index];
74 bool valid_store_SSID = validSSIT[store_index];
75
76 if (!valid_load_SSID && !valid_store_SSID) {
77 // Calculate a new SSID here.
78 SSID new_set = calcSSID(load_PC);
79
80 validSSIT[load_index] = true;
81
82 SSIT[load_index] = new_set;
83
84 validSSIT[store_index] = true;
85
86 SSIT[store_index] = new_set;
87
88 assert(new_set < LFST_size);
89
90 SSCounters[new_set]++;
91
92
93 DPRINTF(StoreSet, "StoreSet: Neither load nor store had a valid "
94 "storeset, creating a new one: %i for load %#x, store %#x\n",
95 new_set, load_PC, store_PC);
96 } else if (valid_load_SSID && !valid_store_SSID) {
97 SSID load_SSID = SSIT[load_index];
98
99 validSSIT[store_index] = true;
100
101 SSIT[store_index] = load_SSID;
102
103 assert(load_SSID < LFST_size);
104
105 SSCounters[load_SSID]++;
106
107 DPRINTF(StoreSet, "StoreSet: Load had a valid store set. Adding "
108 "store to that set: %i for load %#x, store %#x\n",
109 load_SSID, load_PC, store_PC);
110 } else if (!valid_load_SSID && valid_store_SSID) {
111 SSID store_SSID = SSIT[store_index];
112
113 validSSIT[load_index] = true;
114
115 SSIT[load_index] = store_SSID;
116
117 // Because we are having a load point to an already existing set,
118 // the size of the store set is not incremented.
119
120 DPRINTF(StoreSet, "StoreSet: Store had a valid store set: %i for "
121 "load %#x, store %#x\n",
122 store_SSID, load_PC, store_PC);
123 } else {
124 SSID load_SSID = SSIT[load_index];
125 SSID store_SSID = SSIT[store_index];
126
127 assert(load_SSID < LFST_size && store_SSID < LFST_size);
128
129 int load_SS_size = SSCounters[load_SSID];
130 int store_SS_size = SSCounters[store_SSID];
131
132 // If the load has the bigger store set, then assign the store
133 // to the same store set as the load. Otherwise vice-versa.
134 if (load_SS_size > store_SS_size) {
135 SSIT[store_index] = load_SSID;
136
137 SSCounters[load_SSID]++;
138 SSCounters[store_SSID]--;
139
140 DPRINTF(StoreSet, "StoreSet: Load had bigger store set: %i; "
141 "for load %#x, store %#x\n",
142 load_SSID, load_PC, store_PC);
143 } else {
144 SSIT[load_index] = store_SSID;
145
146 SSCounters[store_SSID]++;
147 SSCounters[load_SSID]--;
148
149 DPRINTF(StoreSet, "StoreSet: Store had bigger store set: %i; "
150 "for load %#x, store %#x\n",
151 store_SSID, load_PC, store_PC);
152 }
153 }
154}
155
156void
157StoreSet::insertLoad(Addr load_PC, InstSeqNum load_seq_num)
158{
159 // Does nothing.
160 return;
161}
162
163void
164StoreSet::insertStore(Addr store_PC, InstSeqNum store_seq_num)
165{
166 int index = calcIndex(store_PC);
167
168 int store_SSID;
169
170 assert(index < SSIT_size);
171
172 if (!validSSIT[index]) {
173 // Do nothing if there's no valid entry.
174 return;
175 } else {
176 store_SSID = SSIT[index];
177
178 assert(store_SSID < LFST_size);
179
180 // Update the last store that was fetched with the current one.
181 LFST[store_SSID] = store_seq_num;
182
183 validLFST[store_SSID] = 1;
184
185 DPRINTF(StoreSet, "Store %#x updated the LFST, SSID: %i\n",
186 store_PC, store_SSID);
187 }
188}
189
190InstSeqNum
191StoreSet::checkInst(Addr PC)
192{
193 int index = calcIndex(PC);
194
195 int inst_SSID;
196
197 assert(index < SSIT_size);
198
199 if (!validSSIT[index]) {
200 DPRINTF(StoreSet, "Inst %#x with index %i had no SSID\n",
201 PC, index);
202
203 // Return 0 if there's no valid entry.
204 return 0;
205 } else {
206 inst_SSID = SSIT[index];
207
208 assert(inst_SSID < LFST_size);
209
210 if (!validLFST[inst_SSID]) {
211
212 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had no "
213 "dependency\n", PC, index, inst_SSID);
214
215 return 0;
216 } else {

--- 12 unchanged lines hidden (view full) ---

229 if (!is_store) {
230 return;
231 }
232
233 int index = calcIndex(issued_PC);
234
235 int store_SSID;
236
237 assert(index < SSIT_size);
238
239 // Make sure the SSIT still has a valid entry for the issued store.
240 if (!validSSIT[index]) {
241 return;
242 }
243
244 store_SSID = SSIT[index];
245
246 assert(store_SSID < LFST_size);
247
248 // If the last fetched store in the store set refers to the store that
249 // was just issued, then invalidate the entry.
250 if (validLFST[store_SSID] && LFST[store_SSID] == issued_seq_num) {
251 DPRINTF(StoreSet, "StoreSet: store invalidated itself in LFST.\n");
252 validLFST[store_SSID] = false;
253 }
254}
255
256void
257StoreSet::squash(InstSeqNum squashed_num)
258{
259 // Not really sure how to do this well.
260 // Generally this is small enough that it should be okay; short circuit
261 // evaluation should take care of invalid entries.
262
263 DPRINTF(StoreSet, "StoreSet: Squashing until inum %i\n",
264 squashed_num);
265
266 for (int i = 0; i < LFST_size; ++i) {
267 if (validLFST[i] && LFST[i] < squashed_num) {
268 validLFST[i] = false;
269 }
270 }
271}
272
273void
274StoreSet::clear()
275{
276 for (int i = 0; i < SSIT_size; ++i) {
277 validSSIT[i] = false;
278 }
279
280 for (int i = 0; i < LFST_size; ++i) {
281 validLFST[i] = false;
282 }
283}
284