update in new order
This commit is contained in:
@@ -17,6 +17,8 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
unordered_set<int> loop_tags = {FOR_NODE/*, FORALL_NODE, WHILE_NODE, DO_WHILE_NODE*/};
|
unordered_set<int> loop_tags = {FOR_NODE/*, FORALL_NODE, WHILE_NODE, DO_WHILE_NODE*/};
|
||||||
|
unordered_set<int> importantDepsTags = {FOR_NODE, IF_NODE, ELSEIF_NODE};
|
||||||
|
unordered_set<int> importantEndTags = {CONTROL_END};
|
||||||
|
|
||||||
|
|
||||||
vector<SAPFOR::IR_Block*> findInstructionsFromOperator(SgStatement* st, vector<SAPFOR::BasicBlock*> Blocks)
|
vector<SAPFOR::IR_Block*> findInstructionsFromOperator(SgStatement* st, vector<SAPFOR::BasicBlock*> Blocks)
|
||||||
@@ -124,19 +126,34 @@ map<SgStatement*, set<SgStatement*>> AnalyzeLoopAndFindDeps(SgForStmt* forStatem
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// int PrintSmthFromLoop(int firstLine, int lastLine, map<SgStatement*, unordered_set<SgStatement*>> moveRules) {
|
void buildAdditionalDeps(SgForStmt* forStatement, map<SgStatement*, set<SgStatement*>>& dependencies)
|
||||||
// // only cout done yet ((
|
{
|
||||||
// cout << "LOOP ANALYZE FROM " << firstLine << " TO " << lastLine << " RES\n" << endl;
|
SgStatement* lastNode = forStatement->lastNodeOfStmt();
|
||||||
// for (auto r: moveRules) {
|
vector<SgStatement*> importantDeps;
|
||||||
// cout << "OPERATOR: " << endl;
|
SgStatement* st = (SgStatement*) forStatement;
|
||||||
// cout << r.first -> lineNumber() << r.first -> sunparse();
|
SgStatement* logIfOp = NULL;
|
||||||
// cout << "DEPENDS FROM NEXT: " << endl;
|
importantDeps.push_back(st);
|
||||||
// for (SgStatement* st: r.second)
|
while (st && st != lastNode)
|
||||||
// cout << st -> lineNumber() << endl;
|
{
|
||||||
// }
|
if (st != importantDeps.back()) {
|
||||||
// cout << "\n\n\n";
|
dependencies[st].insert(importantDeps.back());
|
||||||
// return 0;
|
}
|
||||||
// }
|
if (logIfOp != NULL) {
|
||||||
|
dependencies[st].insert(logIfOp);
|
||||||
|
logIfOp = NULL;
|
||||||
|
}
|
||||||
|
if (st -> variant() == LOGIF_NODE) {
|
||||||
|
logIfOp = st;
|
||||||
|
}
|
||||||
|
if (importantDepsTags.find(st -> variant()) != importantDepsTags.end()) {
|
||||||
|
importantDeps.push_back(st);
|
||||||
|
}
|
||||||
|
if (importantEndTags.find(st -> variant()) != importantEndTags.end()) {
|
||||||
|
importantDeps.pop_back();
|
||||||
|
}
|
||||||
|
st = st -> lexNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GenNodesOfGraph(
|
void GenNodesOfGraph(
|
||||||
const map<SgStatement*, set<SgStatement*>>& dependencies,
|
const map<SgStatement*, set<SgStatement*>>& dependencies,
|
||||||
@@ -254,23 +271,25 @@ void runSwapOperators(SgFile *file, std::map<std::string, std::vector<LoopGraph*
|
|||||||
{
|
{
|
||||||
map<SgStatement*, set<SgStatement*>> dependencyGraph = AnalyzeLoopAndFindDeps(loopForAnalyze.first, loopForAnalyze.second, FullIR);
|
map<SgStatement*, set<SgStatement*>> dependencyGraph = AnalyzeLoopAndFindDeps(loopForAnalyze.first, loopForAnalyze.second, FullIR);
|
||||||
// TODO: Write a function that will go through the operators and update all dependencies so that there are no mix-ups and splits inside the semantic blocks (for if, do and may be some other cases)
|
// TODO: Write a function that will go through the operators and update all dependencies so that there are no mix-ups and splits inside the semantic blocks (for if, do and may be some other cases)
|
||||||
|
buildAdditionalDeps(loopForAnalyze.first, dependencyGraph);
|
||||||
cout << "\n\n";
|
cout << "\n\n";
|
||||||
for (auto v: dependencyGraph) {
|
|
||||||
cout << "OPERATOR: " << v.first -> lineNumber() << "\nDEPENDS ON:" << endl;
|
|
||||||
for (auto vv: v.second) {
|
|
||||||
cout << vv -> lineNumber() << " ";
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
if (dependencyGraph.size() != 0) {
|
|
||||||
int firstLine = loopForAnalyze.first -> lineNumber();
|
int firstLine = loopForAnalyze.first -> lineNumber();
|
||||||
int lastLine = loopForAnalyze.first -> lastNodeOfStmt() -> lineNumber();
|
int lastLine = loopForAnalyze.first -> lastNodeOfStmt() -> lineNumber();
|
||||||
// countOfTransform += PrintSmthFromLoop(firstLine, lastLine, dependencyGraph);
|
// for (auto v: dependencyGraph) {
|
||||||
|
// cout << "OPERATOR: " << v.first -> lineNumber() << "\nDEPENDS ON:" << endl;
|
||||||
|
// if (v.second.size() != 0)
|
||||||
|
// for (auto vv: v.second) {
|
||||||
|
// if (vv -> lineNumber() > firstLine)
|
||||||
|
// cout << vv -> lineNumber() << " ";
|
||||||
|
// }
|
||||||
|
// cout << endl;
|
||||||
|
// }
|
||||||
|
if (dependencyGraph.size() != 0) {
|
||||||
vector<SgStatement*> new_order = SortNoInterleaving(dependencyGraph);
|
vector<SgStatement*> new_order = SortNoInterleaving(dependencyGraph);
|
||||||
cout << "\n\nLOOP ANALYZE FROM " << firstLine << " TO " << lastLine << " RES\n" << endl;
|
cout << "\n\nLOOP ANALYZE FROM " << firstLine << " TO " << lastLine << " RES\n" << endl;
|
||||||
for (auto v: new_order)
|
for (auto v: new_order)
|
||||||
if (v -> lineNumber() > firstLine)
|
if (v -> lineNumber() > firstLine)
|
||||||
cout << v -> lineNumber() << " ";
|
cout << v -> lineNumber() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user