lrusecurity_ExistHitPrevUAdapter.cpp 1.58 KB
Newer Older
1
#include "ExistHitPrevUAdapter.h"
2

Valentin Touzeau's avatar
Valentin Touzeau committed
3 4
#include <lrupreanalysis/ExistHitDomain.h>

5 6 7 8
using namespace otawa;

namespace lrusecurity
{
9

10
ExistHitPrevUAdapter::ExistHitPrevUAdapter(
11 12 13 14 15
		int set,
		const t* init,
		const icat3::LBlockCollection& coll,
		const CFGCollection& cfgs,
		otawa::WorkSpace* ws) :
16
    _set(set),
Valentin Touzeau's avatar
Valentin Touzeau committed
17
	_ehManager(ws),
18 19 20 21 22 23
	_domain(coll, set, init),
	_graph(cfgs),
	_store(_domain, _graph)
{
}

24
void ExistHitPrevUAdapter::update(const Bag<icache::Access>& accs, t& d)
25
{
26
	for(int i = 0; i < accs.count(); i++) {
Valentin Touzeau's avatar
Valentin Touzeau committed
27 28
		_domain.update(accs[i], d, _ehManager);
		_ehManager.update(accs[i]);
29 30 31
	}
}

32
void ExistHitPrevUAdapter::update(Block *v, t& d)
33 34
{
	_domain.copy(d, _domain.bot());
Valentin Touzeau's avatar
Valentin Touzeau committed
35
	lrupreanalysis::eh_em::ExistHitDomain::t d_eh;
36

37 38
	t s;

39
	bool first = true;
40 41 42 43 44
	// update and join along edges
	for(auto e = _graph.preds(v); e; e++) {
		Block *w = e->source();
		_domain.copy(s, _store.get(w));

Valentin Touzeau's avatar
Valentin Touzeau committed
45
		_ehManager.start(w);
46

47 48
		if(first) {
		  first = false;
Valentin Touzeau's avatar
Valentin Touzeau committed
49
		  _ehManager.ehDomain(_set).copy(d_eh, _ehManager.ehDomain(_set).bot());
50
		}
51

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
		// apply block
		{
			const Bag<icache::Access>& accs = icache::ACCESSES(w);
			if(accs.count() > 0)
				update(accs, s);
		}

		// apply edge
		{
			const Bag<icache::Access>& accs = icache::ACCESSES(e);
			if(accs.count() > 0)
				update(accs, s);
		}


		// merge result
Valentin Touzeau's avatar
Valentin Touzeau committed
68
		lrupreanalysis::eh_em::ExistHitDomain::t* tmp = _ehManager.ehValue(_set);
69
		ASSERT(tmp && "tmp null");
Valentin Touzeau's avatar
Valentin Touzeau committed
70
		lrupreanalysis::eh_em::ExistHitDomain::t& s_eh = *tmp;
71
        ASSERT(d_eh.count() == s_eh.count());
72
		_domain.join(d, s, d_eh, s_eh);
Valentin Touzeau's avatar
Valentin Touzeau committed
73
		_ehManager.ehDomain(_set).join(d_eh, s_eh);
74 75 76 77
	}
}

} // namespace lrusecurity