OpenASIP  2.0
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 }

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 BBSchedulerController, Peel2BBLoops, PreOptimizer, SimpleIfConverter, CallsToJumps, and ScheduleEstimator.

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 }

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:
BoostGraph::node
Node & node(const int index) const
SchedulerPass::SchedulerPass
SchedulerPass(InterPassData &data)
Definition: SchedulerPass.cc:40
BasicBlockNode::isScheduled
bool isScheduled() const
Definition: BasicBlockNode.hh:93
ControlFlowGraph::instructionReferenceManager
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
Definition: ControlFlowGraph.cc:2401
BasicBlockNode::basicBlock
TTAProgram::BasicBlock & basicBlock()
Definition: BasicBlockNode.cc:126
BasicBlockPass
Definition: BasicBlockPass.hh:60
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
BasicBlockPass::handleBasicBlock
virtual void handleBasicBlock(TTAProgram::BasicBlock &basicBlock, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, BasicBlockNode *bbn=NULL)
Definition: BasicBlockPass.cc:79
ControlFlowGraphPass::executeBasicBlockPass
void executeBasicBlockPass(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine, BasicBlockPass &bbPass)
Definition: ControlFlowGraphPass.cc:90
BasicBlockNode
Definition: BasicBlockNode.hh:64
BasicBlockNode::isNormalBB
bool isNormalBB() const
Definition: BasicBlockNode.cc:239
ControlFlowGraph::isSingleBBLoop
bool isSingleBBLoop(const BasicBlockNode &node) const
Definition: ControlFlowGraph.cc:2919
BasicBlockNode::setScheduled
void setScheduled(bool state=true)
Definition: BasicBlockNode.hh:94
BoostGraph::nodeCount
int nodeCount() const