Skip to content

AstBottomUpProcessing

Attribute evaluator for synthesized attributes.

Synopsis

Declared in <src/midend/astProcessing/AstProcessing.h>

template<class SynthesizedAttributeType>
class AstBottomUpProcessing
    : public SgTreeTraversal<DummyAttribute, SynthesizedAttributeType>

Description

This class allows computation of synthesized attributes on the AST. It requires a synthesized attribute type as a template parameter and the implementation of the function evaluateSynthesizedAttribute. This function is invoked in post-order while the AST is traversed. It can be used for passing information up the AST and for computing a synthesized attribute at each node based on the results of its children in the AST.

Initialization of synthesized attributes is necessary for values which represent results of non-existent nodes (null pointers in the AST) or skipped nodes (e.g. traverseWithinFile skips all nodes which do not represent the same file as from where the evaluation of attributes started).

  • Class as synthesized attribute type. The default constructor is sufficient to initialize the object representing an attribute value.
  • Primitive type as synthesized attribute type (e.g. int, bool, etc.). The method defaultSynthesizedAttribute must be implemented to initialize the synthesized attribute. This function is automatically called during attribute evaluation whenever necessary.

Internal: This class is derived from the SgTreeTraversal class.

Base Classes

Name Description
SgTreeTraversal<DummyAttribute, SynthesizedAttributeType>

Type Aliases

Name
SubTreeSynthesizedAttributes
SynthesizedAttributesList

Member Functions

Name Description
traverse
SynthesizedAttributeType traverse(SgNode* node);
evaluates attributes on the entire AST
traverseInputFiles
void traverseInputFiles(SgProject* projectNode);
evaluates attributes only at nodes which represent files which were specified on the command line (=input files).
traverseWithinFile
SynthesizedAttributeType traverseWithinFile(SgNode* node);
evaluates attributes only at nodes which represent the same file as where the evaluation was started

Protected Member Functions

Name Description
atTraversalEnd
virtual void atTraversalEnd(); [virtual]
atTraversalStart
virtual void atTraversalStart(); [virtual]
Function called at the start of the traversal, before any node is visited; override if necessary, the default implementation is a no-op.
defaultSynthesizedAttribute
virtual SynthesizedAttributeType defaultSynthesizedAttribute(); [virtual]
Allows to provide a default value for a synthesized attribute of primitive type (e.g. int, bool, etc.). If a class is used as type for a synthesized attribute the default constructor of this class is sufficient and this function does not have be implemented.
evaluateSynthesizedAttribute
virtual SynthesizedAttributeType evaluateSynthesizedAttribute( SgNode*, SynthesizedAttributesList) = 0; [virtual]
pure virtual function which must be implemented to compute the synthesized attribute at a node. The list of synthesized attributes consists of the synthesized attributes computed at the children node of the current node. The inherited attribute value is computed by the function evaluateInheritedAttribute at the same node and simply passed to this function. Use the typedef SynthesizedAttributeList as type for the synthesized attributes list.

Private Member Functions

Name Description
defaultSynthesizedAttribute
virtual SynthesizedAttributeType defaultSynthesizedAttribute(DummyAttribute inheritedValue); [virtual]
evaluateInheritedAttribute
virtual DummyAttribute evaluateInheritedAttribute( SgNode* astNode, DummyAttribute inheritedValue); [virtual]
/////////////////////////////////////////// BOTTOM UP PROCESSING IMPLEMENTATION //////////////////////////////////////////////
evaluateSynthesizedAttribute
virtual SynthesizedAttributeType evaluateSynthesizedAttribute( SgNode* astNode, DummyAttribute inheritedValue, SynthesizedAttributesList l); [virtual]

Friends

Name Description
DistributedMemoryAnalysisPostTraversal
AstCombinedBottomUpProcessing

Derived Classes

Name Description
AstCombinedBottomUpProcessing
AstReverseBranchSynProcessing
AstReversePrefixSynProcessing
BottomUpTraversalLivenessIN
BottomUpTraversalLivenessOUT
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.
SgBottomUpProcessing
TestAstProperties
UniqueNameTraversal Class to traverse the AST and assign unique names to every varRef.

Created with MrDocs