Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

lrusecurity_ExistHitPrevUDomain.cpp 1.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "ExistHitPrevUDomain.h"

using namespace otawa;

namespace lrusecurity
{

ExistHitPrevUDomain::ExistHitPrevUDomain(
		const icat3::LBlockCollection& coll,
		int set,
		const t *init) :
	_n(coll[set].count()),
	_bot(_n),
	_top(_n, Address(0x0)),//TO CHANGE
	_set(set),
	_coll(coll),
	_A(coll.A()),
	_init(init ? *init : _top),
	_tmp(_n)
{
}

bool ExistHitPrevUDomain::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
  void ExistHitPrevUDomain::join(t& dcss, const t& scss, icat3::ACS d_eh,  icat3::ACS s_eh)
31
{
32
  for (int i = 0; i < _n; i++){
33
    if (s_eh[i] < d_eh[i] || (d_eh[i] == -1 && s_eh[i] != -1)){
34
35
36
      dcss[i] = scss[i];
    }
    else if (s_eh[i] == d_eh[i]){
37
      int fullsize = (dcss[i]).size()+(scss[i]).size();
38
39
      Bag<Address> tmp = Bag<Address>(fullsize);
      for (int j = 0; j < fullsize; j++){
40
	if (j < (dcss[i]).size())
41
42
	  tmp[j] = dcss[i][j] ;
	else
Maeva Ramarjiaona's avatar
Maeva Ramarjiaona committed
43
	  tmp[j] = scss[i][j-dcss[i].size()];
44
45
46
47
      }
      dcss[i] = tmp;
    }
  }
48
}
Valentin Touzeau's avatar
Valentin Touzeau committed
49
  void ExistHitPrevUDomain::fetch(t& acss, const icache::Access& access, lrupreanalysis::eh_em::ACSManager& ehManager)
50
51
52
53
54
55
56
57
58
59
60
61
{
  icat3::LBlock *lb = icat3::LBLOCK(access);
  int b = lb->index();
  for (int i = 0; i < _n; i++){
    if (i == b){
      Address smol[]  = {access.address()};  
      acss[i] = Bag<Address>(1,smol);}
    else if (ehManager.existHitAge(lb) == _A)
      acss[i] = Bag<Address>();
  }
}

Valentin Touzeau's avatar
Valentin Touzeau committed
62
void ExistHitPrevUDomain::update(const icache::Access& access, t& a, lrupreanalysis::eh_em::ACSManager& ehManager)
63
64
65
66
67
68
69
70
71
72
73
74
{
	switch(access.kind()) {

	case icache::FETCH:
		if(_coll.cache()->set(access.address()) == _set)
			fetch(a, access, ehManager);
		break;

	case icache::PREFETCH:
		if(_coll.cache()->set(access.address()) == _set) {
			copy(_tmp, a);
			fetch(a, access, ehManager);
75
			join(a, _tmp, icat3::ACS(), icat3::ACS());
76
77
78
79
80
81
82
83
84
85
86
87
		}
		break;

	case icache::NONE:
		break;

	default:
		ASSERT(false);
	}
}

} // namespace lrusecurity