From 1ce3603c778348602ac75e48a3fc5a222a51b252 Mon Sep 17 00:00:00 2001 From: Julien BP Date: Thu, 1 Aug 2019 16:49:37 +0200 Subject: [PATCH] =?UTF-8?q?Passage=20=C3=A0=20AccMatcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- .../{InstMatching.cpp => AccMatching.cpp} | 18 +++++------ src/Graphic/AccMatching.h | 31 ++++++++++++++++++ src/Graphic/DotModificator.cpp | 2 +- src/Graphic/DotModificator.h | 8 ++--- src/Graphic/InstMatching.h | 32 ------------------- src/lrusecurity_Displayer.cpp | 6 ++-- 7 files changed, 49 insertions(+), 50 deletions(-) rename src/Graphic/{InstMatching.cpp => AccMatching.cpp} (53%) create mode 100644 src/Graphic/AccMatching.h delete mode 100644 src/Graphic/InstMatching.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 95943eb..59cb612 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES "src/lrusecurity.cpp" "src/Prev_Under/lrusecurity_ExistHitPrevUDomain.cpp" "src/Prev_Under/lrusecurity_ExistHitPrevUAdapter.cpp" "src/lrusecurity_Displayer.cpp" - "src/Graphic/InstMatching.cpp" # Modification for Dot + "src/Graphic/AccMatching.cpp" # Modification for Dot "src/Graphic/DotModificator.cpp" ) diff --git a/src/Graphic/InstMatching.cpp b/src/Graphic/AccMatching.cpp similarity index 53% rename from src/Graphic/InstMatching.cpp rename to src/Graphic/AccMatching.cpp index 716c01d..098dc63 100644 --- a/src/Graphic/InstMatching.cpp +++ b/src/Graphic/AccMatching.cpp @@ -1,11 +1,11 @@ -#include "InstMatching.h" +#include "AccMatching.h" using namespace otawa; namespace lrusecurity { -void InstMatcher::setupCFG(CFG *cfg) +void AccMatcher::setupCFG(CFG *cfg) { CFG::BlockIter iter_block; @@ -13,24 +13,24 @@ void InstMatcher::setupCFG(CFG *cfg) Block *b = *iter_block; if (b->isBasic()){ BasicBlock *bb = b->toBasic(); - BasicBlock::InstIter iter_inst; - for (iter_inst = bb->begin(); iter_inst != bb->end(); iter_inst++){ - insert(*iter_inst, bb); + const Bag& bag = otawa::icache::ACCESSES(bb); + for (int i = 0; i < bag.size(); i++){ + insert(&bag[i], bb); } } } } -void InstMatcher::setupColl(CFGCollection *collection) +void AccMatcher::setupColl(CFGCollection *collection) { for(int i = 0; i < collection->count(); i++) { - InstMatcher::setupCFG(*collection[i]); + AccMatcher::setupCFG(*collection[i]); } } -otawa::BasicBlock* InstMatcher::match_instruction(otawa::Inst *instruction) +otawa::BasicBlock* AccMatcher::match_access(const otawa::icache::Access *access) { - auto search = this->_match.find(instruction); + auto search = this->_match.find(access); if (search != _match.end()) return search->second; diff --git a/src/Graphic/AccMatching.h b/src/Graphic/AccMatching.h new file mode 100644 index 0000000..3cdb2a7 --- /dev/null +++ b/src/Graphic/AccMatching.h @@ -0,0 +1,31 @@ +#ifndef LRUSECURITY_ACC_MATCHING_H +#define LRUSECURITY_ACC_MATCHING_H + +#include +#include +#include +#include +#include + +namespace lrusecurity +{ + +class AccMatcher +{ +public: + AccMatcher(void){}; + void setupColl(otawa::CFGCollection *coll); + void setupCFG(otawa::CFG *cfg); + inline void insert(const otawa::icache::Access *acc, otawa::BasicBlock *bb){_match.insert({acc, bb});}; + + otawa::BasicBlock *match_access(const otawa::icache::Access *access); + + inline void clean(void){_match = std::map();}; + +private: + std::map _match; +}; + +} // namespace lrusecurity + +#endif /* ifndef LRUSECURITY_ACC_MATCHING_H */ diff --git a/src/Graphic/DotModificator.cpp b/src/Graphic/DotModificator.cpp index 73867fb..dfb57b7 100644 --- a/src/Graphic/DotModificator.cpp +++ b/src/Graphic/DotModificator.cpp @@ -29,7 +29,7 @@ void DotModificator::modify(otawa::CFG *cfg, const otawa::icache::Access *access if (access){ // On récupère le bloc correspondant à l'accès grâce à l'InstMatcher - otawa::BasicBlock *bb_match = _intM->match_access(access); + otawa::BasicBlock *bb_match = getMatcher()->match_access(access); // Copie de l'adresse de l'accès pour affichage string acc_addr = _ << access->address(); diff --git a/src/Graphic/DotModificator.h b/src/Graphic/DotModificator.h index bc5c87e..8281fa9 100644 --- a/src/Graphic/DotModificator.h +++ b/src/Graphic/DotModificator.h @@ -4,7 +4,7 @@ #include #include #include -#include "InstMatching.h" +#include "AccMatching.h" namespace lrusecurity { @@ -12,15 +12,15 @@ namespace lrusecurity class DotModificator { public: - DotModificator(const char *dot_file, InstMatcher *match):_filename(dot_file), _intM(match), _count(0){}; + DotModificator(const char *dot_file, AccMatcher *match):_filename(dot_file), _accM(match), _count(0){}; void modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address); void finish(void); - inline InstMatcher *getMatcher(void){return _intM;}; + inline AccMatcher *getMatcher(void){return _accM;}; inline bool isFirst(void){return _count == 0;}; private: const char *_filename; - InstMatcher *_intM; + AccMatcher *_accM; int _count; }; diff --git a/src/Graphic/InstMatching.h b/src/Graphic/InstMatching.h deleted file mode 100644 index 054bb4f..0000000 --- a/src/Graphic/InstMatching.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef LRUSECURITY_INST_MATCHING_H -#define LRUSECURITY_INST_MATCHING_H - -#include -#include -#include -#include -#include - -namespace lrusecurity -{ - -class InstMatcher -{ -public: - InstMatcher(void){}; - void setupCFG(otawa::CFG *cfg); - void setupColl(otawa::CFGCollection *collection); - inline void insert(otawa::Inst *inst, otawa::BasicBlock *bb){_match.insert({inst, bb});}; - - otawa::BasicBlock *match_instruction(otawa::Inst *instruction); - inline otawa::BasicBlock *match_access(const otawa::icache::Access *access){return match_instruction(access->instruction());}; - - inline void clean(void){_match = std::map();}; - -private: - std::map _match; -}; - -} // namespace lrusecurity - -#endif /* ifndef LRUSECURITY_INST_MATCHING_H */ diff --git a/src/lrusecurity_Displayer.cpp b/src/lrusecurity_Displayer.cpp index 7baa178..f85bc08 100644 --- a/src/lrusecurity_Displayer.cpp +++ b/src/lrusecurity_Displayer.cpp @@ -9,7 +9,7 @@ #include #include -#include "Graphic/InstMatching.h" +#include "Graphic/AccMatching.h" #include "Graphic/DotModificator.h" //#include "SecCFGOutput.h" @@ -30,7 +30,7 @@ public: _stream(nullptr), _line(false), // Modification pour affichage en dot - _modificator(new DotModificator("result.dot", new InstMatcher)) //TODO: changer l'accès au fichier + _modificator(new DotModificator("result.dot", new AccMatcher)) //TODO: changer l'accès au fichier { } @@ -79,7 +79,7 @@ protected: virtual void processCFG(WorkSpace* ws, CFG* cfg) override { - InstMatcher *match = getModificator() -> getMatcher(); + AccMatcher *match = getModificator() -> getMatcher(); match->setupCFG(cfg); _out << "FUNCTION " << cfg->label() << io::endl; -- GitLab