本文整理汇总了C++中SgProject::get_fileList方法的典型用法代码示例。如果您正苦于以下问题:C++ SgProject::get_fileList方法的具体用法?C++ SgProject::get_fileList怎么用?C++ SgProject::get_fileList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgProject
的用法示例。
在下文中一共展示了SgProject::get_fileList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: backend
int
main ( int argc, char * argv[] )
{
// Initialize and check compatibility. See Rose::initialize
ROSE_INITIALIZE;
vector<string> argvList(argv, argv + argc);
SgProject* project = NULL;
bool removeCommandOption = true;
string pathToSkip;
// The specified path string will be put into "skipPathString" and then the option will be removed
if ( CommandlineProcessing::isOptionWithParameter(argvList,"-skipFile:","(path)",pathToSkip,removeCommandOption) )
{
printf ("Skip file containing path = %s \n",pathToSkip.c_str());
// Builds SgProject with valid but empty SgFile objects, but with all command line processing
// done. The frontend can then be invoked conditionally for each SgFile object.
project = frontendShell(argvList);
// Loop over all files in the SgProject (and call the frontend on a selected subset)
SgFilePtrList::iterator fileIterator = project->get_fileList().begin();
while (fileIterator != project->get_fileList().end())
{
string filename = (*fileIterator)->get_sourceFileNameWithPath();
// Skip processing of files from a specific directory
// If there is a match between the path and any part of the filename then skip processing this file
if (filename.find(pathToSkip) != string::npos)
{
printf ("Skipping call to the frontend for this file (%s) \n",filename.c_str());
}
else
{
// Call the front-end (which will internally call EDG).
// Note: The commandline can be reset by using set_originalCommandLineArgumentList().
int EDG_FrontEndErrorCode = (*fileIterator)->callFrontEnd();
// Warnings from EDG processing are OK, but not errors (EDG detail)
ROSE_ASSERT (EDG_FrontEndErrorCode <= 3);
}
// increment the file list iterator
fileIterator++;
}
}
else
{
// This call the frontend automatically for all source files on the command line
project = frontend(argvList);
}
// Call the backend, where files were not processed the original file will be compiled
// directly by the backend (vendor) compiler. The SgFile objects here would also be
// looped over and unparsed and or compiled separately.
return backend(project);
}
示例4: 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);
}
示例5: 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;
}
示例6: 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;
OmpSupport::useDDE = true; // using Device Data Environment to manage data on GPUs
vector<string> argvList(argv, argv + argc);
// -rose:openmp:nodde to turn off the use of DDE runtime
// This option does not work with collapse() now. It is only for debugging and seeing old code only
if(CommandlineProcessing::isOption (argvList,
"-rose:openmp:",
"nodde",
true) ||
CommandlineProcessing::isOption (argvList,
"--rose:openmp:",
"nodde",
true))
{
OmpSupport::useDDE = false;
cout<<"OpenMP Lowering is set to turn off the use of DDE (Device Data Environment) functions ..."<<endl;
}
SgProject *project = frontend (argvList);
//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);
}
示例7: timer
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);
// Build a vector of strings to represent the command line arguments.
std::vector<std::string> sourceCommandline = std::vector<std::string>(argv, argv + argc);
sourceCommandline.push_back("-rose:unparse_tokens");
SgProject* project = frontend(sourceCommandline);
AstTests::runAllTests(project);
// Evaluate the number of tokens generated for each file on the command line.
SgFilePtrList & fileList = project->get_fileList();
for (size_t i=0; i < fileList.size(); i++)
{
SgSourceFile* sourceFile = isSgSourceFile(fileList[i]);
if (sourceFile != NULL)
{
size_t numberOfTokens = sourceFile->get_token_list().size();
printf ("Number of tokens in file %s = %zu \n",sourceFile->get_sourceFileNameWithPath().c_str(),numberOfTokens);
if (numberOfTokens == 0)
{
// We output an error, but since this test is only presently valid for fortran files it is not serious.
if (sourceFile->get_Fortran_only() == true)
{
printf ("Warning: numberOfTokens in file equal zero (could be an error). \n");
}
else
{
printf ("Warning: token evaluation only valid for Fortran files at present. \n");
}
}
}
else
{
printf ("Warning, token evaluation only valid for source files. \n");
}
}
// 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);
}
示例8: isSgScopeStatement
/*
* The function
* findScope()
* takes as a parameter a SgNode* which is a SgStatement*. It returns a SgNodePtrVector of all
* preceding scopes the SgStatement is in.
*
*/
SgNodePtrVector
findScopes (SgNode * astNode)
{
ROSE_ASSERT (isSgStatement (astNode));
SgNodePtrVector returnVector;
SgScopeStatement *currentScope;
if (isSgScopeStatement (astNode))
{
currentScope = isSgScopeStatement (astNode);
ROSE_ASSERT (currentScope != NULL);
returnVector.push_back (astNode);
}
else
{
SgStatement *sageStatement = isSgStatement (astNode);
ROSE_ASSERT (sageStatement != NULL);
currentScope = sageStatement->get_scope ();
ROSE_ASSERT (currentScope != NULL);
returnVector.push_back (currentScope);
}
while (currentScope->variantT () != V_SgGlobal)
{
currentScope = currentScope->get_scope ();
ROSE_ASSERT (currentScope != NULL);
returnVector.push_back (currentScope);
}
//Must also include the Global Scopes of the other files in the project
if (currentScope->variantT () == V_SgGlobal)
{
SgFile *sageFile = isSgFile ((currentScope)->get_parent ());
ROSE_ASSERT (sageFile != NULL);
SgProject *sageProject = isSgProject (sageFile->get_parent ());
ROSE_ASSERT (sageProject != NULL);
//Get a list of all files in the current project
const SgFilePtrList& sageFilePtrList = sageProject->get_fileList ();
//Iterate over the list of files to find all Global Scopes
SgNodePtrVector globalScopes;
for (unsigned int i = 0; i < sageFilePtrList.size (); i += 1)
{
const SgSourceFile *sageFile = isSgSourceFile (sageFilePtrList[i]);
ROSE_ASSERT (sageFile != NULL);
SgGlobal *sageGlobal = sageFile->get_globalScope();
ROSE_ASSERT (sageGlobal != NULL);
returnVector.push_back (sageGlobal);
}
}
return returnVector;
};
示例9: main
int main( int argc, char * argv[] )
{
vector<string> argvList(argv, argv + argc);
SgProject* project = frontend(argvList);
if (project->get_fileList().size() ==0)
return 0;
// Prepare the Def-Use Analysis
DFAnalysis* defuse = new DefUseAnalysis(project);
bool debug = false;
defuse->run(debug);
if (debug)
defuse->dfaToDOT();
// Prepare liveness analysis
LivenessAnalysis* liv = new LivenessAnalysis(debug,(DefUseAnalysis*)defuse);
ROSE_ASSERT (liv != NULL);
// Find all function definitions
Rose_STL_Container<SgNode*> nodeList= NodeQuery::querySubTree(project, V_SgFunctionDefinition);
std::vector <FilteredCFGNode < IsDFAFilter > > dfaFunctions;
Rose_STL_Container<SgNode*>::const_iterator i = nodeList.begin();
bool abortme=false;
for (; i!=nodeList.end();++i)
{
SgFunctionDefinition* func = isSgFunctionDefinition(*i);
// run liveness analysis
FilteredCFGNode <IsDFAFilter> rem_source = liv->run(func,abortme);
if (abortme) {
cerr<<"Error: Liveness analysis is ABORTING ." << endl;
ROSE_ASSERT(false);
}
if (rem_source.getNode()!=NULL)
dfaFunctions.push_back(rem_source);
}
SgFilePtrList file_list = project->get_fileList();
std::string firstFileName = StringUtility::stripPathFromFileName(file_list[0]->getFileName());
std::string fileName = firstFileName+"_liveness.dot" ;
std::ofstream fs(fileName.c_str());
dfaToDot(fs, string("var"), dfaFunctions, (DefUseAnalysis*)defuse, liv);
fs.close();
return 0;
}
示例10: sageProject
int
main ( int argc, char * argv[] )
{
if (argc <= 1) {
PrintUsage(argv[0]);
return -1;
}
SgProject sageProject ( (int)argc,argv);
SageInterface::changeAllBodiesToBlocks(&sageProject);
CmdOptions::GetInstance()->SetOptions(argc, argv);
int filenum = sageProject.numberOfFiles();
for (int i = 0; i < filenum; ++i) {
SgSourceFile* sageFile = isSgSourceFile(sageProject.get_fileList()[i]);
ROSE_ASSERT(sageFile != NULL);
TestCFGWrap::AnalysisDomain t = UseOA(argc, argv)? TestCFGWrap::OA : TestCFGWrap::ROSE;
string filename = sageFile->getFileName();
#if 0 // Test harness uses stdout rather than a temporary file
string txtname = filename.substr(filename.rfind('/')+1) + ".outx";
TestCFGWrap_Text txtop(t,txtname);
#else
TestCFGWrap_Stdout txtop(t);
#endif
//string dotname = string(strrchr(sageFile.getFileName(),'/')+1) + ".dot";
string dotname = filename.substr(filename.rfind('/')+1) + ".dot";
TestCFGWrap_DOT dotop(t);
SgGlobal *root = sageFile->get_globalScope();
SgDeclarationStatementPtrList& declList = root->get_declarations ();
for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) {
SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
if (func == 0)
continue;
SgFunctionDefinition *defn = func->get_definition();
if (defn == 0)
continue;
SgNode* stmts = defn;
if (GenerateDOT(argc, argv)) {
dotop(stmts, dotname);
}
else {
txtop(stmts);
}
}
}
return 0;
}
示例11: sageProject
int
main ( int argc, char * argv[] )
{
if (argc <= 1) {
PrintUsage(argv[0]);
return -1;
}
SgProject sageProject ( (int)argc,argv);
SageInterface::changeAllBodiesToBlocks(&sageProject);
CmdOptions::GetInstance()->SetOptions(argc, argv);
int filenum = sageProject.numberOfFiles();
for (int i = 0; i < filenum; ++i) {
SgSourceFile* sageFile = isSgSourceFile(sageProject.get_fileList()[i]);
ROSE_ASSERT(sageFile != NULL);
SgGlobal *root = sageFile->get_globalScope();
SgDeclarationStatementPtrList& declList = root->get_declarations ();
for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) {
SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
if (func == 0)
continue;
SgFunctionDefinition *defn = func->get_definition();
if (defn == 0)
continue;
SgBasicBlock *stmts = defn->get_body();
AstInterfaceImpl scope(stmts);
AstInterface fa(&scope);
StmtVarAliasCollect alias;
alias(fa, AstNodePtrImpl(defn));
if (GenerateDOT(argc, argv)) {
string name = string(strrchr(sageFile->getFileName().c_str(),'/')+1) + ".dot";
TestDUWrap_DOT op(alias);
op(fa, defn, name);
}
else {
string name = string(strrchr(sageFile->getFileName().c_str(),'/')+1) + ".outx";
#if 0 // Test harness uses stdout now rather than a temporary file [Robb P. Matzke 2013-02-25]
TestDUWrap_Text op(alias,name);
#else
TestDUWrap_Stdout op(alias);
#endif
op(fa, defn);
}
}
}
return 0;
}
示例12: os
void
WalrusGraph::generateWalrusGraph( SgNode* node, string outputFilename )
{
// Notes: The generated file in the Walrus format typically requies some editing by hand.
// For large files the "comma" always has to be remove at the end of the edge list and the node list.
// For Binary files the first edge which points to itself ("source=0 distination=0") has to be removed.
// Then the last entry for the node list has to be removed.
// Then is can often work.
SgProject* project = isSgProject(node);
if (project != NULL)
{
printf ("Found the SgProject \n");
SgFile* fileNode = project->get_fileList()[0];
if (isSgBinaryComposite(fileNode) != NULL)
{
if (project->get_binary_only() == false)
printf ("This should have been set already, what is wrong here! \n");
project->set_binary_only(true);
}
if (project->get_binary_only() == true)
{
printf ("Found a binary file \n");
WalrusGraph::isBinary = true;
}
}
Counter traversal;
traversal.traverse(node,preorder);
printf ("node_to_index_map.size() = %zu \n",node_to_index_map.size());
filebuf fb;
fb.open (outputFilename.c_str(),ios::out);
ostream os(&fb);
ostream outputFile(&fb);
outputFilePtr = &outputFile;
ROSE_ASSERT(outputFilePtr != NULL);
generateEdges(node);
generateNodes(node);
outputFile.flush();
}
示例13: main
/*
* Main Function
*/
int main(int argc, char * argv[]) {
// Build the AST used by ROSE
SgProject* sageProject = frontend(argc, argv);
// For each source file in the project
SgFilePtrList & ptr_list = sageProject->get_fileList();
for (SgFilePtrList::iterator iter = ptr_list.begin(); iter
!= ptr_list.end(); iter++) {
SgFile* sageFile = (*iter);
SgSourceFile * sfile = isSgSourceFile(sageFile);
ROSE_ASSERT(sfile);
SgGlobal *root = sfile->get_globalScope();
SgDeclarationStatementPtrList& declList = root->get_declarations();
// Insert header file
insertHeader(sfile);
//For each function body in the scope
for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p
!= declList.end(); ++p) {
SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
if (func == 0)
continue;
SgFunctionDefinition *defn = func->get_definition();
if (defn == 0)
continue;
//ignore functions in system headers, Can keep them to test robustness
if (defn->get_file_info()->get_filename()
!= sageFile->get_file_info()->get_filename())
continue;
SgBasicBlock *body = defn->get_body();
ROSE_ASSERT(body);
vector<SgForStatement*> loops = querySubTree<SgForStatement> (defn,
V_SgForStatement);
if (loops.size() == 0)
continue;
visitLoops(loops);
}
// Generate source code from AST and call the vendor's compiler
return backend(sageProject);
}
}
示例14: processTemplateHandlingOptions
void processTemplateHandlingOptions( SgNode* node )
{
// DQ (7/7/2005): Introduce tracking of performance of ROSE.
TimingPerformance timer ("Fixup templateHandlingOptions:");
ROSE_ASSERT(node != NULL);
SgFile* file = TransformationSupport::getFile(node);
if (file == NULL)
{
// printf ("Detected AST fragement not associated with primary AST, ignore template handling ... \n");
SgProject *project = isSgProject(node);
if (project != NULL)
{
// GB (9/4/2009): Added this case for handling SgProject nodes. We do
// this simply by iterating over the list of files in the project and
// calling this function recursively. This is only one level of
// recursion since files are not nested.
SgFilePtrList &files = project->get_fileList();
SgFilePtrList::iterator fIterator;
for (fIterator = files.begin(); fIterator != files.end(); ++fIterator)
{
SgFile *file = *fIterator;
ROSE_ASSERT(file != NULL);
markTemplateInstantiationsForOutput(file);
}
}
}
else
{
bool buildImplicitTemplates = (file != NULL) && (file->get_no_implicit_templates() == false);
bool buildImplicitInlineTemplates = (file != NULL) && (file->get_no_implicit_inline_templates() == false);
#if 0
printf ("buildImplicitTemplates = %s \n",buildImplicitTemplates ? "true" : "false");
printf ("buildImplicitInlineTemplates = %s \n",buildImplicitInlineTemplates ? "true" : "false");
#endif
// This simplifies how the traversal is called!
ProcessTemplateHandlingOptions astFixupTraversal(file,buildImplicitTemplates,buildImplicitInlineTemplates);
// I think the default should be preorder so that the interfaces would be more uniform
astFixupTraversal.traverse(node,preorder);
}
}
示例15: main
int main(int argc, char * argv[])
{
//this adds -rose:openmp:ast_only -linearize args
MintOptions::setInternalCommandLineArgs(argc, argv);
vector<string> argvList(argv, argv + argc);
MintOptions::GetInstance()->SetMintOptions(argvList);
//isCFileNameSuffix ();
//call the front end with -rose:openmp:ast_only and
//then call the lowering explicitly
SgProject *project = frontend (argc, argv);
//currently we only handle single input file
SgSourceFile* file = isSgSourceFile(project->get_fileList()[0]);
MintTools::setOutputFileName(isSgFile(file));
//insert cuda header files. is there any?
MintCudaMidend::insertHeaders(project);
//Now we have the AST and search for Mint pragmas
MintCudaMidend::lowerMinttoCuda(file);
if(MintOptions::GetInstance()->linearize()){
cout << " INFO:Mint: flattening the array accesses" << endl;
MintArrayInterface::linearizeArrays(file);
}
cout << " INFO:Mint: calling ROSE backend" << endl;
project->unparse();
//return backend(project);
cout << endl <<" INFO:Mint: Good Job. Translation is done!" << endl << endl;
return 0;
}