OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
BBSchedulerController Class Reference

#include <BBSchedulerController.hh>

Inheritance diagram for BBSchedulerController:
Inheritance graph
Collaboration diagram for BBSchedulerController:
Collaboration graph

Public Member Functions

 BBSchedulerController (const TTAMachine::Machine &targetMachine, InterPassData &data, SoftwareBypasser *bypasser=NULL, CopyingDelaySlotFiller *delaySlotFiller=NULL, DataDependenceGraph *bigDDG=NULL)
 
virtual ~BBSchedulerController ()
 
virtual void handleBasicBlock (TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, BasicBlockNode *bbn=NULL) override
 
virtual void handleControlFlowGraph (ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine) override
 
virtual void handleProcedure (TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine) override
 
virtual void handleProgram (TTAProgram::Program &program, const TTAMachine::Machine &targetMachine) override
 
bool handleBBNode (ControlFlowGraph &cfg, BasicBlockNode &bbn, const TTAMachine::Machine &targetMachine, int nodeCount)
 
virtual void executeDDGPass (TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, std::vector< DDGPass * > ddgPasses, BasicBlockNode *bbn=NULL) override
 
virtual void handleCFGDDG (ControlFlowGraph &cfg, DataDependenceGraph *ddg, const TTAMachine::Machine &targetMachine)
 
virtual std::string shortDescription () const override
 
virtual std::string longDescription () const override
 
- Public Member Functions inherited from BasicBlockPass
 BasicBlockPass (InterPassData &data)
 
virtual ~BasicBlockPass ()
 
virtual bool executeLoopPass (TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, std::vector< DDGPass * > ddgPasses, BasicBlockNode *bbn=NULL)
 
virtual DataDependenceGraphBuilderddgBuilder ()
 
- Public Member Functions inherited from SchedulerPass
 SchedulerPass (InterPassData &data)
 
virtual ~SchedulerPass ()
 
InterPassDatainterPassData ()
 
- Public Member Functions inherited from ControlFlowGraphPass
 ControlFlowGraphPass (InterPassData &data)
 
virtual ~ControlFlowGraphPass ()
 
void executeBasicBlockPass (ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine, BasicBlockPass &bbPass)
 
- Public Member Functions inherited from ProcedurePass
 ProcedurePass (InterPassData &data)
 
virtual ~ProcedurePass ()
 
- Public Member Functions inherited from ProgramPass
 ProgramPass (InterPassData &data)
 
virtual ~ProgramPass ()
 

Protected Member Functions

virtual DataDependenceGraphcreateDDGFromBB (TTAProgram::BasicBlock &bb, const TTAMachine::Machine &mach)
 
- Protected Member Functions inherited from BasicBlockPass
void ddgSnapshot (DataDependenceGraph *ddg, std::string &name, DataDependenceGraph::DumpFileFormat format, bool final)
 

Private Attributes

const TTAMachine::MachinetargetMachine_
 
TTAProgram::ProcedurescheduledProcedure_
 The currently scheduled procedure.
 
ControlFlowGraphcfg_
 Control flow graph of the procedure.
 
DataDependenceGraphbigDDG_
 whole-procedure DDG.
 
SoftwareBypassersoftwareBypasser_
 The software bypasser to use to bypass registers when possible.
 
CopyingDelaySlotFillerdelaySlotFiller_
 
int basicBlocksScheduled_
 Number of basic blocks scheduled so far.
 
int totalBasicBlocks_
 Total basic blocks in the CFG currently being scheduled.
 
LLVMTCECmdLineOptionsoptions_
 

Additional Inherited Members

- Static Public Member Functions inherited from BasicBlockPass
static void copyRMToBB (SimpleResourceManager &rm, TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, int lastCycle=-1)
 
- Static Public Member Functions inherited from ProcedurePass
static void copyCfgToProcedure (TTAProgram::Procedure &procedure, ControlFlowGraph &cfg)
 
static void executeControlFlowGraphPass (TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetmachine, ControlFlowGraphPass &cfgp)
 
- Static Public Member Functions inherited from ProgramPass
static void executeProcedurePass (TTAProgram::Program &program, const TTAMachine::Machine &targetMachine, ProcedurePass &procedurePass)
 

Detailed Description

A class that control operation of a basic block scheduler.

This class handles calling other optimization passes and tranferring data for the actual BB scheduler and loop scheudlers etc.

Definition at line 60 of file BBSchedulerController.hh.

Constructor & Destructor Documentation

◆ BBSchedulerController()

BBSchedulerController::BBSchedulerController ( const TTAMachine::Machine targetMachine,
InterPassData data,
SoftwareBypasser bypasser = NULL,
CopyingDelaySlotFiller delaySlotFiller = NULL,
DataDependenceGraph bigDDG = NULL 
)

