OpenASIP 2.2
Loading...
Searching...
No Matches
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"
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
46bool
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
83void
85#ifdef DEBUG_BUBBLEFISH_SCHEDULER
86 std::cerr << "\tUndoing dropping of pre-shared: " << mn_.toString()
87 << std::endl;
88#endif
91}
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition MoveNode.hh:53
void nodeResurrected(MoveNode &mn)
TTAMachine::FUPort * isPreLoopSharedOperand(MoveNode &mn) const
void nodeKilled(MoveNode &mn)
BF2Scheduler & sched_
static MoveNode * getSisterTrigger(const MoveNode &mn, const TTAMachine::Machine &mach)
DataDependenceGraph & ddg()
const TTAMachine::Machine & targetMachine() const
void restoreNodeFromParent(GraphNode &node)
virtual void dropNode(Node &node)
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
ProgramOperationPtr destinationOperationPtr(unsigned int index=0) const
virtual int numberOfInputs() const
Definition Operation.cc:192
virtual bool canSwap(int id1, int id2) const
Definition Operation.cc:470
bool runPreChild(Reversible *preChild)
Terminal & destination() const
Definition Move.cc:323
virtual int operationIndex() const
Definition Terminal.cc:364