Skip to content

Commit

Permalink
Remove OmpAttribute leftover in omp AST constructor
Browse files Browse the repository at this point in the history
It's also related to issue #98.
According to the comments, the post-processing function determines "omp target begin/end".
They are not listed on the OpenMP 5.0 specs.
  • Loading branch information
ouankou committed Jun 4, 2021
1 parent 3c27c16 commit 4bf0e48
Showing 1 changed file with 0 additions and 154 deletions.
154 changes: 0 additions & 154 deletions src/frontend/SageIII/ompAstConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,48 +1087,6 @@ namespace OmpSupport
return result;
}

//A helper function to set SgVarRefExpPtrList from OmpAttribute's construct-varlist map
static void setClauseVariableList(SgOmpVariablesClause* target, OmpAttribute* att, omp_construct_enum key)
{
ROSE_ASSERT(target&&att);
// build variable list
std::vector<std::pair<std::string,SgNode* > > varlist = att->getVariableList(key);
#if 0
// Liao 6/10/2010 we relax this assertion to workaround
// shared(num_threads), a clause keyword is used as a variable
// we skip variable list of shared() for now so shared clause will have empty variable list
#endif
ROSE_ASSERT(varlist.size()!=0);
std::vector<std::pair<std::string,SgNode* > >::iterator iter;
for (iter = varlist.begin(); iter!= varlist.end(); iter ++)
{
// cout<<"debug setClauseVariableList: " << target <<":"<<(*iter).second->class_name() <<endl;
// We now start to use SgExpression* to store variables showing up in a varlist
if (SgInitializedName* iname = isSgInitializedName((*iter).second))
{
//target->get_variables().push_back(iname);
// Liao 1/27/2010, fix the empty parent pointer of the SgVarRefExp here
SgVarRefExp * var_ref = buildVarRefExp(iname);
target->get_variables()->get_expressions().push_back(var_ref);
var_ref->set_parent(target);
}
else if (SgPntrArrRefExp* aref= isSgPntrArrRefExp((*iter).second))
{
target->get_variables()->get_expressions().push_back(aref);
aref->set_parent(target);
}
else if (SgVarRefExp* vref = isSgVarRefExp((*iter).second))
{
target->get_variables()->get_expressions().push_back(vref);
vref->set_parent(target);
}
else
{
cerr<<"error: unhandled type of variable within a list:"<< ((*iter).second)->class_name();
ROSE_ASSERT(false);
}
}
}

static SgOmpClause::omp_depobj_modifier_enum toSgOmpClauseDepobjModifierType(OpenMPDepobjUpdateClauseDependeceType type)
{
Expand Down Expand Up @@ -1616,115 +1574,6 @@ namespace OmpSupport
convert_OpenMP_pragma_to_AST( sageFilePtr);
}

// Liao 12/21/2015 special handling to support target begin and target end aimed for MPI code generation
// In this case, we already use postParsingProcessing () to wrap the statements in between into a basic block after "target begin"
// The "target end" attribute should be ignored.
// Skip "target end" here.
void postParsingProcessing (SgSourceFile *sageFilePtr)
{
// This experimental support should only happen to C/C++ code for now
if (sageFilePtr->get_Fortran_only()||sageFilePtr->get_F77_only()||sageFilePtr->get_F90_only()||
sageFilePtr->get_F95_only() || sageFilePtr->get_F2003_only())
{
return;
}

list<SgPragmaDeclaration* >::reverse_iterator iter; // bottom up handling for nested cases
ROSE_ASSERT (sageFilePtr != NULL);
for (iter = omp_pragma_list.rbegin(); iter != omp_pragma_list.rend(); iter ++)
{
// Liao, 11/18/2009
// It is possible that several source files showing up in a single compilation line
// We have to check if the pragma declaration's file information matches the current file being processed
// Otherwise we will process the same pragma declaration multiple times!!
SgPragmaDeclaration* decl = *iter;
// Liao, 2/8/2010
// Some pragmas are set to "transformation generated" when we fix scopes for some pragma under single statement block
// e.g if ()
// #pragma
// do_sth()
// will be changed to
// if ()
// {
// #pragma
// do_sth()
// }
// So we process a pragma if it is either within the same file or marked as transformation
if (decl->get_file_info()->get_filename()!= sageFilePtr->get_file_info()->get_filename()
&& !(decl->get_file_info()->isTransformation()))
continue;
// Liao 10/19/2010
// We now support OpenMP AST construction for both C/C++ and Fortran
// But we allow Fortran End directives to exist after -rose:openmp:ast_only
// Otherwise the code unparsed will be illegal Fortran code (No {} blocks in Fortran)
// if (isFortranEndDirective(getOmpAttribute(decl)->getOmpDirectiveType()))
// continue;
ROSE_ASSERT (decl->get_scope() !=NULL);
ROSE_ASSERT (decl->get_parent() !=NULL);
//cout<<"debug: convert_OpenMP_pragma_to_AST() handling pragma at "<<decl<<endl;
//ROSE_ASSERT (decl->get_file_info()->get_filename() != string("transformation"));
OmpAttributeList* oattlist= getOmpAttributeList(decl);
// oattlist could be empty due to ompparser
// need a way to determine the actual cause.
if (oattlist == NULL) {
continue;
};
ROSE_ASSERT (oattlist != NULL) ;
vector <OmpAttribute* > ompattlist = oattlist->ompAttriList;
ROSE_ASSERT (ompattlist.size() != 0) ;
ROSE_ASSERT (ompattlist.size() == 1) ; // when do we have multiple directives associated with one pragma?

// Liao 12/21/2015 special handling to support target begin and target end aimed for MPI code generation
// In this case, we already use postParsingProcessing () to wrap the statements in between into a basic block after "target begin"
// The "target end" attribute should be ignored.
// Skip "target end" here.
// find omp target begin
OmpAttribute* oa = getOmpAttribute (decl);
ROSE_ASSERT (oa != NULL);
omp_construct_enum omp_type = oa->getOmpDirectiveType();
// The first attribute should always be the directive type
ROSE_ASSERT(isDirective(omp_type));

if ( omp_type == e_target && oa->hasClause(e_begin))
{
// find the matching end decl with "target end" attribute
SgPragmaDeclaration* end_decl = NULL;
SgStatement* next_stmt = getNextStatement(decl);
std::vector<SgStatement*> affected_stmts; // statements which are inside the begin .. end pair
while (next_stmt!= NULL)
{
end_decl = isSgPragmaDeclaration (next_stmt);
if (end_decl) // candidate pragma declaration
if (getOmpConstructEnum(end_decl) == e_target) // It is target directive
{
OmpAttribute* oa2 = getOmpAttribute (end_decl);
ROSE_ASSERT (oa2 != NULL);
if (oa2->hasClause (e_end))
break; // found the matching target end, break out the while loop
}

// No match found yet? store the current stmt into the affected stmt list
end_decl = NULL; // MUST reset to NULL if not a match
affected_stmts.push_back(next_stmt);
// prev_stmt = next_stmt; // save previous statement
next_stmt = getNextStatement (next_stmt);
} // end while

if (end_decl == NULL)
{
cerr<<"postParsingProcessing(): cannot find required end directive for: "<< endl;
cerr<<decl->get_pragma()->get_pragma()<<endl;
ROSE_ASSERT (false);
} // end if sanity check

//at this point, we have found a matching end directive/pragma
ROSE_ASSERT (end_decl);
ensureSingleStmtOrBasicBlock(decl, affected_stmts);
removeStatement(end_decl);

} // end if "target begin"
} // end for
} // end postParsingProcessing()

// Liao, 5/31/2009 an entry point for OpenMP related processing
// including parsing, AST construction, and later on translation
Expand Down Expand Up @@ -1753,9 +1602,6 @@ namespace OmpSupport
// parse OpenMP directives and attach OmpAttributeList to relevant SgNode
attachOmpAttributeInfo(sageFilePtr);

// Additional processing of the AST after parsing
postParsingProcessing (sageFilePtr);

// stop here if only OpenMP parsing is requested
if (sageFilePtr->get_openmp_parse_only())
{
Expand Down

0 comments on commit 4bf0e48

Please sign in to comment.