Skip to content

Commit

Permalink
Merge branch 'liao6/rose-dev' of ssh://rosecompiler2.llnl.gov:10022/r…
Browse files Browse the repository at this point in the history
…ose-compiler/rose
  • Loading branch information
chunhualiao committed Apr 26, 2021
2 parents 40404fa + 688db54 commit 871ad25
Show file tree
Hide file tree
Showing 30 changed files with 1,201 additions and 311 deletions.
2 changes: 1 addition & 1 deletion ROSE_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.29.0
0.11.29.4
2 changes: 1 addition & 1 deletion config/SCM_DATE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
110280007
110290004
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dnl DQ (1/11/2010): Consider handing configure options as specified at:
dnl https://projects.coin-or.org/BuildTools/wiki/user-configure

dnl The version number in the AC_INIT([ROSE], [0.11.29.0])
dnl do the replacement here in the configure file because AC_INIT([ROSE], [0.11.29.0])
dnl The version number in the AC_INIT([ROSE], [0.11.29.4])
dnl do the replacement here in the configure file because AC_INIT([ROSE], [0.11.29.4])
dnl shell variable.
AC_INIT([ROSE], [0.11.29.0])
AC_INIT([ROSE], [0.11.29.4])
AC_PREREQ([2.59])

# This one should perhaps be named ROSE_VERSION_STR instead of ROSE_SCM_VERSION_ID since it is not the SCM system's version
Expand Down
19 changes: 19 additions & 0 deletions src/ROSETTA/Grammar/Expression.code
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,7 @@ HEADER_JOVIAL_TABLE_PRESET_EXP_END

// Rasmussen (4/9/2021): Added SgJovialPresetPositionExp to support initialization of Jovial tables
HEADER_JOVIAL_PRESET_POSITION_EXP_START
int replace_expression (SgExpression *o, SgExpression *n);
HEADER_JOVIAL_PRESET_POSITION_EXP_END

HEADER_UPC_LOCAL_SIZEOF_EXPRESSION_START
Expand Down Expand Up @@ -9486,6 +9487,24 @@ SgJovialPresetPositionExp::get_type() const
ROSE_ASSERT(p_value);
return p_value->get_type();
}

int
SgJovialPresetPositionExp::replace_expression (SgExpression *o, SgExpression *n)
{
ROSE_ASSERT(o != NULL);
ROSE_ASSERT(n != NULL);

if (p_indices == o) {
p_indices = isSgExprListExp(n);
return p_indices != nullptr;
} else if (p_value) {
p_value = n;
return 1;
} else {
printf ("Warning: inside of SgUnaryOp::replace_expression original SgExpression unidentified \n");
return 0;
}
}
SOURCE_JOVIAL_PRESET_POSITION_EXP_END


Expand Down
4 changes: 2 additions & 2 deletions src/ROSETTA/src/statement.C
Original file line number Diff line number Diff line change
Expand Up @@ -3473,9 +3473,9 @@ Grammar::setUpStatements ()
"control_kind", "= SgProcessControlStatement::e_unknown",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
ProcessControlStatement.setDataPrototype ( "SgExpression*", "code", "= NULL",
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);
ProcessControlStatement.setDataPrototype ( "SgExpression*", "quiet", "= NULL",
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, NO_TRAVERSAL, NO_DELETE);
NO_CONSTRUCTOR_PARAMETER, BUILD_ACCESS_FUNCTIONS, DEF_TRAVERSAL, NO_DELETE);

// DQ (8/14/2007): Added new data members to Fortran IR nodes.
IOStatement.setFunctionPrototype ( "HEADER_IO_STATEMENT", "../Grammar/Statement.code" );
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/CxxFrontend/EDG_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.28.7
0.11.29.4
113 changes: 71 additions & 42 deletions src/frontend/Experimental_Ada_ROSE_Connection/AdaMaker.C
Original file line number Diff line number Diff line change
Expand Up @@ -1321,32 +1321,45 @@ namespace
}
*/

size_t char2Val(char c)
std::pair<size_t, bool>
check(size_t s, size_t m)
{
return std::make_pair(s, s < m);
}

std::pair<size_t, bool>
char2Val(char c, size_t max)
{
using ResultType = std::pair<size_t, bool>;

if ((c >= '0') && (c <= '9'))
return c - '0';
return check(c - '0', max);

if ((c >= 'A') && (c <= 'F'))
return c - 'A' + 10;
return check(c - 'A' + 10, max);

if ((c >= 'a') && (c <= 'f'))
return check(c - 'a' + 10, max);

ROSE_ASSERT((c >= 'a') && (c <= 'f'));
return c - 'a' + 10;
return ResultType{0, false};
}