Constructs the basic block scheduler.

Parameters
dataInterpass data
bypasserHelper module implementing software bypassing
delaySlotFillerHelper module implementing jump delay slot filling

Definition at line 90 of file BBSchedulerController.cc.

94 : BasicBlockPass(data),
96 ProcedurePass(data),
97 ProgramPass(data),
98 targetMachine_(targetMachine),
100 bigDDG_(bigDDG),
101 softwareBypasser_(bypasser),
102 delaySlotFiller_(delaySlotFiller),
106 options_ = dynamic_cast<LLVMTCECmdLineOptions*>(cmdLineOptions);
107}
static CmdLineOptions * cmdLineOptions()
DataDependenceGraph * bigDDG_
whole-procedure DDG.
TTAProgram::Procedure * scheduledProcedure_
The currently scheduled procedure.
int basicBlocksScheduled_
Number of basic blocks scheduled so far.
LLVMTCECmdLineOptions * options_
SoftwareBypasser * softwareBypasser_
The software bypasser to use to bypass registers when possible.
const TTAMachine::Machine & targetMachine_
CopyingDelaySlotFiller * delaySlotFiller_
int totalBasicBlocks_
Total basic blocks in the CFG currently being scheduled.

References Application::cmdLineOptions(), and options_.

Here is the call graph for this function:

◆ ~BBSchedulerController()

BBSchedulerController::~BBSchedulerController ( )
virtual

Definition at line 109 of file BBSchedulerController.cc.

109 {
110}

Member Function Documentation

◆ createDDGFromBB()

DataDependenceGraph * BBSchedulerController::createDDGFromBB ( TTAProgram::BasicBlock bb,
const TTAMachine::Machine mach 
)
protectedvirtual

Helper function used to create DDG for BBPass.

Overrided version in order to use subgraphs.

Parameters
bbBasicBlock where DDG is to be created from

Reimplemented from BasicBlockPass.

Definition at line 438 of file BBSchedulerController.cc.

