ROSE  0.9.10.54
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ssa_unfiltered_cfg::SSA_UnfilteredCfg Class Reference

Description

Static single assignment analysis. This analysis attaches uses an definitions to unfiltered CFG nodes rather than to AST nodes; as such its interfaces are more intuitive and easier to use. It also resolves some ambiguity issues when attaching definitions to AST nodes.

Known bugs:

Definition at line 81 of file ssaUnfilteredCfg.h.

#include <ssaUnfilteredCfg.h>

Collaboration diagram for ssa_unfiltered_cfg::SSA_UnfilteredCfg:
Collaboration graph
[legend]

Public Types

typedef std::vector< SgInitializedName * > VarName
 A compound variable name as used by the variable renaming. More...
 
typedef boost::shared_ptr< ReachingDefReachingDefPtr
 
typedef std::map< VarName, ReachingDefPtr > NodeReachingDefTable
 A map from each variable to its reaching definitions at the current node. More...
 
typedef std::map< CFGNode, std::set< VarName > > CFGNodeToVarNamesMap
 
typedef std::map< SgNode *, std::set< SgVarRefExp * > > ASTNodeToVarRefsMap
 
typedef std::map< CFGNode, NodeReachingDefTableCFGNodeToDefTableMap
 

Public Member Functions

 SSA_UnfilteredCfg (SgProject *proj)
 
void run ()
 Run the analysis. More...
 
void toDOT (const std::string fileName)
 Print the CFG with any UniqueNames and Def/Use information visible. More...
 
void toFilteredDOT (const std::string fileName)
 Print the CFG with any UniqueNames and Def/Use information visible. More...
 
const NodeReachingDefTablegetReachingDefsBefore (const CFGNode &node) const
 Returns the reaching definitions before the given node was executed.
 
const NodeReachingDefTablegetReachingDefsAfter (const CFGNode &node) const
 Returns the reaching definitions after the given node was executed. More...
 
const NodeReachingDefTablegetDefsAtNode (const CFGNode &node) const
 Returns the definitions that occur at the given node. More...
 
const NodeReachingDefTablegetReachingDefsBefore (SgNode *astNode) const
 Get the reaching definitions before the given AST node is executed. More...
 
const NodeReachingDefTablegetReachingDefsAfter (SgNode *astNode) const
 Get the reaching definitions after the given AST node is executed. More...
 
const NodeReachingDefTablegetLastVersions (SgFunctionDefinition *astNode) const
 Get the final versions of all the variables at the end of the given function.
 
const std::set< SgVarRefExp * > & getUsesAtNode (SgNode *astNode) const
 Returns all the SgVarRef objects that are used in the execution of the given AST node. More...
 
const ReachingDefPtr getDefinitionForUse (SgVarRefExp *astNode) const
 Given a use obtained through getUsesAtNode, resolve its corresponding def. More...
 
const ASTNodeToVarRefsMap & getUseTable () const
 Returns the entire use table, mapping each non-statement AST node to the variables used in its execution. More...
 

Static Public Member Functions

static bool getDebug ()
 
static bool getDebugExtra ()
 
static bool isPrefixOfName (VarName name, VarName prefix)
 Find if the given prefix is a prefix of the given name. More...
 
static ssa_private::VarUniqueNamegetUniqueName (SgNode *node)
 Get the uniqueName attribute for the given node. More...
 
static const VarNamegetVarName (SgNode *node)
 Get the variable name of the given node. More...
 
static const VarNamegetVarForExpression (SgNode *node)
 If an expression evaluates to a reference of a variable, returns that variable. More...
 
static SgExpressionbuildVariableReference (const VarName &var, SgScopeStatement *scope=NULL)
 Get an AST fragment containing the appropriate varRefs and Dot/Arrow ops to access the given variable. More...
 
static std::string varnameToString (const VarName &vec)
 Get a string representation of a varName. More...
 
static void printNodeDefTable (const NodeReachingDefTable &table)
 
static void printFullDefTable (const CFGNodeToDefTableMap &defTable)
 

Static Public Attributes

static VarName emptyName
 

Member Typedef Documentation

A compound variable name as used by the variable renaming.

Definition at line 90 of file ssaUnfilteredCfg.h.

