Ejemplo n.º 1
0
   //! Setup MPI finalize 
  void setupMPIFinalize(SgSourceFile* sfile)
  {
    SgFunctionDeclaration* main_decl = findMain(sfile);
    // TODO: handle multiple files, some of them don't have main()
    ROSE_ASSERT (main_decl != NULL);
    SgFunctionDefinition* main_def = main_decl->get_definition();
    ROSE_ASSERT (main_def != NULL);
    SgBasicBlock* func_body = main_def->get_body();
    ROSE_ASSERT (func_body != NULL);

    SgStatement* mf = buildFunctionCallStmt ("MPI_Finalize", buildVoidType(), NULL, func_body );
    
    instrumentEndOfFunction (main_decl, mf);
  }
Ejemplo n.º 2
0
void MigrationOutliner::outline_ForToFunction(SgForStatement *f){
	#define TOOL "OutlineFor_ToFunction"
	string msg;
	msg = "START: outline For loops";
	DEBUG(TOOL,msg);

	//get parent function to create appropriate Name
	
	//append name to reflect position
	string addon = convertInt(counter);
	string outlineFuncName = "foorLOOP";
	outlineFuncName +=addon;
	++counter;
	//make parameterList
	SgFunctionParameterList *pList = new SgFunctionParameterList();
	
	//make the func
	SgFunctionDeclaration *outlined = buildDefiningFunctionDeclaration(outlineFuncName, buildVoidType(), pList, f->get_scope());
	//query for dependencies


//make function declaration copy at top?
//SgFunctionDeclaration* outlineFunc_Decl = buildNondefiningFunctionDeclaration(outlineFuncName, buildVoidType(), pList, f->get_scope());

//fill function with guts
SgStatement* loop_body = f->get_loop_body();
//SgBasicBlock* lbody = loop_body->get_definition();
ROSE_ASSERT(loop_body != NULL);
copyToFunctionBody(loop_body,outlined);
appendStatement(outlined, f->get_scope());
//add dependencies to function parameters

//insert funciton declaration in same file as where for loop originates

//insert function definition at EOF

}