fixed different names of same arrays in common
This commit is contained in:
@@ -853,12 +853,21 @@ static pair<string, string> getModuleRename(const set<SgStatement*>& allocatable
|
||||
return make_pair("", "");
|
||||
}
|
||||
|
||||
static void doRename(string& str, const pair<string, string>& renamePair)
|
||||
{
|
||||
auto it = str.find(renamePair.first);
|
||||
if (it != string::npos)
|
||||
if (str[it + renamePair.first.size()] == '(' && str[it - 1] == ' ')
|
||||
str = str.replace(it, renamePair.first.size(), renamePair.second);
|
||||
}
|
||||
|
||||
static pair<DIST::Array*, string>
|
||||
getNewDirective(const string &fullArrayName,
|
||||
const vector<string> &distrRules,
|
||||
const vector<string> &alignRules,
|
||||
const DataDirective &dataDir,
|
||||
const set<SgStatement*>& allocatableStmts)
|
||||
const set<SgStatement*>& allocatableStmts,
|
||||
const pair<string, int>& position_decl)
|
||||
{
|
||||
string out = "";
|
||||
DIST::Array* outA = NULL;
|
||||
@@ -877,7 +886,8 @@ getNewDirective(const string &fullArrayName,
|
||||
|
||||
for (int i = 0; i < dataDir.alignRules.size(); ++i)
|
||||
{
|
||||
if (dataDir.alignRules[i].alignArray->GetName() == fullArrayName)
|
||||
auto alignArray = dataDir.alignRules[i].alignArray;
|
||||
if (alignArray->GetName() == fullArrayName)
|
||||
{
|
||||
string rule = alignRules[i];
|
||||
if (allocatableStmts.size())
|
||||
@@ -889,21 +899,21 @@ getNewDirective(const string &fullArrayName,
|
||||
it = rule.find("ALIGN", it + 7);
|
||||
}
|
||||
|
||||
auto renamePair = getModuleRename(allocatableStmts, dataDir.alignRules[i].alignArray);
|
||||
if (renamePair.first != "")
|
||||
{
|
||||
it = rule.find(renamePair.first);
|
||||
if (it != string::npos)
|
||||
if (rule[it + renamePair.first.size()] == '(' && rule[it - 1] == ' ')
|
||||
rule = rule.replace(it, renamePair.first.size(), renamePair.second);
|
||||
}
|
||||
auto renamePair = getModuleRename(allocatableStmts, alignArray);
|
||||
doRename(rule, renamePair);
|
||||
}
|
||||
else if (alignArray->GetLocation().first == DIST::l_COMMON)
|
||||
{
|
||||
auto symb = alignArray->GetDeclSymbol(position_decl);
|
||||
if (symb->identifier() != alignArray->GetShortName())
|
||||
doRename(rule, make_pair(alignArray->GetShortName(), symb->identifier()));
|
||||
}
|
||||
|
||||
out += "!DVM$ " + rule + "\n";
|
||||
if (!out_free_form)
|
||||
out = splitDirective(out);
|
||||
|
||||
return make_pair(dataDir.alignRules[i].alignArray, out);
|
||||
return make_pair(alignArray, out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1743,7 +1753,7 @@ void insertDistributionToFile(SgFile *file, const char *fin_name, const DataDire
|
||||
if (allocatableStmtsCopy.size())
|
||||
allocatableStmts = filterAllocateStats(file, allocatableStmtsCopy, currSymb->identifier());
|
||||
|
||||
pair<DIST::Array*, string> dirWithArray = getNewDirective(fullArrayName, distrRules, alignRules, dataDir, allocatableStmts);
|
||||
pair<DIST::Array*, string> dirWithArray = getNewDirective(fullArrayName, distrRules, alignRules, dataDir, allocatableStmts, make_pair(st->fileName(), st->lineNumber()));
|
||||
|
||||
string toInsert = dirWithArray.second;
|
||||
if (toInsert != "")
|
||||
@@ -1975,20 +1985,27 @@ void insertDistributionToFile(SgFile *file, const char *fin_name, const DataDire
|
||||
set<string> toInsertArrays;
|
||||
for (auto &array : dynamicArraysLocal)
|
||||
{
|
||||
string name = array->GetShortName();
|
||||
if (array->GetLocation().first == DIST::l_COMMON)
|
||||
{
|
||||
auto symb = array->GetDeclSymbol(make_pair(st->fileName(), st->lineNumber()));
|
||||
name = symb->identifier();
|
||||
}
|
||||
|
||||
if (extractDir)
|
||||
{
|
||||
if (dynamicArraysAdded.find(array->GetShortName()) != dynamicArraysAdded.end())
|
||||
if (dynamicArraysAdded.find(name) != dynamicArraysAdded.end())
|
||||
{
|
||||
dynamicArraysAdded.erase(array->GetShortName());
|
||||
toInsertArrays.insert(array->GetShortName());
|
||||
dynamicArraysAdded.erase(name);
|
||||
toInsertArrays.insert(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dynamicArraysAdded.find(array->GetShortName()) == dynamicArraysAdded.end())
|
||||
if (dynamicArraysAdded.find(name) == dynamicArraysAdded.end())
|
||||
{
|
||||
dynamicArraysAdded.insert(array->GetShortName());
|
||||
toInsertArrays.insert(array->GetShortName());
|
||||
dynamicArraysAdded.insert(name);
|
||||
toInsertArrays.insert(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2145,7 +2162,14 @@ void insertShadowSpecToFile(SgFile *file, const char *fin_name, const set<string
|
||||
|
||||
if (needToGen)
|
||||
{
|
||||
string shadowSpecInsert = "!DVM$ SHADOW " + array->GetShortName() + "(";
|
||||
string name = array->GetShortName();
|
||||
if (array->GetLocation().first == DIST::l_COMMON)
|
||||
{
|
||||
auto symb = array->GetDeclSymbol(make_pair(st->fileName(), st->lineNumber()));
|
||||
name = symb->identifier();
|
||||
}
|
||||
|
||||
string shadowSpecInsert = "!DVM$ SHADOW " + name + "(";
|
||||
for (int k = 0; k < currSpec.size(); ++k)
|
||||
{
|
||||
char buf[256];
|
||||
@@ -2157,7 +2181,7 @@ void insertShadowSpecToFile(SgFile *file, const char *fin_name, const set<string
|
||||
shadowSpecInsert += ")\n";
|
||||
|
||||
shadowsSpecsString.push_back(shadowSpecInsert);
|
||||
pair<SgExpression*, SgExpression*> newSpec = genShadowSpec(file, make_pair(array->GetShortName(), currSpec));
|
||||
pair<SgExpression*, SgExpression*> newSpec = genShadowSpec(file, make_pair(name, currSpec));
|
||||
if (newSpec.first == NULL || newSpec.second == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
shadowsSpecs.push_back(newSpec);
|
||||
|
||||
Reference in New Issue
Block a user