refactored, added pass to Visualizer calls

This commit is contained in:
ALEXks
2025-12-29 21:22:53 +03:00
parent d9f54739d2
commit af85311480
3 changed files with 25 additions and 13 deletions

View File

@@ -235,11 +235,10 @@ static vector<OperatorInfo> analyzeOperatorsInLoop(SgForStmt* loop, const vector
static map<string, vector<SgStatement*>> findVariableDefinitions(SgForStmt* loop, vector<OperatorInfo>& operators) {
map<string, vector<SgStatement*>> varDefinitions;
for (auto& op : operators) {
for (const string& var : op.definedVars) {
for (auto& op : operators)
for (const string& var : op.definedVars)
varDefinitions[var].push_back(op.stmt);
}
}
return varDefinitions;
}
@@ -369,12 +368,9 @@ static vector<SgStatement*> optimizeOperatorOrder(SgForStmt* loop,
stmtToOpInfo[op.stmt] = &op;
bool changed = true;
int iterations = 0;
const int MAX_ITERATIONS = 50;
while (changed && iterations < MAX_ITERATIONS) {
while (changed) {
changed = false;
iterations++;
for (int i = operators.size() - 1; i >= 0; i--) {
if (!operators[i].isMovable)
@@ -434,6 +430,7 @@ static vector<SgStatement*> optimizeOperatorOrder(SgForStmt* loop,
break;
}
}
if (usesDefinedVar) {
targetPos = j;
break;
@@ -566,6 +563,7 @@ static vector<SgStatement*> optimizeOperatorOrder(SgForStmt* loop,
}
}
}
if (dependencyViolation)
break;
}
@@ -656,7 +654,9 @@ static bool applyOperatorReordering(SgForStmt* loop, const vector<SgStatement*>&
if (extractedSet.find(stmt) != extractedSet.end()) {
SgStatement* stmtToInsert = stmtToExtracted[stmt];
if (!stmtToInsert) continue;
if (!stmtToInsert)
continue;
SgStatement* insertAfter = loop;
@@ -730,9 +730,11 @@ vector<SAPFOR::BasicBlock*> findFuncBlocksByFuncStatement(SgStatement *st, const
Statement* forSt = (Statement*)st;
for (auto& func: FullIR) {
if (func.first -> funcPointer -> getCurrProcessFile() == forSt -> getCurrProcessFile()
&& func.first -> funcPointer -> lineNumber() == forSt -> lineNumber())
if (func.first->funcPointer->getCurrProcessFile() == forSt->getCurrProcessFile()
&& func.first->funcPointer->lineNumber() == forSt->lineNumber())
{
result = func.second;
}
}
return result;
}
@@ -770,7 +772,8 @@ map<SgForStmt*, vector<SAPFOR::BasicBlock*>> findAndAnalyzeLoops(SgStatement *st
static void processLoopRecursively(SgForStmt* loop, const vector<SAPFOR::BasicBlock*>& blocks,
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR) {
if (!loop) return;
if (!loop)
return;
SgStatement* loopStart = loop->lexNext();
SgStatement* loopEnd = loop->lastNodeOfStmt();

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2450"
#define VERSION_SPF "2451"

View File

@@ -1802,6 +1802,13 @@ int SPF_InsertPrivateArrayDirectives(void*& context, int winHandler, short* opti
return simpleTransformPass(FIND_PRIVATE_ARRAYS, options, projName, folderName, output, outputMessage);
}
int SPF_MoveOperators(void*& context, int winHandler, short* options, short* projName, short* folderName, string& output, string& outputMessage)
{
MessageManager::clearCache();
MessageManager::setWinHandler(winHandler);
return simpleTransformPass(MOVE_OPERATORS, options, projName, folderName, output, outputMessage);
}
static inline void convertBackSlash(char *str, int strL)
{
for (int z = 0; z < strL; ++z)
@@ -2510,6 +2517,8 @@ const wstring Sapfor_RunTransformation(const char* transformName_c, const char*
retCode = SPF_RenameIncludes(context, winHandler, optSh, projSh, fold, output, outputMessage);
else if (whichRun == "SPF_InsertPrivateArrayDirectives")
retCode = SPF_InsertPrivateArrayDirectives(context, winHandler, optSh, projSh, fold, output, outputMessage);
else if (whichRun == "SPF_MoveOperators")
retCode = SPF_MoveOperators(context, winHandler, optSh, projSh, fold, output, outputMessage);
else if (whichRun == "SPF_CreateParallelVariant")
{
vector<string> splited;