Nearly CC
An educational compiler skeleton
Public Member Functions | List of all members
ControlFlowGraphTransform Class Referenceabstract

Base class for ControlFlowGraphTransform transformations. More...

#include "cfg_transform.h"

Inheritance diagram for ControlFlowGraphTransform:
Inheritance graph
[legend]

Public Member Functions

 ControlFlowGraphTransform (const std::shared_ptr< ControlFlowGraph > &cfg)
 Constructor. More...
 
std::shared_ptr< ControlFlowGraphget_orig_cfg ()
 Get a shared pointer to the original ControlFlowGraph. More...
 
virtual std::shared_ptr< ControlFlowGraphtransform_cfg ()
 Transform the original ControlFlowGraph. More...
 
virtual std::shared_ptr< InstructionSequencetransform_basic_block (std::shared_ptr< InstructionSequence > orig_bb)=0
 Create a transformed version of the instructions in a basic block. More...
 

Detailed Description

Base class for ControlFlowGraphTransform transformations.

This is the preferred way to implement local optimizations. In general, implementations of ControlFlowGraphTransform are intended to be nondestructive, meaning that they return a new result ControlFlowGraph without modifying the original one.

Constructor & Destructor Documentation

◆ ControlFlowGraphTransform()

ControlFlowGraphTransform::ControlFlowGraphTransform ( const std::shared_ptr< ControlFlowGraph > &  cfg)

Constructor.

Parameters
cfgthe ControlFlowGraph to transform

Member Function Documentation

◆ get_orig_cfg()

std::shared_ptr< ControlFlowGraph > ControlFlowGraphTransform::get_orig_cfg ( )

Get a shared pointer to the original ControlFlowGraph.

Returns
the original ControlFlowGraph

◆ transform_basic_block()

virtual std::shared_ptr<InstructionSequence> ControlFlowGraphTransform::transform_basic_block ( std::shared_ptr< InstructionSequence orig_bb)
pure virtual

Create a transformed version of the instructions in a basic block.

Note that an InstructionSequence "owns" the Instruction objects it contains, and is responsible for deleting them. Therefore, be careful to avoid having two InstructionSequences contain pointers to the same Instruction. If you need to make an exact copy of an Instruction object, you can do so using the duplicate() member function, as follows:

Instruction *orig_ins = // ...an Instruction object...
Instruction *dup_ins = orig_ins->duplicate();
Instruction object type.
Definition: instruction.h:31
Instruction * duplicate() const
Return an exact duplicate of this Instruction.
Definition: instruction.h:69
Parameters
orig_bbthe original basic block
Returns
shared pointer to the new basic block InstructionSequence

Implemented in PeepholeLowLevel.

◆ transform_cfg()

std::shared_ptr< ControlFlowGraph > ControlFlowGraphTransform::transform_cfg ( )
virtual

Transform the original ControlFlowGraph.

Returns
shared pointer to the transformed ControlFlowGraph

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