OpenASIP  2.0
BFDropPreShared.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 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 /**
26  * @file BFDropPreShared.cc
27  *
28  * Definition of BFDropPreShared class
29  *
30  * Removes an operand write which is not needed because the operand is
31  * loop-operand shared and put to the prolog of the loop.
32  *
33  * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
34  * @note rating: red
35  */
36 
37 #include "BFDropPreShared.hh"
38 #include "DataDependenceGraph.hh"
39 #include "BF2Scheduler.hh"
40 #include "BFSwapOperands.hh"
41 #include "Operation.hh"
42 #include "Move.hh"
43 #include "Terminal.hh"
44 #include "MoveNodeSet.hh"
45 
46 bool
48 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
49  std::cerr << "\tDropping pre-shared: " << mn_.toString() << std::endl;
50 #endif
52  if (trigger == &mn_) {
53 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
54  std::cerr << "Cannot pre-share trigger operand, must swap operands"
55  << std::endl;
56 #endif
58  const Operation& op = destPO->operation();
59  int operandCount = op.numberOfInputs();
60  bool swapped = false;
61  for (int i = 1 ; i <= operandCount && !swapped; i++) {
62  int idx = mn_.move().destination().operationIndex();
63  MoveNode& mn = destPO->inputNode(i).at(0);
64  if (i != idx && op.canSwap(i, idx) &&
66  // TODO: force the indeces here
67  BFSwapOperands* bfswo =
68  new BFSwapOperands(sched_, destPO, mn_, mn);
69  if (runPreChild(bfswo)) {
70  swapped = true;
71  }
72  }
73  }
74  if (!swapped) {
75  return false;
76  }
77  }
78  ddg().dropNode(mn_);
80  return true;
81 }
82 
83 void
85 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
86  std::cerr << "\tUndoing dropping of pre-shared: " << mn_.toString()
87  << std::endl;
88 #endif
91 }
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
BFDropPreShared::mn_
MoveNode & mn_
Definition: BFDropPreShared.hh:48
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
Operation::numberOfInputs
virtual int numberOfInputs() const
Definition: Operation.cc:192
BFOptimization::getSisterTrigger
static MoveNode * getSisterTrigger(const MoveNode &mn, const TTAMachine::Machine &mach)
Definition: BFOptimization.cc:848
DataDependenceGraph.hh
MoveNode
Definition: MoveNode.hh:65
Terminal.hh
BoostGraph::dropNode
virtual void dropNode(Node &node)
BFOptimization::targetMachine
const TTAMachine::Machine & targetMachine() const
Definition: BFOptimization.cc:81
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
ProgramOperationPtr
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition: MoveNode.hh:52
Operation::canSwap
virtual bool canSwap(int id1, int id2) const
Definition: Operation.cc:470
BFSwapOperands.hh
BF2Scheduler::isPreLoopSharedOperand
TTAMachine::FUPort * isPreLoopSharedOperand(MoveNode &mn) const
Definition: BF2Scheduler.cc:1625
TTAProgram::Terminal::operationIndex
virtual int operationIndex() const
Definition: Terminal.cc:364
BF2Scheduler.hh
BFDropPreShared.hh
Operation.hh
BFDropPreShared::operator()
bool operator()()
Definition: BFDropPreShared.cc:47
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
Operation
Definition: Operation.hh:59
MoveNode::destinationOperationPtr
ProgramOperationPtr destinationOperationPtr(unsigned int index=0) const
MoveNode::move
TTAProgram::Move & move()
Reversible::runPreChild
bool runPreChild(Reversible *preChild)
Definition: Reversible.cc:127
BF2Scheduler::nodeResurrected
void nodeResurrected(MoveNode &mn)
Definition: BF2Scheduler.cc:811
MoveNodeSet.hh
BFSwapOperands
Definition: BFSwapOperands.hh:41
BF2Scheduler::nodeKilled
void nodeKilled(MoveNode &mn)
Definition: BF2Scheduler.cc:807
Move.hh
BFDropPreShared::undoOnlyMe
void undoOnlyMe()
Definition: BFDropPreShared.cc:84
BoostGraph::restoreNodeFromParent
void restoreNodeFromParent(GraphNode &node)