Commit 388a1251 authored by Julien Balette-Pape's avatar Julien Balette-Pape

add setup CFG for matching

parent 446042fd
......@@ -7,10 +7,16 @@ namespace lrusecurity
void InstMatcher::setupColl(CFGCollection *collection)
{
CFGCollection::BlockRange range = collection->blocks();
CFGCollection::BlockIter iter_block;
for(int i = 0; i < collection->count(); i++) {
setupCFG(*collection[i]);
}
}
for (iter_block = range.begin(); iter_block != range.end(); iter_block++){
void InstMatcher::setupCFG(CFG *cfg)
{
CFG::BlockIter iter_block;
for (iter_block = cfg->blocks(); iter_block; iter_block++){
Block *b = *iter_block;
if (b->isBasic()){
BasicBlock *bb = b->toBasic();
......@@ -20,8 +26,6 @@ void InstMatcher::setupColl(CFGCollection *collection)
}
}
}
_setup = true;
}
otawa::BasicBlock* InstMatcher::match_instruction(otawa::Inst *instruction)
......@@ -31,6 +35,7 @@ otawa::BasicBlock* InstMatcher::match_instruction(otawa::Inst *instruction)
if (search != _match.end())
return search->second;
else
cout << "Unable to find instruction";
exit(EXIT_FAILURE);
}
......
......@@ -13,18 +13,17 @@ namespace lrusecurity
class InstMatcher
{
public:
InstMatcher(void){_setup = false;};
InstMatcher(void);
void setupColl(otawa::CFGCollection *collection);
void setupCFG(otawa::CFG *cfg);
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(otawa::icache::Access *access){return match_instruction(access->instruction());};
inline void manual_setup(void){_setup = true;};
inline bool isSetup(void){return _setup;};
inline void clean(void){_match = std::map<otawa::Inst *, otawa::BasicBlock *>();};
private:
bool _setup;
std::map<otawa::Inst *, otawa::BasicBlock *> _match;
};
......
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