Merge pull request 'REMOVE_DIST_ARRAYS_FROM_IO: improve parsing of IO operators, fix substitution borders' (#63) from replace_io_arrays into master

Reviewed-on: #63
This commit was merged in pull request #63.
This commit is contained in:
2025-06-15 17:07:00 +00:00
2 changed files with 27 additions and 17 deletions

View File

@@ -88,24 +88,36 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
case READ_STAT: case READ_STAT:
case WRITE_STAT: case WRITE_STAT:
{ {
SgExpression* spec = stat->expr(1); SgExpression* spec = stat->expr(1);
__spf_print(DEBUG_TRACE, "[%d: %s (%d)]\n", 2000, spec->rhs()->unparse(), spec->rhs()->variant());
if (!spec || spec->variant() != EXPR_LIST || if (spec->variant() == SPEC_PAIR)
spec->lhs()->variant() != SPEC_PAIR ||
!spec->rhs() || !spec->rhs()->lhs() || spec->rhs()->lhs()->variant() != SPEC_PAIR)
{ {
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); if (spec->rhs()->variant() != KEYWORD_VAL || spec->rhs()->sunparse() != "*")
return; {
need_replace = true;
break;
}
} }
else
{
while (spec)
{
auto *kv = spec->lhs();
if (!kv || kv->variant() != SPEC_PAIR || !kv->rhs())
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return;
}
SgExpression* unit_val = spec->lhs()->rhs(), * fmt_val = spec->rhs()->lhs()->rhs(); if (kv->rhs()->variant() != KEYWORD_VAL || kv->rhs()->sunparse() != "*")
{
need_replace = true;
break;
}
if (unit_val->variant() != KEYWORD_VAL || unit_val->sunparse() != "*" || spec = spec->rhs();
fmt_val->variant() != KEYWORD_VAL || fmt_val->sunparse() != "*") }
need_replace = true; }
break;
} }
default: default:
break; break;
@@ -203,11 +215,9 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace
while (start->lexNext() && !isSgExecutableStatement(start->lexNext())) while (start->lexNext() && !isSgExecutableStatement(start->lexNext()))
start = start->lexNext(); start = start->lexNext();
auto* stop = last->lexNext();
bool has_read = false, has_write = false; bool has_read = false, has_write = false;
for (auto* st = start->lexNext(); st && st != stop->lexPrev(); st = st->lexNext()) for (auto* st = start->lexNext(); st && st != last; st = st->lexNext())
replaceArrayRec(replace_symb, replace_by, st, has_read, has_write); replaceArrayRec(replace_symb, replace_by, st, has_read, has_write);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2428" #define VERSION_SPF "2429"