Guest User

Untitled

a guest
Nov 17th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <algorithm>
  4.  
  5. struct StoreSimulator
  6. {
  7. int m_k = 0, i = 0, j = 0, prob = 0;
  8. std::list<int> addresses;
  9.  
  10. StoreSimulator(int k)
  11. {
  12. m_k = k;
  13. }
  14.  
  15. bool GenNextStore()
  16. {
  17. if (j == 8)
  18. {
  19. ++i;
  20. j = 0;
  21. }
  22.  
  23. if (i == 32)
  24. return false; // Done.
  25.  
  26.  
  27. int zaddr = 0xfe0 & (((64 * i + 8 * j) * 4) + (64 * m_k));
  28.  
  29. if (prob != 10)
  30. {
  31. // Remove the olderst store from the buffer.
  32. if (!addresses.empty())
  33. addresses.pop_front();
  34. ++prob;
  35. }
  36. else
  37. prob = 0;
  38.  
  39. if (addresses.size() < 42)
  40. {
  41. addresses.push_back(zaddr); // Add the new store to the store buffer.
  42. ++j;
  43. }
  44.  
  45. return true;
  46.  
  47. }
  48.  
  49. bool Find(int addr)
  50. {
  51. return std::find(addresses.cbegin(), addresses.cend(), addr) !=
  52. addresses.end();
  53. }
  54. };
  55.  
  56. int main() {
  57. std::list<int> addresses;
  58. int aliasCount = 0, k, i, j;
  59.  
  60. for (k = 0; k < 64; ++k)
  61. {
  62. StoreSimulator ss(k);
  63.  
  64. for (i = 0; i < 32; ++i)
  65. {
  66. for (j = 0; j < 8; ++j)
  67. {
  68. // We only need to compare bits 5-11.
  69. // 0xfe0 = 1111 1110 0000
  70. int xaddr = 0xfe0 & ((64 * i + 8 * j) * 4);
  71. int yaddr = 0xfe0 & (((64 * i + 8 * j) * 4) + (64 * k));
  72.  
  73. if (ss.Find(xaddr) || ss.Find(yaddr))
  74. aliasCount = aliasCount + 2;
  75.  
  76. //if (ss.Find(xaddr))
  77. // ++aliasCount;
  78. //if (ss.Find(yaddr))
  79. // ++aliasCount;
  80.  
  81. ss.GenNextStore();
  82. }
  83. }
  84.  
  85. std::cout << k << ", " << aliasCount << "\n";
  86. aliasCount = 0;
  87.  
  88. }
  89.  
  90. return 0;
  91. }
Add Comment
Please, Sign In to add comment