fixed getNameInLocation
This commit is contained in:
@@ -199,15 +199,6 @@ static set<string> fillUsedSymbols(SgStatement *loop)
|
|||||||
return usedS;
|
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)
|
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
|
||||||
{
|
{
|
||||||
auto it = origFull.find("::");
|
auto it = origFull.find("::");
|
||||||
@@ -959,7 +950,7 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
|||||||
SgSymbol* redS;
|
SgSymbol* redS;
|
||||||
string clearName = correctSymbolModuleName(red);
|
string clearName = correctSymbolModuleName(red);
|
||||||
if (clearName != 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
|
else
|
||||||
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
|
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));
|
string clearName2 = correctSymbolModuleName(get<1>(list));
|
||||||
|
|
||||||
if (clearName1 != get<0>(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
|
else
|
||||||
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
||||||
|
|
||||||
if (clearName2 != get<1>(list))
|
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
|
else
|
||||||
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
||||||
|
|
||||||
|
|||||||
@@ -343,9 +343,9 @@ const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
|
|||||||
return symbs;
|
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))
|
for (const auto& s : getModuleSymbols(func))
|
||||||
{
|
{
|
||||||
SgSymbol* orig = OriginalSymbol(s);
|
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)
|
if (orig->identifier() == varName && orig->scope()->symbol()->identifier() == locName)
|
||||||
altNames[s->identifier()] = s;
|
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)
|
if (altNames.size() > 0)
|
||||||
return altNames.begin()->second;
|
return altNames.begin()->second;
|
||||||
else {
|
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__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,6 +404,15 @@ SgSymbol* getNameInLocation(SgSymbol* curr, SgStatement* location)
|
|||||||
return returnVal;
|
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
|
namespace Distribution
|
||||||
{
|
{
|
||||||
const string Array::GetNameInLocation(void* location_p) const
|
const string Array::GetNameInLocation(void* location_p) const
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
std::string correctSymbolModuleName(const std::string& origFull);
|
||||||
const std::set<SgSymbol*>& getModuleSymbols(SgStatement* func);
|
const std::set<SgSymbol*>& getModuleSymbols(SgStatement* func);
|
||||||
void getModulesAndFunctions(SgFile* file, std::vector<SgStatement*>& modulesAndFunctions);
|
void getModulesAndFunctions(SgFile* file, std::vector<SgStatement*>& modulesAndFunctions);
|
||||||
void findModulesInFile(SgFile* file, std::vector<SgStatement*>& modules);
|
void findModulesInFile(SgFile* file, std::vector<SgStatement*>& modules);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2416"
|
#define VERSION_SPF "2417"
|
||||||
|
|||||||
Reference in New Issue
Block a user