Commit dfa8aaab authored by Maeva Ramarjiaona's avatar Maeva Ramarjiaona

trying to fix underapproximation

parent 62abb982
......@@ -12,6 +12,9 @@ set(SOURCES "src/lrusecurity.cpp"
"src/Prev_Over/lrusecurity_ExistHitPrevOAnalysis.cpp"
"src/Prev_Over/lrusecurity_ExistHitPrevOAdapter.cpp"
"src/Prev_Over/lrusecurity_ExistHitPrevODomain.cpp"
"src/Prev_Under/lrusecurity_ExistHitPrevUAnalysis.cpp"
"src/Prev_Under/lrusecurity_ExistHitPrevUDomain.cpp"
"src/Prev_Under/lrusecurity_ExistHitPrevUAdapter.cpp"
"src/lrusecurity_Displayer.cpp"
)
......
#ifndef LRUSECURITY_EXIST_HIT_PREV_ADAPTER_O_H_
#define LRUSECURITY_EXIST_HIT_PREV_ADAPTER_O_H_
#ifndef LRUSECURITY_EXIST_HIT_PREV_ADAPTER_U_H_
#define LRUSECURITY_EXIST_HIT_PREV_ADAPTER_U_H_
#include <otawa/ai/ArrayStore.h>
#include <otawa/icat3/features.h>
......@@ -8,20 +9,20 @@
#include <lrupreanalysis/features.h>
#include "ExistHitPrevODomain.h"
#include "ExistHitPrevUDomain.h"
namespace lrusecurity
{
class ExistHitPrevOAdapter
class ExistHitPrevUAdapter
{
public:
using domain_t = ExistHitPrevODomain;
using domain_t = ExistHitPrevUDomain;
using t = typename domain_t::t;
using graph_t = otawa::CompositeCFG;
using store_t = otawa::ai::ArrayStore<domain_t, graph_t>;
ExistHitPrevOAdapter(int set, const t* init, const otawa::icat3::LBlockCollection& coll, const otawa::CFGCollection& cfgs, otawa::WorkSpace* ws);
ExistHitPrevUAdapter(int set, const t* init, const otawa::icat3::LBlockCollection& coll, const otawa::CFGCollection& cfgs, otawa::WorkSpace* ws);
inline domain_t& domain(void) { return _domain; }
inline graph_t& graph(void) { return _graph; }
......@@ -31,6 +32,8 @@ public:
void update(otawa::Block *v, t& d);
private:
int _set;
lrumc::ACSManager _mayManager;
domain_t _domain;
graph_t _graph;
......@@ -39,4 +42,4 @@ private:
} // namespace lrusecurity
#endif // LRUSECURITY_EXIST_HIT_ADAPTER_O_H_
#endif // LRUSECURITY_EXIST_HIT_ADAPTER_U_H_
#ifndef LRUSECURITY_EXIST_HIT_ANALYSIS_O_H_
#define LRUSECURITY_EXIST_HIT_ANALYSIS_O_H_
#ifndef LRUSECURITY_EXIST_HIT_ANALYSIS_U_H_
#define LRUSECURITY_EXIST_HIT_ANALYSIS_U_H_
#include <otawa/proc/Processor.h>
#include <otawa/icat3/features.h>
......@@ -8,12 +9,11 @@
namespace lrusecurity
{
class ExistHitPrevOAnalysis: public otawa::Processor
class ExistHitPrevUAnalysis: public otawa::Processor
{
public:
static otawa::p::declare reg;
ExistHitPrevOAnalysis(otawa::p::declare& r = reg);
ExistHitPrevUAnalysis(otawa::p::declare& r = reg);
protected:
void configure(const otawa::PropList& props) override;
......@@ -24,7 +24,7 @@ protected:
private:
void processSet(int i, otawa::WorkSpace* ws);
const otawa::icat3::Container<ACSSecurity>* _initExistHitPrevO;
const otawa::icat3::Container<ACSSecurity>* _initExistHitPrevU;
const otawa::icat3::LBlockCollection* _coll;
const otawa::CFGCollection* _cfgs;
};
......@@ -38,11 +38,11 @@ private:
* @li @ref EXIST_HIT_PREV_INIT
*
* @par Implementation
* @li @ref ExistHitPrevOAnalysis
* @li @ref ExistHitPrevUAnalysis
*
* @ingroup lrusecurity
*/
extern otawa::p::feature EXIST_HIT_PREV_O_ANALYSIS_FEATURE;
extern otawa::p::feature EXIST_HIT_PREV_U_ANALYSIS_FEATURE;
/**
* ACSSecurity for the Exist-Hit analysis at the entry of the corresponding block or edge.
......
#ifndef LRUSECURITY_EXIST_HIT_DOMAIN_O_H_
#define LRUSECURITY_EXIST_HIT_DOMAIN_O_H_
#ifndef LRUSECURITY_EXIST_HIT_DOMAIN_U_H_
#define LRUSECURITY_EXIST_HIT_DOMAIN_U_H_
#include <otawa/icat3/features.h>
#include <otawa/icache/features.h>
......@@ -11,20 +12,21 @@
namespace lrusecurity
{
class ExistHitPrevODomain {
class ExistHitPrevUDomain {
public:
using t = ACSSecurity;
ExistHitPrevODomain(const otawa::icat3::LBlockCollection& coll, int set, const t* init);
ExistHitPrevUDomain(const otawa::icat3::LBlockCollection& coll, int set, const t* init);
inline const t& bot(void) const { return _bot; }
inline const t& top(void) const { return _top; }
inline const t& init(void) const { return _init; }
inline void print(const t& a, otawa::io::Output& out) const { a.print(_set, _coll, out); }
inline elm::io::Printable<t, ExistHitPrevODomain> print(const t& a) const { return elm::io::p(a, *this); }
inline elm::io::Printable<t, ExistHitPrevUDomain> print(const t& a) const { return elm::io::p(a, *this); }
inline bool contains(const t& a, int i) { return(a[i] !=otawa::Bag< otawa::Address>()); }
inline void copy(t& d, const t& s) { d.copy(s); }
bool equals(const t& a, const t& b) const;
void join(t& d, const t& s);
void join(t& d, const t& s, otawa::icat3::ACS d_eh, otawa::icat3::ACS s_eh);
void fetch(t& a, const otawa::icache::Access& ac, lrumc::ACSManager& mayManager);
void update(const otawa::icache::Access& access, t& a, lrumc::ACSManager& mayManager);
......@@ -40,4 +42,5 @@ private:
} // namespace lrusecurity
#endif // LRUSECURITY_EXIST_HIT_DOMAIN_O_H_
#endif // LRUSECURITY_EXIST_HIT_DOMAIN_U_H_
#include "ExistHitPrevOAdapter.h"
#include "ExistHitPrevUAdapter.h"
using namespace otawa;
namespace lrusecurity
{
ExistHitPrevOAdapter::ExistHitPrevOAdapter(
ExistHitPrevUAdapter::ExistHitPrevUAdapter(
int set,
const t* init,
const icat3::LBlockCollection& coll,
const CFGCollection& cfgs,
otawa::WorkSpace* ws) :
_set(set),
_mayManager(ws),
_domain(coll, set, init),
_graph(cfgs),
......@@ -18,26 +19,33 @@ ExistHitPrevOAdapter::ExistHitPrevOAdapter(
{
}
void ExistHitPrevOAdapter::update(const Bag<icache::Access>& accs, t& d)
{
void ExistHitPrevUAdapter::update(const Bag<icache::Access>& accs, t& d)
for(int i = 0; i < accs.count(); i++) {
_domain.update(accs[i], d, _mayManager);
_mayManager.update(accs[i]);
}
}
void ExistHitPrevOAdapter::update(Block *v, t& d)
void ExistHitPrevUAdapter::update(Block *v, t& d)
{
_domain.copy(d, _domain.bot());
lrumc::ExistHitDomain::t d_eh;
t s;
bool first = true;
// update and join along edges
for(auto e = _graph.preds(v); e; e++) {
Block *w = e->source();
_domain.copy(s, _store.get(w));
_mayManager.start(w);
if(first) {
first = false;
_mayManager.ehDomain(_set).copy(d_eh, _mayManager.ehDomain(_set).bot());
}
// apply block
{
const Bag<icache::Access>& accs = icache::ACCESSES(w);
......@@ -54,7 +62,10 @@ void ExistHitPrevOAdapter::update(Block *v, t& d)
// merge result
_domain.join(d, s);
lrumc::ExistHitDomain::t* tmp = _mayManager.ehValue(_set);
ASSERT(tmp && "tmp null");
_domain.join(d, s, d_eh, *tmp);
_mayManager.ehDomain(_set).join(d_eh, *tmp);
}
}
......
#include "ExistHitPrevOAnalysis.h"
#include "ExistHitPrevUAnalysis.h"
#include <chrono>
......@@ -9,30 +10,28 @@
#include <lrusecurity/features.h>
#include "ExistHitPrevOAdapter.h"
#include "ExistHitPrevODomain.h"
#include "ExistHitPrevUAdapter.h"
#include "ExistHitPrevUDomain.h"
using namespace otawa;
namespace lrusecurity
{
ExistHitPrevOAnalysis::ExistHitPrevOAnalysis(p::declare& r) :
ExistHitPrevUAnalysis::ExistHitPrevUAnalysis(p::declare& r) :
Processor(r),
_initExistHitPrevO(nullptr),
_initExistHitPrevU(nullptr),
_coll(nullptr),
_cfgs(nullptr)
{
}
void ExistHitPrevOAnalysis::configure(const PropList& props)
void ExistHitPrevUAnalysis::configure(const PropList& props)
{
Processor::configure(props);
if(props.hasProp(EXIST_HIT_PREV_INIT))
_initExistHitPrevO = &EXIST_HIT_PREV_INIT(props);
_initExistHitPrevU = &EXIST_HIT_PREV_INIT(props);
}
void ExistHitPrevOAnalysis::setup(WorkSpace* ws)
void ExistHitPrevUAnalysis::setup(WorkSpace* ws)
{
_coll = icat3::LBLOCKS(ws);
ASSERT(_coll != nullptr);
......@@ -40,8 +39,7 @@ void ExistHitPrevOAnalysis::setup(WorkSpace* ws)
ASSERT(_cfgs != nullptr);
}
void ExistHitPrevOAnalysis::processWorkSpace(WorkSpace* ws) //changer les ACS en ACSSecurity
{
void ExistHitPrevUAnalysis::processWorkSpace(WorkSpace* ws) //changer les ACS en ACSSecurity
auto start = std::chrono::system_clock::now();
// prepare containers
......@@ -62,18 +60,18 @@ void ExistHitPrevOAnalysis::setup(WorkSpace* ws)
if(logFor(LOG_FUN))
log << "\tExist Hit Prev Analysis running time: " << elapsed.count() << " s" << io::endl;
}
void ExistHitPrevOAnalysis::destroy(WorkSpace*)
void ExistHitPrevUAnalysis::destroy(WorkSpace*)
{
for(CFGCollection::BlockIter b(_cfgs); b; b++)
EXIST_HIT_PREV_IN(b).remove();
}
void ExistHitPrevOAnalysis::processSet(int set, WorkSpace* ws)
void ExistHitPrevUAnalysis::processSet(int set, WorkSpace* ws)
{
// perform the analysis
ExistHitPrevOAdapter ada(set, _initExistHitPrevO ? &_initExistHitPrevO->get(set) : nullptr, *_coll, *_cfgs, ws);
ai::SimpleAI<ExistHitPrevOAdapter> ana(ada);
ExistHitPrevUAdapter ada(set, _initExistHitPrevU ? &_initExistHitPrevU->get(set) : nullptr, *_coll, *_cfgs, ws);
ai::SimpleAI<ExistHitPrevUAdapter> ana(ada);
ana.run();
// store the results
for(CFGCollection::BlockIter b(_cfgs); b; b++)
......@@ -84,14 +82,14 @@ void ExistHitPrevOAnalysis::processSet(int set, WorkSpace* ws)
}
}
p::declare ExistHitPrevOAnalysis::reg = p::init("lrusecurity::ExistHitPrevOAnalysis", Version(1, 0, 0))
p::declare ExistHitPrevUAnalysis::reg = p::init("lrusecurity::ExistHitPrevUAnalysis", Version(1, 0, 0))
.require(icat3::LBLOCKS_FEATURE)
.require(COLLECTED_CFG_FEATURE)
.require(icat3::MUST_PERS_ANALYSIS_FEATURE)
.require(icat3::CATEGORY_FEATURE)
.require(lrumc::EXIST_HIT_ANALYSIS_FEATURE)
.provide(EXIST_HIT_PREV_O_ANALYSIS_FEATURE)
.make<ExistHitPrevOAnalysis>();
.provide(EXIST_HIT_PREV_U_ANALYSIS_FEATURE)
.make<ExistHitPrevUAnalysis>();
p::feature EXIST_HIT_PREV_O_ANALYSIS_FEATURE("lrusecurity::EXIST_HIT_PREV_ANALYSIS_O_FEATURE", p::make<ExistHitPrevOAnalysis>());
p::feature EXIST_HIT_PREV_U_ANALYSIS_FEATURE("lrusecurity::EXIST_HIT_PREV_ANALYSIS_U_FEATURE", p::make<ExistHitPrevUAnalysis>());
}; // namespace lrusecurity
......@@ -27,21 +27,24 @@ bool ExistHitPrevUDomain::equals(const t& acss, const t& bcss) const
return false;
return true;
}
void ExistHitPrevUDomain::join(t& dcss, const t& scss)
void ExistHitPrevUDomain::join(t& dcss, const t& scss, icat3::ACS d_eh, icat3::ACS s_eh)
{
//TODO : regarder comment on trouve l'objet auquel est attaché une property
/*
for (int i = 0; i < _n; i++){
int q1 = dcss.proplist()::EXIST_HIT_IN(i);
int q2 = scss.proplist()::EXIST_HIT_IN(i);
if (q2 < q1){
scss[i] = dcss[i];
}
else if (q2 == q1){
do the union thing i guess;
}
}
*/
for (int i = 0; i < _n; i++){
if (s_eh[i] < d_eh[i]){
dcss[i] = scss[i];
}
else if (s_eh[i] == d_eh[i]){
int fullsize = dcss.size()+scss.size();
Bag<Address> tmp = Bag<Address>(fullsize);
for (int j = 0; j < fullsize; j++){
if (j < dcss.size())
tmp[j] = dcss[i][j] ;
else
tmp[j] = scss[i][j-dcss.size()];
}
dcss[i] = tmp;
}
}
}
void ExistHitPrevUDomain::fetch(t& acss, const icache::Access& access, lrumc::ACSManager& ehManager)
{
......@@ -69,7 +72,7 @@ void ExistHitPrevUDomain::update(const icache::Access& access, t& a, lrumc::ACSM
if(_coll.cache()->set(access.address()) == _set) {
copy(_tmp, a);
fetch(a, access, ehManager);
join(a, _tmp);
join(a, _tmp, icat3::ACS(), icat3::ACS());
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment