Nearly CC
An educational compiler skeleton
Classes | Public Member Functions | List of all members
ControlFlowGraphBuilder< InstructionProperties > Class Template Reference

ControlFlowGraphBuilder builds a ControlFlowGraph from an InstructionSequence. More...

#include "cfg_builder.h"

Public Member Functions

 ControlFlowGraphBuilder (const std::shared_ptr< InstructionSequence > &iseq)
 Constuctor. More...
 
std::shared_ptr< ControlFlowGraphbuild ()
 Build a ControlFlowGraph from the original InstructionSequence. More...
 
virtual bool is_branch (Instruction *ins)
 Subclasses may override this method to specify which Instructions are branches (i.e., have a control successor other than the next instruction in the original InstructionSequence). More...
 

Detailed Description

template<typename InstructionProperties>
class ControlFlowGraphBuilder< InstructionProperties >

ControlFlowGraphBuilder builds a ControlFlowGraph from an InstructionSequence.

It is templated by InstructionProperties, which should be either HighLevelInstructionProperties or LowLevelInstructionProperties, depending on whether you're building a high-level or low-level control-flow graph.

Template Parameters
InstructionPropertieseither HighLevelInstructionProperties or LowLevelInstructionProperties, depending on whether the InstructionSequence has high-level or low-level instructions

Constructor & Destructor Documentation

◆ ControlFlowGraphBuilder()

template<typename InstructionProperties >
ControlFlowGraphBuilder< InstructionProperties >::ControlFlowGraphBuilder ( const std::shared_ptr< InstructionSequence > &  iseq)

Constuctor.

Parameters
iseqthe InstructionSequence containing the instructions to build

Member Function Documentation

◆ build()

template<typename InstructionProperties >
std::shared_ptr< ControlFlowGraph > ControlFlowGraphBuilder< InstructionProperties >::build

Build a ControlFlowGraph from the original InstructionSequence.

Returns
a shared pointer to the ControlFlowGraph of the original InstructionSequence

◆ is_branch()

template<typename InstructionProperties >
bool ControlFlowGraphBuilder< InstructionProperties >::is_branch ( Instruction ins)
virtual

Subclasses may override this method to specify which Instructions are branches (i.e., have a control successor other than the next instruction in the original InstructionSequence).

The default implementation assumes that any Instruction with an operand of type Operand::LABEL is a branch.

Parameters
insthe Instruction to check
Returns
true if the instruction is a branch, false otherwise

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