fixed implicit and imtent insertion
This commit is contained in:
@@ -793,10 +793,7 @@ static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, co
|
||||
continue;
|
||||
|
||||
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
||||
{
|
||||
st = st->lastNodeOfStmt();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (st->variant() == ASSIGN_STAT)
|
||||
{
|
||||
@@ -961,6 +958,15 @@ static void fillCommons(FuncInfo *currInfo, const map<string, vector<SgExpressio
|
||||
}
|
||||
}
|
||||
|
||||
static void printActiveLines(const set<SgStatement*>& activeOps)
|
||||
{
|
||||
set<int> lines;
|
||||
for (auto& st : activeOps)
|
||||
lines.insert(st->lineNumber());
|
||||
for (auto& line : lines)
|
||||
printf("%d\n", line);
|
||||
}
|
||||
|
||||
static FuncInfo* createNewFuction(const string& funcName, SgStatement *st, SgStatement* entry,
|
||||
vector<Messages>& messagesForFile,
|
||||
const map<string, vector<SgExpression*>>& commonBlocks,
|
||||
@@ -993,7 +999,6 @@ static FuncInfo* createNewFuction(const string& funcName, SgStatement *st, SgSta
|
||||
}
|
||||
|
||||
currInfo->funcParams.completeParams();
|
||||
|
||||
return currInfo;
|
||||
}
|
||||
|
||||
@@ -1089,7 +1094,6 @@ static FuncInfo* analyzeFunction(const string& funcName, const string& containsP
|
||||
isSgExecutableStatement(st) &&
|
||||
activeOps.find(st) == activeOps.end())
|
||||
{
|
||||
st = st->lastNodeOfStmt();
|
||||
st = st->lexNext();
|
||||
continue;
|
||||
}
|
||||
@@ -1197,7 +1201,7 @@ static FuncInfo* analyzeFunction(const string& funcName, const string& containsP
|
||||
return procInfo;
|
||||
}
|
||||
|
||||
static set<SgStatement*> fillActiveOperators(const vector<SAPFOR::BasicBlock*>& blocks)
|
||||
static set<SgStatement*> fillActiveOperators(SgStatement* func, const vector<SAPFOR::BasicBlock*>& blocks)
|
||||
{
|
||||
if (blocks.size() == 0)
|
||||
return set<SgStatement*>();
|
||||
@@ -1233,6 +1237,28 @@ static set<SgStatement*> fillActiveOperators(const vector<SAPFOR::BasicBlock*>&
|
||||
}
|
||||
}
|
||||
|
||||
//complete blocked statements
|
||||
for (auto st = func->lexNext(); st != func->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
if (st->variant() == CONTAINS_STMT)
|
||||
break;
|
||||
|
||||
if (st->variant() == SWITCH_NODE)
|
||||
{
|
||||
auto select = isSgSwitchStmt(st);
|
||||
int numOfCases = select->numberOfCaseOptions();
|
||||
for (int z = 0; z < numOfCases; ++z)
|
||||
{
|
||||
auto caseOp = isSgCaseOptionStmt(select->caseOption(z));
|
||||
if (active.count(caseOp))
|
||||
{
|
||||
active.insert(st);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
@@ -1319,7 +1345,7 @@ void functionAnalyzer(SgFile *file, map<string, vector<FuncInfo*>> &allFuncInfo,
|
||||
if (tmpInfoInIR.count(function) == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
activeOps = fillActiveOperators(fullIR[tmpInfoInIR[function]]);
|
||||
activeOps = fillActiveOperators((isEntry ? function->controlParent() : function), fullIR[tmpInfoInIR[function]]);
|
||||
activeOps.insert(function);
|
||||
if (isEntry)
|
||||
activeOps.insert(function->controlParent());
|
||||
|
||||
@@ -826,8 +826,11 @@ static void insertStmtToModule(const map<string, SgStatement*>& moduleStmts, con
|
||||
SgStatement* borderStmt = new SgStatement(VAR_DECL);
|
||||
proc_moduleF->insertStmtAfter(*borderStmt, *proc_moduleF);
|
||||
|
||||
for (const auto& [varName, varStmt] : moduleStmts)
|
||||
for (auto& stat : moduleStmts)
|
||||
{
|
||||
const auto& varName = stat.first;
|
||||
SgStatement* varStmt = stat.second;
|
||||
|
||||
string varNameNoPref = varName;
|
||||
varNameNoPref.erase(0, prefixLen + 1);
|
||||
|
||||
|
||||
@@ -434,25 +434,20 @@ static void insertIntents(set<string>& identificators, SgStatement* header, cons
|
||||
}
|
||||
|
||||
SgExpression* attr = new SgExpression(intentVariant);
|
||||
SgExpression* args = NULL;
|
||||
vector<SgExpression*> args;
|
||||
for (auto& par : identificators)
|
||||
{
|
||||
if (parSym.count(par) == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
auto s = parSym.at(par);
|
||||
|
||||
SgExprListExp* tempArgs = new SgExprListExp();
|
||||
SgVarRefExp* tempPar = new SgVarRefExp(s);
|
||||
tempArgs->setLhs(tempPar);
|
||||
if (args)
|
||||
tempArgs->setRhs(args);
|
||||
args = tempArgs;
|
||||
auto s = parSym.at(par);
|
||||
args.push_back(new SgVarRefExp(s));
|
||||
s->setAttribute(s->attributes() | intentBit);
|
||||
}
|
||||
|
||||
if (args)
|
||||
if (args.size())
|
||||
{
|
||||
SgIntentStmt* intent = new SgIntentStmt(*args, *attr);
|
||||
SgIntentStmt* intent = new SgIntentStmt(*makeExprList(args), *attr);
|
||||
lastDecl->insertStmtAfter(*intent, (header == lastDecl) ? *header : *lastDecl->controlParent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,17 +39,15 @@ static void FindAllVars(SgExpression* expr, set<SgSymbol*>& allVars, set<SgSymbo
|
||||
if (var == VAR_REF || var == ARRAY_REF || var == FUNC_CALL)
|
||||
{
|
||||
auto s = expr->symbol();
|
||||
if ((s->attributes() & EXTERNAL_BIT))
|
||||
if (var == FUNC_CALL /*(s->attributes() & EXTERNAL_BIT)*/)
|
||||
{
|
||||
if (var == FUNC_CALL && !IS_BY_USE(s) && s->scope() == scope)
|
||||
if (!IS_BY_USE(s) /* && s->scope() == scope*/)
|
||||
allVars.insert(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IS_BY_USE(s) && s->scope() == scope)
|
||||
{
|
||||
allVars.insert(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (var == CONST_REF)
|
||||
@@ -210,6 +208,15 @@ static map<char, SgType*> FunctionImplicitCheck(SgStatement* function, const map
|
||||
functionSymbs.insert(hedr->resultName()->identifier());
|
||||
}
|
||||
|
||||
auto prog = isSgProgHedrStmt(function);
|
||||
if (prog)
|
||||
{
|
||||
for (int z = 0; z < prog->numberOfInternalSubroutinesDefined(); ++z)
|
||||
functionSymbs.insert(prog->internalSubroutine(z)->symbol()->identifier());
|
||||
for (int z = 0; z < prog->numberOfInternalFunctionsDefined(); ++z)
|
||||
functionSymbs.insert(prog->internalFunction(z)->symbol()->identifier());
|
||||
}
|
||||
|
||||
for (auto st = function->lexNext(); st != endOfFunc && st->variant() != CONTAINS_STMT; st = st->lexNext())
|
||||
{
|
||||
if (skip.count(st->variant()))
|
||||
@@ -247,7 +254,6 @@ static map<char, SgType*> FunctionImplicitCheck(SgStatement* function, const map
|
||||
}
|
||||
|
||||
//add parameters
|
||||
auto prog = isSgProgHedrStmt(function);
|
||||
if (prog)
|
||||
{
|
||||
for (int z = 0; z < prog->numberOfParameters(); ++z)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2343"
|
||||
#define VERSION_SPF "2346"
|
||||
|
||||
Reference in New Issue
Block a user