Skip to content

VariableRenaming

Class that defines an VariableRenaming of a program

Synopsis

Declared in <src/midend/programAnalysis/variableRenaming/VariableRenaming.h>

Types

Name

Description

DefUseTable

A table storing the name‐>node mappings for every node in the program.

FirstDefTable

A table mapping a name to a single node.

InitNameVec

A vector of SgInitializedName*

NodeNumRenameEntry

An entry in the rename table that maps a node to a number.

NodeNumRenameTable

A table that maps a name to it's node‐>number renamings.

NodeVec

Vector of SgNode*

NumNodeRenameEntry

An entry in the rename table that maps a number to a node.

NumNodeRenameTable

A table that maps a name to it's number‐>node renamings.

TableEntry

An entry in the rename table mapping a name to a nodeVec.

VarName

A compound variable name as used by the variable renaming.

cfgEdge

A filtered CFGEdge that is used for DefUse traversal.

cfgEdgeVec

A vector of cfgEdges.

cfgNode

A filtered CFGNode that is used for DefUse traversal.

cfgNodeVec

A vector of cfgNodes.

Member Functions

Name

Description

VariableRenaming [constructor]

Construct from SgProject

~VariableRenaming [destructor]

Destructor

getAllUsesForDef

getAllUsesForDef overloads

getDebug

getDebugExtra

getDefTable

Get the table of definitions for every node.

getDefsAtNode

Get name:num mapping for all defs at the given node.

getDefsAtNodeForName

Get name:num mapping for def of the specified variable at the given node.

getDefsForSubtree

Get all definitions for the subtree rooted at this node. If m.x is defined, the resulting table will also include a definition for m.

getExpandedDefsAtNode

Get name:num mapping for all expanded defs at the given node.

getExpandedDefsAtNodeForName

Get name:num mapping for def of the specified variable at the given node.

getMaxRenameNumberForName

Get the number of the last rename of the given variable.

getNodeForRenameNumber

Get the node that defines the given number of the given variable.

getOriginalDefsAtNode

Get name:num mapping for all original defs at the given node.

getOriginalDefsAtNodeForName

Get name:num mapping for def of the specified variable at the given node.

getOriginalDefsForSubtree

Get all original definitions for the subtree rooted at this node. No expanded definitions will be included ‐ for example, if m.x is defined, there will be no definition for the structure m.

getOriginalUsesAtNode

Get name:num mappings for the original uses at this node. For example, if p.x appears, there will be a use for p.x, but not for p.

getPropDefTable

Get the defTable containing the propogated definition information.

getReachingDefsAtFunctionEnd

Get the final versions if all variables at the end of the given function.

getReachingDefsAtFunctionEndForName

Get the versions of a variable at the end of the given function.

getReachingDefsAtFunctionStart

Get the versions of all variables at the start of the given function.

getReachingDefsAtFunctionStartForName

Get the versions of a variable at the start of the given function.

getReachingDefsAtNode

Get name:num mappings for all reaching definitions of all variables at the node.

getReachingDefsAtNodeForName

Get name:num mapping for all reaching definitions of the given variable at the node.

getReachingDefsAtScopeEnd

Get the final versions if all variables at the end of the given scope.

getReachingDefsAtStatementStart

Gets the versions of all variables reaching a statment before its execution. Notice that this method and getReachingDefsAtNode potentially return different values for loops. With loops, variable values from the body of the loop flow to the top; hence getReachingDefsAtNode returns definitions from the loop body. On the other hand, getReachingDefsAtStatementStart does not return definitions coming in from a loop body.

getRenameNumberForNode

Get the rename number for the given variable and the given node.

getUseTable

Get the table of uses for every node.

getUsesAtNode

Get name:num mappings for all uses at this node. For example, if p.x appears, there will be a use for both p and p.x

getUsesAtNodeForName

Get name:num mapping for use of the given variable at this node.

printDefs

printOriginalDefTable

printOriginalDefs

printRenameTable

printUses

run

toDOT

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

toFilteredDOT

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

Static Member Functions

Name

Description

buildVariableReference

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

getUniqueName

Get the uniqueName attribute for the given node.

getVarName

Get the variable name of the given node.

isFromLibrary

Gets whether or not the function is from a library.

isPrefixOfName

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

keyToString

Get a string representation of a varName.

printRenameEntry

printRenameTable

Static Data Members

Name

Description

emptyName

emptyRenameEntry

emptyRenameTable

thisDecl

This represents the initializedName for the 'this' keyword.

varKeyTag

Tag to use to retrieve unique naming key from node.

Private Types

Name

Description

ChildUses

Attribute that describes the variables used by a given expression.

DefsAndUsesTraversal

This class collects all the defs and uses associated with each node in the traversed CFG. Note that this does not compute reachability information; it just records each instance of a variable used or defined.

UniqueNameTraversal

Class to traverse the AST and assign unique names to every varRef.

VarRefSynthAttr

Attribute that describes the variables modified by a given expression.

Private Member Functions

Name

Description

addRenameNumberForNode

Add an entry to the renumbering table for the given var and node.

aggregatePreviousDefs

Trace backwards in the cfg one step and return an aggregate of all previous defs.

defUse

expandMemberDefinitions

Expand all member definitions (chained names) to define every name in the chain.

expandMemberUses

Expand all member uses (chained names) to explicitly use every name in the chain.

getVarsUsedInSubtree

Returns a set of all the variables names that have uses in the subtree.

insertDefsForExternalVariables

Insert defs for functions that are declared outside the function scope.

insertExpandedDefsForUse

Insert defs for member uses (chained names) that do not have an explicit def.

isBuiltinVar

mergeDefs

Called to merge the defs from previous nodes in the CFG to this one.

printDefs

printToDOT

printToFilteredDOT

printUses

resolveUses

Called to update the uses on the current node.

runDefUse

Private Data Members

Name

Description

DEBUG_MODE

DEBUG_MODE_EXTRA

defTable

This is the table that is populated with all the def information for all the variables at all the nodes. It is populated during the runDefUse function, and is done with the steady‐state dataflow algorithm.

expandedDefTable

This is the table of definitions that is expanded from the original table. It is used to populate the actual def/use table.

firstDefList

Holds a list of the locations that a particular name is first defined.

nodeRenameTable

This holds the mapping between variables and the nodes where they are renumbered. Given a name and a node, we can get the number of the name that is defined at that node. Nodes which do not define a name are not in the table.

numRenameTable

This holds the mapping between variables and the nodes where they are renumbered. Given a name and a number, we can get the node where that number is defined. Nodes which do not define a name are not in the table.

originalDefTable

This is the table of variable definition locations that is generated by the VarDefUseTraversal. It is later used to populate the actual def/use table.

project

The project to perform SSA Analysis on.

useTable

This is the table that is populated with all the use information for all the variables at all the nodes. It is populated during the runDefUse function, and is done with the steady‐state dataflow algorithm.

Description

Contains all the functionality to implement variable renaming on a given program. For this class, we do not actually transform the AST directly, rather we perform the analysis and add attributes to the AST nodes so that later optimizations can access the results of this analysis while still preserving the original AST.

Created with MrDocs