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_ExistHitPrevDomain.cpp 1.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "ExistHitPrevDomain.h"

using namespace otawa;

namespace lrusecurity
{

ExistHitPrevDomain::ExistHitPrevDomain(
		const icat3::LBlockCollection& coll,
		int set,
		const t *init) :
	_n(coll[set].count()),
	_bot(_n, icat3::BOT_AGE),
	_top(_n, 0),
	_set(set),
	_coll(coll),
	_A(coll.A()),
	_init(init ? *init : _top),
19
	_tmp(*new icat3::ACS( _n))
20
21
22
{
}

23
bool ExistHitPrevDomain::equals(const t& acss, const t& bcss) const
24
{
25
26
  icat3::ACS a = acss._acs;
  icat3::ACS b = bcss._acs;
27
28
29
30
31
32
	for(int i = 0; i < _n; i++)
		if(a[i] != b[i])
			return false;

	return true;
}
33
void ExistHitPrevDomain::join(t& dcss, const t& scss)
34
{
35
36
  icat3::ACS d = dcss._acs;
  icat3::ACS s = scss._acs;
37
38
39
40
41
42
43
44
45
46
	for(int i = 0; i < _n; i++) {
		// d[i] = min(d[i], s[i])
		if(d[i] == icat3::BOT_AGE)
			d[i] = s[i];
		else if(s[i] != icat3::BOT_AGE)
			d[i] = min(d[i], s[i]);

	}

	//join of the Prev is a union
47
	dcss._prev = scss._prev;
48
49
}

50
void ExistHitPrevDomain::fetch(t& acss, const icache::Access ac, lrupreanalysis::ACSManager& mustManager)
51
52
53
{
        icat3::LBlock *lb = icat3::LBLOCK(ac);
	int b = lb->index();
54
	icat3::ACS a = acss._acs;
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
	if(a[0] == icat3::BOT_AGE)
		return;

	for(int i = 0; i < _n; i++) {
		ASSERT(a[i] != icat3::BOT_AGE);
		if(i == b)
			continue;

		if(a[i] < mustManager.mustAge(lb) && a[i] < _A)
			a[i]++;
	}
	a[b] = 0;

	//Updating prev
	for(int i = 0; i < _n; i++) {
	  if (a[i] == icat3::BOT_AGE)
71
	    acss._prev = *new Bag<icache::Access>();
72
73

	  if (i == b)
74
	    acss._prev = *new Bag<icache::Access>(1, &ac);
75
76
77
78
79
80
81
82
83
	}
}

void ExistHitPrevDomain::update(const icache::Access& access, t& a, lrupreanalysis::ACSManager& mustManager)
{
	switch(access.kind()) {

	case icache::FETCH:
		if(_coll.cache()->set(access.address()) == _set)
84
			fetch(a, access, mustManager);
85
86
87
88
89
		break;

	case icache::PREFETCH:
		if(_coll.cache()->set(access.address()) == _set) {
			copy(_tmp, a);
90
			fetch(a, access, mustManager);
91
92
93
94
95
96
97
98
99
100
101
102
103
			join(a, _tmp);
		}
		break;

	case icache::NONE:
		break;

	default:
		ASSERT(false);
	}
}

} // namespace lrusecurity