Compare commits
3 Commits
egormayoro
...
746bdf29b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
746bdf29b2 | ||
|
|
16f0560c8e | ||
|
|
8cae169131 |
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// Provided by Sage runtime (declared in libSage++.h)
|
||||||
|
extern SgFile *current_file;
|
||||||
|
|
||||||
|
|
||||||
set<int> loop_tags = {FOR_NODE};
|
set<int> loop_tags = {FOR_NODE};
|
||||||
set<int> control_tags = {IF_NODE, ELSEIF_NODE, DO_WHILE_NODE, WHILE_NODE, LOGIF_NODE};
|
set<int> control_tags = {IF_NODE, ELSEIF_NODE, DO_WHILE_NODE, WHILE_NODE, LOGIF_NODE};
|
||||||
@@ -551,13 +554,23 @@ static bool reorderOperatorsInBasicBlockUsingDeps(SAPFOR::BasicBlock* bb)
|
|||||||
void moveOperators(SgFile *file, map<string, vector<LoopGraph*>>& loopGraph,
|
void moveOperators(SgFile *file, map<string, vector<LoopGraph*>>& loopGraph,
|
||||||
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR,
|
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR,
|
||||||
int& countOfTransform) {
|
int& countOfTransform) {
|
||||||
if (!file)
|
// Correct usage pattern in this project:
|
||||||
return;
|
// save current file -> switch -> work on current_file -> restore.
|
||||||
|
const string oldFileName = (current_file ? current_file->filename() : "");
|
||||||
|
|
||||||
const int funcNum = file->numberOfFunctions();
|
for (const auto& [fileName, _] : loopGraph)
|
||||||
|
{
|
||||||
|
if (SgFile::switchToFile(fileName.c_str()) == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < funcNum; ++i) {
|
SgFile* curFile = current_file;
|
||||||
SgStatement* st = file->functions(i);
|
if (!curFile)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const int funcNum = curFile->numberOfFunctions();
|
||||||
|
for (int i = 0; i < funcNum; ++i)
|
||||||
|
{
|
||||||
|
SgStatement* st = curFile->functions(i);
|
||||||
|
|
||||||
const auto loopBlocks = findBlocksInLoopsByFullIR(st, FullIR);
|
const auto loopBlocks = findBlocksInLoopsByFullIR(st, FullIR);
|
||||||
for (auto* bb : loopBlocks)
|
for (auto* bb : loopBlocks)
|
||||||
@@ -569,3 +582,7 @@ void moveOperators(SgFile *file, map<string, vector<LoopGraph*>>& loopGraph,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!oldFileName.empty())
|
||||||
|
SgFile::switchToFile(oldFileName.c_str());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user