mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Eliminate the use of PriorityQueue and just use a std::vector,
implementing pop with a linear search for a "best" element. The priority queue was a neat idea, but in practice the comparison functions depend on dynamic information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104718 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f0f1bfe89a
commit
93d3433579
@ -17,7 +17,6 @@
|
||||
#define LATENCY_PRIORITY_QUEUE_H
|
||||
|
||||
#include "llvm/CodeGen/ScheduleDAG.h"
|
||||
#include "llvm/ADT/PriorityQueue.h"
|
||||
|
||||
namespace llvm {
|
||||
class LatencyPriorityQueue;
|
||||
@ -41,10 +40,11 @@ namespace llvm {
|
||||
std::vector<unsigned> NumNodesSolelyBlocking;
|
||||
|
||||
/// Queue - The queue.
|
||||
PriorityQueue<SUnit*, std::vector<SUnit*>, latency_sort> Queue;
|
||||
std::vector<SUnit*> Queue;
|
||||
latency_sort Picker;
|
||||
|
||||
public:
|
||||
LatencyPriorityQueue() : Queue(latency_sort(this)) {
|
||||
LatencyPriorityQueue() : Picker(this) {
|
||||
}
|
||||
|
||||
void initNodes(std::vector<SUnit> &sunits) {
|
||||
@ -77,17 +77,9 @@ namespace llvm {
|
||||
|
||||
virtual void push(SUnit *U);
|
||||
|
||||
SUnit *pop() {
|
||||
if (empty()) return NULL;
|
||||
SUnit *V = Queue.top();
|
||||
Queue.pop();
|
||||
return V;
|
||||
}
|
||||
virtual SUnit *pop();
|
||||
|
||||
void remove(SUnit *SU) {
|
||||
assert(!Queue.empty() && "Not in queue!");
|
||||
Queue.erase_one(SU);
|
||||
}
|
||||
virtual void remove(SUnit *SU);
|
||||
|
||||
// ScheduledNode - As nodes are scheduled, we look to see if there are any
|
||||
// successor nodes that have a single unscheduled predecessor. If so, that
|
||||
|
@ -79,7 +79,7 @@ void LatencyPriorityQueue::push(SUnit *SU) {
|
||||
}
|
||||
NumNodesSolelyBlocking[SU->NodeNum] = NumNodesBlocking;
|
||||
|
||||
Queue.push(SU);
|
||||
Queue.push_back(SU);
|
||||
}
|
||||
|
||||
|
||||
@ -114,3 +114,25 @@ void LatencyPriorityQueue::AdjustPriorityOfUnscheduledPreds(SUnit *SU) {
|
||||
// NumNodesSolelyBlocking value.
|
||||
push(OnlyAvailablePred);
|
||||
}
|
||||
|
||||
SUnit *LatencyPriorityQueue::pop() {
|
||||
if (empty()) return NULL;
|
||||
std::vector<SUnit *>::iterator Best = Queue.begin();
|
||||
for (std::vector<SUnit *>::iterator I = next(Queue.begin()),
|
||||
E = Queue.end(); I != E; ++I)
|
||||
if (Picker(*Best, *I))
|
||||
Best = I;
|
||||
SUnit *V = *Best;
|
||||
if (Best != prior(Queue.end()))
|
||||
std::swap(*Best, Queue.back());
|
||||
Queue.pop_back();
|
||||
return V;
|
||||
}
|
||||
|
||||
void LatencyPriorityQueue::remove(SUnit *SU) {
|
||||
assert(!Queue.empty() && "Queue is empty!");
|
||||
std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(), SU);
|
||||
if (I != prior(Queue.end()))
|
||||
std::swap(*I, Queue.back());
|
||||
Queue.pop_back();
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/ADT/PriorityQueue.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
@ -1027,7 +1026,8 @@ CalcNodeSethiUllmanNumber(const SUnit *SU, std::vector<unsigned> &SUNumbers) {
|
||||
namespace {
|
||||
template<class SF>
|
||||
class RegReductionPriorityQueue : public SchedulingPriorityQueue {
|
||||
PriorityQueue<SUnit*, std::vector<SUnit*>, SF> Queue;
|
||||
std::vector<SUnit*> Queue;
|
||||
SF Picker;
|
||||
unsigned CurQueueId;
|
||||
|
||||
protected:
|
||||
@ -1044,7 +1044,7 @@ namespace {
|
||||
public:
|
||||
RegReductionPriorityQueue(const TargetInstrInfo *tii,
|
||||
const TargetRegisterInfo *tri)
|
||||
: Queue(SF(this)), CurQueueId(0),
|
||||
: Picker(this), CurQueueId(0),
|
||||
TII(tii), TRI(tri), scheduleDAG(NULL) {}
|
||||
|
||||
void initNodes(std::vector<SUnit> &sunits) {
|
||||
@ -1110,13 +1110,20 @@ namespace {
|
||||
void push(SUnit *U) {
|
||||
assert(!U->NodeQueueId && "Node in the queue already");
|
||||
U->NodeQueueId = ++CurQueueId;
|
||||
Queue.push(U);
|
||||
Queue.push_back(U);
|
||||
}
|
||||
|
||||
SUnit *pop() {
|
||||
if (empty()) return NULL;
|
||||
SUnit *V = Queue.top();
|
||||
Queue.pop();
|
||||
std::vector<SUnit *>::iterator Best = Queue.begin();
|
||||
for (std::vector<SUnit *>::iterator I = next(Queue.begin()),
|
||||
E = Queue.end(); I != E; ++I)
|
||||
if (Picker(*Best, *I))
|
||||
Best = I;
|
||||
SUnit *V = *Best;
|
||||
if (Best != prior(Queue.end()))
|
||||
std::swap(*Best, Queue.back());
|
||||
Queue.pop_back();
|
||||
V->NodeQueueId = 0;
|
||||
return V;
|
||||
}
|
||||
@ -1124,7 +1131,11 @@ namespace {
|
||||
void remove(SUnit *SU) {
|
||||
assert(!Queue.empty() && "Queue is empty!");
|
||||
assert(SU->NodeQueueId != 0 && "Not in queue!");
|
||||
Queue.erase_one(SU);
|
||||
std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(),
|
||||
SU);
|
||||
if (I != prior(Queue.end()))
|
||||
std::swap(*I, Queue.back());
|
||||
Queue.pop_back();
|
||||
SU->NodeQueueId = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user