fixed inliner
This commit is contained in:
@@ -264,7 +264,6 @@ static SgValueExp* zeroExpr = NULL;
|
|||||||
|
|
||||||
static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
|
static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (oneExpr == NULL)
|
if (oneExpr == NULL)
|
||||||
oneExpr = new SgValueExp(1);
|
oneExpr = new SgValueExp(1);
|
||||||
|
|
||||||
@@ -314,6 +313,8 @@ static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
|
|||||||
if (consistInAllocates != 1)
|
if (consistInAllocates != 1)
|
||||||
list = NULL;
|
list = NULL;
|
||||||
|
|
||||||
|
if (list == NULL)
|
||||||
|
__spf_print(1, "find for %s, consistInAllocates = %d", arrayS->identifier(), consistInAllocates);
|
||||||
checkNull(list, convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(list, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -365,10 +366,20 @@ static SgArrayRefExp* addressPass(SgArrayRefExp* result, SgArrayRefExp* arrayExp
|
|||||||
{
|
{
|
||||||
checkNull(boundsOld[z], convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(boundsOld[z], convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
checkNull(boundsNew[z], convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(boundsNew[z], convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
SgExpression* shift = NULL;
|
||||||
|
SgExpression& baseShift = (boundsNew[z]->copy() - boundsOld[z]->copy());
|
||||||
|
|
||||||
|
if (arrayExpNew->subscript(z) &&
|
||||||
|
!isEqExpressions(arrayExpNew->subscript(z), boundsNew[z], collection))
|
||||||
|
{
|
||||||
|
shift = &(arrayExpNew->subscript(z)->copy() - boundsNew[z]->copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
SgExpression& oldSub = arrayExpOld->subscript(z)->copy();
|
||||||
if (isEqExpressions(boundsOld[z], boundsNew[z], collection))
|
if (isEqExpressions(boundsOld[z], boundsNew[z], collection))
|
||||||
result->addSubscript(arrayExpOld->subscript(z)->copy());
|
result->addSubscript(shift ? (oldSub + *shift) : oldSub);
|
||||||
else
|
else
|
||||||
result->addSubscript(arrayExpOld->subscript(z)->copy() + (boundsNew[z]->copy() - boundsOld[z]->copy()));
|
result->addSubscript(shift ? (oldSub + baseShift + *shift) : (oldSub + baseShift));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -454,12 +465,19 @@ static SgExpression* doReplace(SgExpression* oldExp, SgExpression* newExp, map<S
|
|||||||
SgArrayRefExp* arrayExpOld = isSgArrayRefExp(oldExp);
|
SgArrayRefExp* arrayExpOld = isSgArrayRefExp(oldExp);
|
||||||
SgArrayRefExp* arrayExpNew = isSgArrayRefExp(newExp);
|
SgArrayRefExp* arrayExpNew = isSgArrayRefExp(newExp);
|
||||||
|
|
||||||
//arrayExpOld->unparsestdout();
|
/*arrayExpOld->unparsestdout();
|
||||||
//arrayExpNew->unparsestdout();
|
arrayExpNew->unparsestdout();
|
||||||
//printf("\n");
|
printf("\n");*/
|
||||||
|
|
||||||
auto boundsOld = getLowBounds(oldExp->symbol());
|
auto boundsOld = getLowBounds(oldExp->symbol());
|
||||||
auto boundsNew = getLowBounds(newExp->symbol());
|
auto boundsNew = getLowBounds(newExp->symbol());
|
||||||
|
|
||||||
|
/*for (auto& elem : boundsOld)
|
||||||
|
elem->unparsestdout();
|
||||||
|
printf("--\n");
|
||||||
|
for (auto& elem : boundsNew)
|
||||||
|
elem->unparsestdout();
|
||||||
|
printf("--\n");*/
|
||||||
|
|
||||||
const int numOldSubs = arrayExpOld->numberOfSubscripts();
|
const int numOldSubs = arrayExpOld->numberOfSubscripts();
|
||||||
const int numNewSubs = arrayExpNew->numberOfSubscripts();
|
const int numNewSubs = arrayExpNew->numberOfSubscripts();
|
||||||
@@ -508,7 +526,6 @@ static SgExpression* doReplace(SgExpression* oldExp, SgExpression* newExp, map<S
|
|||||||
result = addressPass(result, arrayExpOld, arrayExpNew, boundsOld, boundsNew, collection);
|
result = addressPass(result, arrayExpOld, arrayExpNew, boundsOld, boundsNew, collection);
|
||||||
for (int z = 0; z < boundsNew.size() - boundsOld.size(); ++z)
|
for (int z = 0; z < boundsNew.size() - boundsOld.size(); ++z)
|
||||||
result->addSubscript(arrayExpNew->subscript(boundsOld.size() + z)->copy());
|
result->addSubscript(arrayExpNew->subscript(boundsOld.size() + z)->copy());
|
||||||
|
|
||||||
retVal = result;
|
retVal = result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3080,11 +3080,15 @@ static set<FileInfo*> applyModuleDeclsForFile(FileInfo *forFile, const map<strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
string include = "";
|
string include = "";
|
||||||
|
int includeCount = 0;
|
||||||
set<string> included;
|
set<string> included;
|
||||||
for (auto& incl : toIncl)
|
for (auto& incl : toIncl)
|
||||||
{
|
{
|
||||||
if (included.find(incl) == included.end())
|
if (included.find(incl) == included.end())
|
||||||
|
{
|
||||||
include += " include '" + incl + "'\n";
|
include += " include '" + incl + "'\n";
|
||||||
|
includeCount++;
|
||||||
|
}
|
||||||
included.insert(incl);
|
included.insert(incl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3117,8 +3121,8 @@ static set<FileInfo*> applyModuleDeclsForFile(FileInfo *forFile, const map<strin
|
|||||||
includeLast += " include '" + incl + "'\n";
|
includeLast += " include '" + incl + "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (include != "")
|
if (includeCount)
|
||||||
include = "!SPF NUM FILES " + std::to_string(included.size()) + "\n" + include;
|
include = "!SPF NUM FILES " + std::to_string(includeCount) + "\n" + include;
|
||||||
|
|
||||||
const string data = include + mainText + includeLast;
|
const string data = include + mainText + includeLast;
|
||||||
__spf_print(1, "include to file %s before\n", forFile->fileName.c_str());
|
__spf_print(1, "include to file %s before\n", forFile->fileName.c_str());
|
||||||
@@ -4161,7 +4165,7 @@ SgProject* createProject(const char* proj_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
filterModuleUse(moduleUsesByFile, moduleDecls);
|
filterModuleUse(moduleUsesByFile, moduleDecls);
|
||||||
|
|
||||||
map<string, int> shifts;
|
map<string, int> shifts;
|
||||||
//shiftLines if modules included
|
//shiftLines if modules included
|
||||||
const string shiftInfo = "!SPF NUM FILES";
|
const string shiftInfo = "!SPF NUM FILES";
|
||||||
@@ -4200,7 +4204,6 @@ SgProject* createProject(const char* proj_name,
|
|||||||
for (int z = 0; z < project->numberOfFiles(); ++z)
|
for (int z = 0; z < project->numberOfFiles(); ++z)
|
||||||
{
|
{
|
||||||
SgFile* file = &(project->file(z));
|
SgFile* file = &(project->file(z));
|
||||||
|
|
||||||
for (SgStatement* st = file->firstStatement()->lexNext(); st; st = st->lexNext())
|
for (SgStatement* st = file->firstStatement()->lexNext(); st; st = st->lexNext())
|
||||||
{
|
{
|
||||||
string currF = st->fileName();
|
string currF = st->fileName();
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2271"
|
#define VERSION_SPF "2273"
|
||||||
|
|||||||
Reference in New Issue
Block a user