本文整理汇总了C++中SgProject类的典型用法代码示例。如果您正苦于以下问题:C++ SgProject类的具体用法?C++ SgProject怎么用?C++ SgProject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SgProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main ( int argc, char* argv[] )
{
ROSE_INITIALIZE;
if (SgProject::get_verbose() > 0)
printf ("In preprocessor.C: main() \n");
SgProject* project = frontend(argc,argv);
ROSE_ASSERT (project != NULL);
Rose_STL_Container<SgNode*> nodeList;
nodeList = NodeQuery::querySubTree (project,V_SgForStatement);
printf ("\nnodeList.size() = %zu \n",nodeList.size());
Rose_STL_Container<SgNode*>::iterator i = nodeList.begin();
while (i != nodeList.end())
{
Sg_File_Info & fileInfo = *((*i)->get_file_info());
printf ("Query node = %p = %s in %s \n ----- at line %d on column %d \n",
*i,(*i)->sage_class_name(),fileInfo.get_filename(),
fileInfo.get_line(), fileInfo.get_col());
i++;
}
if (project->get_verbose() > 0)
printf ("Calling the backend() \n");
return 0;
}
示例2: main
int main(int argc, char **argv)
{
std::vector<std::string> argvList(argv, argv + argc);
//Read the comparison file
std::string graphCompareOutput = "";
CommandlineProcessing::isOptionWithParameter(argvList, "-compare:", "(graph)", graphCompareOutput, true);
CommandlineProcessing::removeArgsWithParameters(argvList, "-compare:");
//Run frontend
SgProject* project = frontend(argvList);
ROSE_ASSERT(project != NULL);
// Build the callgraph
CallGraphBuilder cgb(project);
cgb.buildCallGraph(OnlyCurrentDirectory());
if (graphCompareOutput == "")
graphCompareOutput = ((project->get_outputFileName()) + ".cg.dmp");
cout << "Writing custom compare to: " << graphCompareOutput << endl;
SgIncidenceDirectedGraph *newGraph = cgb.getGraph();
sortedCallGraphDump(graphCompareOutput, newGraph);
return 0;
}
示例3: main
int
main(int argc, char* argv[])
{
// This program test the conversion of the ROSE AST to n ATerm and back to a ROSE AST.
// Generate a ROSE AST as input.
// printf ("Building the ROSE AST \n");
SgProject* project = frontend(argc,argv);
// printf ("Done: Building the ROSE AST \n");
// Output an optional graph of the AST (just the tree, when active)
// generateDOT(*project);
SgFile* roseFile = project->operator[](0);
ROSE_ASSERT(roseFile != NULL);
SgSourceFile* sourceFile = isSgSourceFile(roseFile);
ROSE_ASSERT(sourceFile != NULL);
// printf ("Calling ATinit \n");
ATerm bottom;
ATinit(argc, argv, &bottom);
// printf ("Calling convertAstNodeToRoseAterm \n");
// ATerm term = convertNodeToAterm(project);
// ATerm term = convertNodeToAterm(sourceFile);
// ATerm term = convertAstNodeToRoseAterm(sourceFile);
// Actually this implementation in convertNodeToAterm already adds the pointer value to the aterm, so we can just return this Aterm directly.
ATerm term = convertNodeToAterm(sourceFile);
// printf ("DONE: Calling convertAstNodeToRoseAterm term = %p \n",term);
ROSE_ASSERT (term != NULL);
string roseAST_filename = project->get_file(0).getFileName();
char* s = strdup(roseAST_filename.c_str());
string file_basename = basename(s);
// ATerm_Graph::graph_aterm_ast(term,file_basename);
#if 1
// DQ (9/17/2014): Adding test for conversion of Aterm back to AST.
printf ("Testing the reverse process to generate the ROSE AST from the Aterm \n");
SgNode* rootOfAST = convertAtermToNode(term);
printf ("rootOfAST = %p = %s \n",rootOfAST,rootOfAST->class_name().c_str());
#endif
// generateDOT(*project);
generateDOTforMultipleFile(*project, "AFTER_ATERM");
// Output an optional graph of the AST (the whole graph, of bounded complexity, when active)
const int MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH = 5000;
generateAstGraph(project,MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH,"AFTER_ATERM");
#if 0
printf ("Program Terminated Normally \n");
#endif
return 0;
}
示例4: main
int main ( int argc, char* argv[] ) {
SgProject * project = frontend ( argc , argv ) ;
Rose_STL_Container<SgNode*> pragma_decls = NodeQuery::querySubTree(project, V_SgPragmaDeclaration);
Rose_STL_Container<SgNode*>::iterator it;
for (it = pragma_decls.begin(); it != pragma_decls.end(); it++) {
SgPragmaDeclaration * pragma_decl = isSgPragmaDeclaration(*it);
try {
PolyhedricAnnotation::parse(pragma_decl);
}
catch (Exception::ExceptionBase & e) {
e.print(std::cerr);
continue;
}
PolyhedricAnnotation::PragmaPolyhedralProgram & polyhedral_program =
PolyhedricAnnotation::getPolyhedralProgram<SgPragmaDeclaration, SgExprStatement, RoseVariable>(pragma_decl);
Scheduling::PragmaSchedule schedule(polyhedral_program, 0);
CodeGeneration::generateAndReplace(schedule);
}
project->unparse();
return 0;
}
示例5: main
int
main ( int argc, char * argv[] )
{
// Main Function for default example ROSE Preprocessor
// This is an example of a preprocessor that can be built with ROSE
// This example tests the ROSE infrastructure
ios::sync_with_stdio(); // Syncs C++ and C I/O subsystems!
// Declare usage (if incorrect number of inputs):
if (argc == 1)
{
// Print usage and exit with exit status == 1
Rose::usage (1);
}
// Build the project object which we will fill up with multiple files and use as a
// handle for all processing of the AST(s) associated with one or more source files.
SgProject sageProject (argc,argv);
// Warnings from EDG processing are OK but not errors
// ROSE_ASSERT (EDG_FrontEndErrorCode <= 3);
// cout << "EDG/SAGE Processing DONE! (manipulate AST with ROSE ...) " << endl;
// DQ (10/17/2004): Added internal testing of AST
AstTests::runAllTests(&sageProject);
SIDL_TreeTraversal treeTraversal(chooseConstructor(&sageProject));
MethodSearchVisitor treeVisitor(&sageProject);
treeVisitor.traverseInputFiles(&sageProject, preorder);
// Ignore the return value since we don't need it
treeTraversal.traverseInputFiles(&sageProject);
AstDOTGeneration dotgen;
dotgen.generateInputFiles(&sageProject, AstDOTGeneration::PREORDER);
cout << "ROSE Processing DONE! (no need to call unparse or backend C++ compiler ...) " << endl;
#if 0
// DQ (10/17/2004): This seems to be a problem, some sort of infinit loop is generated in the unparser!
// the test code has been transfrered to another location for internal testing. for now this should
// be commented out. It is not required for Babel Processing. This is now fixed!
// Generate the final C++ source code from the potentially modified SAGE AST
// sageProject.set_verbose(true);
sageProject.unparse();
#endif
// Later we want to call babel to process the generated SIDL file and generate the imple files which
// we will process as part of the next phase of work to completely automate the process.
int finalCombinedExitStatus = 0;
printf ("Program Compiled Normally (exit status = %d)! \n\n\n\n",finalCombinedExitStatus);
// either of these will work similarly
// exit (finalCombinedExitStatus);
return finalCombinedExitStatus;
}
示例6: storeProjectState
void ProjectManager::storeProjectState()
{
QSettings s;
s.remove("LoadedProjects");
s.beginGroup("LoadedProjects");
s.beginWriteArray("Projects");
for(int p=0; p<rootNode->childrenCount(); p++)
{
ProjectNode * projNode = dynamic_cast<ProjectNode*>(rootNode->child(p));
s.setArrayIndex(p);
s.setValue("Name",projNode->getName());
SgProject * sgProj = projNode->getSgProject();
s.beginWriteArray("files");
for(int i=0; i < sgProj->numberOfFiles(); i++)
{
QString name = (*sgProj)[i]->getFileName().c_str();
s.setArrayIndex(i);
s.setValue("name",name);
}
s.endArray();
}
s.endArray(); //Projects
s.endGroup();
}
示例7: main
int main (int argc, char* argv[])
{
// Main Function for default example ROSE Preprocessor
// This is an example of a preprocessor that can be built with ROSE
// Build the project object (AST) which we will fill up with multiple files and use as a
// handle for all processing of the AST(s) associated with one or more source files.
vector<string> argvList(argv, argv + argc);
VectorCmdOptions::GetInstance()->SetOptions(argvList);
SgProject* sageProject = frontend(argvList);
// FixSgProject(sageProject);
// AstTests::runAllTests(const_cast<SgProject*>(project));
AstTests::runAllTests(sageProject);
PRE::partialRedundancyElimination(sageProject);
// AstPDFGeneration().generateInputFiles(sageProject);
AstTests::runAllTests(sageProject);
// AstPDFGeneration().generateInputFiles(sageProject);
// Generate the final C++ source code from the potentially modified SAGE AST
sageProject->unparse();
// What remains is to run the specified compiler (typically the C++ compiler) using
// the generated output file (unparsed and transformed application code) to generate
// an object file.
// int finalCombinedExitStatus = sageProject.compileOutput();
// return exit code from complilation of generated (unparsed) code
return 0;
}
示例8: main
int
main( int argc, char * argv[] )
{
// Introduces tracking of performance of ROSE at the top most level.
TimingPerformance timer ("AST translation (main): time (sec) = ",true);
SgProject* project = frontend(argc,argv);
AstTests::runAllTests(project);
// Output statistics about how ROSE was used...
if (project->get_verbose() > 1)
{
std::cout << AstNodeStatistics::traversalStatistics(project);
std::cout << AstNodeStatistics::IRnodeUsageStatistics();
}
// Just set the project, the report will be generated upon calling the destructor for "timer"
// Use option "-rose:verbose 2" to see the report.
timer.set_project(project);
// Skip calling the typical backend for ROSE (not required for just testing analysis)
// This backend calls the backend compiler using the original input source file list.
return backendCompilesUsingOriginalInputFile(project);
}
示例9: main
//! A test main program
int main ( int argc, char * argv[] )
{
std::vector <std::string> argvList (argv, argv + argc);
// turn on OpenMP parsing support for device() map (a[][] dist_data())
argvList.push_back("-rose:openmp:parse_only");
SgProject* project = frontend(argvList); //frontendConstantFolding);
ROSE_ASSERT(project != NULL);
// Assuming single input file for this prototype
ROSE_ASSERT (project->get_fileList().size() ==1);
SgFile * cur_file = project->get_fileList()[0];
SgSourceFile* sfile = isSgSourceFile(cur_file);
setupMPIInit (sfile);
setupMPIFinalize (sfile);
#if 0
// old V 0.1
std::vector <MPI_PragmaAttribute*> pragma_attribute_list;
// Parsing all relevant pragmas, generate MPI_Pragma_Attribute_List.
parsePragmas (sfile, pragma_attribute_list);
translatePragmas (pragma_attribute_list);
#else
// newer V 0.2
lower_xomp (sfile);
#endif
AstTests::runAllTests(project);
return backend(project);
// return 0;
}
示例10: main
int main (int argc, char* argv[]) {
// Main Function for default example ROSE Preprocessor
// This is an example of a preprocessor that can be built with ROSE
// Build the project object (AST) which we will fill up with multiple files and use as a
// handle for all processing of the AST(s) associated with one or more source files.
SgProject* sageProject = frontend(argc,argv);
simpleIndexFiniteDifferencing(sageProject);
FixSgProject(*sageProject);
// partialRedundancyElimination(sageProject);
// AstPDFGeneration().generateInputFiles(sageProject);
// Generate the final C++ source code from the potentially modified SAGE AST
sageProject->unparse();
// What remains is to run the specified compiler (typically the C++ compiler) using
// the generated output file (unparsed and transformed application code) to generate
// an object file.
// int finalCombinedExitStatus = sageProject->compileOutput();
// return exit code from complilation of generated (unparsed) code
return 0;
}
示例11: main
int main(int argc, char ** argv) {
std::vector<std::string> args(argv, argv + argc);
#if defined(TILEK_ACCELERATOR)
# if defined(TILEK_TARGET_OPENCL)
args.push_back("-DSKIP_OPENCL_SPECIFIC_DEFINITION");
# endif
#endif
SgProject * project = new SgProject(args);
assert(project->numberOfFiles() == 1);
SgSourceFile * source_file = isSgSourceFile(project->get_fileList()[0]);
assert(source_file != NULL);
std::string filename = source_file->get_sourceFileNameWithoutPath();
std::string basename = filename.substr(0, filename.find_last_of('.'));
KLT::DLX::Compiler< ::DLX::TileK::language_t, ::KLT::TileK::Generator> compiler(project, KLT_PATH, TILEK_PATH, basename);
// MFB::api_t * api = compiler.getDriver().getAPI();
// dump_api(api);
compiler.compile(project);
project->unparse();
return 0;
}
示例12: main
int
main ( int argc, char* argv[] )
{
// Main Function for default example ROSE Preprocessor
// This is an example of a preprocessor that can be built with ROSE
// This example can be used to test the ROSE infrastructure
ios::sync_with_stdio(); // Syncs C++ and C I/O subsystems!
if (SgProject::get_verbose() > 0)
printf ("In preprocessor.C: main() \n");
SgProject* project = frontend(argc,argv);
ROSE_ASSERT (project != NULL);
#if 0
// This fails for test2005_63.C but Rich has fixed this
// by updating the pdf library we are using within ROSE.
printf ("Generate the pdf output of the SAGE III AST \n");
generatePDF ( *project );
#endif
#if 0
printf ("Generate the dot output of the SAGE III AST \n");
generateDOT ( *project );
#endif
#if 1
// DQ (2/6/2004): These tests fail in Coco for test2004_14.C
AstTests::runAllTests(const_cast<SgProject*>(project));
#else
printf ("Skipped agressive (slow) internal consistancy tests! \n");
#endif
if (project->get_verbose() > 0)
printf ("Calling the AST copy mechanism \n");
// Demonstrate the copying of the whole AST
SgProject* newProject = static_cast<SgProject*>(copyAST(project));
ROSE_ASSERT(newProject != NULL);
printf ("Running tests on copy of AST \n");
AstTests::runAllTests(newProject);
if (project->get_verbose() > 0)
printf ("Calling the backend() \n");
int errorCode = 0;
errorCode = backend(project);
// DQ (7/7/2005): Only output the performance report if verbose is set (greater than zero)
if (project->get_verbose() > 0)
{
// Output any saved performance data (see ROSE/src/astDiagnostics/AstPerformance.h)
AstPerformance::generateReport();
}
// printf ("Exiting with errorCode = %d \n",errorCode);
return errorCode;
}
示例13: main
int main(int argc, char * argv[])
{
// This flag can skip insertion of XOMP_init() and XOMP_terminate(), both of which are defined in libxomp.a
// But somehow nvcc cannot link the entire libxomp.a with the cuda object file
// TODO: ultimate solution is to outline all CUDA code into a separate file and keep the original file type intact
OmpSupport::enable_accelerator = true;
SgProject *project = frontend (argc, argv);
//TODO: turn this back on once blockDim.x * blockIdx.x + threadIdx.x is built properly in omp_lowering.cpp
// AstTests::runAllTests(project);
// change .c suffix to .cu suffix
// We only process one single input file at a time
ROSE_ASSERT (project->get_fileList().size() ==1);
SgFile * cur_file = project->get_fileList()[0];
string orig_name = cur_file->get_file_info()->get_filenameString();
string file_suffix = StringUtility::fileNameSuffix(orig_name);
// We only allow C file to be compatible with nvcc CUDA compiler
ROSE_ASSERT (CommandlineProcessing::isCFileNameSuffix(file_suffix));
orig_name = StringUtility::stripPathFromFileName(orig_name);
string naked_name = StringUtility::stripFileSuffixFromFileName(orig_name);
cur_file->set_unparse_output_filename("rose_"+naked_name+".cu");
return backend(project);
}
示例14: main
int
main ( int argc, char* argv[] )
{
// DQ (7/7/2005): Introduce tracking of performance of ROSE.
TimingPerformance timer ("AST check Main:");
SgProject* project = frontend(argc,argv);
ROSE_ASSERT (project != NULL);
findSwitchWithoutDefault(project);
// if (project->get_verbose() > 0)
// printf ("Calling the backend() \n");
int errorCode = 0;
// errorCode = backend(project);
// Just set the project, the report will be generated upon calling the destructor for "timer"
timer.set_project(project);
if (project->get_verbose() > 0)
{
// Output any saved performance data (see ROSE/src/astDiagnostics/AstPerformance.h)
AstPerformance::generateReport();
}
// return 0;
// printf ("Exiting with errorCode = %d \n",errorCode);
return errorCode;
}
示例15: main
int main(int argc, char * argv[])
{
SgProject *project = frontend (argc, argv);
// Generate a file handle from the first file of the project
abstract_node* file_node= buildroseNode((project->get_fileList())[0]);
abstract_handle* handle0 = new abstract_handle(file_node);
cout<<"Created a file handle:\n"<<handle0->toString()<<endl<<endl;;
//Create a handle to a namespace given its name and parent handle
string input1="NamespaceDeclarationStatement<name,space1>";
abstract_handle* handle1 = new abstract_handle(handle0,input1);
cout<<"Created a handle:\n"<<handle1->toString()<<endl<<endl;
cout<<"It points to:\n"<<handle1->getNode()->toString()<<endl<<endl;
// Create a handle within the file, given a string specifying
// its construct type (class declaration) and source position
string input="ClassDeclaration<position,4.3-9.2>";
abstract_handle* handle2 = new abstract_handle(handle0,input);
cout<<"Created a handle:\n"<<handle2->toString()<<endl<<endl;
cout<<"It points to:\n"<<handle2->getNode()->toString()<<endl<<endl;;
// find the second function declaration within handle2
abstract_handle handle3(handle2,"FunctionDeclaration<numbering,2>");
cout<<"Created a handle:\n"<<handle3.toString()<<endl<<endl;
cout<<"It points to:\n"<<handle3.getNode()->toString()<<endl;
// Generate source code from AST and call the vendor's compiler
return backend(project);
}