439 {
440 if (bigDDG_ != NULL) {
441 return bigDDG_->createSubgraph(bb);
442 } else {
443 return this->ddgBuilder().build(
445 scheduledProcedure_->name() + '_' +
447 }
448}
virtual DataDependenceGraphBuilder & ddgBuilder()
static std::string toString(const T &source)
virtual DataDependenceGraph * build(ControlFlowGraph &cGraph, DataDependenceGraph::AntidependenceLevel antidependenceLevel, const TTAMachine::Machine &mach, const UniversalMachine *um=NULL, bool createMemAndFUDeps=true, bool createDeathInformation=true, llvm::AliasAnalysis *AA=NULL)
DataDependenceGraph * createSubgraph(NodeSet &nodes, bool includeLoops=false)
TCEString name() const
Definition Procedure.hh:66

References basicBlocksScheduled_, bigDDG_, DataDependenceGraphBuilder::build(), DataDependenceGraph::createSubgraph(), BasicBlockPass::ddgBuilder(), DataDependenceGraph::INTRA_BB_ANTIDEPS, TTAProgram::Procedure::name(), scheduledProcedure_, and Conversion::toString().

Referenced by executeDDGPass().

Here is the call graph for this function:

◆ executeDDGPass()

void BBSchedulerController::executeDDGPass ( TTAProgram::BasicBlock bb,
const TTAMachine::Machine targetMachine,
TTAProgram::InstructionReferenceManager irm,
std::vector< DDGPass * >  ddgPasses,
BasicBlockNode bbn = NULL 
)
overridevirtual

Creates a DDG from the given basic block and executes the set of DDG passes for that.

Reimplemented from BasicBlockPass.

Definition at line 455 of file BBSchedulerController.cc.

458 {
459 int minCycle = 0;
460 DataDependenceGraph* ddg = NULL;
461 SimpleResourceManager* rm = NULL;
462 // Used for live info dumping.
463 static int bbNumber = 0;
464 int min = INT_MAX;
465 int fastest = 0;
466 if (ddgPasses.size() > 1) {
467 for (unsigned int i = 0; i < ddgPasses.size(); i++) {
468 ddg = createDDGFromBB(bb, targetMachine);
469 rm = SimpleResourceManager::createRM(targetMachine);
470 rm->setDDG(ddg);
471 rm->setCFG(cfg_);
472 rm->setBBN(bbn);
473
474 int size =
475 ddgPasses[i]->handleDDG(*ddg, *rm, targetMachine, minCycle, true);
476 if (size < min) {
477 min = size;
478 fastest = i;
479 }
481 delete ddg;
482 ddg = NULL;
483 }
484 }
485 ddg = createDDGFromBB(bb, targetMachine);
486 rm = SimpleResourceManager::createRM(targetMachine);
487 rm->setDDG(static_cast<DataDependenceGraph*>(ddg->rootGraph()));
488 rm->setCFG(cfg_);
489 rm->setBBN(bbn);
490
491 if (options_ != NULL && options_->printResourceConstraints()) {
492 TCEString ddgName = ddg->name();
493 // Use the BBN id if possible so it's easier to find the matching BBs when
494 // looking at the if-conversion CFGs.
495 if (bbn != NULL)
496 ddgName << bbn->nodeID();
497 else
498 ddgName << bbNumber;
499 ResourceConstraintAnalyzer rcAnalyzer(*ddg, *rm, ddgName);
500 rcAnalyzer.analyzePreSchedule();
501 }
502
503
504#ifdef DDG_SNAPSHOTS
505 std::string name = "scheduling";
506 ddgSnapshot(ddg, name, false);
507#endif
508
509 try {
510 ddgPasses[fastest]->handleDDG(*ddg, *rm, targetMachine, minCycle);
511 if (bbn->isHWLoop()) {
513 ddg->largestCycle() + 1 - ddg->smallestCycle());
514 }
515 } catch (const Exception &e) {
517 abortWithError("Scheduling failed!");
518 }
519
520#ifdef DDG_SNAPSHOTS
521 std::string name = "scheduling";
522 ddgSnapshot(ddg, name, true);
523#endif
524
525 copyRMToBB(*rm, bb, targetMachine, irm);
526
527 bbNumber++;
528
529 if (options_ != NULL && options_->printResourceConstraints()) {
530 TCEString ddgName = ddg->name();
531 // Use the BBN id if possible so it's easier to find the matching BBs when
532 // looking at the if-conversion CFGs.
533 if (bbn != NULL)
534 ddgName << bbn->nodeID();
535 else
536 ddgName << bbNumber;
537 ResourceConstraintAnalyzer rcAnalyzer(*ddg, *rm, ddgName);
538 rcAnalyzer.analyze();
539 }
540
541 if (delaySlotFiller_ != NULL && bigDDG_ != NULL) {
542 rm->clearOldResources();
544 } else {
546 }
547
548 // print some stats about the loop kernel body DDGs
549 if (Application::verboseLevel() > 1 && bb.isInInnerLoop()) {
551 << "DDG height " << ddg->height() << std::endl;
552 }
553
554 delete ddg;
555}
#define debugLog(text)
#define abortWithError(message)
static int verboseLevel()
static std::ostream & logStream()
ControlFlowGraph * cfg_
Control flow graph of the procedure.
virtual DataDependenceGraph * createDDGFromBB(TTAProgram::BasicBlock &bb, const TTAMachine::Machine &mach)
bool isHWLoop() const
const BasicBlockNode * predecessor() const
void updateHWloopLength(unsigned len)
static void copyRMToBB(SimpleResourceManager &rm, TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, int lastCycle=-1)
void ddgSnapshot(DataDependenceGraph *ddg, std::string &name, DataDependenceGraph::DumpFileFormat format, bool final)
BoostGraph * rootGraph()
virtual const TCEString & name() const
int height() const
void addResourceManager(TTAProgram::BasicBlock &bbn, SimpleResourceManager &rm)
std::string errorMessageStack(bool messagesOnly=false) const
Definition Exception.cc:138
int nodeID() const
void setBBN(const BasicBlockNode *bbn)
static void disposeRM(SimpleResourceManager *rm, bool allowReuse=true)
void setCFG(const ControlFlowGraph *cfg)
static SimpleResourceManager * createRM(const TTAMachine::Machine &machine, unsigned int ii=0)
void setDDG(const DataDependenceGraph *ddg)
bool isInInnerLoop() const
returns true in case the BB is known to be inside an inner loop

References abortWithError, CopyingDelaySlotFiller::addResourceManager(), ResourceConstraintAnalyzer::analyze(), ResourceConstraintAnalyzer::analyzePreSchedule(), bigDDG_, cfg_, SimpleResourceManager::clearOldResources(), BasicBlockPass::copyRMToBB(), createDDGFromBB(), SimpleResourceManager::createRM(), BasicBlockPass::ddgSnapshot(), debugLog, delaySlotFiller_, SimpleResourceManager::disposeRM(), Exception::errorMessageStack(), BoostGraph< GraphNode, GraphEdge >::height(), BasicBlockNode::isHWLoop(), TTAProgram::BasicBlock::isInInnerLoop(), DataDependenceGraph::largestCycle(), Application::logStream(), BoostGraph< GraphNode, GraphEdge >::name(), GraphNode::nodeID(), options_, BasicBlockNode::predecessor(), SchedulerCmdLineOptions::printResourceConstraints(), BoostGraph< GraphNode, GraphEdge >::rootGraph(), SimpleResourceManager::setBBN(), SimpleResourceManager::setCFG(), SimpleResourceManager::setDDG(), DataDependenceGraph::smallestCycle(), BasicBlockNode::updateHWloopLength(), and Application::verboseLevel().

