OpenASIP  2.0
PostpassOperandSharer.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 PostpassOperandSharer.hh
26  *
27  * Declaration of PostpassOperandSharer class.
28  *
29  * This optimizer removes operand writes which are redundant due
30  * other operations using same value.
31  * This is executed after the main scheduler, so this mainly helps
32  * to reduce power consumption, not to improve performance.
33  *
34  * @author Heikki Kultala 2013 (hkultala-no.spam-cs.tut.fi)
35  * @note rating: red
36  */
37 
38 #include "BasicBlockPass.hh"
39 #include "ControlFlowGraphPass.hh"
40 
41 namespace TTAProgram {
42  class BasicBlocK;
43  class Move;
44  class InstructionReferenceManager;
45 }
46 
48  public BasicBlockPass, public ControlFlowGraphPass {
49 
50 public:
52  InterPassData& ipd,
54  BasicBlockPass(ipd), ControlFlowGraphPass(ipd), irm_(&irm) {}
55 
56  virtual ~PostpassOperandSharer();
57 
58  virtual void handleBasicBlock(
59  TTAProgram::BasicBlock& basicBlock,
60  const TTAMachine::Machine& targetMachine,
62  BasicBlockNode* bbn = NULL);
63 
65  TTAProgram::BasicBlock& basicBlock,
66  int insIndex,
67  TTAProgram::Move& move);
68 
69  static void printStats();
70 
71  virtual std::string shortDescription() const {
72  return "Post-pass that reduced redundant operand writes";
73  }
74 private:
76  static unsigned int moveCount_;
77  static unsigned int operandCount_;
78  static unsigned int removedOperands_;
79  static unsigned int registerReads_;
80  static unsigned int triggerCannotRemove_;
81 };
TTAProgram
Definition: Estimator.hh:65
PostpassOperandSharer::registerReads_
static unsigned int registerReads_
Definition: PostpassOperandSharer.hh:79
PostpassOperandSharer::~PostpassOperandSharer
virtual ~PostpassOperandSharer()
Definition: PostpassOperandSharer.cc:223
PostpassOperandSharer::handleBasicBlock
virtual void handleBasicBlock(TTAProgram::BasicBlock &basicBlock, const TTAMachine::Machine &targetMachine, TTAProgram::InstructionReferenceManager &irm, BasicBlockNode *bbn=NULL)
Definition: PostpassOperandSharer.cc:62
BasicBlockPass
Definition: BasicBlockPass.hh:60
PostpassOperandSharer::operandCount_
static unsigned int operandCount_
Definition: PostpassOperandSharer.hh:77
PostpassOperandSharer::moveCount_
static unsigned int moveCount_
Definition: PostpassOperandSharer.hh:76
PostpassOperandSharer::triggerCannotRemove_
static unsigned int triggerCannotRemove_
Definition: PostpassOperandSharer.hh:80
PostpassOperandSharer::printStats
static void printStats()
Definition: PostpassOperandSharer.cc:225
PostpassOperandSharer::PostpassOperandSharer
PostpassOperandSharer(InterPassData &ipd, TTAProgram::InstructionReferenceManager &irm)
Definition: PostpassOperandSharer.hh:51
BasicBlockPass.hh
BasicBlockNode
Definition: BasicBlockNode.hh:64
InterPassData
Definition: InterPassData.hh:48
TTAProgram::Move
Definition: Move.hh:55
TTAProgram::BasicBlock
Definition: BasicBlock.hh:85
PostpassOperandSharer
Definition: PostpassOperandSharer.hh:47
TTAProgram::InstructionReferenceManager
Definition: InstructionReferenceManager.hh:82
ControlFlowGraphPass.hh
PostpassOperandSharer::irm_
TTAProgram::InstructionReferenceManager * irm_
Definition: PostpassOperandSharer.hh:75
ControlFlowGraphPass
Definition: ControlFlowGraphPass.hh:50
PostpassOperandSharer::removedOperands_
static unsigned int removedOperands_
Definition: PostpassOperandSharer.hh:78
PostpassOperandSharer::tryRemoveOperandWrite
bool tryRemoveOperandWrite(TTAProgram::BasicBlock &basicBlock, int insIndex, TTAProgram::Move &move)
Definition: PostpassOperandSharer.cc:83
TTAMachine::Machine
Definition: Machine.hh:73
PostpassOperandSharer::shortDescription
virtual std::string shortDescription() const
Definition: PostpassOperandSharer.hh:71