template <class T>
std::pair<T, const char*>
parseDec(const char* buf, size_t base = 10, char delim = 0)
parseDec(const char* buf, size_t base = 10)
{
ROSE_ASSERT((*buf != 0) && (*buf != '#'));
ROSE_ASSERT((*buf != 0) && char2Val(*buf, base).second);

T res = 0;

while ((*buf != 0) && (*buf != '#') && (*buf != delim))
while (*buf != 0)
{
const size_t v = char2Val(*buf);
const auto v = char2Val(*buf, base);

if (!v.second)
return std::make_pair(res, buf);

ROSE_ASSERT(v < base);
res = res*base + v;
res = res*base + v.first;

++buf;

Expand All @@ -1363,17 +1376,20 @@ namespace
std::pair<T, const char*>
parseFrac(const char* buf, size_t base = 10)
{
ROSE_ASSERT((*buf != 0) && (*buf != '#'));
ROSE_ASSERT((*buf != 0) && char2Val(*buf, base).second);

T res = 0;
size_t divisor = 1*base;

while ((*buf != 0) && (*buf != '#'))
{
T v = char2Val(*buf);
const auto v = char2Val(*buf, base);

ROSE_ASSERT(v < base);
res += v/divisor;
ROSE_ASSERT(v.second);

T val = v.first;

res += val/divisor;
divisor = divisor*base;

++buf;
Expand Down Expand Up @@ -1411,8 +1427,36 @@ namespace

return std::make_pair(exp, buf);
}
}

template <class T>
T computeLiteral(T val, int base, int exp)
{
return val * std::pow(base, exp);
}


long int
basedLiteral(long int res, const char* cur, int base)
{
int exp = 0;

ROSE_ASSERT(*cur == '#');

++cur;
base = res;

std::tie(res, cur) = parseDec<long int>(cur, base);

if (*cur == '#')
{
++cur;

std::tie(exp, cur) = parseExp(cur);
}

return computeLiteral(res, base, exp);
}
}


template <>
Expand All @@ -1423,34 +1467,21 @@ int convAdaLiteral<int>(const char* img)
int exp = 0;
const char* cur = img;

std::tie(res, cur) = parseDec<long int>(cur);

// we just parsed the base
if (*cur == '#')
{
++cur;
base = res;

std::tie(res, cur) = parseDec<long int>(cur, base);
}
return basedLiteral(res, cur, base);

if (*cur == '#')
if (*cur == '.')
{
++cur;
logError() << "decimal literals not yet handled!" << std::endl;
long int decimal = 0;

std::tie(exp, cur) = parseExp(cur);
++cur;
std::tie(decimal, cur) = parseDec<long int>(cur);
}

//~ base = powInt(base, exp);
base = std::pow(base, exp);
std::tie(exp, cur) = parseExp(cur);

/*
logWarn() << "i: "
<< res << ' ' << base << ' ' << exp << '\n'
<< res * base
<< std::endl;
*/
return res * base;
return computeLiteral(res, base, exp);
}


Expand Down Expand Up @@ -1479,30 +1510,28 @@ long double convAdaLiteral<long double>(const char* img)
ROSE_ASSERT(*cur == '#');

++cur;
std::tie(dec, cur) = parseDec<long double>(cur, base, '.');
std::tie(dec, cur) = parseDec<long double>(cur, base);

if (*cur == '.')
{
++cur;
std::tie(frac, cur) = parseFrac<long double>(cur, base);
}

long double res = dec + frac;
const long double res = dec + frac;

ROSE_ASSERT(*cur == '#');
++cur;

std::tie(exp, cur) = parseExp(cur);

base = std::pow(base, exp);

/*
logWarn() << "r: "
<< res << ' ' << dec << '+' << frac << ' ' << base << ' ' << exp << '\n'
<< res * base
<< std::endl;
*/
return res * base;
return computeLiteral(res, base, exp);
}


Expand Down
31 changes: 16 additions & 15 deletions src/frontend/Experimental_Ada_ROSE_Connection/AdaStatement.C
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,12 @@ namespace

