OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ControlFlowGraphPass Class Reference

#include <ControlFlowGraphPass.hh>

Inheritance diagram for ControlFlowGraphPass:
Inheritance graph
Collaboration diagram for ControlFlowGraphPass:
Collaboration graph

Public Member Functions

 ControlFlowGraphPass (InterPassData &data)
 
virtual ~ControlFlowGraphPass ()
 
virtual void handleControlFlowGraph (ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine)
 
void executeBasicBlockPass (ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine, BasicBlockPass &bbPass)
 
- Public Member Functions inherited from SchedulerPass
 SchedulerPass (InterPassData &data)
 
virtual ~SchedulerPass ()
 
InterPassDatainterPassData ()
 
virtual std::string shortDescription () const =0
 
virtual std::string longDescription () const
 

Detailed Description

Interface for scheduler passes that handle control flow graphs.

Definition at line 50 of file ControlFlowGraphPass.hh.

Constructor & Destructor Documentation

◆ ControlFlowGraphPass()

ControlFlowGraphPass::ControlFlowGraphPass ( InterPassData data)

Constructor.

Definition at line 42 of file ControlFlowGraphPass.cc.

42 :
43 SchedulerPass(data) {
44}

◆ ~ControlFlowGraphPass()

ControlFlowGraphPass::~ControlFlowGraphPass ( )
virtual

Destructor.

Definition at line 49 of file ControlFlowGraphPass.cc.

49 {
50}

Member Function Documentation

◆ executeBasicBlockPass()

void ControlFlowGraphPass::executeBasicBlockPass ( ControlFlowGraph cfg,
const TTAMachine::Machine targetMachine,
BasicBlockPass bbPass 
)

Executes the given basic block pass on each basic block of the given control flow graph in the original program order.

A helper function for implementing most simplest types of CFG passes.

Parameters
cfgThe control flow graph to handle.
targetMachineThe target machine, if any. (NullMachine::instance() if target machine is irrelevant).
bbPassThe basic block pass to execute.
Exceptions
Incase handling is unsuccesful for any reason (cfg might still get modified).

Definition at line 90 of file ControlFlowGraphPass.cc.

92 {
93 // first schedule all inner-loop basic blocks.
94 int nodeCount = cfg.nodeCount();
95 for (int bbIndex = 0; bbIndex < nodeCount; ++bbIndex) {
96 BasicBlockNode& bb = dynamic_cast<BasicBlockNode&>(cfg.node(bbIndex));
97 if (!bb.isNormalBB() || bb.isScheduled() || !cfg.isSingleBBLoop(bb)) {
98 continue;
99 }
100 bbPass.handleBasicBlock(
101 bb.basicBlock(), targetMachine,
102 cfg.instructionReferenceManager(), &bb);
103 bb.setScheduled();
104 // if some node is removed, make sure does not skip some node and
105 // then try to handle too many nodes.
106 if (cfg.nodeCount() != nodeCount) {
107 nodeCount = cfg.nodeCount();
108 bbIndex = 0;
109 }
110 }
111
112 // then other basic blocks.
113 nodeCount = cfg.nodeCount();
114 for (int bbIndex = 0; bbIndex < nodeCount; ++bbIndex) {
115 BasicBlockNode& bb = dynamic_cast<BasicBlockNode&>(cfg.node(bbIndex));
116 if (!bb.isNormalBB())
117 continue;
118 if (bb.isScheduled()) {
119 continue;
120 }
121
122 bbPass.handleBasicBlock(
123 bb.basicBlock(), targetMachine,
124 cfg.instructionReferenceManager(), &bb);
125 bb.setScheduled();
126 // if some node is removed, make sure does not skip some node and
127 // then try to handle too many nodes.
128 if (cfg.nodeCount() != nodeCount) {
129 nodeCount = cfg.nodeCount();
130 bbIndex = 0;
131 }
132 }
133}
void setScheduled(bool state=true)
TTAProgram::BasicBlock & basicBlock()
bool isNormalBB() const
bool isScheduled() const
virtual void handleBasicBlock(TTAProgram::BasicBlock &basicBlock, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, BasicBlockNode *bbn=NULL)
int nodeCount() const
Node & node(const int index) const
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
bool isSingleBBLoop(const BasicBlockNode &node) const

References BasicBlockNode::basicBlock(), BasicBlockPass::handleBasicBlock(), ControlFlowGraph::instructionReferenceManager(), BasicBlockNode::isNormalBB(), BasicBlockNode::isScheduled(), ControlFlowGraph::isSingleBBLoop(), BoostGraph< GraphNode, GraphEdge >::node(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), and BasicBlockNode::setScheduled().

Referenced by handleControlFlowGraph().

Here is the call graph for this function:

◆ handleControlFlowGraph()

void ControlFlowGraphPass::handleControlFlowGraph ( ControlFlowGraph cfg,
const TTAMachine::Machine targetMachine 
)
virtual

Handles a single control flow graph.

The pass should work with any kind of control flow graph, it should not assume the CFG represents a whole procedure, for example.

Parameters
cfgThe control flow graph to handle.
machineThe target machine if any. (NullMachine::instance() if target machine is irrelevant).
Exceptions
Incase handling is unsuccesful for any reason (cfg might still get modified).

Reimplemented in ScheduleEstimator, CallsToJumps, PreOptimizer, SimpleIfConverter, BBSchedulerController, and Peel2BBLoops.

Definition at line 65 of file ControlFlowGraphPass.cc.

66 {
67 BasicBlockPass* bbPass = dynamic_cast<BasicBlockPass*>(this);
68 if (bbPass != NULL) {
69 executeBasicBlockPass(cfg, targetMachine, *bbPass);
70 } else {
71 abortWithError("CFG Pass is not also a BB pass so you "
72 "must overload handleControlFlowGraph method!");
73 }
74}
#define abortWithError(message)
void executeBasicBlockPass(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine, BasicBlockPass &bbPass)

References abortWithError, and executeBasicBlockPass().

Referenced by llvm::LLVMTCEIRBuilder::compileFast(), llvm::LLVMTCEIRBuilder::compileOptimized(), and ProcedurePass::executeControlFlowGraphPass().

Here is the call graph for this function:

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