sageInterface.h

Go to the documentation of this file.
00001 #ifndef ROSE_SAGE_INTERFACE
00002 #define ROSE_SAGE_INTERFACE
00003 
00004 #include "sage3basic.hhh"
00005 #include <stdint.h>
00006 #include <utility>
00007 
00008 #if 0   // FMZ(07/07/2010): the argument "nextErrorCode" should be call-by-reference
00009 SgFile* determineFileType ( std::vector<std::string> argv, int nextErrorCode, SgProject* project );
00010 #else
00011 SgFile* determineFileType ( std::vector<std::string> argv, int& nextErrorCode, SgProject* project );
00012 #endif
00013 
00014 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
00015 #include "rewrite.h"
00016 #endif
00017 
00018 // DQ (7/20/2008): Added support for unparsing abitrary strings in the unparser.
00019 #include "astUnparseAttribute.h"
00020 #include <set>
00021 
00022 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
00023 #include "LivenessAnalysis.h"
00024 #include "abstract_handle.h"
00025 #include "ClassHierarchyGraph.h"
00026 #endif
00027 
00028 // DQ (8/19/2004): Moved from ROSE/src/midend/astRewriteMechanism/rewrite.h
00030 std::string getVariantName (VariantT v);
00031 
00032 // DQ (12/9/2004): Qing, Rich and Dan have decided to start this namespace within ROSE
00033 // This namespace is specific to interface functions that operate on the Sage III AST.
00034 // The name was chosen so as not to conflict with other classes within ROSE.
00035 // This will become the future home of many interface functions which operate on
00036 // the AST and which are generally useful to users.  As a namespace multiple files can be used
00037 // to represent the compete interface and different developers may contribute interface
00038 // functions easily.
00039 
00040 // Constructor handling: (We have sageBuilder.h now for this purpose, Liao 2/1/2008)
00041 //     We could add simpler layers of support for construction of IR nodes by
00042 // hiding many details in "makeSg***()" functions. Such functions would
00043 // return pointers to the associated Sg*** objects and would be able to hide
00044 // many IR specific details, including:
00045 //      memory handling
00046 //      optional parameter settings not often required
00047 //      use of Sg_File_Info objects (and setting them as transformations)
00048 //
00049 // namespace AST_Interface  (this name is taken already by some of Qing's work :-)
00050 
00052 #define TRANS_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode()
00053 
00054 //------------------------------------------------------------------------
00084 namespace SageInterface
00085 {
00087 extern int gensym_counter;
00088 
00089 // tps : 28 Oct 2008 - support for finding the main interpretation
00090  SgAsmInterpretation* getMainInterpretation(SgAsmGenericFile* file);
00091 
00093 uint64_t getAsmConstant(SgAsmValueExpression* e);
00094 
00096 int64_t getAsmSignedConstant(SgAsmValueExpression *e);
00097 
00099  void addMessageStatement( SgStatement* stmt, std::string message );
00100 
00102   class UniqueNameAttribute : public AstAttribute
00103   {
00104     private:
00105      std::string name;
00106     public:
00107      UniqueNameAttribute(std::string n="") {name =n; };
00108      void set_name (std::string n) {name = n;};
00109      std::string get_name () {return name;};
00110   };
00111 
00112 // DQ (3/2/2009): Added support for collectiong an merging the referenced symbols in the outlined
00113 // function into the list used to edit the outlined code subtree to fixup references (from symbols
00114 // in the original file to the symbols in the newer separate file).
00115 // typedef rose_hash::unordered_map<SgNode*, SgNode*, hash_nodeptr> ReplacementMapType;
00116 // void supplementReplacementSymbolMap ( const ReplacementMapTraversal::ReplacementMapType & inputReplacementMap );
00117 
00118 // CH (4/9/2010): Use boost::hash instead
00119 //#ifdef _MSC_VER
00120 #if 0
00121 inline size_t hash_value(SgNode* t) {return (size_t)t;}
00122 #endif
00123 
00124 struct hash_nodeptr
00125    {
00126 // CH (4/9/2010): Use boost::hash instead
00127 //#ifndef _MSC_VER
00128 #if 0
00129            //rose_hash::hash<char*> hasher;
00130 #endif
00131      public:
00132           size_t operator()(SgNode* node) const
00133              {
00134 // CH (4/9/2010): Use boost::hash instead
00135 //#ifdef _MSC_VER
00136  #if 0
00137                                   return (size_t) hash_value(node);
00138  #else
00139                                   return (size_t) node;
00140  #endif
00141                    }
00142     };
00143 
00144   void supplementReplacementSymbolMap ( rose_hash::unordered_map<SgNode*, SgNode*, hash_nodeptr> & inputReplacementMap );
00145 
00146  //------------------------------------------------------------------------
00148 
00151    // Liao 1/22/2008, used for get symbols for generating variable reference nodes
00152    // ! Find a variable symbol in current and ancestor scopes for a given name
00153    SgVariableSymbol *lookupVariableSymbolInParentScopes (const SgName & name,
00154                                                          SgScopeStatement *currentScope=NULL);
00156    SgSymbol *lookupSymbolInParentScopes (const SgName & name,
00157                                                          SgScopeStatement *currentScope=NULL);
00158 
00159    // DQ (11/24/2007): Functions moved from the Fortran support so that they could be called from within astPostProcessing.
00161    SgFunctionSymbol *lookupFunctionSymbolInParentScopes (const SgName & functionName,
00162                                                          SgScopeStatement *currentScope=NULL);
00163 
00164    // Liao, 1/24/2008, find exact match for a function
00166    SgFunctionSymbol *lookupFunctionSymbolInParentScopes (const SgName &  functionName,
00167                                                          const SgType* t,
00168                                                          SgScopeStatement *currentScope=NULL);
00169 
00170 // DQ (5/7/2011): Added support for SgClassSymbol (used in name qualification support).
00171    SgClassSymbol*     lookupClassSymbolInParentScopes    (const SgName & name, SgScopeStatement *currentScope = NULL);
00172    SgTypedefSymbol*   lookupTypedefSymbolInParentScopes  (const SgName & name, SgScopeStatement *currentScope = NULL);
00173    SgTemplateSymbol*  lookupTemplateSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
00174    SgEnumSymbol*      lookupEnumSymbolInParentScopes     (const SgName & name, SgScopeStatement *currentScope = NULL);
00175    SgNamespaceSymbol* lookupNamespaceSymbolInParentScopes(const SgName & name, SgScopeStatement *currentScope = NULL);
00176 
00177 // DQ (7/17/2011): Added function from cxx branch that I need here for the Java support.
00178 // SgClassSymbol* lookupClassSymbolInParentScopes (const SgName &  name, SgScopeStatement *cscope);
00179 
00188    // DQ (12/9/2004): Moved this function (by Alin Jula) from being a member of SgInitializedName
00189    // to this location where it can be a part of the interface for the Sage III AST.
00190    int set_name (SgInitializedName * initializedNameNode, SgName new_name);
00191 
00194    void outputGlobalFunctionTypeSymbolTable ();
00195 
00196    // DQ (6/27/2005):
00201    void outputLocalSymbolTables (SgNode * node);
00202 
00203    class OutputLocalSymbolTables:public AstSimpleProcessing
00204          {
00205            public:
00206      void visit (SgNode * node);
00207          };
00213    // DQ (9/28/2005):
00214    void rebuildSymbolTable (SgScopeStatement * scope);
00215 
00218    void clearUnusedVariableSymbols ();
00219 
00220    // DQ (3/1/2009):
00222    void fixupReferencesToSymbols( const SgScopeStatement* this_scope,  SgScopeStatement* copy_scope, SgCopyHelp & help );
00223 
00225 
00226  //------------------------------------------------------------------------
00228 
00235    // DQ (9/21/2005): General function for extracting the name of declarations (when they have names)
00236      std::string get_name (const SgNode * node);
00237 
00242    // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
00243      std::string get_name (const SgStatement * stmt);
00244 
00249      std::string get_name (const SgExpression * expr);
00250 
00255    // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
00256      std::string get_name (const SgDeclarationStatement * declaration);
00257 
00262    // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
00263      std::string get_name (const SgScopeStatement * scope);
00264 
00269    // DQ (2/11/2007): Added this function to make debugging support more complete (useful for symbol table debugging support).
00270      std::string get_name (const SgSymbol * symbol);
00271 
00276      std::string get_name (const SgType * type);
00277 
00278 
00281      std::string get_name (const SgSupport * node);
00282 
00283 
00286      std::string get_name (const SgLocatedNodeSupport * node);
00287 
00290      std::string get_name ( const SgC_PreprocessorDirectiveStatement* directive );
00291 
00294      std::string get_name ( const SgToken* token );
00295 
00297 
00298  //------------------------------------------------------------------------
00300 
00305    // DQ (6/21/2005): Get the default destructor from the class declaration
00306    SgMemberFunctionDeclaration *getDefaultDestructor (SgClassDeclaration *
00307                                                       classDeclaration);
00308 
00311    // DQ (6/22/2005): Get the default constructor from the class declaration
00312    SgMemberFunctionDeclaration *getDefaultConstructor (SgClassDeclaration *
00313                                                        classDeclaration);
00316    // DQ (8/27/2005):
00317    bool templateDefinitionIsInClass (SgTemplateInstantiationMemberFunctionDecl
00318                                      * memberFunctionDeclaration);
00319 
00324    // DQ (9/17/2005):
00325       SgTemplateInstantiationMemberFunctionDecl*
00326       buildForwardFunctionDeclaration
00327          (SgTemplateInstantiationMemberFunctionDecl * memberFunctionInstantiation);
00328 
00330    bool isStructDeclaration(SgNode * node);
00331  #if 0
00332  // DQ (8/28/2005): This is already a member function of the SgFunctionDeclaration
00333  // (so that it can handle template functions and member functions)
00334 
00338     // DQ (8/27/2005):
00339    bool isTemplateMemberFunction (SgTemplateInstantiationMemberFunctionDecl *
00340                                   memberFunctionDeclaration);
00341  #endif
00342 
00344 
00345  //------------------------------------------------------------------------
00347 
00351 
00352    bool isOmpStatement(SgNode* );
00355    // DQ (8/27/2005):
00356    bool isOverloaded (SgFunctionDeclaration * functionDeclaration);
00357 
00359   void annotateExpressionsWithUniqueNames (SgProject* project);
00360 
00362    bool isMain (const SgNode* node);
00363    // DQ (6/22/2005):
00374     std::string generateUniqueName ( const SgNode * node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations);
00375 
00378     std::string generateUniqueVariableName(SgScopeStatement* scope, std::string baseName = "temp");
00379     
00380   // DQ (8/10/2010): Added const to first parameter.
00381   // DQ (3/10/2007):
00383     std::string declarationPositionString (const SgDeclarationStatement * declaration);
00384 
00385   // DQ (1/20/2007):
00387     std::string generateProjectName (const SgProject * project, bool supressSuffix = false );
00388 
00391   SgFunctionDeclaration* getDeclarationOfNamedFunction(SgExpression* func);
00392 
00394   SgExpression* forallMaskExpression(SgForAllStatement* stmt);
00395 
00397   void addVarRefExpFromArrayDimInfo(SgNode * astNode, Rose_STL_Container<SgNode *>& NodeList_t);
00398 
00399   // DQ (10/6/2006): Added support for faster mangled name generation (caching avoids recomputation).
00403   void clearMangledNameCache (SgGlobal * globalScope);
00404   void resetMangledNameCache (SgGlobal * globalScope);
00405   std::string getMangledNameFromCache (SgNode * astNode);
00406   std::string addMangledNameToCache (SgNode * astNode, const std::string & mangledName);
00407 
00408   SgDeclarationStatement * getNonInstantiatonDeclarationForClass (SgTemplateInstantiationMemberFunctionDecl * memberFunctionInstantiation);
00409 
00412   void setBaseTypeDefiningDeclaration(SgVariableDeclaration* var_decl, SgDeclarationStatement *base_decl);
00413 
00414   // DQ (10/14/2006): This function tests the AST to see if for a non-defining declaration, the
00415   // bool declarationPreceedsDefinition ( SgClassDeclaration* classNonDefiningDeclaration, SgClassDeclaration* classDefiningDeclaration );
00417   bool declarationPreceedsDefinition (SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration);
00418 
00419   // DQ (10/19/2006): Function calls have interesting context dependent rules to determine if
00420   // they are output with a global qualifier or not.  Were this is true we have to avoid global
00421   // qualifiers, since the function's scope has not been defined.  This is an example of where
00422   // qualification of function names in function calls are context dependent; an interesting
00423   // example of where the C++ language is not friendly to source-to-source processing :-).
00424   bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope (SgFunctionCallExp * functionCall);
00425 
00430     std::vector < SgNode * >astIntersection (SgNode * original, SgNode * copy, SgCopyHelp * help = NULL);
00431 
00433    SgNode* deepCopyNode (const SgNode* subtree);
00434 
00436    template <typename NodeType>
00437    NodeType* deepCopy (const NodeType* subtree) {
00438      return dynamic_cast<NodeType*>(deepCopyNode(subtree));
00439    }
00440 
00442    SgExpression* copyExpression(SgExpression* e);
00443 
00445    SgStatement* copyStatement(SgStatement* s);
00446 
00447 // from VarSym.cc in src/midend/astOutlining/src/ASTtools
00449   SgVariableSymbol* getFirstVarSym (SgVariableDeclaration* decl);
00450 
00452   SgInitializedName* getFirstInitializedName (SgVariableDeclaration* decl);
00453 
00455 void myRemoveStatement(SgStatement* stmt);
00456 
00457 bool isConstantTrue(SgExpression* e);
00458 bool isConstantFalse(SgExpression* e);
00459 
00460 bool isCallToParticularFunction(SgFunctionDeclaration* decl, SgExpression* e);
00461 bool isCallToParticularFunction(const std::string& qualifiedName, size_t arity, SgExpression* e);
00462 
00464 bool isStatic(SgDeclarationStatement* stmt);
00465 
00467 void setStatic(SgDeclarationStatement* stmt);
00468 
00470 bool isExtern(SgDeclarationStatement* stmt);
00471 
00473 void setExtern(SgDeclarationStatement* stmt);
00474 
00477 class StatementGenerator {
00478   public:
00479   virtual ~StatementGenerator() {};
00480   virtual SgStatement* generate(SgExpression* where_to_write_answer) = 0;
00481 };
00482 
00486   bool isAssignmentStatement(SgNode* _s, SgExpression** lhs=NULL, SgExpression** rhs=NULL, bool* readlhs=NULL);
00487 
00489 SgInitializedName* convertRefToInitializedName(SgNode* current);
00490 
00492 SgNode* getSgNodeFromAbstractHandleString(const std::string& input_string);
00493 
00495 void dumpInfo(SgNode* node, std::string desc="");
00496 
00498 std::vector<SgDeclarationStatement*>
00499 sortSgNodeListBasedOnAppearanceOrderInSource(const std::vector<SgDeclarationStatement*>& nodevec);
00500 
00502 
00503 //------------------------------------------------------------------------
00505 
00509 //  std::string version();  // utility_functions.h, version number
00512   bool is_C_language ();
00513   bool is_OpenMP_language ();
00514   bool is_UPC_language ();
00516   bool is_UPC_dynamic_threads();
00517   bool is_C99_language ();
00518   bool is_Cxx_language ();
00519   bool is_Java_language ();
00520   bool is_Fortran_language ();
00521   bool is_CAF_language ();
00522   bool is_PHP_language();
00523   bool is_Python_language();
00524   bool is_Cuda_language();
00525   bool is_binary_executable();
00526   bool is_mixed_C_and_Cxx_language ();
00527   bool is_mixed_Fortran_and_C_language ();
00528   bool is_mixed_Fortran_and_Cxx_language ();
00529   bool is_mixed_Fortran_and_C_and_Cxx_language ();
00531 
00532 //------------------------------------------------------------------------
00534 
00538   // DQ (10/5/2006): Added support for faster (non-quadratic) computation of unique
00539   // labels for scopes in a function (as required for name mangling).
00545   void resetScopeNumbers (SgFunctionDefinition * functionDeclaration);
00546 
00547   // DQ (10/5/2006): Added support for faster (non-quadratic) computation of unique
00548   // labels for scopes in a function (as required for name mangling).
00557   void clearScopeNumbers (SgFunctionDefinition * functionDefinition);
00558 
00559 
00561   SgNamespaceDefinitionStatement * enclosingNamespaceScope (SgDeclarationStatement * declaration);
00562 //  SgNamespaceDefinitionStatement * getEnclosingNamespaceScope (SgNode * node);
00563 
00564   bool isPrototypeInScope (SgScopeStatement * scope,
00565                            SgFunctionDeclaration * functionDeclaration,
00566                            SgDeclarationStatement * startingAtDeclaration);
00567 
00569   bool isAncestor(SgNode* node1, SgNode* node2);
00571 //------------------------------------------------------------------------
00573 
00577 
00578   void dumpPreprocInfo (SgLocatedNode* locatedNode);
00579 
00581 PreprocessingInfo* insertHeader(const std::string& filename, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::after, bool isSystemHeader=false, SgScopeStatement* scope=NULL);
00582 
00584 void moveUpPreprocessingInfo (SgStatement* stmt_dst, SgStatement* stmt_src, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef,  PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend= false);
00585 
00587 void movePreprocessingInfo (SgStatement* stmt_src, SgStatement* stmt_dst,  PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef,
00588                              PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend= false);
00589 
00590 
00592 void cutPreprocessingInfo (SgLocatedNode* src_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& save_buf);
00593 
00595 void pastePreprocessingInfo (SgLocatedNode* dst_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& saved_buf);
00596 
00598 PreprocessingInfo* attachArbitraryText(SgLocatedNode* target,
00599                 const std::string & text,
00600                PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before);
00601 
00603 void replaceMacroCallsWithExpandedStrings(SgPragmaDeclaration* target);
00605 
00606 
00607 //------------------------------------------------------------------------
00609 
00612 
00613    PreprocessingInfo* attachComment(SgLocatedNode* target, const std::string & content,
00614                PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before,
00615                PreprocessingInfo::DirectiveType dtype= PreprocessingInfo::CpreprocessorUnknownDeclaration);
00616 
00617 // DQ (11/25/2009): Added matching support for adding comments to SgAsm nodes.
00618 // Build and attach comment
00619 // void attachComment(SgAsmStatement* target, const std::string & content );
00620 
00621 // DQ (7/20/2008): I am not clear were I should put this function, candidates include: SgLocatedNode or SgInterface
00623   void addTextForUnparser ( SgNode* astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation );
00624 
00625 
00626   // Liao, 1/8/2007, set file info. for a whole subtree as transformation generated
00628   void setOneSourcePositionForTransformation(SgNode *node);
00629 
00631   void setOneSourcePositionNull(SgNode *node);
00632 
00634   void setSourcePositionForTransformation (SgNode * root);
00635 
00637   void setSourcePositionForTransformation_memoryPool();
00638 
00640   void setSourcePosition (SgLocatedNode * locatedNode);
00641 
00643 
00644 
00645 //------------------------------------------------------------------------
00647 
00651 // from src/midend/astInlining/typeTraits.h
00652 // src/midend/astUtil/astInterface/AstInterface.h
00653 
00655 SgType* getBoolType(SgNode* n);
00656 
00657 
00661 bool isStrictIntegerType(SgType* t);
00663 SgType* getFirstVarType(SgVariableDeclaration* decl);
00664 
00666 bool isDefaultConstructible(SgType* type);
00667 
00669 bool isCopyConstructible(SgType* type);
00670 
00672 bool isAssignable(SgType* type);
00673 
00674 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
00678 bool isPureVirtualClass(SgType* type, const ClassHierarchyWrapper& classHierarchy);
00679 #endif
00680 
00682 bool hasTrivialDestructor(SgType* t);
00683 
00685 bool isNonconstReference(SgType* t);
00686 
00688 bool isReferenceType(SgType* t);
00689 
00691 bool isPointerType(SgType* t);
00692 
00698 bool isPointerToNonConstType(SgType* type);
00699 
00701 /* const char* p = "aa"; is not treated as having a const type. It is a pointer to const char.
00702  * Similarly, neither for const int b[10]; or const int & c =10;
00703  * The standard says, "A compound type is not cv-qualified by the cv-qualifiers (if any) of
00704 the types from which it is compounded. Any cv-qualifiers applied to an array type affect the array element type, not the array type".
00705  */
00706 bool isConstType(SgType* t);
00707 
00709 SgType* removeConst(SgType* t);
00710 
00712 bool isVolatileType(SgType* t);
00713 
00715 bool isRestrictType(SgType* t);
00716 
00718 
00720 bool isScalarType(SgType* t);
00721 
00725 bool isStrictIntegerType(SgType* t);
00726 
00728 bool isStructType(SgType* t);
00729 
00731 std::string mangleType(SgType* type);
00732 
00734   std::string mangleScalarType(SgType* type);
00735 
00737   std::string mangleModifierType(SgModifierType* type);
00738 
00740 size_t getArrayElementCount(SgArrayType* t);
00741 
00743 int getDimensionCount(SgType* t);
00744 
00746 SgType* getArrayElementType(SgType* t);
00747 
00749 SgType* getElementType(SgType* t);
00750 
00752 bool isArrayReference(SgExpression* ref, SgExpression** arrayNameExp=NULL, std::vector<SgExpression*>** subscripts=NULL);
00753 
00754 
00756 
00765 bool hasUpcSharedType(SgType* t, SgModifierType ** mod_type_out = NULL  );
00766 
00768 
00771 bool isUpcSharedType(SgType* t, SgModifierType ** mod_type_out = NULL);
00772 
00774 bool isUpcSharedModifierType (SgModifierType* mod_type);
00775 
00777 bool isUpcSharedArrayType (SgArrayType* array_type);
00778 
00780 bool isUpcStrictSharedModifierType(SgModifierType* mode_type);
00781 
00783 size_t getUpcSharedBlockSize(SgModifierType* mod_type);
00784 
00786 size_t getUpcSharedBlockSize(SgType* t);
00787 
00789 bool isUpcPhaseLessSharedType (SgType* t);
00790 
00792 bool isUpcPrivateToSharedType(SgType* t);
00793 
00795 bool isUpcArrayWithThreads(SgArrayType* t);
00796 
00798 SgType* lookupNamedTypeInParentScopes(const std::string& type_name, SgScopeStatement* scope=NULL);
00799 
00801 
00802 //------------------------------------------------------------------------
00804 
00808 // by Jeremiah
00817 void addStepToLoopBody(SgScopeStatement* loopStmt, SgStatement* step);
00818 
00819 void moveForStatementIncrementIntoBody(SgForStatement* f);
00820 void convertForToWhile(SgForStatement* f);
00821 void convertAllForsToWhiles(SgNode* top);
00823 void changeContinuesToGotos(SgStatement* stmt, SgLabelStatement* label);
00824 
00826 SgInitializedName* getLoopIndexVariable(SgNode* loop);
00827 
00830 bool isLoopIndexVariable(SgInitializedName* ivar, SgNode* subtree_root);
00831 
00833 SgStatement* getLoopBody(SgScopeStatement* loop);
00834 
00835 void setLoopBody(SgScopeStatement* loop, SgStatement* body);
00836 
00838 SgStatement* getLoopCondition(SgScopeStatement* loop);
00839 
00841 void setLoopCondition(SgScopeStatement* loop, SgStatement* cond);
00842 
00846 bool isCanonicalForLoop(SgNode* loop, SgInitializedName** ivar=NULL, SgExpression** lb=NULL, SgExpression** ub=NULL, SgExpression** step=NULL, SgStatement** body=NULL, bool *hasIncrementalIterationSpace = NULL, bool* isInclusiveUpperBound = NULL);
00847 
00849 bool isCanonicalDoLoop(SgFortranDo* loop,SgInitializedName** ivar/*=NULL*/, SgExpression** lb/*=NULL*/, SgExpression** ub/*=NULL*/, SgExpression** step/*=NULL*/, SgStatement** body/*=NULL*/, bool *hasIncrementalIterationSpace/*= NULL*/, bool* isInclusiveUpperBound/*=NULL*/);
00850 
00852 void setLoopLowerBound(SgNode* loop, SgExpression* lb);
00853 
00855 void setLoopUpperBound(SgNode* loop, SgExpression* ub);
00856 
00858 void setLoopStride(SgNode* loop, SgExpression* stride);
00859 
00860 
00862 bool normalizeForLoopInitDeclaration(SgForStatement* loop);
00863 
00875 bool forLoopNormalization(SgForStatement* loop);
00876 
00878 bool doLoopNormalization(SgFortranDo* loop);
00879 
00881 bool loopUnrolling(SgForStatement* loop, size_t unrolling_factor);
00882 
00884 bool loopInterchange(SgForStatement* loop, size_t depth, size_t lexicoOrder);
00885 
00887 bool loopTiling(SgForStatement* loopNest, size_t targetLevel, size_t tileSize);
00888 
00890 
00891 //------------------------------------------------------------------------
00893 
00897 
00898 template <typename NodeType>
00899 std::vector<NodeType*> querySubTree(SgNode* top, VariantT variant = (VariantT)NodeType::static_variant)
00900 {
00901   Rose_STL_Container<SgNode*> nodes = NodeQuery::querySubTree(top,variant);
00902   std::vector<NodeType*> result(nodes.size(), NULL);
00903   int count = 0;
00904   for (Rose_STL_Container<SgNode*>::const_iterator i = nodes.begin();
00905        i != nodes.end(); ++i, ++count) {
00906     NodeType* node = dynamic_cast<NodeType*>(*i);
00907     ROSE_ASSERT (node);
00908     result[count] = node;
00909   }
00910   return result;
00911 }
00916     std::vector < SgFile * >generateFileList ();
00917 
00919   SgProject * getProject();
00920 
00922 template <typename NodeType>
00923 static std::vector<NodeType*> getSgNodeListFromMemoryPool()
00924 {
00925   // This function uses a memory pool traversal specific to the SgFile IR nodes
00926   class MyTraversal : public ROSE_VisitTraversal
00927   {
00928     public:
00929       std::vector<NodeType*> resultlist;
00930       void visit ( SgNode* node)
00931       {
00932         NodeType* result = dynamic_cast<NodeType* > (node);
00933         ROSE_ASSERT(result!= NULL);
00934         if (result!= NULL)
00935         {
00936           resultlist.push_back(result);
00937         }
00938       };
00939       virtual ~MyTraversal() {}
00940   };
00941 
00942   MyTraversal my_traversal;
00943   NodeType::visitRepresentativeNode(my_traversal);
00944   return my_traversal.resultlist;
00945 }
00946 
00947 
00950 SgFunctionDeclaration* findMain(SgNode* currentNode);
00951 
00953 SgStatement* findLastDeclarationStatement(SgScopeStatement * scope);
00954 
00955           //midend/programTransformation/partialRedundancyElimination/pre.h
00957 std::vector<SgVariableSymbol*> getSymbolsUsedInExpression(SgExpression* expr);
00958 
00960 
00965 std::vector<SgBreakStmt*> findBreakStmts(SgStatement* code, const std::string& fortranLabel = "");
00966 
00968 
00973   std::vector<SgContinueStmt*> findContinueStmts(SgStatement* code, const std::string& fortranLabel = "");
00974   std::vector<SgGotoStatement*> findGotoStmts(SgStatement* scope, SgLabelStatement* l);
00975   std::vector<SgStatement*> getSwitchCases(SgSwitchStatement* sw);
00976 
00978   template <typename T>
00979   T* findDeclarationStatement(SgNode* root, std::string name, SgScopeStatement* scope, bool isDefining)
00980   {
00981     if (!root) return 0;
00982     T* decl = dynamic_cast<T*>(root);
00983     if (decl!=NULL)
00984     {
00985       if (scope)
00986       {
00987         if ((decl->get_scope() == scope)&&
00988             (decl->search_for_symbol_from_symbol_table()->get_name()==name))
00989           return decl;
00990       }
00991       else // Liao 2/9/2010. We should allow NULL scope
00992       {
00993         if(decl->search_for_symbol_from_symbol_table()->get_name()==name)
00994           return decl;
00995       }
00996     }
00997 
00998     std::vector<SgNode*> children = root->get_traversalSuccessorContainer();
00999     for (std::vector<SgNode*>::const_iterator i = children.begin();
01000             i != children.end(); ++i)
01001     {
01002      T* target= findDeclarationStatement<T> (*i,name, scope, isDefining);
01003      if (target)
01004        return target;
01005     }
01006     return 0;
01007   }
01009   SgFunctionDeclaration* findFunctionDeclaration(SgNode* root, std::string name, SgScopeStatement* scope, bool isDefining);
01010 
01011 #if 0 //TODO
01012   // 1. preorder traversal from current SgNode till find next SgNode of type V_SgXXX
01013   //    until reach the end node
01014   SgNode* getNextSgNode( const SgNode* astSourceNode, VariantT=V_SgNode, SgNode* astEndNode=NULL);
01015 
01016   // 2. return all nodes of type VariantT following the source node
01017   std::vector<SgNode*> getAllNextSgNode( const SgNode* astSourceNode, VariantT=V_SgNode, SgNode* astEndNode=NULL);
01018 #endif
01019 
01021 
01022 //------------------------------------------------------------------------
01024 
01027 // remember to put const to all arguments.
01028 
01029 
01040 template <typename NodeType>
01041 NodeType* getEnclosingNode(const SgNode* astNode, const bool includingSelf=false)
01042 {
01043   if (NULL==astNode)
01044     return NULL;
01045   if ((includingSelf)&&(dynamic_cast<const NodeType*>(astNode)))
01046     return const_cast<NodeType*>(dynamic_cast<const NodeType*> (astNode));
01047 
01048   SgNode* parent = astNode->get_parent();
01049   while ((parent!=NULL)&&(!dynamic_cast<const NodeType*>(parent)))
01050     parent = parent->get_parent();
01051 
01052   return const_cast<NodeType*>(dynamic_cast<const NodeType*> (parent));
01053 }
01054 
01056 SgScopeStatement* getScope(const SgNode* astNode);
01057 
01059   SgGlobal* getGlobalScope( const SgNode* astNode);
01060 
01061 
01063   SgFunctionDefinition* getEnclosingProcedure(SgNode* n, const bool includingSelf=false);
01064 
01065   SgFunctionDefinition* getEnclosingFunctionDefinition(SgNode* astNode, const bool includingSelf=false);
01066 
01068   SgStatement* getEnclosingStatement(SgNode* n);
01069 
01071   SgSwitchStatement* findEnclosingSwitch(SgStatement* s);
01072 
01074   SgScopeStatement* findEnclosingLoop(SgStatement* s, const std::string& fortranLabel = "", bool stopOnSwitches = false);
01075 
01077   SgFunctionDeclaration * getEnclosingFunctionDeclaration (SgNode * astNode, const bool includingSelf=false);
01078    //roseSupport/utility_functions.h
01080   SgFile* getEnclosingFileNode (SgNode* astNode );
01081 
01083   SgInitializer* getInitializerOfExpression(SgExpression* n);
01084 
01086   SgClassDefinition* getEnclosingClassDefinition(SgNode* astnode, const bool includingSelf=false);
01087 
01088 // TODO
01089 #if 0
01090    SgNode * getEnclosingSgNode(SgNode* source,VariantT, SgNode* endNode=NULL);
01091    std::vector<SgNode *>  getAllEnclosingSgNode(SgNode* source,VariantT, SgNode* endNode=NULL);
01092    SgVariableDeclaration* findVariableDeclaratin( const string& varname)
01093 
01094    SgClassDeclaration* getEnclosingClassDeclaration( const SgNode* astNode);
01095 
01096    // e.g. for some expression, find its parent statement
01097    SgStatement* getEnclosingStatement(const SgNode* astNode);
01098 
01099    SgSwitchStatement* getEnclosingSwitch(SgStatement* s);
01100    SgModuleStatement* getEnclosingModuleStatement( const SgNode* astNode);
01101 
01102   // used to build a variable reference for compiler generated code in current scope
01103    SgSymbol * findReachingDefinition (SgScopeStatement* startScope, SgName &name);
01104 #endif
01105 
01106 
01107 //------------------------------------------------------------------------
01109 
01112   // Liao, 1/9/2008
01116   SgGlobal * getFirstGlobalScope(SgProject *project);
01117 
01121   SgStatement* getLastStatement(SgScopeStatement *scope);
01122 
01124   SgStatement* getFirstStatement(SgScopeStatement *scope,bool includingCompilerGenerated=false);
01126   SgFunctionDeclaration* findFirstDefiningFunctionDecl(SgScopeStatement* scope);
01127 
01129   SgStatement* getNextStatement(SgStatement * currentStmt);
01130 
01132   SgStatement* getPreviousStatement(SgStatement * currentStmt);
01133 #if 0 //TODO
01134   // preorder traversal from current SgNode till find next SgNode of type V_SgXXX
01135   SgNode* getNextSgNode( const SgNode* currentNode, VariantT=V_SgNode);
01136 #endif
01137 
01138 
01139 //------------------------------------------------------------------------
01141 
01144 
01145  bool isEqualToIntConst(SgExpression* e, int value);
01146 
01148 
01151  bool isSameFunction(SgFunctionDeclaration* func1, SgFunctionDeclaration* func2);
01152 
01154  bool isLastStatement(SgStatement* stmt);
01155 
01157 
01158 //------------------------------------------------------------------------
01160 
01166 // DQ (2/24/2009): Simple function to delete an AST subtree (used in outlining).
01168  void deleteAST(SgNode* node);
01169 
01171  void deleteExpressionTreeWithOriginalExpressionSubtrees(SgNode* root);
01172 
01173 // DQ (2/25/2009): Added new function to support outliner.
01175  void moveStatementsBetweenBlocks ( SgBasicBlock* sourceBlock, SgBasicBlock* targetBlock );
01176 
01177 
01179 void appendStatement(SgStatement *stmt, SgScopeStatement* scope=NULL);
01180 
01182 void appendStatementList(const std::vector<SgStatement*>& stmt, SgScopeStatement* scope=NULL);
01183 
01184 // DQ (2/6/2009): Added function to support outlining into separate file.
01186 void appendStatementWithDependentDeclaration( SgDeclarationStatement* decl, SgGlobal* scope, SgStatement* original_statement, bool excludeHeaderFiles );
01187 
01190 void prependStatement(SgStatement *stmt, SgScopeStatement* scope=NULL);
01191 
01194 void prependStatementList(const std::vector<SgStatement*>& stmt, SgScopeStatement* scope=NULL);
01195 
01199 bool  hasSimpleChildrenList (SgScopeStatement* scope);
01200 
01202 void insertStatement(SgStatement *targetStmt, SgStatement* newStmt, bool insertBefore= true, bool autoMovePreprocessingInfo = true);
01203 
01205 //target's scope
01206 void insertStatementList(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmts, bool insertBefore= true);
01207 
01209 void insertStatementBefore(SgStatement *targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
01210 
01212 void insertStatementListBefore(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmts);
01213 
01215 void insertStatementAfter(SgStatement *targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
01216 
01218 void insertStatementListAfter(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmt);
01219 
01221 void insertStatementAfterLastDeclaration(SgStatement* stmt, SgScopeStatement* scope);
01222 
01224 void insertStatementAfterLastDeclaration(std::vector<SgStatement*> stmt_list, SgScopeStatement* scope);
01225 
01227 void removeStatement(SgStatement* stmt, bool autoRelocatePreprocessingInfo = true);
01228 
01230 void deepDelete(SgNode* root);
01231 
01233 void replaceStatement(SgStatement* oldStmt, SgStatement* newStmt, bool movePreprocessinInfo = false);
01234 
01236 SgNode* replaceWithPattern (SgNode * anchor, SgNode* new_pattern);
01237 
01248 std::pair<SgVariableDeclaration*, SgExpression* > createTempVariableForExpression(SgExpression* expression,
01249         SgScopeStatement* scope, bool initializeInDeclaration, SgAssignOp** reEvaluate = NULL);
01250 
01252 
01256 SgVariableSymbol* appendArg(SgFunctionParameterList *, SgInitializedName*);
01258 SgVariableSymbol* prependArg(SgFunctionParameterList *, SgInitializedName*);
01259 
01261 void appendExpression(SgExprListExp *, SgExpression*);
01262 
01264 void appendExpressionList(SgExprListExp *, const std::vector<SgExpression*>&);
01265 
01267 void setParameterList(SgFunctionDeclaration *func,SgFunctionParameterList *paralist);
01268 
01270 void setPragma(SgPragmaDeclaration* decl, SgPragma *pragma);
01271 
01273 void replaceExpression(SgExpression* oldExp, SgExpression* newExp, bool keepOldExp=false);
01274 
01276 void replaceExpressionWithStatement(SgExpression* from,
01277                                     SageInterface::StatementGenerator* to);
01280 void replaceSubexpressionWithStatement(SgExpression* from,
01281                                       SageInterface::StatementGenerator* to);
01282 
01284 void setOperand(SgExpression* target, SgExpression* operand);
01285 
01287 void setLhsOperand(SgExpression* target, SgExpression* lhs);
01288 
01290 void setRhsOperand(SgExpression* target, SgExpression* rhs);
01291 
01293 void removeAllOriginalExpressionTrees(SgNode* top);
01294 
01295 // DQ (1/25/2010): Added support for directories
01297 void moveToSubdirectory ( std::string directoryName, SgFile* file );
01298 
01300 SgStatement* findSurroundingStatementFromSameFile(SgStatement* targetStmt, bool & surroundingStatementPreceedsTargetStatement);
01301 
01303    void moveCommentsToNewStatement(SgStatement* sourceStatement, const std::vector<int> & indexList, SgStatement* targetStatement, bool surroundingStatementPreceedsTargetStatement);
01304 
01306 //------------------------------------------------------------------------
01308 
01315 
01316 
01321 int fixVariableReferences(SgNode* root);
01322 
01324 
01328 void fixVariableDeclaration(SgVariableDeclaration* varDecl, SgScopeStatement* scope);
01329 
01331 void fixStructDeclaration(SgClassDeclaration* structDecl, SgScopeStatement* scope);
01333 void fixClassDeclaration(SgClassDeclaration* classDecl, SgScopeStatement* scope);
01334 
01336 void fixNamespaceDeclaration(SgNamespaceDeclarationStatement* structDecl, SgScopeStatement* scope);
01337 
01338 
01340 void fixLabelStatement(SgLabelStatement* label_stmt, SgScopeStatement* scope);
01341 
01343 void setFortranNumericLabel(SgStatement* stmt, int label_value);
01344 
01346 int  suggestNextNumericLabel(SgFunctionDefinition* func_def);
01347 
01349 void fixStatement(SgStatement* stmt, SgScopeStatement* scope);
01351 
01353 
01358 void updateDefiningNondefiningLinks(SgFunctionDeclaration* func, SgScopeStatement* scope);
01359 
01360 //------------------------------------------------------------------------
01362 
01366 
01367 bool
01368 collectReadWriteRefs(SgStatement* stmt, std::vector<SgNode*>& readRefs, std::vector<SgNode*>& writeRefs);
01369 
01371 bool collectReadWriteVariables(SgStatement* stmt, std::set<SgInitializedName*>& readVars, std::set<SgInitializedName*>& writeVars);
01372 
01374 void collectReadOnlyVariables(SgStatement* stmt, std::set<SgInitializedName*>& readOnlyVars);
01375 
01377 void collectReadOnlySymbols(SgStatement* stmt, std::set<SgVariableSymbol*>& readOnlySymbols);
01378 
01380 bool isUseByAddressVariableRef(SgVarRefExp* ref);
01381 
01383 void collectUseByAddressVariableRefs (const SgStatement* s, std::set<SgVarRefExp* >& varSetB);
01384 
01385 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
01387 LivenessAnalysis * call_liveness_analysis(SgProject* project, bool debug=false);
01388 
01390 void getLiveVariables(LivenessAnalysis * liv, SgForStatement* loop, std::set<SgInitializedName*>& liveIns, std::set<SgInitializedName*> & liveOuts);
01391 #endif
01392 
01394 void ReductionRecognition(SgForStatement* loop, std::set< std::pair <SgInitializedName*, VariantT> > & results);
01395 
01397 
01398 void constantFolding(SgNode* r);
01399 
01401 
01403 int instrumentEndOfFunction(SgFunctionDeclaration * func, SgStatement* s);
01404 
01406 void removeJumpsToNextStatement(SgNode*);
01407 
01409 void removeUnusedLabels(SgNode* top);
01410 
01412 void removeConsecutiveLabels(SgNode* top);
01413 
01415 
01422  SgAssignInitializer* splitExpression(SgExpression* from, std::string newName = "");
01423 
01425 void splitExpressionIntoBasicBlock(SgExpression* expr);
01426 
01428 void removeLabeledGotos(SgNode* top);
01429 
01431 void changeBreakStatementsToGotos(SgStatement* loopOrSwitch);
01432 
01434 SgBasicBlock* ensureBasicBlockAsBodyOfFor(SgForStatement* fs);
01435 
01437 SgBasicBlock* ensureBasicBlockAsBodyOfUpcForAll(SgUpcForAllStatement* fs);
01438 
01440 SgBasicBlock* ensureBasicBlockAsBodyOfWhile(SgWhileStmt* ws);
01442 SgBasicBlock* ensureBasicBlockAsBodyOfDoWhile(SgDoWhileStmt* ws);
01444 SgBasicBlock* ensureBasicBlockAsBodyOfSwitch(SgSwitchStatement* ws);
01446 SgBasicBlock* ensureBasicBlockAsTrueBodyOfIf(SgIfStmt* ifs);
01448 SgBasicBlock* ensureBasicBlockAsFalseBodyOfIf(SgIfStmt* ifs);
01449 SgBasicBlock* ensureBasicBlockAsBodyOfCatch(SgCatchOptionStmt* cos);
01451 SgBasicBlock* ensureBasicBlockAsBodyOfOmpBodyStmt(SgOmpBodyStatement* ompbodyStmt);
01455 SgLocatedNode* ensureBasicBlockAsParent(SgStatement* s);
01456 
01459 void changeAllLoopBodiesToBlocks(SgNode* top);
01460 
01463 unsigned long long getIntegerConstantValue(SgValueExp* expr);
01464 
01466 std::vector<SgDeclarationStatement*> getDependentDeclarations (SgStatement* stmt );
01467 
01468 
01470 SgCommaOpExp *insertBeforeUsingCommaOp (SgExpression* new_exp, SgExpression* anchor_exp);
01471 
01473 SgCommaOpExp *insertAfterUsingCommaOp (SgExpression* new_exp, SgExpression* anchor_exp, SgStatement** temp_decl = NULL, SgVarRefExp** temp_ref = NULL);
01474 
01475 
01477 
01478 
01479 #if 0
01480 
01481 //------------------------AST dump, stringify-----------------------------
01482 //------------------------------------------------------------------------
01483   std::string buildOperatorString ( SgNode* astNode ); //transformationSupport.h
01484 
01485   // do we need these?
01486   std::string dump_node(const SgNode* astNode);
01487   std::string dump_tree(const SgNode* astNode);
01488 
01489   // or a friendly version of  unparseToString(), as a memeber function
01490   std::string SgNode::toString(bool asSubTree=true); // dump node or subtree
01491 
01492 //----------------------------AST comparison------------------------------
01493 //------------------------------------------------------------------------
01494 // How to get generic functions for comparison?
01495   bool isNodeEqual(SgNode* node1, SgNode* node2); //?
01496   bool isTreeEqual(SgNode* tree1, SgNode* tree2);
01497 
01499   bool expressionTreeEqual(SgExpression*, SgExpression*);
01501   bool expressionTreeEqualStar(const SgExpressionPtrList&,
01502                              const SgExpressionPtrList&);
01503 
01504 //----------------------AST verfication/repair----------------------------
01505 //------------------------------------------------------------------------
01506 // sanity check of AST subtree, any suggestions?
01507 //  TODO
01508     verifySgNode(SgNode* node, bool subTree=true);
01509   //src/midend/astDiagnostics/AstConsistencyTests.h
01510   // AstTests::runAllTests(SgProject * )
01511 
01512   //src/midend/astUtil/astInterface/AstInterface.h.C
01513   //FixSgProject(SgProject &project)
01514   //FixSgTree(SgNode* r)
01515 
01516   //src/frontend/SageIII/astPostProcessing
01517   //AstPostProcessing(SgNode * node)
01518 
01519 //--------------------------AST modification------------------------------
01520 //------------------------------------------------------------------------
01521 // any operations changing AST tree, including
01522 // insert, copy, delete(remove), replace
01523 
01524   // insert before or after some point, argument list is consistent with LowLevelRewrite
01525   void insertAst(SgNode* targetPosition, SgNode* newNode, bool insertBefore=true);
01526 
01527   // previous examples
01528   //void myStatementInsert(SgStatement* target,...)
01529   // void AstInterfaceBase::InsertStmt(AstNodePtr const & orig, AstNodePtr const &n, bool insertbefore, bool extractfromBasicBlock)
01530 
01531   // copy
01532   // copy children of one basic block to another basic block
01533   //void appendStatementCopy (const SgBasicBlock* a, SgBasicBlock* b);
01534   void copyStatements (const SgBasicBlock* src, SgBasicBlock* dst);
01535 
01536   // delete (remove) a node or a whole subtree
01537   void removeSgNode(SgNode* targetNode); // need this?
01538   void removeSgNodeTree(SgNode* subtree); // need this?
01539 
01540   void removeStatement( SgStatement* targetStmt);
01541 
01542   //Move = delete + insert
01543   void moveAst (SgNode* src, SgNode* target); // need this?
01544       // similar to
01545   void moveStatements (SgBasicBlock* src, SgBasicBlock* target);
01546 
01547   // replace= delete old + insert new (via building or copying)
01548 
01549 // DQ (1/25/2010): This does not appear to exist as a definition anywhere in ROSE.
01550 // void replaceAst(SgNode* oldNode, SgNode* newNode);
01551 
01552    //void replaceChild(SgNode* parent, SgNode* from, SgNode* to);
01553    //bool AstInterface::ReplaceAst( const AstNodePtr& orig, const AstNodePtr& n)
01554 
01555 //--------------------------AST transformations---------------------------
01556 //------------------------------------------------------------------------
01557 // Advanced AST modifications through basic AST modifications
01558 // Might not be included in AST utitlity list, but listed here for the record.
01559 
01560   // extract statements/content from a scope
01561   void flattenBlocks(SgNode* n);
01562 
01563   //src/midend/astInlining/inlinerSupport.h
01564   void renameVariables(SgNode* n);
01565   void renameLabels(SgNode* n, SgFunctionDefinition* enclosingFunctionDefinition);
01566 
01567   void simpleCopyAndConstantPropagation(SgNode* top);
01568   void changeAllMembersToPublic(SgNode* n);
01569 
01570   void removeVariableDeclaration(SgInitializedName* initname);
01571 
01573   SgAssignOp* convertInitializerIntoAssignment(SgAssignInitializer* init);
01574 
01579   void pushTestIntoBody(LoopStatement* loopStmt);
01580 
01581   //programTransformation/finiteDifferencing/finiteDifferencing.h
01583   void moveForDeclaredVariables(SgNode* root);
01584 
01585 //------------------------ Is/Has functions ------------------------------
01586 //------------------------------------------------------------------------
01587 // misc. boolean functions
01588 // some of them could moved to SgXXX class as a member function
01589 
01590   bool isOverloaded (SgFunctionDeclaration * functionDeclaration);
01591 
01592   bool isSwitchCond (const SgStatement* s);
01593   bool isIfCond (const SgStatement* s);
01594   bool isWhileCond (const SgStatement* s);
01595   bool isStdNamespace (const SgScopeStatement* scope);
01596   bool isTemplateInst (const SgDeclarationStatement* decl);
01597 
01598 
01599   bool isCtor (const SgFunctionDeclaration* func);
01600   bool isDtor (const SgFunctionDeclaration* func);
01601 
01602    // src/midend/astInlining/typeTraits.h
01603   bool hasTrivialDestructor(SgType* t);
01604   bool isNonconstReference(SgType* t);
01605   bool isReferenceType(SgType* t);
01606 
01607   //  generic ones, or move to the SgXXX class as a member function
01608 
01609   bool isConst(SgNode* node); // const type, variable, function, etc.
01610   // .... and more
01611 
01612   bool isConstType (const SgType* type);
01613   bool isConstFunction (const SgFunctionDeclaration* decl);
01614 
01615 
01616   bool isMemberVariable(const SgInitializedName & var);
01617   //bool isMemberVariable(const SgNode& in);
01618 
01619   bool isPrototypeInScope (SgScopeStatement * scope,
01620                            SgFunctionDeclaration * functionDeclaration,
01621                            SgDeclarationStatement * startingAtDeclaration);
01622 
01623   bool MayRedefined(SgExpression* expr, SgNode* root);
01624   // bool isPotentiallyModified(SgExpression* expr, SgNode* root); // inlinderSupport.h
01625   bool hasAddressTaken(SgExpression* expr, SgNode* root);
01626 
01627   //src/midend/astInlining/inlinerSupport.C
01628      // can also classified as topdown search
01629   bool containsVariableReference(SgNode* root, SgInitializedName* var);
01630 
01631   bool isDeclarationOf(SgVariableDeclaration* decl, SgInitializedName* var);
01632   bool isPotentiallyModifiedDuringLifeOf(SgBasicBlock* sc,
01633                                        SgInitializedName* toCheck,
01634                                        SgInitializedName* lifetime)
01635   //src/midend/programTransformation/partialRedundancyElimination/pre.h
01636   bool anyOfListPotentiallyModifiedIn(const std::vector<SgVariableSymbol*>& syms, SgNode* n);
01637 
01638 //------------------------ loop handling ---------------------------------
01639 //------------------------------------------------------------------------
01640   //get and set loop control expressions
01641   // 0: init expr, 1: condition expr, 2: stride expr
01642 
01643   SgExpression* getForLoopTripleValues(int valuetype,SgForStatement* forstmt );
01644   int setForLoopTripleValues(int valuetype,SgForStatement* forstmt, SgExpression* exp);
01645 
01646   bool isLoopIndexVarRef(SgForStatement* forstmt, SgVarRefExp *varref);
01647   SgInitializedName * getLoopIndexVar(SgForStatement* forstmt);
01648 
01649 //------------------------expressions-------------------------------------
01650 //------------------------------------------------------------------------
01651   //src/midend/programTransformation/partialRedundancyElimination/pre.h
01652   int countComputationsOfExpressionIn(SgExpression* expr, SgNode* root);
01653 
01654         //src/midend/astInlining/replaceExpressionWithStatement.h
01655   void replaceAssignmentStmtWithStatement(SgExprStatement* from, StatementGenerator* to);
01656 
01657   void replaceSubexpressionWithStatement(SgExpression* from,
01658                                        StatementGenerator* to);
01659   SgExpression* getRootOfExpression(SgExpression* n);
01660 
01661 //--------------------------preprocessing info. -------------------------
01662 //------------------------------------------------------------------------
01664   void cutPreprocInfo (SgBasicBlock* b,
01665                        PreprocessingInfo::RelativePositionType pos,
01666                        AttachedPreprocessingInfoType& save_buf);
01668   void pastePreprocInfoFront (AttachedPreprocessingInfoType& save_buf,
01669                               SgStatement* s);
01671   void pastePreprocInfoBack (AttachedPreprocessingInfoType& save_buf,
01672                              SgStatement* s);
01673 
01679   // a generic one for all
01681   void moveBeforePreprocInfo (SgStatement* src, SgStatement* dest);
01682   void moveInsidePreprocInfo (SgBasicBlock* src, SgBasicBlock* dest);
01683   void moveAfterPreprocInfo (SgStatement* src, SgStatement* dest);
01684 
01685 //--------------------------------operator--------------------------------
01686 //------------------------------------------------------------------------
01687   from transformationSupport.h, not sure if they should be included here
01688   /* return enum code for SAGE operators */
01689   operatorCodeType classifyOverloadedOperator(); // transformationSupport.h
01690 
01696   std::string stringifyOperator (std::string name);
01697 
01698 //--------------------------------macro ----------------------------------
01699 //------------------------------------------------------------------------
01700   std::string buildMacro ( std::string s ); //transformationSupport.h
01701 
01702 //--------------------------------access functions---------------------------
01703 //----------------------------------get/set sth.-----------------------------
01704 // several categories:
01705 * get/set a direct child/grandchild node or fields
01706 * get/set a property flag value
01707 * get a descendent child node using preorder searching
01708 * get an ancestor node using bottomup/reverse searching
01709 
01710         // SgName or string?
01711   std::string getFunctionName (SgFunctionCallExp* functionCallExp);
01712   std::string getFunctionTypeName ( SgFunctionCallExp* functionCallExpression );
01713 
01714     // do we need them anymore? or existing member functions are enought?
01715     // a generic one:
01716    std::string get_name (const SgNode* node);
01717    std::string get_name (const SgDeclarationStatement * declaration);
01718 
01719   // get/set some property: should moved to SgXXX as an inherent memeber function?
01720   // access modifier
01721   void  setExtern (SgFunctionDeclartion*)
01722   void  clearExtern()
01723 
01724    // similarly for other declarations and other properties
01725   void setExtern (SgVariableDeclaration*)
01726   void setPublic()
01727   void setPrivate()
01728 
01729 
01730 #endif
01731 }// end of namespace
01732 
01733 #endif

Generated on Tue Jan 31 05:31:37 2012 for ROSE by  doxygen 1.4.7