for (int i = 0; i < num; ++i)
{
ROSE_ASSERT(names.at(i).fullName == names.at(i).ident);
const NameCreator::result_container::value_type obj = names.at(i);

const std::string& name = names.at(i).fullName;
Element_ID id = names.at(i).id();
ROSE_ASSERT(obj.fullName == obj.ident);

const std::string& name = obj.fullName;
Element_ID id = obj.id();
SgInitializedName& dcl = mkInitializedName(name, dcltype, cloneIfNeeded(initexpr, initexpr && (i != 0)));

attachSourceLocation(dcl, retrieveAs<Element_Struct>(elemMap(), id), ctx);
Expand Down Expand Up @@ -725,27 +727,23 @@ namespace
return SG_DEREF(the_name);
}

SgAdaTaskBody&
getTaskBody(Declaration_Struct& decl, AstContext ctx)
void
fillTaskBody(Declaration_Struct& decl, SgAdaTaskBody& sgnode, AstContext ctx)
{
ROSE_ASSERT(decl.Declaration_Kind == A_Task_Body_Declaration);

SgAdaTaskBody& sgnode = mkAdaTaskBody();

{
ElemIdRange decls = idRange(decl.Body_Declarative_Items);

traverseIDs(decls, elemMap(), StmtCreator{ctx.scope_npc(sgnode)});
traverseIDs(decls, elemMap(), StmtCreator{ctx.scope(sgnode)});
}

{
ElemIdRange stmts = idRange(decl.Body_Statements);
LabelAndLoopManager lblmgr;

traverseIDs(stmts, elemMap(), StmtCreator{ctx.scope_npc(sgnode).labelsAndLoops(lblmgr)});
traverseIDs(stmts, elemMap(), StmtCreator{ctx.scope(sgnode).labelsAndLoops(lblmgr)});
}

return sgnode;
}

SgAdaTaskSpec&
Expand Down Expand Up @@ -2491,10 +2489,11 @@ void handleDeclaration(Element_Struct& elem, AstContext ctx, bool isPrivate)

if (range.size())
{
SgBasicBlock& pkgblock = mkBasicBlock();
LabelAndLoopManager lblmgr;
SgBasicBlock& pkgblock = mkBasicBlock();

pkgbody.append_statement(&pkgblock);
traverseIDs(range, elemMap(), StmtCreator{ctx.scope(pkgblock)});
traverseIDs(range, elemMap(), StmtCreator{ctx.scope(pkgblock).labelsAndLoops(lblmgr)});
placePragmas(decl.Pragmas, ctx, std::ref(pkgbody), std::ref(pkgblock));
}
else
Expand Down Expand Up @@ -2709,7 +2708,7 @@ void handleDeclaration(Element_Struct& elem, AstContext ctx, bool isPrivate)

TypeData ty = getTypeFoundation(adaname.ident, decl, ctx);
SgScopeStatement& scope = ctx.scope();
ROSE_ASSERT(scope.get_parent());
//~ ROSE_ASSERT(scope.get_parent());

Element_ID id = adaname.id();
SgDeclarationStatement* nondef = findFirst(asisTypes(), id);
Expand Down Expand Up @@ -2909,7 +2908,7 @@ void handleDeclaration(Element_Struct& elem, AstContext ctx, bool isPrivate)
{
logKind("A_Task_Body_Declaration");

SgAdaTaskBody& tskbody = getTaskBody(decl, ctx);
SgAdaTaskBody& tskbody = mkAdaTaskBody();
NameData adaname = singleName(decl, ctx);
Element_ID declID = decl.Corresponding_Declaration;
SgDeclarationStatement* tskdecl = findNode(asisDecls(), declID);
Expand All @@ -2928,6 +2927,8 @@ void handleDeclaration(Element_Struct& elem, AstContext ctx, bool isPrivate)

placePragmas(decl.Pragmas, ctx, std::ref(tskbody));

fillTaskBody(decl, tskbody, ctx);

/* unused fields:
bool Has_Task;
Pragma_Element_ID_List Pragmas;
Expand Down
7 changes: 6 additions & 1 deletion src/frontend/Experimental_Ada_ROSE_Connection/AdaType.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ namespace
ROSE_ASSERT(!FAIL_ON_ERROR);
logError() << "Unknown exception: " << ex.Name_Image << std::endl;

return mkInitializedName(ex.Name_Image, lookupNode(adaTypes(), AdaIdentifier{"Exception"}), nullptr);
// \todo create an SgInitializedName if the exception was not found
// \todo the exception could be from a renaming declaration
SgInitializedName& sgnode = mkInitializedName(ex.Name_Image, lookupNode(adaTypes(), AdaIdentifier{"Exception"}), nullptr);

sgnode.set_scope(&ctx.scope());
return sgnode;
}

SgNode&
Expand Down
Loading

0 comments on commit 871ad25

Please sign in to comment.