A map from each variable to its reaching definitions at the current node.

Definition at line 95 of file ssaUnfilteredCfg.h.

Member Function Documentation

void ssa_unfiltered_cfg::SSA_UnfilteredCfg::run ( )

Run the analysis.

void ssa_unfiltered_cfg::SSA_UnfilteredCfg::toDOT ( const std::string  fileName)

Print the CFG with any UniqueNames and Def/Use information visible.

Parameters
fileNameThe filename to save graph as. Filenames will be prepended.
void ssa_unfiltered_cfg::SSA_UnfilteredCfg::toFilteredDOT ( const std::string  fileName)

Print the CFG with any UniqueNames and Def/Use information visible.

This will only print the nodes that are of interest to the filter function used by the def/use traversal.

Parameters
fileNameThe filename to save graph as. Filenames will be prepended.
const NodeReachingDefTable& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getReachingDefsAfter ( const CFGNode &  node) const

Returns the reaching definitions after the given node was executed.

If there are no local defs at the node (i.e. getDefsAtNode returns empty), then the reaching defs After a node are identical to the reaching defs before the node.

const NodeReachingDefTable& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getDefsAtNode ( const CFGNode &  node) const

Returns the definitions that occur at the given node.

If no definitions occur at the node, the result is empty

const NodeReachingDefTable& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getReachingDefsBefore ( SgNode astNode) const

Get the reaching definitions before the given AST node is executed.

This method is equivalent to looking up the reaching definitions before astNode->cfgForBeginning()

const NodeReachingDefTable& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getReachingDefsAfter ( SgNode astNode) const

Get the reaching definitions after the given AST node is executed.

This method is equivalent to looking up the reaching definitions after astNode->cfgForEnd()

const std::set<SgVarRefExp*>& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getUsesAtNode ( SgNode astNode) const

Returns all the SgVarRef objects that are used in the execution of the given AST node.

Each of the SgVarRef objects returned corresponds to a variable name

const ReachingDefPtr ssa_unfiltered_cfg::SSA_UnfilteredCfg::getDefinitionForUse ( SgVarRefExp astNode) const

Given a use obtained through getUsesAtNode, resolve its corresponding def.

This function may return NULL for SgVarRef objects not returned by getUsesAtNode

const ASTNodeToVarRefsMap& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getUseTable ( ) const

Returns the entire use table, mapping each non-statement AST node to the variables used in its execution.

static bool ssa_unfiltered_cfg::SSA_UnfilteredCfg::isPrefixOfName ( VarName  name,
VarName  prefix 
)
static

Find if the given prefix is a prefix of the given name.

This will return whether the given name has the given prefix inside it.

ex. a.b.c has prefix a.b, but not a.c

Parameters
nameThe name to search.
prefixThe prefix to search for.
Returns
Whether or not the prefix is in this name.
static ssa_private::VarUniqueName* ssa_unfiltered_cfg::SSA_UnfilteredCfg::getUniqueName ( SgNode node)
static

Get the uniqueName attribute for the given node.

Parameters
nodeNode to get the attribute from.
Returns
The attribute, or NULL.
static const VarName& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getVarName ( SgNode node)
static

Get the variable name of the given node.

Parameters
nodeThe node to get the name for.
Returns
The name, or empty name.
static const VarName& ssa_unfiltered_cfg::SSA_UnfilteredCfg::getVarForExpression ( SgNode node)
static

If an expression evaluates to a reference of a variable, returns that variable.

Handles casts, comma ops, address of ops, etc. For example, Given the expression (...., &a), this method would return the VarName for a.

static SgExpression* ssa_unfiltered_cfg::SSA_UnfilteredCfg::buildVariableReference ( const VarName var,
SgScopeStatement scope = NULL 
)
static

Get an AST fragment containing the appropriate varRefs and Dot/Arrow ops to access the given variable.

Parameters
varThe variable to construct access for.
scopeThe scope within which to construct the access.
Returns
An expression that access the given variable in the given scope.
static std::string ssa_unfiltered_cfg::SSA_UnfilteredCfg::varnameToString ( const VarName vec)
static

Get a string representation of a varName.

Parameters
vecvarName to get string for.
Returns
String for given varName.

The documentation for this class was generated from the following file: