#include "sage3basic.hhh"
#include <stdint.h>
#include <utility>
#include "rewrite.h"
#include "astUnparseAttribute.h"
#include <set>
#include "LivenessAnalysis.h"
#include "abstract_handle.h"
#include "ClassHierarchyGraph.h"
Include dependency graph for sageInterface.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Namespaces | |
| namespace | SageInterface |
Classes | |
| class | SageInterface::UniqueNameAttribute |
| A persistent attribute to represent a unique name for an expression. More... | |
| struct | SageInterface::hash_nodeptr |
| class | SageInterface::OutputLocalSymbolTables |
| class | SageInterface::StatementGenerator |
| Interface for creating a statement whose computation writes its answer into a given variable. More... | |
Symbol tables | |
| utility functions for symbol tables | |
| SgVariableSymbol * | SageInterface::lookupVariableSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| SgSymbol * | SageInterface::lookupSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. | |
| SgFunctionSymbol * | SageInterface::lookupFunctionSymbolInParentScopes (const SgName &functionName, SgScopeStatement *currentScope=NULL) |
| look up the first matched function symbol in parent scopes given only a function name, starting from top of ScopeStack if currentscope is not given or NULL | |
| SgFunctionSymbol * | SageInterface::lookupFunctionSymbolInParentScopes (const SgName &functionName, const SgType *t, SgScopeStatement *currentScope=NULL) |
| look up function symbol in parent scopes given both name and function type, starting from top of ScopeStack if currentscope is not given or NULL | |
| SgClassSymbol * | SageInterface::lookupClassSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| SgTypedefSymbol * | SageInterface::lookupTypedefSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| SgTemplateSymbol * | SageInterface::lookupTemplateSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| SgEnumSymbol * | SageInterface::lookupEnumSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| SgNamespaceSymbol * | SageInterface::lookupNamespaceSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL) |
| int | SageInterface::set_name (SgInitializedName *initializedNameNode, SgName new_name) |
| set_name of symbol in symbol table. | |
| void | SageInterface::outputGlobalFunctionTypeSymbolTable () |
| Output function type symbols in global function type symbol table. | |
| void | SageInterface::outputLocalSymbolTables (SgNode *node) |
| Output the local symbol tables. | |
| void | SageInterface::rebuildSymbolTable (SgScopeStatement *scope) |
| Regenerate the symbol table. | |
| void | SageInterface::clearUnusedVariableSymbols () |
| Clear those variable symbols (together with initialized names) which are not referenced by any variable references or declarations. | |
| void | SageInterface::fixupReferencesToSymbols (const SgScopeStatement *this_scope, SgScopeStatement *copy_scope, SgCopyHelp &help) |
| All the symbol table references in the copied AST need to be reset after rebuilding the copied scope's symbol table. | |
Stringify | |
| Generate a useful string (name) to describe a SgNode | |
| std::string | SageInterface::get_name (const SgNode *node) |
| Generate a useful name to describe the SgNode. | |
| std::string | SageInterface::get_name (const SgStatement *stmt) |
| Generate a useful name to describe the declaration. | |
| std::string | SageInterface::get_name (const SgExpression *expr) |
| Generate a useful name to describe the expression. | |
| std::string | SageInterface::get_name (const SgDeclarationStatement *declaration) |
| Generate a useful name to describe the declaration. | |
| std::string | SageInterface::get_name (const SgScopeStatement *scope) |
| Generate a useful name to describe the scope. | |
| std::string | SageInterface::get_name (const SgSymbol *symbol) |
| Generate a useful name to describe the SgSymbol. | |
| std::string | SageInterface::get_name (const SgType *type) |
| Generate a useful name to describe the SgType. | |
| std::string | SageInterface::get_name (const SgSupport *node) |
| Generate a useful name to describe the SgSupport IR node. | |
| std::string | SageInterface::get_name (const SgLocatedNodeSupport *node) |
| Generate a useful name to describe the SgLocatedNodeSupport IR node. | |
| std::string | SageInterface::get_name (const SgC_PreprocessorDirectiveStatement *directive) |
| Generate a useful name to describe the SgC_PreprocessorDirectiveStatement IR node. | |
| std::string | SageInterface::get_name (const SgToken *token) |
| Generate a useful name to describe the SgToken IR node. | |
Class utilities | |
| SgMemberFunctionDeclaration * | SageInterface::getDefaultDestructor (SgClassDeclaration *classDeclaration) |
| Get the default destructor from the class declaration. | |
| SgMemberFunctionDeclaration * | SageInterface::getDefaultConstructor (SgClassDeclaration *classDeclaration) |
| Get the default constructor from the class declaration. | |
| bool | SageInterface::templateDefinitionIsInClass (SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration) |
| Return true if template definition is in the class, false if outside of class. | |
| SgTemplateInstantiationMemberFunctionDecl * | SageInterface::buildForwardFunctionDeclaration (SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation) |
| Generate a non-defining (forward) declaration from a defining function declaration. | |
| bool | SageInterface::isStructDeclaration (SgNode *node) |
| Check if a SgNode is a declaration for a structure. | |
Misc. | |
| Not sure the classifications right now | |
| bool | SageInterface::isOmpStatement (SgNode *) |
| Check if a node is SgOmp*Statement. | |
| bool | SageInterface::isOverloaded (SgFunctionDeclaration *functionDeclaration) |
| Return true if function is overloaded. | |
| void | SageInterface::annotateExpressionsWithUniqueNames (SgProject *project) |
| Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttribute"). | |
| bool | SageInterface::isMain (const SgNode *node) |
| Check if a SgNode is a main() function declaration. | |
| std::string | SageInterface::generateUniqueName (const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations) |
| Generate unique name from C and C++ constructs. The name may contain space. | |
| std::string | SageInterface::generateUniqueVariableName (SgScopeStatement *scope, std::string baseName="temp") |
| Generate a name that is unique in the current scope and any parent and children scopes. | |
| std::string | SageInterface::declarationPositionString (const SgDeclarationStatement *declaration) |
| Generate a unique string from the source file position information. | |
| std::string | SageInterface::generateProjectName (const SgProject *project, bool supressSuffix=false) |
| Added mechanism to generate project name from list of file names. | |
| SgFunctionDeclaration * | SageInterface::getDeclarationOfNamedFunction (SgExpression *func) |
| Given a SgExpression that represents a named function (or bound member function), return the mentioned function. | |
| SgExpression * | SageInterface::forallMaskExpression (SgForAllStatement *stmt) |
| Get the mask expression from the header of a SgForAllStatement. | |
| void | SageInterface::addVarRefExpFromArrayDimInfo (SgNode *astNode, Rose_STL_Container< SgNode * > &NodeList_t) |
| Find all SgPntrArrRefExp under astNode, then add SgVarRefExp (if any) of SgPntrArrRefExp's dim_info into NodeList_t. | |
| void | SageInterface::clearMangledNameCache (SgGlobal *globalScope) |
| Support for faster mangled name generation (caching avoids recomputation). | |
| void | SageInterface::resetMangledNameCache (SgGlobal *globalScope) |
| Check if a node is SgOmp*Statement. | |
| std::string | SageInterface::getMangledNameFromCache (SgNode *astNode) |
| Check if a node is SgOmp*Statement. | |
| std::string | SageInterface::addMangledNameToCache (SgNode *astNode, const std::string &mangledName) |
| Check if a node is SgOmp*Statement. | |
| SgDeclarationStatement * | SageInterface::getNonInstantiatonDeclarationForClass (SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation) |
| Check if a node is SgOmp*Statement. | |
| void | SageInterface::setBaseTypeDefiningDeclaration (SgVariableDeclaration *var_decl, SgDeclarationStatement *base_decl) |
| a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side effects automatically Used to have a struct declaration embedded into a variable declaration | |
| bool | SageInterface::declarationPreceedsDefinition (SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration) |
| Check if a defining declaration comes before of after the non-defining declaration. | |
| bool | SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope (SgFunctionCallExp *functionCall) |
| Check if a node is SgOmp*Statement. | |
| std::vector< SgNode * > | SageInterface::astIntersection (SgNode *original, SgNode *copy, SgCopyHelp *help=NULL) |
| Compute the intersection set for two ASTs. | |
| SgNode * | SageInterface::deepCopyNode (const SgNode *subtree) |
| Deep copy an arbitrary subtree. | |
| template<typename NodeType> | |
| NodeType * | SageInterface::deepCopy (const NodeType *subtree) |
| A template function for deep copying a subtree. It is also used to create deepcopy functions with specialized parameter and return types. e.g SgExpression* copyExpression(SgExpression* e);. | |
| SgExpression * | SageInterface::copyExpression (SgExpression *e) |
| Deep copy an expression. | |
| SgStatement * | SageInterface::copyStatement (SgStatement *s) |
| Deep copy a statement. | |
| SgVariableSymbol * | SageInterface::getFirstVarSym (SgVariableDeclaration *decl) |
| Get the variable symbol for the first initialized name of a declaration stmt. | |
| SgInitializedName * | SageInterface::getFirstInitializedName (SgVariableDeclaration *decl) |
| Get the first initialized name of a declaration statement. | |
| void | SageInterface::myRemoveStatement (SgStatement *stmt) |
| A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's attention to refine it. Please don't use it for now. | |
| bool | SageInterface::isConstantTrue (SgExpression *e) |
| Check if a node is SgOmp*Statement. | |
| bool | SageInterface::isConstantFalse (SgExpression *e) |
| Check if a node is SgOmp*Statement. | |
| bool | SageInterface::isCallToParticularFunction (SgFunctionDeclaration *decl, SgExpression *e) |
| Check if a node is SgOmp*Statement. | |
| bool | SageInterface::isCallToParticularFunction (const std::string &qualifiedName, size_t arity, SgExpression *e) |
| Check if a node is SgOmp*Statement. | |
| bool | SageInterface::isStatic (SgDeclarationStatement *stmt) |
| Check if a declaration has a "static' modifier. | |
| void | SageInterface::setStatic (SgDeclarationStatement *stmt) |
| Set a declaration as static. | |
| bool | SageInterface::isExtern (SgDeclarationStatement *stmt) |
| Check if a declaration has an "extern" modifier. | |
| void | SageInterface::setExtern (SgDeclarationStatement *stmt) |
| Set a declaration as extern. | |
| bool | SageInterface::isAssignmentStatement (SgNode *_s, SgExpression **lhs=NULL, SgExpression **rhs=NULL, bool *readlhs=NULL) |
| Check if a SgNode _s is an assignment statement (any of =,+=,-=,&=,/=, ^=, etc). | |
| SgInitializedName * | SageInterface::convertRefToInitializedName (SgNode *current) |
| Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. This function will convert them all to a top level SgInitializedName. | |
| SgNode * | SageInterface::getSgNodeFromAbstractHandleString (const std::string &input_string) |
| Obtain a matching SgNode from an abstract handle string. | |
| void | SageInterface::dumpInfo (SgNode *node, std::string desc="") |
| Dump information about a SgNode for debugging. | |
| std::vector< SgDeclarationStatement * > | SageInterface::sortSgNodeListBasedOnAppearanceOrderInSource (const std::vector< SgDeclarationStatement * > &nodevec) |
| Reorder a list of declaration statements based on their appearance order in source files. | |
AST properties | |
| version, language properties of current AST. | |
| bool | SageInterface::is_C_language () |
| bool | SageInterface::is_OpenMP_language () |
| bool | SageInterface::is_UPC_language () |
| bool | SageInterface::is_UPC_dynamic_threads () |
| Check if dynamic threads compilation is used for UPC programs. | |
| bool | SageInterface::is_C99_language () |
| bool | SageInterface::is_Cxx_language () |
| bool | SageInterface::is_Java_language () |
| bool | SageInterface::is_Fortran_language () |
| bool | SageInterface::is_CAF_language () |
| bool | SageInterface::is_PHP_language () |
| bool | SageInterface::is_Python_language () |
| bool | SageInterface::is_Cuda_language () |
| bool | SageInterface::is_binary_executable () |
| bool | SageInterface::is_mixed_C_and_Cxx_language () |
| bool | SageInterface::is_mixed_Fortran_and_C_language () |
| bool | SageInterface::is_mixed_Fortran_and_Cxx_language () |
| bool | SageInterface::is_mixed_Fortran_and_C_and_Cxx_language () |
Scope | |
| void | SageInterface::resetScopeNumbers (SgFunctionDefinition *functionDeclaration) |
| Assigns unique numbers to each SgScopeStatement of a function. | |
| void | SageInterface::clearScopeNumbers (SgFunctionDefinition *functionDefinition) |
| Clears the cache of scope,integer pairs for the input function. | |
| SgNamespaceDefinitionStatement * | SageInterface::enclosingNamespaceScope (SgDeclarationStatement *declaration) |
| Find the enclosing namespace of a declaration. | |
| bool | SageInterface::isPrototypeInScope (SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration) |
| Assigns unique numbers to each SgScopeStatement of a function. | |
| bool | SageInterface::isAncestor (SgNode *node1, SgNode *node2) |
| check if node1 is a strict ancestor of node 2. (a node is not considered its own ancestor) | |
Preprocessing Information | |
| if-else-end, comments, include, etc | |
| void | SageInterface::dumpPreprocInfo (SgLocatedNode *locatedNode) |
| Dumps a located node's preprocessing information. | |
| PreprocessingInfo * | SageInterface::insertHeader (const std::string &filename, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::after, bool isSystemHeader=false, SgScopeStatement *scope=NULL) |
| Insert include "filename" or include <filename> (system header) into the global scope containing the current scope, right after other include XXX. | |
| void | SageInterface::moveUpPreprocessingInfo (SgStatement *stmt_dst, SgStatement *stmt_src, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false) |
| Identical to movePreprocessingInfo(), except for the stale name and confusing order of parameters. It will be deprecated soon. | |
| void | SageInterface::movePreprocessingInfo (SgStatement *stmt_src, SgStatement *stmt_dst, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false) |
| Move preprocessing information of stmt_src to stmt_dst, Only move preprocessing information from the specified source-relative position to a specified target position, otherwise move all preprocessing information with position information intact. The preprocessing information is appended to the existing preprocessing information list of the target node by default. Prepending is used if usePreprend is set to true. Optionally, the relative position can be adjust after the moving using dst_position. | |
| void | SageInterface::cutPreprocessingInfo (SgLocatedNode *src_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType &save_buf) |
| Cut preprocessing information from a source node and save it into a buffer. Used in combination of pastePreprocessingInfo(). The cut-paste operation is similar to moveUpPreprocessingInfo() but it is more flexible in that the destination node can be unknown during the cut operation. | |
| void | SageInterface::pastePreprocessingInfo (SgLocatedNode *dst_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType &saved_buf) |
| Paste preprocessing information from a buffer to a destination node. Used in combination of cutPreprocessingInfo(). | |
| PreprocessingInfo * | SageInterface::attachArbitraryText (SgLocatedNode *target, const std::string &text, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before) |
| Attach an arbitrary string to a located node. A workaround to insert irregular statements or vendor-specific attributes. | |
| void | SageInterface::replaceMacroCallsWithExpandedStrings (SgPragmaDeclaration *target) |
| Check if a pragma declaration node has macro calls attached, if yes, replace macro calls within the pragma string with expanded strings. This only works if -rose:wave is turned on. | |
Source File Position | |
| set Sg_File_Info for a SgNode | |
| PreprocessingInfo * | SageInterface::attachComment (SgLocatedNode *target, const std::string &content, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before, PreprocessingInfo::DirectiveType dtype=PreprocessingInfo::CpreprocessorUnknownDeclaration) |
| Build and attach comment, comment style is inferred from the language type of the target node if not provided. | |
| void | SageInterface::addTextForUnparser (SgNode *astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation) |
| Add a string to be unparsed to support code generation for back-end specific tools or compilers. | |
| void | SageInterface::setOneSourcePositionForTransformation (SgNode *node) |
| Set current node's source position as transformation generated. | |
| void | SageInterface::setOneSourcePositionNull (SgNode *node) |
| Set current node's source position as NULL. | |
| void | SageInterface::setSourcePositionForTransformation (SgNode *root) |
| Recursively set source position info(Sg_File_Info) as transformation generated. | |
| void | SageInterface::setSourcePositionForTransformation_memoryPool () |
| Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool. | |
| void | SageInterface::setSourcePosition (SgLocatedNode *locatedNode) |
| Set the source position of SgLocatedNode to Sg_File_Info::generateDefaultFileInfo(). These nodes WILL be unparsed. Not for transformation usage. | |
Data types | |
| SgType * | SageInterface::getBoolType (SgNode *n) |
| Get the right bool type according to C or C++ language input. | |
| bool | SageInterface::isStrictIntegerType (SgType *t) |
| Check if a type is an integral type, only allowing signed/unsigned short, int, long, long long. | |
| SgType * | SageInterface::getFirstVarType (SgVariableDeclaration *decl) |
| Get the data type of the first initialized name of a declaration statement. | |
| bool | SageInterface::isDefaultConstructible (SgType *type) |
| Is a type default constructible? This may not quite work properly. | |
| bool | SageInterface::isCopyConstructible (SgType *type) |
| Is a type copy constructible? This may not quite work properly. | |
| bool | SageInterface::isAssignable (SgType *type) |
| Is a type assignable? This may not quite work properly. | |
| bool | SageInterface::isPureVirtualClass (SgType *type, const ClassHierarchyWrapper &classHierarchy) |
| Check if a class type is a pure virtual class. | |
| bool | SageInterface::hasTrivialDestructor (SgType *t) |
| Does a type have a trivial (built-in) destructor? | |
| bool | SageInterface::isNonconstReference (SgType *t) |
| Is this type a non-constant reference type? (Handles typedefs correctly). | |
| bool | SageInterface::isReferenceType (SgType *t) |
| Is this type a const or non-const reference type? (Handles typedefs correctly). | |
| bool | SageInterface::isPointerType (SgType *t) |
| Is this type a pointer type? (Handles typedefs correctly). | |
| bool | SageInterface::isPointerToNonConstType (SgType *type) |
| Is this a pointer to a non-const type? Note that this function will return true for const pointers pointing to non-const types. | |
| bool | SageInterface::isConstType (SgType *t) |
| Is this a const type? | |
| SgType * | SageInterface::removeConst (SgType *t) |
| Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers. | |
| bool | SageInterface::isVolatileType (SgType *t) |
| Is this a volatile type? | |
| bool | SageInterface::isRestrictType (SgType *t) |
| Is this a restrict type? | |
| bool | SageInterface::isScalarType (SgType *t) |
| Is this a scalar type? | |
| bool | SageInterface::isStructType (SgType *t) |
| Check if a type is a struct type (a special SgClassType in ROSE). | |
| std::string | SageInterface::mangleType (SgType *type) |
| Generate a mangled string for a given type based on Itanium C++ ABI. | |
| std::string | SageInterface::mangleScalarType (SgType *type) |
| Generate mangled scalar type names according to Itanium C++ ABI, the input type should pass isScalarType() in ROSE. | |
| std::string | SageInterface::mangleModifierType (SgModifierType *type) |
| Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI, with extension to handle UPC shared types. | |
| size_t | SageInterface::getArrayElementCount (SgArrayType *t) |
| Calculate the number of elements of an array type: dim1* dim2*... , assume element count is 1 for int a[]; Strip off THREADS if it is a UPC array. | |
| int | SageInterface::getDimensionCount (SgType *t) |
| Get the number of dimensions of an array type. | |
| SgType * | SageInterface::getArrayElementType (SgType *t) |
| Get the element type of an array. | |
| SgType * | SageInterface::getElementType (SgType *t) |
| Get the element type of an array, pointer or string, or NULL if not applicable. | |
| bool | SageInterface::isArrayReference (SgExpression *ref, SgExpression **arrayNameExp=NULL, std::vector< SgExpression * > **subscripts=NULL) |
| Check if an expression is an array access (SgPntrArrRefExp). If so, return its name expression and subscripts if requested. Users can use convertRefToInitializedName() to get the possible name. It does not check if the expression is a top level SgPntrArrRefExp. | |
| bool | SageInterface::hasUpcSharedType (SgType *t, SgModifierType **mod_type_out=NULL) |
| Has a UPC shared type of any kinds (shared-to-shared, private-to-shared, shared-to-private, shared scalar/array)? An optional parameter, mod_type_out, stores the first SgModifierType with UPC access information. | |
| bool | SageInterface::isUpcSharedType (SgType *t, SgModifierType **mod_type_out=NULL) |
| Check if a type is a UPC shared type, including shared array, shared pointers etc. Exclude private pointers to shared types. Optionally return the modifier type with the UPC shared property. | |
| bool | SageInterface::isUpcSharedModifierType (SgModifierType *mod_type) |
| Check if a modifier type is a UPC shared type. | |
| bool | SageInterface::isUpcSharedArrayType (SgArrayType *array_type) |
| Check if an array type is a UPC shared type. ROSE AST represents a UPC shared array as regular array of elements of UPC shared Modifier Type. Not directly a UPC shared Modifier Type of an array. | |
| bool | SageInterface::isUpcStrictSharedModifierType (SgModifierType *mode_type) |
| Check if a shared UPC type is strict memory consistency or not. Return false if it is relaxed. (So isUpcRelaxedSharedModifierType() is not necessary.). | |
| size_t | SageInterface::getUpcSharedBlockSize (SgModifierType *mod_type) |
| Get the block size of a UPC shared modifier type. | |
| size_t | SageInterface::getUpcSharedBlockSize (SgType *t) |
| Get the block size of a UPC shared type, including Modifier types and array of modifier types (shared arrays). | |
| bool | SageInterface::isUpcPhaseLessSharedType (SgType *t) |
| Is UPC phase-less shared type? Phase-less means block size of the first SgModifierType with UPC information is 1 or 0/unspecified. Also return false if the type is not a UPC shared type. | |
| bool | SageInterface::isUpcPrivateToSharedType (SgType *t) |
| Is a UPC private-to-shared pointer? SgPointerType comes first compared to SgModifierType with UPC information. Input type must be any of UPC shared types first. | |
| bool | SageInterface::isUpcArrayWithThreads (SgArrayType *t) |
| Is a UPC array with dimension of X*THREADS. | |
| SgType * | SageInterface::lookupNamedTypeInParentScopes (const std::string &type_name, SgScopeStatement *scope=NULL) |
| Lookup a named type based on its name, bottomup searching from a specified scope. Note name collison might be allowed for c (not C++) between typedef and enum/struct. Only the first matched named type will be returned in this case. typedef is returned as it is, not the base type it actually refers to. | |
Loop handling | |
| void | SageInterface::addStepToLoopBody (SgScopeStatement *loopStmt, SgStatement *step) |
| Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. | |
| void | SageInterface::moveForStatementIncrementIntoBody (SgForStatement *f) |
| Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. | |
| void | SageInterface::convertForToWhile (SgForStatement *f) |
| Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. | |
| void | SageInterface::convertAllForsToWhiles (SgNode *top) |
| Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. | |
| void | SageInterface::changeContinuesToGotos (SgStatement *stmt, SgLabelStatement *label) |
| Change continue statements in a given block of code to gotos to a label. | |
| SgInitializedName * | SageInterface::getLoopIndexVariable (SgNode *loop) |
| Return the loop index variable for a for loop. | |
| bool | SageInterface::isLoopIndexVariable (SgInitializedName *ivar, SgNode *subtree_root) |
| Check if a SgInitializedName is used as a loop index within a AST subtree This function will use a bottom-up traverse starting from the subtree_root to find all enclosing loops and check if ivar is used as an index for either of them. | |
| SgStatement * | SageInterface::getLoopBody (SgScopeStatement *loop) |
| Routines to get and set the body of a loop. | |
| void | SageInterface::setLoopBody (SgScopeStatement *loop, SgStatement *body) |
| Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. | |
| SgStatement * | SageInterface::getLoopCondition (SgScopeStatement *loop) |
| Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop. | |
| void | SageInterface::setLoopCondition (SgScopeStatement *loop, SgStatement *cond) |
| Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop. | |
| bool | SageInterface::isCanonicalForLoop (SgNode *loop, SgInitializedName **ivar=NULL, SgExpression **lb=NULL, SgExpression **ub=NULL, SgExpression **step=NULL, SgStatement **body=NULL, bool *hasIncrementalIterationSpace=NULL, bool *isInclusiveUpperBound=NULL) |
| Check if a for-loop has a canonical form, return loop index, bounds, step, and body if requested. | |
| bool | SageInterface::isCanonicalDoLoop (SgFortranDo *loop, SgInitializedName **ivar, SgExpression **lb, SgExpression **ub, SgExpression **step, SgStatement **body, bool *hasIncrementalIterationSpace, bool *isInclusiveUpperBound) |
| Check if a Fortran Do loop has a complete canonical form: Do I=1, 10, 1. | |
| void | SageInterface::setLoopLowerBound (SgNode *loop, SgExpression *lb) |
| Set the lower bound of a loop header for (i=lb; ...). | |
| void | SageInterface::setLoopUpperBound (SgNode *loop, SgExpression *ub) |
| Set the upper bound of a loop header,regardless the condition expression type. for (i=lb; i op up, ...). | |
| void | SageInterface::setLoopStride (SgNode *loop, SgExpression *stride) |
| Set the stride(step) of a loop 's incremental expression, regardless the expression types (i+=s; i= i+s, etc). | |
| bool | SageInterface::normalizeForLoopInitDeclaration (SgForStatement *loop) |
| Normalize loop init stmt by promoting the single variable declaration statement outside of the for loop header's init statement, e.g. for (int i=0;) becomes int i_x; for (i_x=0;..) and rewrite the loop with the new index variable, if necessary. | |
| bool | SageInterface::forLoopNormalization (SgForStatement *loop) |
| Normalize a for loop, return true if successful. | |
| bool | SageInterface::doLoopNormalization (SgFortranDo *loop) |
| Normalize a Fortran Do loop. Make the default increment expression (1) explicit. | |
| bool | SageInterface::loopUnrolling (SgForStatement *loop, size_t unrolling_factor) |
| Unroll a target loop with a specified unrolling factor. It handles steps larger than 1 and adds a fringe loop if the iteration count is not evenly divisible by the unrolling factor. | |
| bool | SageInterface::loopInterchange (SgForStatement *loop, size_t depth, size_t lexicoOrder) |
| Interchange/permutate a n-level perfectly-nested loop rooted at 'loop' using a lexicographical order number within (0,depth!). | |
| bool | SageInterface::loopTiling (SgForStatement *loopNest, size_t targetLevel, size_t tileSize) |
| Tile the n-level (starting from 1) loop of a perfectly nested loop nest using tiling size s. | |
Topdown search | |
| Top-down traversal from current node to find a node of a specified type | |
| template<typename NodeType> | |
| std::vector< NodeType * > | SageInterface::querySubTree (SgNode *top, VariantT variant=(VariantT) NodeType::static_variant) |
| Query a subtree to get all nodes of a given type, with an appropriate downcast. | |
| std::vector< SgFile * > | SageInterface::generateFileList () |
| Returns STL vector of SgFile IR node pointers. | |
| SgProject * | SageInterface::getProject () |
| Get the current SgProject IR Node. | |
| template<typename NodeType> | |
| static std::vector< NodeType * > | SageInterface::getSgNodeListFromMemoryPool () |
| Query memory pools to grab SgNode of a specified type. | |
| SgFunctionDeclaration * | SageInterface::findMain (SgNode *currentNode) |
| top-down traversal from current node to find the main() function declaration | |
| SgStatement * | SageInterface::findLastDeclarationStatement (SgScopeStatement *scope) |
| Find the last declaration statement within a scope (if any). This is often useful to decide where to insert another declaration statement. | |
| std::vector< SgVariableSymbol * > | SageInterface::getSymbolsUsedInExpression (SgExpression *expr) |
| Find referenced symbols within an expression. | |
| std::vector< SgBreakStmt * > | SageInterface::findBreakStmts (SgStatement *code, const std::string &fortranLabel="") |
| Find break statements inside a particular statement, stopping at nested loops or switches. | |
| std::vector< SgContinueStmt * > | SageInterface::findContinueStmts (SgStatement *code, const std::string &fortranLabel="") |
| Find all continue statements inside a particular statement, stopping at nested loops. | |
| std::vector< SgGotoStatement * > | SageInterface::findGotoStmts (SgStatement *scope, SgLabelStatement *l) |
| Query a subtree to get all nodes of a given type, with an appropriate downcast. | |
| std::vector< SgStatement * > | SageInterface::getSwitchCases (SgSwitchStatement *sw) |
| Query a subtree to get all nodes of a given type, with an appropriate downcast. | |
| template<typename T> | |
| T * | SageInterface::findDeclarationStatement (SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining) |
| Topdown traverse a subtree from root to find the first declaration given its name, scope (optional, can be NULL), and defining or nondefining flag. | |
| SgFunctionDeclaration * | SageInterface::findFunctionDeclaration (SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining) |
| Topdown traverse a subtree from root to find the first function declaration matching the given name, scope (optional, can be NULL), and defining or nondefining flag. This is an instantiation of findDeclarationStatement<T>. | |
Bottom up search | |
| Backwards traverse through the AST to find a node, findEnclosingXXX() | |
| template<typename NodeType> | |
| NodeType * | SageInterface::getEnclosingNode (const SgNode *astNode, const bool includingSelf=false) |
| Find a node by type using upward traversal. | |
| SgScopeStatement * | SageInterface::getScope (const SgNode *astNode) |
| Get the closest scope from astNode. Return astNode if it is already a scope. | |
| SgGlobal * | SageInterface::getGlobalScope (const SgNode *astNode) |
| Traverse back through a node's parents to find the enclosing global scope. | |
| SgFunctionDefinition * | SageInterface::getEnclosingProcedure (SgNode *n, const bool includingSelf=false) |
| Find the function definition. | |
| SgFunctionDefinition * | SageInterface::getEnclosingFunctionDefinition (SgNode *astNode, const bool includingSelf=false) |
| Find a node by type using upward traversal. | |
| SgStatement * | SageInterface::getEnclosingStatement (SgNode *n) |
| Find the closest enclosing statement, including the given node. | |
| SgSwitchStatement * | SageInterface::findEnclosingSwitch (SgStatement *s) |
| Find the closest switch outside a given statement (normally used for case and default statements). | |
| SgScopeStatement * | SageInterface::findEnclosingLoop (SgStatement *s, const std::string &fortranLabel="", bool stopOnSwitches=false) |
| Find the closest loop outside the given statement; if fortranLabel is not empty, the Fortran label of the loop must be equal to it. | |
| SgFunctionDeclaration * | SageInterface::getEnclosingFunctionDeclaration (SgNode *astNode, const bool includingSelf=false) |
| Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStatement, isSgProgramHeaderStatement, and isSgMemberFunctionDeclaration. | |
| SgFile * | SageInterface::getEnclosingFileNode (SgNode *astNode) |
| get the SgFile node from current node | |
| SgInitializer * | SageInterface::getInitializerOfExpression (SgExpression *n) |
| Get the initializer containing an expression if it is within an initializer. | |
| SgClassDefinition * | SageInterface::getEnclosingClassDefinition (SgNode *astnode, const bool includingSelf=false) |
| Get the closest class definition enclosing the specified AST node,. | |
AST Walk and Traversal | |
| SgGlobal * | SageInterface::getFirstGlobalScope (SgProject *project) |
| return the first global scope under current project | |
| SgStatement * | SageInterface::getLastStatement (SgScopeStatement *scope) |
| get the last statement within a scope, return NULL if it does not exit | |
| SgStatement * | SageInterface::getFirstStatement (SgScopeStatement *scope, bool includingCompilerGenerated=false) |
| Get the first statement within a scope, return NULL if it does not exist. Skip compiler-generated statement by default. Count transformation-generated ones, but excluding those which are not to be outputted in unparsers. | |
| SgFunctionDeclaration * | SageInterface::findFirstDefiningFunctionDecl (SgScopeStatement *scope) |
| Find the first defining function declaration statement in a scope. | |
| SgStatement * | SageInterface::getNextStatement (SgStatement *currentStmt) |
| Get next statement within the same scope of current statement. | |
| SgStatement * | SageInterface::getPreviousStatement (SgStatement *currentStmt) |
| Get previous statement within the same scope of current statement. | |
AST Comparison | |
| Compare AST nodes, subtree, etc | |
| bool | SageInterface::isEqualToIntConst (SgExpression *e, int value) |
| Check if a SgIntVal node has a given value. | |
| bool | SageInterface::isSameFunction (SgFunctionDeclaration *func1, SgFunctionDeclaration *func2) |
| Check if two function declarations refer to the same one. Two function declarations are the same when they are a) identical, b) same name in C c) same qualified named and mangled name in C++. A nondefining (prototype) declaration and a defining declaration of a same function are treated as the same. | |
| bool | SageInterface::isLastStatement (SgStatement *stmt) |
| Check if a statement is the last statement within its closed scope. | |
AST insert, removal, and replacement | |
| Add, remove,and replace AST
scope->append_statement(), exprListExp->append_expression() etc. are not enough to handle side effect of parent pointers, symbol tables, preprocessing info, defining/nondefining pointers etc. | |
| void | SageInterface::deleteAST (SgNode *node) |
| Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
| void | SageInterface::deleteExpressionTreeWithOriginalExpressionSubtrees (SgNode *root) |
| Special purpose function for deleting AST expression tress containing valid original expression trees in constant folded expressions (for internal use only). | |
| void | SageInterface::moveStatementsBetweenBlocks (SgBasicBlock *sourceBlock, SgBasicBlock *targetBlock) |
| Move statements in first block to the second block (preserves order and rebuilds the symbol table). | |
| void | SageInterface::appendStatement (SgStatement *stmt, SgScopeStatement *scope=NULL) |
| Append a statement to the end of the current scope, handle side effect of appending statements, e.g. preprocessing info, defining/nondefining pointers etc. | |
| void | SageInterface::appendStatementList (const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL) |
| Append a list of statements to the end of the current scope, handle side effect of appending statements, e.g. preprocessing info, defining/nondefining pointers etc. | |
| void | SageInterface::appendStatementWithDependentDeclaration (SgDeclarationStatement *decl, SgGlobal *scope, SgStatement *original_statement, bool excludeHeaderFiles) |
| Append a copy ('decl') of a function ('original_statement') into a 'scope', include any referenced declarations required if the scope is within a compiler generated file. All referenced declarations, including those from headers, are inserted if excludeHeaderFiles is set to true (the new file will not have any headers). | |
| void | SageInterface::prependStatement (SgStatement *stmt, SgScopeStatement *scope=NULL) |
| Prepend a statement to the beginning of the current scope, handling side effects as appropriate. | |
| void | SageInterface::prependStatementList (const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL) |
| prepend a list of statements to the beginning of the current scope, handling side effects as appropriate | |
| bool | SageInterface::hasSimpleChildrenList (SgScopeStatement *scope) |
| Check if a scope statement has a simple children statement list so insert additional statements under the scope is straightforward and unambiguous . | |
| void | SageInterface::insertStatement (SgStatement *targetStmt, SgStatement *newStmt, bool insertBefore=true, bool autoMovePreprocessingInfo=true) |
| Insert a statement before or after the target statement within the target's scope. Move around preprocessing info automatically. | |
| void | SageInterface::insertStatementList (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts, bool insertBefore=true) |
| Insert a list of statements before or after the target statement within the. | |
| void | SageInterface::insertStatementBefore (SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true) |
| Insert a statement before a target statement. | |
| void | SageInterface::insertStatementListBefore (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts) |
| Insert a list of statements before a target statement. | |
| void | SageInterface::insertStatementAfter (SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true) |
| Insert a statement after a target statement, Move around preprocessing info automatically by default. | |
| void | SageInterface::insertStatementListAfter (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt) |
| Insert a list of statements after a target statement. | |
| void | SageInterface::insertStatementAfterLastDeclaration (SgStatement *stmt, SgScopeStatement *scope) |
| Insert a statement after the last declaration within a scope. The statement will be prepended to the scope if there is no declaration statement found. | |
| void | SageInterface::insertStatementAfterLastDeclaration (std::vector< SgStatement * > stmt_list, SgScopeStatement *scope) |
| Insert a list of statements after the last declaration within a scope. The statement will be prepended to the scope if there is no declaration statement found. | |
| void | SageInterface::removeStatement (SgStatement *stmt, bool autoRelocatePreprocessingInfo=true) |
| Remove a statement from its attach point of the AST. Automatically keep its associated preprocessing information at the original place after the removal. The statement is still in memory and it is up to the users to decide if the removed one will be inserted somewhere else or released from memory (deleteAST()). | |
| void | SageInterface::deepDelete (SgNode *root) |
| Deep delete a sub AST tree. It uses postorder traversal to delete each child node. Users must take care of any dangling pointers, symbols or types that result. This is identical to deleteAST(). | |
| void | SageInterface::replaceStatement (SgStatement *oldStmt, SgStatement *newStmt, bool movePreprocessinInfo=false) |
| Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested. | |
| SgNode * | SageInterface::replaceWithPattern (SgNode *anchor, SgNode *new_pattern) |
| Replace an anchor node with a specified pattern subtree with optional SgVariantExpression. All SgVariantExpression in the pattern will be replaced with copies of the anchor node. | |
| std::pair< SgVariableDeclaration *, SgExpression * > | SageInterface::createTempVariableForExpression (SgExpression *expression, SgScopeStatement *scope, bool initializeInDeclaration, SgAssignOp **reEvaluate=NULL) |
| Given an expression, generates a temporary variable whose initializer optionally evaluates that expression. | |
| SgVariableSymbol * | SageInterface::appendArg (SgFunctionParameterList *, SgInitializedName *) |
| Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for arguments when possible. | |
| SgVariableSymbol * | SageInterface::prependArg (SgFunctionParameterList *, SgInitializedName *) |
| Prepend an argument to SgFunctionParameterList. | |
| void | SageInterface::appendExpression (SgExprListExp *, SgExpression *) |
| Append an expression to a SgExprListExp, set the parent pointer also. | |
| void | SageInterface::appendExpressionList (SgExprListExp *, const std::vector< SgExpression * > &) |
| Append an expression list to a SgExprListExp, set the parent pointers also. | |
| void | SageInterface::setParameterList (SgFunctionDeclaration *func, SgFunctionParameterList *paralist) |
| Set parameter list for a function declaration, considering existing parameter list etc. | |
| void | SageInterface::setPragma (SgPragmaDeclaration *decl, SgPragma *pragma) |
| Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer. | |
| void | SageInterface::replaceExpression (SgExpression *oldExp, SgExpression *newExp, bool keepOldExp=false) |
| Replace an expression with another, used for variable reference substitution and others. the old expression can be deleted (default case) or kept. | |
| void | SageInterface::replaceExpressionWithStatement (SgExpression *from, SageInterface::StatementGenerator *to) |
| Replace a given expression with a list of statements produced by a generator. | |
| void | SageInterface::replaceSubexpressionWithStatement (SgExpression *from, SageInterface::StatementGenerator *to) |
| Similar to replaceExpressionWithStatement, but with more restrictions. | |
| void | SageInterface::setOperand (SgExpression *target, SgExpression *operand) |
| Set operands for expressions with single operand, such as unary expressions. handle file info, lvalue, pointer downcasting, parent pointer etc. | |
| void | SageInterface::setLhsOperand (SgExpression *target, SgExpression *lhs) |
| set left hand operand for binary expressions, transparently downcasting target expressions when necessary | |
| void | SageInterface::setRhsOperand (SgExpression *target, SgExpression *rhs) |
| set left hand operand for binary expression | |
| void | SageInterface::removeAllOriginalExpressionTrees (SgNode *top) |
| Set original expression trees to NULL for SgValueExp or SgCastExp expressions, so you can change the value and have it unparsed correctly. | |
| void | SageInterface::moveToSubdirectory (std::string directoryName, SgFile *file) |
| Move file to be generated in a subdirectory (will be generated by the unparser). | |
| SgStatement * | SageInterface::findSurroundingStatementFromSameFile (SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement) |
| Supporting function to comment relocation in insertStatement() and removeStatement(). | |
| void | SageInterface::moveCommentsToNewStatement (SgStatement *sourceStatement, const std::vector< int > &indexList, SgStatement *targetStatement, bool surroundingStatementPreceedsTargetStatement) |
| Relocate comments and CPP directives from one statement to another. | |
AST repair, fix, and postprocessing. | |
| Mostly used internally when some AST pieces are built without knowing their target scope/parent, especially during bottom-up construction of AST. The associated symbols, parent and scope pointers cannot be set on construction then. A set of utility functions are provided to patch up scope, parent, symbol for them when the target scope/parent become know. | |
| int | SageInterface::fixVariableReferences (SgNode *root) |
| Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
| void | SageInterface::fixVariableDeclaration (SgVariableDeclaration *varDecl, SgScopeStatement *scope) |
| Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known. | |
| void | SageInterface::fixStructDeclaration (SgClassDeclaration *structDecl, SgScopeStatement *scope) |
| Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a struct declaration was built without knowing its target scope. | |
| void | SageInterface::fixClassDeclaration (SgClassDeclaration *classDecl, SgScopeStatement *scope) |
| Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a class declaration was built without knowing its target scope. | |
| void | SageInterface::fixNamespaceDeclaration (SgNamespaceDeclarationStatement *structDecl, SgScopeStatement *scope) |
| Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a namespace declaration was built without knowing its target scope. | |
| void | SageInterface::fixLabelStatement (SgLabelStatement *label_stmt, SgScopeStatement *scope) |
| Fix symbol table for SgLabelStatement. Used Internally when the label is built without knowing its target scope. Both parameters cannot be NULL. | |
| void | SageInterface::setFortranNumericLabel (SgStatement *stmt, int label_value) |
| Set a numerical label for a Fortran statement. The statement should have a enclosing function definition already. SgLabelSymbol and SgLabelRefExp are created transparently as needed. | |
| int | SageInterface::suggestNextNumericLabel (SgFunctionDefinition *func_def) |
| Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope. | |
| void | SageInterface::fixStatement (SgStatement *stmt, SgScopeStatement *scope) |
| A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(), etc) for all kinds statements. Should be used before attaching the statement into AST. | |
Advanced AST transformations, analyses, and optimizations | |
| Some complex but commonly used AST transformations. | |
| bool | SageInterface::collectReadWriteRefs (SgStatement *stmt, std::vector< SgNode * > &readRefs, std::vector< SgNode * > &writeRefs) |
| Collect all read and write references within stmt, which can be a function, a scope statement, or a single statement. Note that a reference can be both read and written, like i++. | |
| bool | SageInterface::collectReadWriteVariables (SgStatement *stmt, std::set< SgInitializedName * > &readVars, std::set< SgInitializedName * > &writeVars) |
| Collect unique variables which are read or written within a statement. Note that a variable can be both read and written. The statement can be either of a function, a scope, or a single line statement. | |
| void | SageInterface::collectReadOnlyVariables (SgStatement *stmt, std::set< SgInitializedName * > &readOnlyVars) |
| Collect read only variables within a statement. The statement can be either of a function, a scope, or a single line statement. | |
| void | SageInterface::collectReadOnlySymbols (SgStatement *stmt, std::set< SgVariableSymbol * > &readOnlySymbols) |
| Collect read only variable symbols within a statement. The statement can be either of a function, a scope, or a single line statement. | |
| bool | SageInterface::isUseByAddressVariableRef (SgVarRefExp *ref) |
| Check if a variable reference is used by its address: including &a expression and foo(a) when type2 foo(Type& parameter) in C++. | |
| void | SageInterface::collectUseByAddressVariableRefs (const SgStatement *s, std::set< SgVarRefExp * > &varSetB) |
| Collect variable references involving use by address: including &a expression and foo(a) when type2 foo(Type& parameter) in C++. | |
| LivenessAnalysis * | SageInterface::call_liveness_analysis (SgProject *project, bool debug=false) |
| Call liveness analysis on an entire project. | |
| void | SageInterface::getLiveVariables (LivenessAnalysis *liv, SgForStatement *loop, std::set< SgInitializedName * > &liveIns, std::set< SgInitializedName * > &liveOuts) |
| get liveIn and liveOut variables for a for loop from liveness analysis result liv. | |
| void | SageInterface::ReductionRecognition (SgForStatement *loop, std::set< std::pair< SgInitializedName *, VariantT > > &results) |
| Recognize and collect reduction variables and operations within a C/C++ loop, following OpenMP 3.0 specification for allowed reduction variable types and operation types. | |
| void | SageInterface::constantFolding (SgNode *r) |
| Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values, if applicable). Please be advised that constant folding on floating point computation may decrease the accuracy of floating point computations! | |
| int | SageInterface::instrumentEndOfFunction (SgFunctionDeclaration *func, SgStatement *s) |
| Instrument(Add a statement, often a function call) into a function right before the return points, handle multiple return statements and return expressions with side effects. Return the number of statements inserted. | |
| void | SageInterface::removeJumpsToNextStatement (SgNode *) |
| Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments. | |
| void | SageInterface::removeUnusedLabels (SgNode *top) |
| Remove labels which are not targets of any goto statements. | |
| void | SageInterface::removeConsecutiveLabels (SgNode *top) |
| Remove consecutive labels. | |
| SgAssignInitializer * | SageInterface::splitExpression (SgExpression *from, std::string newName="") |
| Replace an expression with a temporary variable and an assignment statement. | |
| void | SageInterface::splitExpressionIntoBasicBlock (SgExpression *expr) |
| Split long expressions into blocks of statements. | |
| void | SageInterface::removeLabeledGotos (SgNode *top) |
| Remove labeled goto statements. | |
| void | SageInterface::changeBreakStatementsToGotos (SgStatement *loopOrSwitch) |
| If the given statement contains any break statements in its body, add a new label below the statement and change the breaks into gotos to that new label. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfFor (SgForStatement *fs) |
| Check if the body of a 'for' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfUpcForAll (SgUpcForAllStatement *fs) |
| Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfWhile (SgWhileStmt *ws) |
| Check if the body of a 'while' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfDoWhile (SgDoWhileStmt *ws) |
| Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfSwitch (SgSwitchStatement *ws) |
| Check if the body of a 'switch' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsTrueBodyOfIf (SgIfStmt *ifs) |
| Check if the true body of a 'if' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsFalseBodyOfIf (SgIfStmt *ifs) |
| Check if the false body of a 'if' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfCatch (SgCatchOptionStmt *cos) |
| Check if the body of a 'catch' statement is a SgBasicBlock, create one if not. | |
| SgBasicBlock * | SageInterface::ensureBasicBlockAsBodyOfOmpBodyStmt (SgOmpBodyStatement *ompbodyStmt) |
| Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not. | |
| bool | SageInterface::isBodyStatement (SgStatement *s) |
| Check if a statement is a (true or false) body of a container-like parent, such as For, Upc_forall, Do-while, switch, If, Catch, OmpBodyStmt, etc. | |
| void | SageInterface::changeAllBodiesToBlocks (SgNode *top) |
| Fix up ifs, loops, while, switch, Catch, OmpBodyStatement, etc. to have blocks as body components. It also adds an empty else body to if statements that don't have them. | |
| void | SageInterface::changeAllLoopBodiesToBlocks (SgNode *top) |
| The same as changeAllBodiesToBlocks(SgNode* top). To be phased out. | |
| SgBasicBlock * | SageInterface::makeSingleStatementBodyToBlock (SgStatement *singleStmt) |
| Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall etc. | |
| unsigned long long | SageInterface::getIntegerConstantValue (SgValueExp *expr) |
| Get the constant value from a constant integer expression; abort on everything else. | |
| std::vector< SgDeclarationStatement * > | SageInterface::getDependentDeclarations (SgStatement *stmt) |
| Get a statement's dependent declarations which declares the types used in the statement. The returned vector of declaration statements are sorted according to their appearance order in the original AST. Any reference to a class or template class from a namespace will treated as a reference to the enclosing namespace. | |
| SgCommaOpExp * | SageInterface::insertBeforeUsingCommaOp (SgExpression *new_exp, SgExpression *anchor_exp) |
| Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects, without changing the original semantics. This is achieved by using a comma operator: (new_exp, anchor_exp). The comma operator is returned. | |
| SgCommaOpExp * | SageInterface::insertAfterUsingCommaOp (SgExpression *new_exp, SgExpression *anchor_exp, SgStatement **temp_decl=NULL, SgVarRefExp **temp_ref=NULL) |
| Insert an expression (new_exp ) after another expression (anchor_exp) has possible side effects, without changing the original semantics. This is done by using two comma operators: type T1; ... ((T1 = anchor_exp, new_exp),T1) )... , where T1 is a temp variable saving the possible side effect of anchor_exp. The top level comma op exp is returned. The reference to T1 in T1 = anchor_exp is saved in temp_ref. | |
| std::pair< SgStatement *, SgInitializedName * > | SageInterface::wrapFunction (SgFunctionDeclaration &definingDeclaration, SgName newName) |
| moves the body of a function f to a new function f`; f's body is replaced with code that forwards the call to f`. | |
| template<class NameGen> | |
| std::pair< SgStatement *, SgInitializedName * > | SageInterface::wrapFunction (SgFunctionDeclaration &definingDeclaration, NameGen nameGen) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. NameGen, functor that generates a new name based on the old name.see wrapFunction for details. | |
| SgInitializedName & | SageInterface::getFirstVariable (SgVariableDeclaration &vardecl) |
| convenience function that returns the first initialized name in a list of variable declarations. | |
Defines | |
| #define | TRANS_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode() |
| An alias for Sg_File_Info::generateDefaultFileInfoForTransformationNode(). | |
Functions | |
| SgFile * | determineFileType (std::vector< std::string > argv, int &nextErrorCode, SgProject *project) |
| std::string | getVariantName (VariantT v) |
| A global function for getting the string associated with an enum (which is defined in global scope). | |
| SgAsmInterpretation * | SageInterface::getMainInterpretation (SgAsmGenericFile *file) |
| uint64_t | SageInterface::getAsmConstant (SgAsmValueExpression *e) |
| Get the unsigned value of a disassembled constant. | |
| int64_t | SageInterface::getAsmSignedConstant (SgAsmValueExpression *e) |
| Get the signed value of a disassembled constant. | |
| void | SageInterface::addMessageStatement (SgStatement *stmt, std::string message) |
| Function to add "C" style comment to statement. | |
| void | SageInterface::supplementReplacementSymbolMap (rose_hash::unordered_map< SgNode *, SgNode *, hash_nodeptr > &inputReplacementMap) |
| void | SageInterface::updateDefiningNondefiningLinks (SgFunctionDeclaration *func, SgScopeStatement *scope) |
| Update defining and nondefining links due to a newly introduced function declaration. Should be used after inserting the function into a scope. | |
Variables | |
| int | SageInterface::gensym_counter |
| An internal counter for generating unique SgName. | |
| #define TRANS_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode() |
An alias for Sg_File_Info::generateDefaultFileInfoForTransformationNode().
Definition at line 52 of file sageInterface.h.
| SgFile* determineFileType | ( | std::vector< std::string > | argv, | |
| int & | nextErrorCode, | |||
| SgProject * | project | |||
| ) |
| std::string getVariantName | ( | VariantT | v | ) |
A global function for getting the string associated with an enum (which is defined in global scope).
1.4.7