aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-05-10 21:06:12 +0000
committerAndrew Trick <atrick@apple.com>2012-05-10 21:06:12 +0000
commitd38f87eeecbf58553e460f4cd9a4666a2caeba62 (patch)
treeb3f2f51a5e1f4add449fa88bef14f4f4ce7703a7 /lib/CodeGen/MachineScheduler.cpp
parent7f8ab785af09e4d6e4db07157a5b5aa449b5c3ae (diff)
downloadexternal_llvm-d38f87eeecbf58553e460f4cd9a4666a2caeba62.zip
external_llvm-d38f87eeecbf58553e460f4cd9a4666a2caeba62.tar.gz
external_llvm-d38f87eeecbf58553e460f4cd9a4666a2caeba62.tar.bz2
misched: Added ReadyQ container wrapper for Top and Bottom Queues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--lib/CodeGen/MachineScheduler.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp
index 7e871a7..c6679c2 100644
--- a/lib/CodeGen/MachineScheduler.cpp
+++ b/lib/CodeGen/MachineScheduler.cpp
@@ -629,15 +629,46 @@ void ScheduleDAGMI::placeDebugValues() {
//===----------------------------------------------------------------------===//
namespace {
+struct ReadyQ {
+ typedef std::vector<SUnit*>::iterator iterator;
+
+ unsigned ID;
+ std::vector<SUnit*> Queue;
+
+ ReadyQ(unsigned id): ID(id) {}
+
+ bool isInQueue(SUnit *SU) const {
+ return SU->NodeQueueId & ID;
+ }
+
+ bool empty() const { return Queue.empty(); }
+
+ iterator find(SUnit *SU) {
+ return std::find(Queue.begin(), Queue.end(), SU);
+ }
+
+ void push(SUnit *SU) {
+ Queue.push_back(SU);
+ }
+
+ void remove(iterator I) {
+ *I = Queue.back();
+ Queue.pop_back();
+ }
+};
+
/// ConvergingScheduler shrinks the unscheduled zone using heuristics to balance
/// the schedule.
class ConvergingScheduler : public MachineSchedStrategy {
ScheduleDAGMI *DAG;
- unsigned NumTopReady;
- unsigned NumBottomReady;
+ ReadyQ TopQueue;
+ ReadyQ BotQueue;
public:
+ // NodeQueueId = 0 (none), = 1 (top), = 2 (bottom), = 3 (both)
+ ConvergingScheduler(): TopQueue(1), BotQueue(2) {}
+
virtual void initialize(ScheduleDAGMI *dag) {
DAG = dag;
@@ -646,13 +677,15 @@ public:
}
virtual SUnit *pickNode(bool &IsTopNode) {
- if (DAG->top() == DAG->bottom())
+ if (DAG->top() == DAG->bottom()) {
+ assert(TopQueue.empty() && BotQueue.empty() && "ReadyQ garbage");
return NULL;
-
+ }
// As an initial placeholder heuristic, schedule in the direction that has
// the fewest choices.
SUnit *SU;
- if (ForceTopDown || (!ForceBottomUp && NumTopReady <= NumBottomReady)) {
+ if (ForceTopDown
+ || (!ForceBottomUp && TopQueue.Queue.size() <= BotQueue.Queue.size())) {
SU = DAG->getSUnit(DAG->top());
IsTopNode = true;
}
@@ -661,21 +694,21 @@ public:
IsTopNode = false;
}
if (SU->isTopReady()) {
- assert(NumTopReady > 0 && "bad ready count");
- --NumTopReady;
+ assert(!TopQueue.empty() && "bad ready count");
+ TopQueue.remove(TopQueue.find(SU));
}
if (SU->isBottomReady()) {
- assert(NumBottomReady > 0 && "bad ready count");
- --NumBottomReady;
+ assert(!BotQueue.empty() && "bad ready count");
+ BotQueue.remove(BotQueue.find(SU));
}
return SU;
}
virtual void releaseTopNode(SUnit *SU) {
- ++NumTopReady;
+ TopQueue.push(SU);
}
virtual void releaseBottomNode(SUnit *SU) {
- ++NumBottomReady;
+ BotQueue.push(SU);
}
};
} // namespace