Referenced by handleBasicBlock().

Here is the call graph for this function:

◆ handleBasicBlock()

void BBSchedulerController::handleBasicBlock ( TTAProgram::BasicBlock bb,
const TTAMachine::Machine targetMachine,
TTAProgram::InstructionReferenceManager irm,
BasicBlockNode bbn = NULL 
)
overridevirtual

Schedules a single basic block.

Parameters
bbThe basic block to schedule.
targetMachineThe target machine.
Exceptions
Exceptionseveral TCE exceptions can be thrown in case of a scheduling error.

Reimplemented from BasicBlockPass.

Definition at line 121 of file BBSchedulerController.cc.

123 {
124 // TODO: define them somewhere in one place.
125 static const TCEString SP_DATUM = "STACK_POINTER";
126 static const TCEString FP_DATUM = "FRAME_POINTER";
127 static const TCEString RV_DATUM = "RV_REGISTER";
128 // high part of 64-bit return values.
129 static const TCEString RV_HIGH_DATUM = "RV_HIGH_REGISTER";
130
131 if (bb.instructionCount() == 0)
132 return;
133
134 bool bbScheduled = false;
135
136 RegisterRenamer* rr = NULL;
137
139 dynamic_cast<SchedulerCmdLineOptions*>(
141
142 // create register renamer if enabled and we know the
143 // reserved registers.
144 if (options != NULL && options->renameRegisters() && bigDDG_ != NULL
149 rr = new RegisterRenamer(targetMachine, bbn->basicBlock());
150 }
151
152 std::vector<DDGPass*> bbSchedulers;
153
154 if (options_ != NULL && options_->useBubbleFish2Scheduler()) {
155 bbSchedulers.push_back(new BF2Scheduler(
157 } else if (options_ != NULL && options_->useBUScheduler()) {
158 bbSchedulers.push_back(new BUBasicBlockScheduler(
160 } else if (options_ != NULL && options_->useTDScheduler()) {
161 bbSchedulers.push_back(new BasicBlockScheduler(
163 } else {
164 bbSchedulers.push_back(new BF2Scheduler(
166 }
167
168 if (options_->isLoopOptDefined() &&
169 cfg_->isSingleBBLoop(*bbn) &&
170 bb.lastInstruction().hasJump() &&
171 bigDDG_ != NULL) {
172
173 LoopAnalyzer::LoopAnalysisResult* analysis = NULL;
174 if (Application::verboseLevel() > 1) {
176 << "CFG detects single BB loop" << std::endl
177 << "tripcount: " << bb.tripCount() << std::endl;
178 }
179 if (bigDDG_ && bb.tripCount() == 0 && options_->useBubbleFish2Scheduler()) {
180 analysis = LoopAnalyzer::analyze(*bbn, *bigDDG_);
181 if (analysis != NULL) {
182 bb.setTripCount(analysis->iterationCount);
183 if (analysis->counterValueNode == NULL) {
184 if (Application::verboseLevel() > 1) {
186 << "loop analyzis analyzed loop to have fixed trip count"
187 << analysis->iterationCount << std::endl;
188 }
189 } else {
190 if (Application::verboseLevel() > 1) {
192 << "loop analyzis analyzed loop to have variable trip count"
193 << analysis->counterValueNode->toString()
194 << " + "
195 << analysis->iterationCount << " divided by"
196 << analysis->counterMultiplier << std::endl;
197 }
198 }
199 }
200 }
201
202 if ((((bb.tripCount() > 0 || (analysis && analysis->counterValueNode)) &&
203 MachineConnectivityCheck::tempRegisterFiles(targetMachine).empty()) ||
205 if (analysis) {
206 (static_cast<BF2Scheduler*>(bbSchedulers[0]))->
207 setLoopLimits(analysis);
208 }
209 // software pipeline instead of calling the flat BB scheduler
210 if (Application::verboseLevel() > 1) {
212 << "executing loop pass with trip count " << bb.tripCount()
213 << std::endl;
214 }
215
216 if (executeLoopPass(
217 bb, targetMachine, irm, bbSchedulers, bbn) ) {
218 bbScheduled = true;
219 } else {
220 if (Application::verboseLevel() > 1) {
222 << "loop scheduler failed, using basic block "
223 << "scheduler instead" << std::endl;
224 }
225 bbScheduled = false;
226 }
227 }
228 // if not scheduled yet (or loop scheduling failed)
229 }
230 if (!bbScheduled) {
231
233 bb, targetMachine, irm, bbSchedulers, bbn);
234
236 }
237 if (rr != NULL) {
238 delete rr;
239 }
240
241 // these are no longer needed. delete them to save memory.
242 if (bb.liveRangeData_ != NULL) {
244 bb.liveRangeData_->regDefines_.clear();
245 bb.liveRangeData_->regLastUses_.clear();
246
247 bb.liveRangeData_->regDefReaches_.clear();
249 bb.liveRangeData_->regFirstUses_.clear();
250 bb.liveRangeData_->regDefines_.clear();
251 } else {
252 std::cerr << "Wargning: BB liverange data null for: "
253 << bbn->toString() << std::endl;
254 }
255 for (unsigned int i = 0; i < bbSchedulers.size(); i++)
256 delete bbSchedulers[i];
257}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
virtual void executeDDGPass(TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, std::vector< DDGPass * > ddgPasses, BasicBlockNode *bbn=NULL) override
TTAProgram::BasicBlock & basicBlock()
std::string toString() const
virtual bool executeLoopPass(TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, std::vector< DDGPass * > ddgPasses, BasicBlockNode *bbn=NULL)
bool isSingleBBLoop(const BasicBlockNode &node) const
bool hasDatum(const std::string &key) const
static LoopAnalysisResult * analyze(BasicBlockNode &bbn, DataDependenceGraph &ddg)
static std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > tempRegisterFiles(const TTAMachine::Machine &machine)
std::string toString() const
Definition MoveNode.cc:576
virtual bool isLoopOptDefined() const
InterPassData & interPassData()
LiveRangeData * liveRangeData_
void setTripCount(unsigned count)
unsigned tripCount() const
in case the BB is inside a loop and trip count is known, returns it, otherwise returns 0
virtual int instructionCount() const
virtual Instruction & lastInstruction() const
MoveNodeUseMapSet regFirstUses_
MoveNodeUseMapSet regLastUses_
std::set< TCEString > registersUsedAfter_
MoveNodeUseMapSet regFirstDefines_
MoveNodeUseMapSet regDefines_
MoveNodeUseMapSet regDefReaches_

References LoopAnalyzer::analyze(), BasicBlockNode::basicBlock(), basicBlocksScheduled_, bigDDG_, cfg_, Application::cmdLineOptions(), LoopAnalyzer::LoopAnalysisResult::counterMultiplier, LoopAnalyzer::LoopAnalysisResult::counterValueNode, executeDDGPass(), BasicBlockPass::executeLoopPass(), InterPassData::hasDatum(), TTAProgram::Instruction::hasJump(), TTAProgram::CodeSnippet::instructionCount(), SchedulerPass::interPassData(), SchedulerCmdLineOptions::isLoopOptDefined(), ControlFlowGraph::isSingleBBLoop(), LoopAnalyzer::LoopAnalysisResult::iterationCount, TTAProgram::CodeSnippet::lastInstruction(), TTAProgram::BasicBlock::liveRangeData_, Application::logStream(), options, options_, LiveRangeData::regDefines_, LiveRangeData::regDefReaches_, LiveRangeData::regFirstDefines_, LiveRangeData::regFirstUses_, LiveRangeData::registersUsedAfter_, LiveRangeData::regLastUses_, TTAProgram::BasicBlock::setTripCount(), softwareBypasser_, MachineConnectivityCheck::tempRegisterFiles(), BasicBlockNode::toString(), MoveNode::toString(), TTAProgram::BasicBlock::tripCount(), LLVMTCECmdLineOptions::useBubbleFish2Scheduler(), LLVMTCECmdLineOptions::useBUScheduler(), LLVMTCECmdLineOptions::useTDScheduler(), and Application::verboseLevel().

Referenced by handleBBNode().

Here is the call graph for this function:

◆ handleBBNode()

bool BBSchedulerController::handleBBNode ( ControlFlowGraph cfg,
BasicBlockNode bbn,
const TTAMachine::Machine targetMachine,
int  nodeCount 
)

Definition at line 558 of file BBSchedulerController.cc.

560 {
561
562 TCEString procName = cfg.procedureName();
563 if (procName == "") procName = cfg.name();
564
565 if (!bb.isNormalBB() || bb.isScheduled()) {
566 return false;
567 }
568
570 bb.basicBlock(), targetMachine,
571 cfg.instructionReferenceManager(), &bb);
572 bb.setScheduled();
573
574 if (delaySlotFiller_ != NULL && bigDDG_ != NULL) {
576 }
577
578 // if some node is removed, make sure does not skip some node and
579 // then try to handle too many nodes.
580 if (cfg.nodeCount() != nodeCount) {
581 return true;
582 }
583 return false;
584}
virtual void handleBasicBlock(TTAProgram::BasicBlock &bb, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, BasicBlockNode *bbn=NULL) override
int nodeCount() const
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
TCEString procedureName() const
void bbnScheduled(BasicBlockNode &bbn)

References BasicBlockNode::basicBlock(), CopyingDelaySlotFiller::bbnScheduled(), bigDDG_, delaySlotFiller_, handleBasicBlock(), ControlFlowGraph::instructionReferenceManager(), BasicBlockNode::isNormalBB(), BasicBlockNode::isScheduled(), BoostGraph< GraphNode, GraphEdge >::name(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), ControlFlowGraph::procedureName(), and BasicBlockNode::setScheduled().

Referenced by handleCFGDDG().

Here is the call graph for this function:

◆ handleCFGDDG()

void BBSchedulerController::handleCFGDDG ( ControlFlowGraph cfg,
DataDependenceGraph ddg,
const TTAMachine::Machine targetMachine 
)
virtual

Definition at line 586 of file BBSchedulerController.cc.

589 {
590 cfg_ = &cfg;
591 bigDDG_ = ddg;
592
594 est.handleControlFlowGraph(cfg, targetMachine);
595
596 int nodeCount = cfg.nodeCount();
597
598 // for handle single-BB-loops
599 for (int bbIndex = 0; bbIndex < nodeCount; ++bbIndex) {
600 BasicBlockNode& bb = cfg.node(bbIndex);
601 if (!cfg.isSingleBBLoop(bb)) {
602 continue;
603 }
604
605 if (handleBBNode(cfg, bb, targetMachine, nodeCount)) {
606 nodeCount = cfg.nodeCount();
607 bbIndex = 0;
608 }
609 }
610
611 // then handle BBs which do not have outgoing jumps.
612 for (int bbIndex = 0; bbIndex < nodeCount; ++bbIndex) {
613 BasicBlockNode& bb = cfg.node(bbIndex);
614 auto jumpDest = cfg.jumpSuccessor(bb);
615 if (jumpDest != nullptr && jumpDest->isNormalBB()) {
616 continue;
617 }
618
619 if (handleBBNode(cfg, bb, targetMachine, nodeCount)) {
620 nodeCount = cfg.nodeCount();
621 bbIndex = 0;
622 }
623 }
624
625
626 for (int bbIndex = cfg.nodeCount() -1; bbIndex >= 0; --bbIndex) {
627 BasicBlockNode& bb = cfg.node(bbIndex);
628 auto jumpDest = cfg.jumpSuccessor(bb);
629 if (jumpDest == nullptr || !jumpDest->isNormalBB()) {
630 continue;
631 }
632
633 if (cfg.allScheduledInBetween(bb, *jumpDest)) {
634 if (handleBBNode(cfg, bb, targetMachine, nodeCount)) {
635 nodeCount = cfg.nodeCount();
636 bbIndex = nodeCount -1;
637 }
638 }
639 }
640
641 for (int bbIndex = cfg.nodeCount() -1; bbIndex >= 0; --bbIndex) {
642 BasicBlockNode& bb = cfg.node(bbIndex);
643 if (handleBBNode(cfg, bb, targetMachine, nodeCount)) {
644 nodeCount = cfg.nodeCount();
645 bbIndex = nodeCount -1;
646 }
647 }
648}
bool handleBBNode(ControlFlowGraph &cfg, BasicBlockNode &bbn, const TTAMachine::Machine &targetMachine, int nodeCount)
Node & node(const int index) const
BasicBlockNode * jumpSuccessor(BasicBlockNode &bbn)
bool allScheduledInBetween(const BasicBlockNode &src, const BasicBlockNode &dst) const

References ControlFlowGraph::allScheduledInBetween(), bigDDG_, cfg_, handleBBNode(), ScheduleEstimator::handleControlFlowGraph(), SchedulerPass::interPassData(), ControlFlowGraph::isSingleBBLoop(), ControlFlowGraph::jumpSuccessor(), BoostGraph< GraphNode, GraphEdge >::node(), and BoostGraph< GraphNode, GraphEdge >::nodeCount().

Referenced by llvm::LLVMTCEIRBuilder::compileOptimized(), and handleControlFlowGraph().

Here is the call graph for this function:

◆ handleControlFlowGraph()

void BBSchedulerController::handleControlFlowGraph ( ControlFlowGraph cfg,
const TTAMachine::Machine targetMachine 
)
overridevirtual

Schedules all nodes in a control flow graph.

The original control flow graph nodes are modified during scheduling.

Parameters
cfgThe control flow graph to schedule.
targetMachineThe target machine.
Exceptions
ExceptionIn case of an error during scheduling. The exception type can be any subtype of Exception.

Reimplemented from ControlFlowGraphPass.

Definition at line 381 of file BBSchedulerController.cc.

382 {
383 return handleCFGDDG(cfg, bigDDG_, targetMachine);
384}
virtual void handleCFGDDG(ControlFlowGraph &cfg, DataDependenceGraph *ddg, const TTAMachine::Machine &targetMachine)

References bigDDG_, and handleCFGDDG().

Referenced by handleProcedure().

Here is the call graph for this function:

◆ handleProcedure()

void BBSchedulerController::handleProcedure ( TTAProgram::Procedure procedure,
const TTAMachine::Machine targetMachine 
)
overridevirtual

Schedules a procedure.

The original procedure is modified during scheduling.

Parameters
procedureThe procedure to schedule.
targetMachineThe target machine.
Todo:
remove the targetMachine argument. The machine is given in the constructor and assumed to be the same for whole lifetime of the scheduler instance.
Exceptions
ExceptionIn case of an error during scheduling. The exception type can be any subtype of Exception.

Reimplemented from ProcedurePass.

Definition at line 277 of file BBSchedulerController.cc.

279 {
281
282 if (Application::verboseLevel() > 0) {
283 totalBasicBlocks_ = cfg.nodeCount() - 3;
285 << " -- " << totalBasicBlocks_ << " basic blocks" << std::endl;
287 }
288
289#ifdef CFG_SNAPSHOTS
290 cfg.writeToDotFile(procedure.name() + "_cfg.dot");
291#endif
292
295 int lowMemThreshold = DEFAULT_LOWMEM_MODE_THRESHOLD;
296
297 if (opts != NULL && opts->lowMemModeThreshold() > -1) {
298 lowMemThreshold = opts->lowMemModeThreshold();
299 }
300
301 if (procedure.instructionCount() < lowMemThreshold) {
302 // create the procedure-wide ddg.
305
306 if (options_ != NULL && options_->dumpDDGsDot()) {
308 (boost::format("proc_%s_before_scheduling.dot") %
309 bigDDG_->name()).str());
310 }
311
312 if (options_ != NULL && options_->dumpDDGsXML()) {
314 (boost::format("proc_%s_before_scheduling.xml") %
315 bigDDG_->name()).str());
316 }
317 }
318
319 if (delaySlotFiller_ != NULL && bigDDG_ != NULL) {
320 delaySlotFiller_->initialize(cfg, *bigDDG_, targetMachine);
321 }
322
323#ifdef BIG_DDG_SNAPSHOTS
324 bigDDG_->writeToDotFile(bigDDG_->name() + "_unscheduled_ddg.dot");
325#endif
326 scheduledProcedure_ = &procedure;
327
328 // dsf also called between scheduling.. have to update these before it.
329 // delay slot filler needs refs to be into instrs in cfg, not in
330 // original program
331 cfg.updateReferencesFromProcToCfg();
332
333 procedure.clear();
334
335 handleControlFlowGraph(cfg, targetMachine);
336
337 if (delaySlotFiller_ != NULL && bigDDG_ != NULL) {
338 delaySlotFiller_->fillDelaySlots(cfg, *bigDDG_, targetMachine);
339 }
340
341#ifdef CFG_SNAPSHOTS
342 cfg.writeToDotFile(procedure.name() + "_cfg_after.dot");
343#endif
344
345 // now all basic blocks are scheduled, let's put them back to the
346 // original procedure
347 cfg.copyToProcedure(procedure);
348 if (bigDDG_ != NULL) {
349
350 if (options_ != NULL && options_->dumpDDGsDot()) {
352 (boost::format("proc_%s_after_scheduling.dot") % bigDDG_->name())
353 .str());
354 }
355
356 if (options_ != NULL && options_->dumpDDGsXML()) {
358 (boost::format("proc_%s_after_scheduling.xml") % bigDDG_->name())
359 .str());
360 }
361 delete bigDDG_;
362 bigDDG_ = NULL;
363 }
364 if (delaySlotFiller_ != NULL) {
366 }
367 scheduledProcedure_ = NULL;
368}
static const int DEFAULT_LOWMEM_MODE_THRESHOLD
virtual void handleControlFlowGraph(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine) override
void initialize(ControlFlowGraph &cfg, DataDependenceGraph &ddg, const TTAMachine::Machine &machine)
void fillDelaySlots(ControlFlowGraph &cfg, DataDependenceGraph &ddg, const TTAMachine::Machine &machine)
void writeToXMLFile(std::string fileName) const
virtual void writeToDotFile(const TCEString &fileName) const
virtual bool dumpDDGsDot() const
virtual bool dumpDDGsXML() const
virtual int lowMemModeThreshold() const

References basicBlocksScheduled_, bigDDG_, DataDependenceGraphBuilder::build(), TTAProgram::Procedure::clear(), Application::cmdLineOptions(), ControlFlowGraph::copyToProcedure(), BasicBlockPass::ddgBuilder(), DEFAULT_LOWMEM_MODE_THRESHOLD, delaySlotFiller_, LLVMTCECmdLineOptions::dumpDDGsDot(), LLVMTCECmdLineOptions::dumpDDGsXML(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::finalizeProcedure(), handleControlFlowGraph(), CopyingDelaySlotFiller::initialize(), TTAProgram::CodeSnippet::instructionCount(), SchedulerPass::interPassData(), Application::logStream(), SchedulerCmdLineOptions::lowMemModeThreshold(), BoostGraph< GraphNode, GraphEdge >::name(), TTAProgram::Procedure::name(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), options_, scheduledProcedure_, DataDependenceGraph::SINGLE_BB_LOOP_ANTIDEPS, totalBasicBlocks_, ControlFlowGraph::updateReferencesFromProcToCfg(), Application::verboseLevel(), GraphBase< GraphNode, GraphEdge >::writeToDotFile(), and DataDependenceGraph::writeToXMLFile().

Referenced by llvm::LLVMTCEIRBuilder::doFinalization().

Here is the call graph for this function:

◆ handleProgram()

void BBSchedulerController::handleProgram ( TTAProgram::Program program,
const TTAMachine::Machine targetMachine 
)
overridevirtual

Schedules a program.

The original program is modified during scheduling.

Parameters
programThe program to schedule.
targetMachineThe target machine.
Exceptions
ExceptionIn case of an error during scheduling. The exception type can be any subtype of Exception.

Reimplemented from ProgramPass.

Definition at line 397 of file BBSchedulerController.cc.

398 {
399 ProgramPass::executeProcedurePass(program, targetMachine, *this);
400}
find Finds info of the inner loops in the program
static void executeProcedurePass(TTAProgram::Program &program, const TTAMachine::Machine &targetMachine, ProcedurePass &procedurePass)

References ProgramPass::executeProcedurePass(), and program.

Here is the call graph for this function:

◆ longDescription()

std::string BBSchedulerController::longDescription ( ) const
overridevirtual

Optional longer description of the pass.

This description can include usage instructions, details of choice of algorithmic details, etc.

Returns
The description as a string.

Reimplemented from SchedulerPass.

Definition at line 422 of file BBSchedulerController.cc.

422 {
423 return
424 "Basic block scheduler that uses the longest path information of "
425 "data dependency graph to prioritize the ready list. Assumes that "
426 "the input has registers allocated and no connectivity missing.";
427}

◆ shortDescription()

std::string BBSchedulerController::shortDescription ( ) const
overridevirtual

A short description of the pass, usually the optimization name, such as "basic block scheduler".

Returns
The description as a string.

Implements SchedulerPass.

Definition at line 409 of file BBSchedulerController.cc.

409 {
410 return "Instruction scheduler with a basic block scope.";
411}

Member Data Documentation

◆ basicBlocksScheduled_

int BBSchedulerController::basicBlocksScheduled_
private

Number of basic blocks scheduled so far.

Definition at line 128 of file BBSchedulerController.hh.

Referenced by createDDGFromBB(), handleBasicBlock(), and handleProcedure().

◆ bigDDG_

DataDependenceGraph* BBSchedulerController::bigDDG_
private

◆ cfg_

ControlFlowGraph* BBSchedulerController::cfg_
private

Control flow graph of the procedure.

Definition at line 118 of file BBSchedulerController.hh.

Referenced by executeDDGPass(), handleBasicBlock(), and handleCFGDDG().

◆ delaySlotFiller_

CopyingDelaySlotFiller* BBSchedulerController::delaySlotFiller_
private

Definition at line 125 of file BBSchedulerController.hh.

Referenced by executeDDGPass(), handleBBNode(), and handleProcedure().

◆ options_

LLVMTCECmdLineOptions* BBSchedulerController::options_
private

◆ scheduledProcedure_

TTAProgram::Procedure* BBSchedulerController::scheduledProcedure_
private

The currently scheduled procedure.

Definition at line 115 of file BBSchedulerController.hh.

Referenced by createDDGFromBB(), and handleProcedure().

◆ softwareBypasser_

SoftwareBypasser* BBSchedulerController::softwareBypasser_
private

The software bypasser to use to bypass registers when possible.

Definition at line 123 of file BBSchedulerController.hh.

Referenced by handleBasicBlock().

◆ targetMachine_

const TTAMachine::Machine& BBSchedulerController::targetMachine_
private

Definition at line 112 of file BBSchedulerController.hh.

◆ totalBasicBlocks_

int BBSchedulerController::totalBasicBlocks_
private

Total basic blocks in the CFG currently being scheduled.

Definition at line 130 of file BBSchedulerController.hh.

Referenced by handleProcedure().


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