Commit 1ce3603c authored by Julien Balette-Pape's avatar Julien Balette-Pape

Passage à AccMatcher

parent 49a96f13
......@@ -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"
)
......
#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<icache::Access>& 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;
......
#ifndef LRUSECURITY_ACC_MATCHING_H
#define LRUSECURITY_ACC_MATCHING_H
#include <otawa/cfg/features.h>
#include <otawa/cfg/CFG.h>
#include <otawa/prog/Inst.h>
#include <otawa/icache/features.h>
#include <map>
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<const otawa::icache::Access *, otawa::BasicBlock *>();};
private:
std::map<const otawa::icache::Access *, otawa::BasicBlock *> _match;
};
} // namespace lrusecurity
#endif /* ifndef LRUSECURITY_ACC_MATCHING_H */
......@@ -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();
......
......@@ -4,7 +4,7 @@
#include <otawa/icache/features.h>
#include <otawa/base.h>
#include <otawa/cfg/CFG.h>
#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;
};
......
#ifndef LRUSECURITY_INST_MATCHING_H
#define LRUSECURITY_INST_MATCHING_H
#include <otawa/cfg/features.h>
#include <otawa/cfg/CFG.h>
#include <otawa/prog/Inst.h>
#include <otawa/icache/features.h>
#include <map>
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<otawa::Inst *, otawa::BasicBlock *>();};
private:
std::map<otawa::Inst *, otawa::BasicBlock *> _match;
};
} // namespace lrusecurity
#endif /* ifndef LRUSECURITY_INST_MATCHING_H */
......@@ -9,7 +9,7 @@
#include <set>
#include <iterator>
#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;
......
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