2008-11-15 01:23:40 +01:00
|
|
|
//===---- LatencyPriorityQueue.h - A latency-oriented priority queue ------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the LatencyPriorityQueue class, which is a
|
|
|
|
// SchedulingPriorityQueue that schedules using latency information to
|
|
|
|
// reduce the length of the critical path through the basic block.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 01:45:19 +01:00
|
|
|
#ifndef LLVM_CODEGEN_LATENCYPRIORITYQUEUE_H
|
|
|
|
#define LLVM_CODEGEN_LATENCYPRIORITYQUEUE_H
|
2008-11-15 01:23:40 +01:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
2018-04-30 16:59:11 +02:00
|
|
|
#include "llvm/Config/llvm-config.h"
|
2008-11-15 01:23:40 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class LatencyPriorityQueue;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2008-11-15 01:23:40 +01:00
|
|
|
/// Sorting functions for the Available queue.
|
2017-09-14 20:33:25 +02:00
|
|
|
struct latency_sort {
|
2008-11-15 01:23:40 +01:00
|
|
|
LatencyPriorityQueue *PQ;
|
|
|
|
explicit latency_sort(LatencyPriorityQueue *pq) : PQ(pq) {}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2018-07-16 20:51:40 +02:00
|
|
|
bool operator()(const SUnit* LHS, const SUnit* RHS) const;
|
2008-11-15 01:23:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class LatencyPriorityQueue : public SchedulingPriorityQueue {
|
|
|
|
// SUnits - The SUnits for the current graph.
|
|
|
|
std::vector<SUnit> *SUnits;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2008-11-15 01:23:40 +01:00
|
|
|
/// NumNodesSolelyBlocking - This vector contains, for every node in the
|
|
|
|
/// Queue, the number of nodes that the node is the sole unscheduled
|
|
|
|
/// predecessor for. This is used as a tie-breaker heuristic for better
|
|
|
|
/// mobility.
|
|
|
|
std::vector<unsigned> NumNodesSolelyBlocking;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2009-11-03 21:57:50 +01:00
|
|
|
/// Queue - The queue.
|
2010-05-26 20:52:00 +02:00
|
|
|
std::vector<SUnit*> Queue;
|
|
|
|
latency_sort Picker;
|
2009-11-03 21:57:50 +01:00
|
|
|
|
2010-05-26 20:37:48 +02:00
|
|
|
public:
|
2010-05-26 20:52:00 +02:00
|
|
|
LatencyPriorityQueue() : Picker(this) {
|
2009-11-03 21:57:50 +01:00
|
|
|
}
|
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
bool isBottomUp() const override { return false; }
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
void initNodes(std::vector<SUnit> &sunits) override {
|
2008-11-15 01:23:40 +01:00
|
|
|
SUnits = &sunits;
|
2008-12-16 04:25:46 +01:00
|
|
|
NumNodesSolelyBlocking.resize(SUnits->size(), 0);
|
2008-11-15 01:23:40 +01:00
|
|
|
}
|
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
void addNode(const SUnit *SU) override {
|
2008-11-15 01:23:40 +01:00
|
|
|
NumNodesSolelyBlocking.resize(SUnits->size(), 0);
|
|
|
|
}
|
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
void updateNode(const SUnit *SU) override {
|
2008-11-15 01:23:40 +01:00
|
|
|
}
|
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
void releaseState() override {
|
2014-04-14 02:51:57 +02:00
|
|
|
SUnits = nullptr;
|
2008-11-15 01:23:40 +01:00
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2008-11-15 01:23:40 +01:00
|
|
|
unsigned getLatency(unsigned NodeNum) const {
|
2008-12-16 04:25:46 +01:00
|
|
|
assert(NodeNum < (*SUnits).size());
|
2009-11-20 20:32:48 +01:00
|
|
|
return (*SUnits)[NodeNum].getHeight();
|
2008-11-15 01:23:40 +01:00
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2008-11-15 01:23:40 +01:00
|
|
|
unsigned getNumSolelyBlockNodes(unsigned NodeNum) const {
|
|
|
|
assert(NodeNum < NumNodesSolelyBlocking.size());
|
|
|
|
return NumNodesSolelyBlocking[NodeNum];
|
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
bool empty() const override { return Queue.empty(); }
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
void push(SUnit *U) override;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
SUnit *pop() override;
|
2008-11-15 01:23:40 +01:00
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
void remove(SUnit *SU) override;
|
2008-11-15 01:23:40 +01:00
|
|
|
|
2018-04-16 12:20:56 +02:00
|
|
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
2018-04-20 02:42:46 +02:00
|
|
|
LLVM_DUMP_METHOD void dump(ScheduleDAG *DAG) const override;
|
2018-04-16 12:20:56 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-08 00:00:49 +01:00
|
|
|
// scheduledNode - As nodes are scheduled, we look to see if there are any
|
2008-11-15 01:23:40 +01:00
|
|
|
// successor nodes that have a single unscheduled predecessor. If so, that
|
|
|
|
// single predecessor has a higher priority, since scheduling it will make
|
|
|
|
// the node available.
|
2018-07-16 20:51:40 +02:00
|
|
|
void scheduledNode(SUnit *SU) override;
|
2008-11-15 01:23:40 +01:00
|
|
|
|
2008-11-20 00:18:57 +01:00
|
|
|
private:
|
2008-11-15 01:23:40 +01:00
|
|
|
void AdjustPriorityOfUnscheduledPreds(SUnit *SU);
|
|
|
|
SUnit *getSingleUnscheduledPred(SUnit *SU);
|
|
|
|
};
|
2015-06-23 11:49:53 +02:00
|
|
|
}
|
2008-11-15 01:23:40 +01:00
|
|
|
|
|
|
|
#endif
|