Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <algorithm>
- struct StoreSimulator
- {
- int m_k = 0, i = 0, j = 0, prob = 0;
- std::list<int> addresses;
- StoreSimulator(int k)
- {
- m_k = k;
- }
- bool GenNextStore()
- {
- if (j == 8)
- {
- ++i;
- j = 0;
- }
- if (i == 32)
- return false; // Done.
- int zaddr = 0xfe0 & (((64 * i + 8 * j) * 4) + (64 * m_k));
- if (prob != 10)
- {
- // Remove the olderst store from the buffer.
- if (!addresses.empty())
- addresses.pop_front();
- ++prob;
- }
- else
- prob = 0;
- if (addresses.size() < 42)
- {
- addresses.push_back(zaddr); // Add the new store to the store buffer.
- ++j;
- }
- return true;
- }
- bool Find(int addr)
- {
- return std::find(addresses.cbegin(), addresses.cend(), addr) !=
- addresses.end();
- }
- };
- int main() {
- std::list<int> addresses;
- int aliasCount = 0, k, i, j;
- for (k = 0; k < 64; ++k)
- {
- StoreSimulator ss(k);
- for (i = 0; i < 32; ++i)
- {
- for (j = 0; j < 8; ++j)
- {
- // We only need to compare bits 5-11.
- // 0xfe0 = 1111 1110 0000
- int xaddr = 0xfe0 & ((64 * i + 8 * j) * 4);
- int yaddr = 0xfe0 & (((64 * i + 8 * j) * 4) + (64 * k));
- if (ss.Find(xaddr) || ss.Find(yaddr))
- aliasCount = aliasCount + 2;
- //if (ss.Find(xaddr))
- // ++aliasCount;
- //if (ss.Find(yaddr))
- // ++aliasCount;
- ss.GenNextStore();
- }
- }
- std::cout << k << ", " << aliasCount << "\n";
- aliasCount = 0;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment