Skip to content
Snippets Groups Projects
Commit 463eb51d authored by Bouquillon Fabien's avatar Bouquillon Fabien
Browse files

correction exploration paths (see explo)

parent 59a7b217
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ ARMCC=arm-none-eabi-gcc
CXXFLAGS += -std=c++11 -O0 -g3 -I ../otawa-core2-build/otawa/include/ -I ../otawa-core2-build/elm/include/ -I ../include/
all: clean explo.so install application large_loop
all: clean explo.so install application large_loop loop_cond
# binaire: binaire.c
# $(ARMCC) -nostdlib -nostdinc -static -o binaire binaire.c
......@@ -28,6 +28,9 @@ all: clean explo.so install application large_loop
large_loop: large_loop.c
$(ARMCC) -nostdlib -nostdinc -static -o large_loop large_loop.c
loop_cond: loop_cond.c
$(ARMCC) -nostdlib -nostdinc -static -o loop_cond loop_cond.c
# large_loop_function: large_loop_function.c
# $(ARMCC) -nostdlib -nostdinc -static -o large_loop_function large_loop_function.c
......
......@@ -51,6 +51,122 @@ namespace otawa {
}
//--------------------------------------------------------------------------
// Exploration loop
//--------------------------------------------------------------------------
void ExploProcessor::rec_loop(Block *loop_header,Block *b, std::vector<std::vector<Block*>> &paths, std::vector<std::vector<Block*>> paths_before) {
// Add the current block to the path
for(int i = 0; i < paths_before.size(); i++) {
paths_before[i].push_back(b);
}
// END condition
if(b == loop_header) {
std::vector<std::vector<Block*>> tmp;
for(int i = 0; i < paths_before.size(); i++) {
paths.push_back(paths_before[i]);
}
return;
}
//if block is function call
if(b->isSynth()) {
std::vector<std::vector<Block*>> path_tmp;
ExploProcessor::explo_fct(b->toSynth()->callee()->exit(), path_tmp, paths_before);
paths_before = path_tmp;
}
// if block is loop
if(LOOP_HEADER(b->toBasic())) {
Block::EdgeIter iter_pred(b->ins());
Edge *edge_fct = *iter_pred;
Block *fct_c = edge_fct->source();
iter_pred++;
Edge *edge_loop = *iter_pred;
Block *loop_c = edge_loop->source();
std::vector<std::vector<Block*>> paths_tmp;
ExploProcessor::rec_loop(b,loop_c, paths_tmp, paths_before);
paths_before = paths_tmp;
ExploProcessor::rec_loop(loop_header, fct_c, paths, paths_before);
} else {
// Rec part
for(Block::EdgeIter iter_pred(b->ins());iter_pred();iter_pred++) {
Edge *edge = *iter_pred;
Block *src = edge->source();
ExploProcessor::rec_loop(loop_header, src, paths, paths_before);
}
}
}
void ExploProcessor::explo_fct(Block *b, std::vector<std::vector<Block*>> &paths, std::vector<std::vector<Block*>> paths_before) {
if(paths_before.size() != 0) {
// Add the current block to the path
for(int i = 0; i < paths_before.size(); i++) {
paths_before[i].push_back(b);
}
} else {
std::vector<Block*> tmp;
tmp.push_back(b);
paths_before.push_back(tmp);
}
// END condition
if(b->isEntry()) {
std::vector<std::vector<Block*>> tmp;
for(int i = 0; i < paths_before.size(); i++) {
paths.push_back(paths_before[i]);
}
return;
}
// if block is loop
if(b->isBasic() && LOOP_HEADER(b->toBasic())) {
Block::EdgeIter iter_pred(b->ins());
Edge *edge_fct = *iter_pred;
Block *fct_c = edge_fct->source();
iter_pred++;
Edge *edge_loop = *iter_pred;
Block *loop_c = edge_loop->source();
std::vector<std::vector<Block*>> paths_tmp;
ExploProcessor::rec_loop(b, loop_c, paths_tmp, paths_before);
paths_before = paths_tmp;
ExploProcessor::explo_fct(fct_c, paths, paths_before);
} else {
//if block is function call
if(b->isSynth()) {
std::vector<std::vector<Block*>> path_tmp;
ExploProcessor::explo_fct(b->toSynth()->callee()->exit(), path_tmp, paths_before);
paths_before = path_tmp;
}
// Rec part
for(Block::EdgeIter iter_pred(b->ins());iter_pred();iter_pred++) {
Edge *edge = *iter_pred;
Block *src = edge->source();
ExploProcessor::explo_fct(src, paths, paths_before);
}
}
}
//--------------------------------------------------------------------------
// unsigned long time_lblock(LBlock* lb) {
// BasicBlock* bb = lb->bb();
// std::cout << " -- LB -- " << std::endl;
......@@ -255,6 +371,9 @@ namespace otawa {
std::cout << "#############################################" << std::endl;
}
void ExploProcessor::processWorkSpace(WorkSpace *ws) {
const CFGCollection *coll = INVOLVED_CFGS(ws);
......@@ -263,6 +382,19 @@ namespace otawa {
explo_cfg(tmp);
std::cout << std::endl;
}
std::cout << "################# LOOP EXPLO ################" << std::endl;
std::vector<std::vector<Block*>> paths;
std::vector<std::vector<Block*>> tmp;
explo_fct(ENTRY_CFG(ws)->exit(), paths, tmp);
for(int i = 0; i < paths.size(); i++) {
std::cout << "PATH[" << i << "]:";
for(int j = 0; j < paths[i].size(); j++) {
std::cout << paths[i][j]->id() << "->";
}
std::cout << "start" << endl;
}
}
......
......@@ -21,6 +21,8 @@ public:
explicit ExploProcessor(p::declare &r = reg);
protected:
void explo_fct(Block *b, std::vector<std::vector<Block*>> &paths, std::vector<std::vector<Block*>> paths_before);
void rec_loop(Block *loop_header,Block *b, std::vector<std::vector<Block*>> &paths, std::vector<std::vector<Block*>> paths_before);
void processWorkSpace(WorkSpace * /*ws*/) override;
void configure(const PropList &props) override;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment