Exemple #1
0
//note that we keep mint for pragma as well 
//#pragma mint for
//#pragma omp for
void MintCudaMidend::replaceMintForWithOmpFor(SgSourceFile* file)
{
  Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(file, V_SgPragmaDeclaration);
  Rose_STL_Container<SgNode*>::reverse_iterator nodeListIterator = nodeList.rbegin();

  for ( ;nodeListIterator !=nodeList.rend();  ++nodeListIterator)
    {
      SgPragmaDeclaration* node = isSgPragmaDeclaration(*nodeListIterator);
      ROSE_ASSERT(node != NULL);

      //checks if the syntax is correct and the parallel region is followed by 
      //a basic block
      if(MintPragmas::isForLoopPragma(node))
	{
	  SgStatement* loop = getNextStatement(node);
	  ROSE_ASSERT(loop);
	  
	  if(isSgForStatement(loop))
	    {
	      removeStatement(loop);

	      SgOmpForStatement* omp_stmt = new SgOmpForStatement(NULL, loop);
	      setOneSourcePositionForTransformation(omp_stmt);
	      loop->set_parent(omp_stmt);

	      insertStatementAfter(node, omp_stmt);

	    }
	}
    }
}
SgIfStmt *
RoseStatementsAndExpressionsBuilder::buildIfStatementWithEmptyElse (
    SgExpression * ifGuard, SgScopeStatement * thenBlock)
{
  using namespace SageBuilder;
  using namespace SageInterface;

  SgStatement * ifGuardStatement = buildExprStatement (ifGuard);

  SgIfStmt * ifStatement = new SgIfStmt (ifGuardStatement, thenBlock, NULL);
  ifStatement->setCaseInsensitive (true);
  ifStatement->set_use_then_keyword (true);
  ifStatement->set_has_end_statement (true);

  setOneSourcePositionForTransformation (ifStatement);

  ifGuardStatement->set_parent (ifStatement);
  thenBlock->set_parent (ifStatement);

  return ifStatement;
}