OpenASIP  2.0
Peel2BBLoops.hh
Go to the documentation of this file.
1 /**
2  * @file Peel2BBLoops.hh
3  *
4  * This optimizer optimizes some 2-bb loops into
5  * 1-BB loop be peeling out the 1st iteration which jumps into the middle
6  * of the jump. The resulting 1-BB loop can then be loop-scheduled.
7  *
8  * @author Heikki Kultala 2016 (heikki.kultala@tut.fi)
9  * @note rating: red
10  */
11 
12 #ifndef TTA_PEEL_2_BB_LOOPS_HH
13 #define TTA_PEEL_2_BB_LOOPS_HH
14 
15 #include "ProcedurePass.hh"
16 #include "ControlFlowGraphPass.hh"
17 #include "ProgramPass.hh"
18 #include "Application.hh"
19 #include <vector>
20 
21 
23 
24 public:
26  InterPassData& data, const TTAMachine::Machine& targetMachine);
27 
29  ControlFlowGraph& cfg,
30  const TTAMachine::Machine& targetMachine) override;
31 
32  virtual std::string shortDescription() const override {
33  return "optimizes two-BB inner loops into single-bb inner loops";
34  }
35 private:
36  struct BBNodes {
37  BBNodes(bool ok) : BBNodes() {
38  assert(!ok && "only call this on fail to allow return false"); }
39  BBNodes() : preLoop(NULL), beginLoop(NULL),
40  endLoop(NULL), postLoop(NULL) {}
43  : preLoop(prel), beginLoop(bl), endLoop(el), postLoop(pol) {}
48  operator bool() const { return preLoop != NULL; }
49  };
50 
52 
53  BBNodes testIf2BBLoop(ControlFlowGraph& cfg, BasicBlockNode& bbn);
54  void peel2BBLoop(ControlFlowGraph& cfg, BBNodes& bbns);
55  void updateCFG(ControlFlowGraph& cfg, BBNodes& bbns);
56  void performCodeMotion(BBNodes& bbns);
57  void appendBB(
58  const TTAProgram::BasicBlock& src,
60  BasicBlockNode* newJumpDest);
61 
65 };
66 
67 #endif
Peel2BBLoops::irm_
TTAProgram::InstructionReferenceManager * irm_
Definition: Peel2BBLoops.hh:63
Peel2BBLoops::BBNodes::postLoop
BasicBlockNode * postLoop
Definition: Peel2BBLoops.hh:47
Peel2BBLoops::BBNodes::beginLoop
BasicBlockNode * beginLoop
Definition: Peel2BBLoops.hh:45
Peel2BBLoops::negateOp
bool negateOp(ProgramOperationPtr po)
Definition: Peel2BBLoops.cc:267
ProgramOperationPtr
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition: MoveNode.hh:52
assert
#define assert(condition)
Definition: Application.hh:86
Peel2BBLoops::Peel2BBLoops
Peel2BBLoops(InterPassData &data, const TTAMachine::Machine &targetMachine)
Definition: Peel2BBLoops.cc:31
ProgramPass.hh
ProcedurePass.hh
Application.hh
BasicBlockNode
Definition: BasicBlockNode.hh:64
Peel2BBLoops::updateCFG
void updateCFG(ControlFlowGraph &cfg, BBNodes &bbns)
Definition: Peel2BBLoops.cc:130
InterPassData
Definition: InterPassData.hh:48
Peel2BBLoops::peel2BBLoop
void peel2BBLoop(ControlFlowGraph &cfg, BBNodes &bbns)
Definition: Peel2BBLoops.cc:124
Peel2BBLoops::BBNodes
Definition: Peel2BBLoops.hh:36
Peel2BBLoops::BBNodes::endLoop
BasicBlockNode * endLoop
Definition: Peel2BBLoops.hh:46
Peel2BBLoops::BBNodes::BBNodes
BBNodes(bool ok)
Definition: Peel2BBLoops.hh:37
Peel2BBLoops
Definition: Peel2BBLoops.hh:22
Peel2BBLoops::appendBB
void appendBB(const TTAProgram::BasicBlock &src, TTAProgram::BasicBlock &dest, BasicBlockNode *newJumpDest)
Definition: Peel2BBLoops.cc:172
TTAProgram::BasicBlock
Definition: BasicBlock.hh:85
Peel2BBLoops::BBNodes::preLoop
BasicBlockNode * preLoop
Definition: Peel2BBLoops.hh:44
Peel2BBLoops::codeGenerator_
TTAProgram::CodeGenerator * codeGenerator_
Definition: Peel2BBLoops.hh:62
TTAProgram::InstructionReferenceManager
Definition: InstructionReferenceManager.hh:82
ControlFlowGraphPass.hh
TTAProgram::CodeGenerator
Definition: CodeGenerator.hh:53
Peel2BBLoops::handleControlFlowGraph
void handleControlFlowGraph(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine) override
Definition: Peel2BBLoops.cc:101
Peel2BBLoops::BBNodes::BBNodes
BBNodes(BasicBlockNode *prel, BasicBlockNode *bl, BasicBlockNode *el, BasicBlockNode *pol)
Definition: Peel2BBLoops.hh:41
Peel2BBLoops::BBNodes::BBNodes
BBNodes()
Definition: Peel2BBLoops.hh:39
ControlFlowGraphPass
Definition: ControlFlowGraphPass.hh:50
Peel2BBLoops::testIf2BBLoop
BBNodes testIf2BBLoop(ControlFlowGraph &cfg, BasicBlockNode &bbn)
Definition: Peel2BBLoops.cc:37
Peel2BBLoops::shortDescription
virtual std::string shortDescription() const override
Definition: Peel2BBLoops.hh:32
Peel2BBLoops::mach_
const TTAMachine::Machine & mach_
Definition: Peel2BBLoops.hh:64
ControlFlowGraph
Definition: ControlFlowGraph.hh:100
TTAMachine::Machine
Definition: Machine.hh:73
Peel2BBLoops::performCodeMotion
void performCodeMotion(BBNodes &bbns)
Definition: Peel2BBLoops.cc:156