added inductive variables and loop type to LoopGraph

This commit is contained in:
ALEXks
2025-06-22 09:19:37 +03:00
parent 7533739488
commit 65237e4d63
13 changed files with 83 additions and 40 deletions

View File

@@ -20,7 +20,7 @@ using std::wstring;
static SgSymbol* getLoopSymbol(const LoopGraph* loop)
{
if (!loop || !loop->isFor)
if (!loop || !loop->isFor())
return NULL;
SgForStmt* stmt = (SgForStmt*)loop->loop->GetOriginal();
@@ -667,12 +667,12 @@ static void renameIterationVariables(LoopGraph* loop, const map<SgSymbol*, SgSym
{
if (loop)
{
string& loopName = loop->loopSymbol;
for (auto& pair : symbols)
string& loopName = loop->loopSymbol();
for (auto& [from, to] : symbols)
{
if (pair.first->identifier() == loopName)
if (from->identifier() == loopName)
{
loop->loopSymbol = (string)pair.second->identifier();
loop->loopSymbols.replaceMainVar(to->identifier());
break;
}
}
@@ -691,9 +691,9 @@ static void renameVariablesInLoop(LoopGraph* loop, const map<SgSymbol*, SgSymbol
if (st->variant() == FOR_NODE)
{
SgForStmt* for_st = (SgForStmt*)st;
for (auto& pair : symbols)
if (isEqSymbols(pair.first, for_st->symbol()))
for_st->setDoName(*pair.second);
for (auto& [from, to] : symbols)
if (isEqSymbols(from, for_st->symbol()))
for_st->setDoName(*to);
}
for (int i = 0; i < 3; ++i)
@@ -710,12 +710,12 @@ static void renamePrivatesInMap(LoopGraph* loop, const map<SgSymbol*, SgSymbol*>
for (auto& priv : privates->second)
{
bool found = false;
for (auto& pair : symbols)
for (auto& [from, to] : symbols)
{
if (isEqSymbols(priv, pair.first))
if (isEqSymbols(priv, from))
{
found = true;
newList.insert(pair.second);
newList.insert(to);
break;
}
}
@@ -1590,7 +1590,7 @@ static bool combine(LoopGraph* firstLoop, const vector<LoopGraph*>& nextLoops, s
bool wasCombine = false;
for (LoopGraph* loop : nextLoops)
{
if (!loop->isFor)
if (!loop->isFor())
return wasCombine;
int perfectLoop = std::min(firstLoop->perfectLoop, loop->perfectLoop);
@@ -1723,7 +1723,7 @@ static bool tryToCombine(vector<LoopGraph*>& loopGraphs, map<LoopGraph*, set<SgS
{
LoopGraph* loop = loops[z];
newloopGraphs.push_back(loop);
if (!loop->isFor)
if (!loop->isFor())
continue;
vector<LoopGraph*> nextLoops = getNextLoops(loop, loopGraphs, -1);