fixed inliner

This commit is contained in:
ALEXks
2024-02-11 21:09:44 +03:00
parent 147ca03733
commit 05bd8379db
3 changed files with 32 additions and 12 deletions

View File

@@ -264,7 +264,6 @@ static SgValueExp* zeroExpr = NULL;
static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
{
if (oneExpr == NULL)
oneExpr = new SgValueExp(1);
@@ -314,6 +313,8 @@ static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
if (consistInAllocates != 1)
list = NULL;
if (list == NULL)
__spf_print(1, "find for %s, consistInAllocates = %d", arrayS->identifier(), consistInAllocates);
checkNull(list, convertFileName(__FILE__).c_str(), __LINE__);
}
else
@@ -365,10 +366,20 @@ static SgArrayRefExp* addressPass(SgArrayRefExp* result, SgArrayRefExp* arrayExp
{
checkNull(boundsOld[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))
result->addSubscript(arrayExpOld->subscript(z)->copy());
result->addSubscript(shift ? (oldSub + *shift) : oldSub);
else
result->addSubscript(arrayExpOld->subscript(z)->copy() + (boundsNew[z]->copy() - boundsOld[z]->copy()));
result->addSubscript(shift ? (oldSub + baseShift + *shift) : (oldSub + baseShift));
}
return result;
}
@@ -454,12 +465,19 @@ static SgExpression* doReplace(SgExpression* oldExp, SgExpression* newExp, map<S
SgArrayRefExp* arrayExpOld = isSgArrayRefExp(oldExp);
SgArrayRefExp* arrayExpNew = isSgArrayRefExp(newExp);
//arrayExpOld->unparsestdout();
//arrayExpNew->unparsestdout();
//printf("\n");
/*arrayExpOld->unparsestdout();
arrayExpNew->unparsestdout();
printf("\n");*/
auto boundsOld = getLowBounds(oldExp->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 numNewSubs = arrayExpNew->numberOfSubscripts();
@@ -508,7 +526,6 @@ static SgExpression* doReplace(SgExpression* oldExp, SgExpression* newExp, map<S
result = addressPass(result, arrayExpOld, arrayExpNew, boundsOld, boundsNew, collection);
for (int z = 0; z < boundsNew.size() - boundsOld.size(); ++z)
result->addSubscript(arrayExpNew->subscript(boundsOld.size() + z)->copy());
retVal = result;
}
else

View File

@@ -3080,11 +3080,15 @@ static set<FileInfo*> applyModuleDeclsForFile(FileInfo *forFile, const map<strin
}
string include = "";
int includeCount = 0;
set<string> included;
for (auto& incl : toIncl)
{
if (included.find(incl) == included.end())
{
include += " include '" + incl + "'\n";
includeCount++;
}
included.insert(incl);
}
@@ -3117,8 +3121,8 @@ static set<FileInfo*> applyModuleDeclsForFile(FileInfo *forFile, const map<strin
includeLast += " include '" + incl + "'\n";
}
if (include != "")
include = "!SPF NUM FILES " + std::to_string(included.size()) + "\n" + include;
if (includeCount)
include = "!SPF NUM FILES " + std::to_string(includeCount) + "\n" + include;
const string data = include + mainText + includeLast;
__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);
map<string, int> shifts;
//shiftLines if modules included
const string shiftInfo = "!SPF NUM FILES";
@@ -4200,7 +4204,6 @@ SgProject* createProject(const char* proj_name,
for (int z = 0; z < project->numberOfFiles(); ++z)
{
SgFile* file = &(project->file(z));
for (SgStatement* st = file->firstStatement()->lexNext(); st; st = st->lexNext())
{
string currF = st->fileName();

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2271"
#define VERSION_SPF "2273"