OpenASIP 2.2
Loading...
Searching...
No Matches
ReadyMoveNodeGroupList.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 ReadyMoveNodeGroupList.hh
26 *
27 * Declaration of ReadyMoveNodeGroupList class.
28 *
29 * @author Pekka Jääskeläinen 2007 (pjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_READY_MOVE_NODE_GROUP_LIST_HH
34#define TTA_READY_MOVE_NODE_GROUP_LIST_HH
35
36#include <vector>
37#include <queue>
38
39#include "MoveNode.hh"
40#include "Move.hh"
41#include "MoveNodeGroup.hh"
42
43/**
44 * A function object for prioritizing the ready list according to the move's
45 * distance from farthest sink node.
46 *
47 */
49 public std::binary_function<MoveNode*, MoveNode*, bool> {
50public:
51 /**
52 * Compares two nodes according to their priority in the ready list.
53 *
54 * @param a Node a.
55 * @param b Node b.
56 * @return True if b should be scheduled before a (b greater than a).
57 */
59
60 if (b.isScheduled()) {
61 // keep scheduled MoveNodeSets on a top of a queue
62 // so they will be poped out
63 return true;
64 }
65 if (a.isScheduled()) {
66 // keep scheduled MoveNodeSets on a top of a queue
67 // so they will be poped out
68 return false;
69 }
70 // Compute distances only once, it is expensive operation on graph
71 int aSinkDistance = a.maxSinkDistance();
72 int bSinkDistance = b.maxSinkDistance();
73
74 if (bSinkDistance == aSinkDistance) {
75 return b.node(0).nodeID() < a.node(0).nodeID();
76 }
77 // the higher the sink distance, the higher the priority
78 return bSinkDistance > aSinkDistance;
79 }
80};
81
82/**
83 * A function object for prioritizing the ready list according to the move's
84 * distance from farthest source node. Futher away from source the better.
85 *
86 */
88public std::binary_function<MoveNode*, MoveNode*, bool> {
89public:
90 /**
91 * Compares two nodes according to their priority in the ready list.
92 *
93 * @param a Node a.
94 * @param b Node b.
95 * @return True if b should be scheduled before a (b greater than a).
96 */
98
99 if (b.isScheduled()) {
100 // keep scheduled MoveNodeSets on a top of a queue
101 // so they will be poped out
102 return true;
103 }
104 if (a.isScheduled()) {
105 // keep scheduled MoveNodeSets on a top of a queue
106 // so they will be poped out
107 return false;
108 }
109 if (a.node(0).move().isControlFlowMove()) {
110 // Push control flow move to beginning of the ready list
111 return false;
112 }
113 if (b.node(0).move().isControlFlowMove()) {
114 // Push control flow move to beginning of the ready list
115 return true;
116 }
117#if 0
118 // also prioritize moves which write the jump guard.
119 if (a.writesJumpGuard()) {
120 return false;
121 }
122
123 // also prioritize moves which write the jump guard.
124 if (b.writesJumpGuard()) {
125 return true;
126 }
127#endif
128 // Compute distances only once, it is expensive operation on graph
129 int aSourceDistance = a.maxSourceDistance();
130 int bSourceDistance = b.maxSourceDistance();
131 if (bSourceDistance == aSourceDistance) {
132 int aSinkDistance = a.maxSinkDistance();
133 int bSinkDistance = b.maxSinkDistance();
134 if (bSinkDistance == aSinkDistance) {
135 return b.node(0).nodeID() < a.node(0).nodeID();
136 }
137 // the lower the sink distance, the higher the priority
138 // this priority is better for loop scheduling, to make
139 // true tails get scheudled first.
140 return bSinkDistance < aSinkDistance;
141
142 }
143 // the higher the source distance, the higher the priority
144 return bSourceDistance > aSourceDistance;
145 }
146};
147
148/// A prioritized list for the ready-to-be-scheduled move node groups.
149typedef std::priority_queue<
150 MoveNodeGroup, std::vector<MoveNodeGroup>,
152
153/// A prioritized list for the ready-to-be-scheduled move node groups.
154typedef std::priority_queue<
155 MoveNodeGroup, std::vector<MoveNodeGroup>,
157
158#endif
std::priority_queue< MoveNodeGroup, std::vector< MoveNodeGroup >, RLPriorityCriticalPath > ReadyMoveNodeGroupList
A prioritized list for the ready-to-be-scheduled move node groups.
std::priority_queue< MoveNodeGroup, std::vector< MoveNodeGroup >, RLBUPriorityCriticalPath > ReadyMoveNodeGroupListBU
A prioritized list for the ready-to-be-scheduled move node groups.
int nodeID() const
int maxSinkDistance() const
MoveNode & node(int index) const
int maxSourceDistance() const
bool writesJumpGuard() const
bool isScheduled() const
TTAProgram::Move & move()
bool operator()(MoveNodeGroup &a, MoveNodeGroup &b)
bool operator()(MoveNodeGroup &a, MoveNodeGroup &b)
bool isControlFlowMove() const
Definition Move.cc:233