WIP add afterLoopLine
This commit is contained in:
@@ -1660,6 +1660,11 @@ void testIR(map<FuncInfo*, vector<SAPFOR::BasicBlock*>> fullIR) {
|
||||
for (auto j : i.second)
|
||||
printBlock(j);
|
||||
|
||||
vector<IR_Block*> all;
|
||||
for (auto j : i.second)
|
||||
for (auto k : j->getInstructions())
|
||||
all.push_back(k);
|
||||
|
||||
vector<int> visited(i.second.size(), 0);
|
||||
vector<pair<SAPFOR::BasicBlock*, SAPFOR::BasicBlock*>> startAndEnd;
|
||||
dfs(i.second[0], visited, startAndEnd, NULL);
|
||||
@@ -1668,23 +1673,39 @@ void testIR(map<FuncInfo*, vector<SAPFOR::BasicBlock*>> fullIR) {
|
||||
vector<LoopGraph*> loops;
|
||||
for (auto j : startAndEnd)
|
||||
{
|
||||
auto instruction = j.second->getInstructions()[0]->getInstruction();
|
||||
if (instruction->getOperator()->variant() == FOR_NODE) {
|
||||
SgForStmt* stmt = isSgForStmt(instruction->getOperator());
|
||||
auto firstInstruction = j.second->getInstructions()[0]->getInstruction();
|
||||
auto lastInstruction = j.first->getInstructions().back()->getInstruction();
|
||||
Instruction* instructionAfterLoop;
|
||||
for (auto a : fullIR)
|
||||
for(auto b : a.second)
|
||||
for (auto c : b->getInstructions())
|
||||
if (c->getInstruction()->getNumber() == lastInstruction->getNumber() + 1)
|
||||
{
|
||||
instructionAfterLoop = c->getInstruction();
|
||||
break;
|
||||
}
|
||||
|
||||
//auto instructionAfterLoop = getInstructionByNumber(all, lastInstruction->getNumber() + 1);
|
||||
cout << "first - " << firstInstruction->getNumber() << " last - " << lastInstruction->getNumber() << " after - " << instructionAfterLoop->getNumber() << endl;
|
||||
|
||||
if (firstInstruction->getOperator()->variant() == FOR_NODE) {
|
||||
SgForStmt* stmt = isSgForStmt(firstInstruction->getOperator());
|
||||
|
||||
auto tmpLoop = new LoopGraph();
|
||||
tmpLoop->isFor = true;
|
||||
tmpLoop->lineNum = instruction->getOperator()->lineNumber();
|
||||
tmpLoop->lineNum = firstInstruction->getOperator()->lineNumber();
|
||||
tmpLoop->lineNumAfterLoop = instructionAfterLoop->getOperator()->lineNumber();
|
||||
|
||||
cout << "for" << endl << stmt->sunparse() << endl;
|
||||
cout << "loop start line " << tmpLoop->lineNum << endl << endl;
|
||||
|
||||
cout << "loop start line " << tmpLoop->lineNum << endl;
|
||||
cout << "after loop line " << tmpLoop->lineNumAfterLoop << endl << endl;
|
||||
loops.push_back(tmpLoop);
|
||||
} else if (instruction->getOperator()->variant() == WHILE_NODE) {
|
||||
SgWhileStmt* stmt = isSgWhileStmt(instruction->getOperator());
|
||||
} else if (firstInstruction->getOperator()->variant() == WHILE_NODE) {
|
||||
SgWhileStmt* stmt = isSgWhileStmt(firstInstruction->getOperator());
|
||||
|
||||
auto tmpLoop = new LoopGraph();
|
||||
tmpLoop->lineNum = instruction->getOperator()->lineNumber();
|
||||
tmpLoop->lineNum = firstInstruction->getOperator()->lineNumber();
|
||||
tmpLoop->lineNumAfterLoop = instructionAfterLoop->getOperator()->lineNumber();
|
||||
|
||||
if (stmt->conditional() == NULL)
|
||||
{
|
||||
@@ -1697,14 +1718,15 @@ void testIR(map<FuncInfo*, vector<SAPFOR::BasicBlock*>> fullIR) {
|
||||
cout << "while " << endl << stmt->sunparse();
|
||||
}
|
||||
|
||||
cout << "loop start line " << tmpLoop->lineNum << endl << endl;
|
||||
cout << "loop start line " << tmpLoop->lineNum << endl;
|
||||
cout << "after loop line " << tmpLoop->lineNumAfterLoop << endl << endl;
|
||||
|
||||
loops.push_back(tmpLoop);
|
||||
} else if (instruction->getOperator()->variant() == LOOP_NODE) {
|
||||
cout << "not known loop" << endl << instruction->getOperator()->sunparse() << endl;
|
||||
} else if (firstInstruction->getOperator()->variant() == LOOP_NODE) {
|
||||
cout << "not known loop" << endl << firstInstruction->getOperator()->sunparse() << endl;
|
||||
}
|
||||
else {
|
||||
cout << "goto loop - " << instruction->getOperator()->sunparse() << endl;
|
||||
cout << "goto loop - " << firstInstruction->getOperator()->sunparse() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user