Nearly CC
An educational compiler skeleton
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Dataflow< Analysis > Class Template Reference

An instance of Dataflow performs a dataflow analysis on the basic blocks of a control flow graph and provides an interface for querying dataflow facts at arbitrary points. More...

#include "dataflow.h"

Public Types

typedef Analysis::FactType FactType
 Data type representing a dataflow fact. More...
 

Public Member Functions

 Dataflow (const std::shared_ptr< ControlFlowGraph > &cfg)
 Constructor. More...
 
void execute ()
 Execute the analysis.
 
const FactTypeget_fact_at_end_of_block (std::shared_ptr< InstructionSequence > bb) const
 Get dataflow fact at end of specified block. More...
 
const FactTypeget_fact_at_beginning_of_block (std::shared_ptr< InstructionSequence > bb) const
 Get dataflow fact at beginning of specific block. More...
 
FactType get_fact_after_instruction (std::shared_ptr< InstructionSequence > bb, Instruction *ins) const
 Get dataflow fact at the location immediately after the specified instruction (in program order). More...
 
FactType get_fact_before_instruction (std::shared_ptr< InstructionSequence > bb, Instruction *ins) const
 Get dataflow fact at the location immediately before the specified instruction (in program order). More...
 

Static Public Member Functions

static std::string fact_to_string (const FactType &fact)
 Convert dataflow fact to a string. More...
 

Static Public Attributes

static const unsigned MAX_BLOCKS = 1024
 We assume there won't be more than this many basic blocks.
 

Detailed Description

template<typename Analysis>
class Dataflow< Analysis >

An instance of Dataflow performs a dataflow analysis on the basic blocks of a control flow graph and provides an interface for querying dataflow facts at arbitrary points.

The Analysis object (instance of the Analysis type parameter) provides the concrete details about how the analysis is performed:

etc.

Template Parameters
Analysisthe analysis class, derived from either ForwardAnalysis or BackwardAnalysis

Member Typedef Documentation

◆ FactType

template<typename Analysis >
typedef Analysis::FactType Dataflow< Analysis >::FactType

Data type representing a dataflow fact.

Inferred from the Analysis type.

Constructor & Destructor Documentation

◆ Dataflow()

template<typename Analysis >
Dataflow< Analysis >::Dataflow ( const std::shared_ptr< ControlFlowGraph > &  cfg)

Constructor.

Parameters
theControlFlowGraph to analyze

Member Function Documentation

◆ fact_to_string()

template<typename Analysis >
std::string Dataflow< Analysis >::fact_to_string ( const FactType fact)
static

Convert dataflow fact to a string.

Parameters
facta dataflow fact
Returns
a stringified representation of the dataflow fact

◆ get_fact_after_instruction()

template<typename Analysis >
Dataflow< Analysis >::FactType Dataflow< Analysis >::get_fact_after_instruction ( std::shared_ptr< InstructionSequence bb,
Instruction ins 
) const

Get dataflow fact at the location immediately after the specified instruction (in program order).

Parameters
bbthe basic block
inspointer to an Instruction in the basic block
Returns
the dataflow fact at the location immediately after the specified Instruction

◆ get_fact_at_beginning_of_block()

template<typename Analysis >
const Dataflow< Analysis >::FactType & Dataflow< Analysis >::get_fact_at_beginning_of_block ( std::shared_ptr< InstructionSequence bb) const

Get dataflow fact at beginning of specific block.

Parameters
bbthe basic block
Returns
the dataflow fact at the beginning of the basic block

◆ get_fact_at_end_of_block()

template<typename Analysis >
const Dataflow< Analysis >::FactType & Dataflow< Analysis >::get_fact_at_end_of_block ( std::shared_ptr< InstructionSequence bb) const

Get dataflow fact at end of specified block.

Parameters
bbthe basic block
Returns
the dataflow fact at the end of the basic block

◆ get_fact_before_instruction()

template<typename Analysis >
Dataflow< Analysis >::FactType Dataflow< Analysis >::get_fact_before_instruction ( std::shared_ptr< InstructionSequence bb,
Instruction ins 
) const

Get dataflow fact at the location immediately before the specified instruction (in program order).

Parameters
bbthe basic block
inspointer to an Instruction in the basic block
Returns
the dataflow fact at the location immediately before the specified Instruction

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