lrusecurity_ExistHitPrevODomain.cpp 1.85 KB
Newer Older
1 2 3 4 5 6 7 8
#include "ExistHitPrevODomain.h"

using namespace otawa;

namespace lrusecurity
{

ExistHitPrevODomain::ExistHitPrevODomain(
9 10 11 12 13 14 15
        const icat3::LBlockCollection& coll,
        int set,
        const t *init):
    _n(coll[set].count()),
    _bot(_n),
    _top(_n, Address(0x0)), //TO CHANGE
    _set(set),
16
	_coll(coll),
17 18 19
    _A(coll.A()),
    _init(init ? *init : _top),
    _tmp(_n)
20 21 22 23 24 25 26 27 28 29
{
}

bool ExistHitPrevODomain::equals(const t& acss, const t& bcss) const
{
  for (int i = 0; i < _n; i++)
    if (acss[i] != bcss[i])
      return false;
  return true;
}
30 31

void ExistHitPrevODomain::join(t& dcss, const t& scss)
32
{
33
  for (int i = 0; i < _n; i++){
34 35 36 37 38 39 40 41 42 43 44
    int newsize = dcss[i].size()+scss[i].size();
    Bag<Address> newbag = Bag<Address>(newsize);
    for (int j = 0; j < newsize; j++) {
      if (j < dcss[i].size())
	newbag[j]=dcss[i][j];
      else
	newbag[j]=scss[i][j - dcss[i].size()];
    }
    dcss[i] = Bag<Address>(newbag);
  }
}
45 46

void ExistHitPrevODomain::fetch(t& acss, const icache::Access& access, lrupreanalysis::eh_em::ACSManager& mayManager)
47 48 49 50 51
{
  icat3::LBlock *lb = icat3::LBLOCK(access);
  int b = lb->index();
  for (int i = 0; i < _n; i++){
    if (i == b){
52 53 54
      Address smol[] = {access.address()};
      acss[i] = Bag<Address>(1, smol);
    } else if (mayManager.mayAge(_coll[_set][i]) == _A)
55 56 57 58
      acss[i] = Bag<Address>();
  }
}

59
void ExistHitPrevODomain::update(const icache::Access& access, t& a, lrupreanalysis::eh_em::ACSManager& mayManager)
60
{
61
  switch(access.kind()) {
62

63 64 65 66
  case icache::FETCH:
    if(_coll.cache()->set(access.address()) == _set)
      fetch(a, access, mayManager);
      break;
67

68 69 70 71 72 73 74
  case icache::PREFETCH:
    if(_coll.cache()->set(access.address()) == _set) {
      copy(_tmp, a);
      fetch(a, access, mayManager);
      join(a, _tmp);
    }
    break;
75

76 77
  case icache::NONE:
    break;
78

79 80 81
  default:
    ASSERT(false);
  }
82 83 84
}

} // namespace lrusecurity