OpenASIP  2.0
PreOptimizer.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file PreOptimizer.hh
26  *
27  * Declaration of PreOptimizer class.
28  *
29  * This optimizer does some peephole optimizations before actual scheduling:
30  *
31  * Removes unneeded predicate arithmetic by using
32  * opposite guard instead where the guard is used.
33  *
34  * Changes registers of address calculations to eliminate entideps
35  *
36  * Removes adds of compile-time ocnstants
37  *
38  * @author Heikki Kultala 2009 (hkultala-no.spam-cs.tut.fi)
39  * @note rating: red
40  */
41 
42 #ifndef TTA_PRE_OPTIMIZER_HH
43 #define TTA_PRE_OPTIMIZER_HH
44 
45 #include "ProcedurePass.hh"
46 #include "ProgramPass.hh"
47 #include "ControlFlowGraphPass.hh"
48 #include "DataDependenceGraph.hh"
49 #include "ControlFlowGraph.hh"
50 
51 namespace TTAProgram {
52  class CodeSnippet;
53  class Procedure;
54  class Program;
55  class InstructionReferenceManager;
56  class Instruction;
57 }
58 
59 namespace TTAMachine {
60  class Machine;
61 }
62 
64 class ProgramOperation;
65 
67  public ProcedurePass, public ProgramPass , public ControlFlowGraphPass {
68 
69 public:
71 
72  void handleProgram(
73  TTAProgram::Program& program, const TTAMachine::Machine& targetMachine);
74 
75  void handleProcedure(
76  TTAProgram::Procedure& procedure,
77  const TTAMachine::Machine& targetMachine);
78 
80  ControlFlowGraph& cfg, const TTAMachine::Machine& targetMachine);
81 
82  void handleCFGDDG(
83  ControlFlowGraph& cfg,
84  DataDependenceGraph& ddg);
85 
86  std::string shortDescription() const {
87  return "optimizes away guard nagation operations, "
88  "uses opposite guards instead"; };
89 private:
93 
97 
100 
105  ControlFlowGraph& cfg);
106 
111  ControlFlowGraph& cfg);
112 
117  ControlFlowGraph& cfg);
118 
121 
124 
125 };
126 
127 #endif
PreOptimizer::shortDescription
std::string shortDescription() const
Definition: PreOptimizer.hh:86
ProcedurePass
Definition: ProcedurePass.hh:53
TTAProgram
Definition: Estimator.hh:65
TTAProgram::Program
Definition: Program.hh:63
PreOptimizer::inverseGuardsOfHeads
ControlFlowGraph::NodeSet inverseGuardsOfHeads(DataDependenceGraph &ddg, DataDependenceGraph::EdgeSet &oEdges)
Definition: PreOptimizer.cc:380
BoostGraph< BasicBlockNode, ControlFlowEdge >::NodeSet
std::set< BasicBlockNode *, typename BasicBlockNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
TTAProgram::Instruction
Definition: Instruction.hh:57
PreOptimizer::handleControlFlowGraph
void handleControlFlowGraph(ControlFlowGraph &cfg, const TTAMachine::Machine &targetMachine)
Definition: PreOptimizer.cc:546
ProgramPass
Definition: ProgramPass.hh:52
PreOptimizer
Definition: PreOptimizer.hh:66
DataDependenceGraph.hh
ProgramOperation
Definition: ProgramOperation.hh:70
PreOptimizer::handleCFGDDG
void handleCFGDDG(ControlFlowGraph &cfg, DataDependenceGraph &ddg)
Definition: PreOptimizer.cc:511
PreOptimizer::tryToRemoveXor
ControlFlowGraph::NodeSet tryToRemoveXor(DataDependenceGraph &ddg, ProgramOperation &po, TTAProgram::InstructionReferenceManager *irm, ControlFlowGraph &cfg)
Definition: PreOptimizer.cc:195
PreOptimizer::checkGuardReversalAllowed
bool checkGuardReversalAllowed(DataDependenceGraph &ddg, DataDependenceGraph::EdgeSet &oEdges)
Definition: PreOptimizer.cc:326
BoostGraph< MoveNode, DataDependenceEdge >::EdgeSet
std::set< DataDependenceEdge *, typename DataDependenceEdge ::Comparator > EdgeSet
Definition: BoostGraph.hh:87
PreOptimizer::cfgAllowsJumpReversal
bool cfgAllowsJumpReversal(TTAProgram::Instruction &ins, ControlFlowGraph &cfg)
Definition: PreOptimizer.cc:562
ControlFlowGraph.hh
ProgramPass.hh
ProcedurePass.hh
PreOptimizer::tryToOptimizeAddressReg
bool tryToOptimizeAddressReg(DataDependenceGraph &ddg, ProgramOperation &po)
Definition: PreOptimizer.cc:87
PreOptimizer::PreOptimizer
PreOptimizer(InterPassData &data)
Definition: PreOptimizer.cc:69
InterPassData
Definition: InterPassData.hh:48
PreOptimizer::tryToPrecalcConstantAdd
void tryToPrecalcConstantAdd(DataDependenceGraph &ddg, ProgramOperation &po)
Definition: PreOptimizer.cc:412
PreOptimizer::tryToRemoveGuardInversingOp
ControlFlowGraph::NodeSet tryToRemoveGuardInversingOp(DataDependenceGraph &ddg, ProgramOperation &po, TTAProgram::InstructionReferenceManager *irm, ControlFlowGraph &cfg)
Definition: PreOptimizer.cc:244
TTAProgram::InstructionReferenceManager
Definition: InstructionReferenceManager.hh:82
ControlFlowGraphPass.hh
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
PreOptimizer::tryToRemoveEq
ControlFlowGraph::NodeSet tryToRemoveEq(DataDependenceGraph &ddg, ProgramOperation &po, TTAProgram::InstructionReferenceManager *irm, ControlFlowGraph &cfg)
Definition: PreOptimizer.cc:215
ControlFlowGraphPass
Definition: ControlFlowGraphPass.hh:50
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
TTAMachine
Definition: Assembler.hh:48
TTAProgram::Procedure
Definition: Procedure.hh:55
PreOptimizer::handleProgram
void handleProgram(TTAProgram::Program &program, const TTAMachine::Machine &targetMachine)
Definition: PreOptimizer.cc:81
PreOptimizer::handleProcedure
void handleProcedure(TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine)
Definition: PreOptimizer.cc:484
ControlFlowGraph
Definition: ControlFlowGraph.hh:100
TTAMachine::Machine
Definition: Machine.hh:73