fixed getNameInLocation

This commit is contained in:
ALEXks
2025-05-11 09:17:16 +03:00
parent 0a4b795900
commit e3d77f51f1
4 changed files with 28 additions and 16 deletions

View File

@@ -199,15 +199,6 @@ static set<string> fillUsedSymbols(SgStatement *loop)
return usedS;
}
static string correctSymbolModuleName(const string& origFull)
{
auto it = origFull.find("::");
if (it == string::npos)
return origFull;
else
return origFull.substr(it + 2);
}
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
{
auto it = origFull.find("::");
@@ -959,7 +950,7 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
SgSymbol* redS;
string clearName = correctSymbolModuleName(red);
if (clearName != red)
redS = getNameInLocation(parentFunc, clearName, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
redS = getNameInLocation(parentFunc, red, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
else
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
@@ -1017,12 +1008,12 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
string clearName2 = correctSymbolModuleName(get<1>(list));
if (clearName1 != get<0>(list))
redS1 = getNameInLocation(parentFunc, clearName1, getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
redS1 = getNameInLocation(parentFunc, get<0>(list), getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
else
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
if (clearName2 != get<1>(list))
redS2 = getNameInLocation(parentFunc, clearName2, getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
redS2 = getNameInLocation(parentFunc, get<1>(list), getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
else
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);

View File

@@ -343,9 +343,9 @@ const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
return symbs;
}
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
static void findSymbol(SgStatement* func, const string& varName, const string& locName,
map<string, SgSymbol*>& altNames)
{
map<string, SgSymbol*> altNames;
for (const auto& s : getModuleSymbols(func))
{
SgSymbol* orig = OriginalSymbol(s);
@@ -353,11 +353,22 @@ SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const stri
if (orig->identifier() == varName && orig->scope()->symbol()->identifier() == locName)
altNames[s->identifier()] = s;
}
}
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
{
const string clearName = correctSymbolModuleName(varName);
map<string, SgSymbol*> altNames;
findSymbol(func, varName, locName, altNames);
if (altNames.size() == 0 && clearName != varName)
findSymbol(func, clearName, locName, altNames);
if (altNames.size() > 0)
return altNames.begin()->second;
else {
__spf_print(1, "%s %s %s\n", func->symbol()->identifier(), varName.c_str(), locName.c_str());
__spf_print(1, "%s (%s %s) %s\n", func->symbol()->identifier(), clearName.c_str(), varName.c_str(), locName.c_str());
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
}
@@ -393,6 +404,15 @@ SgSymbol* getNameInLocation(SgSymbol* curr, SgStatement* location)
return returnVal;
}
string correctSymbolModuleName(const string& origFull)
{
auto it = origFull.find("::");
if (it == string::npos)
return origFull;
else
return origFull.substr(it + 2);
}
namespace Distribution
{
const string Array::GetNameInLocation(void* location_p) const

View File

@@ -1,5 +1,6 @@
#pragma once
std::string correctSymbolModuleName(const std::string& origFull);
const std::set<SgSymbol*>& getModuleSymbols(SgStatement* func);
void getModulesAndFunctions(SgFile* file, std::vector<SgStatement*>& modulesAndFunctions);
void findModulesInFile(SgFile* file, std::vector<SgStatement*>& modules);

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2416"
#define VERSION_SPF "2417"