2010-12-08 20:04:29 +00:00
|
|
|
//===----- ScoreboardHazardRecognizer.cpp - Scheduler Support -------------===//
|
2009-08-10 15:55:25 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-12-08 20:04:29 +00:00
|
|
|
// This file implements the ScoreboardHazardRecognizer class, which
|
|
|
|
// encapsultes hazard-avoidance heuristics for scheduling, based on the
|
|
|
|
// scheduling itineraries specified for the target.
|
2009-08-10 15:55:25 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
#define DEBUG_TYPE ::llvm::ScoreboardHazardRecognizer::DebugType
|
2010-12-08 20:04:29 +00:00
|
|
|
#include "llvm/CodeGen/ScoreboardHazardRecognizer.h"
|
2010-06-14 21:06:53 +00:00
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
2011-06-29 01:14:12 +00:00
|
|
|
#include "llvm/MC/MCInstrItineraries.h"
|
2009-08-10 15:55:25 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2009-08-11 01:44:26 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2011-01-21 05:51:33 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2009-08-10 15:55:25 +00:00
|
|
|
|
2009-08-22 20:08:44 +00:00
|
|
|
using namespace llvm;
|
2009-08-10 15:55:25 +00:00
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
const char *ScoreboardHazardRecognizer::DebugType = "";
|
|
|
|
#endif
|
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
ScoreboardHazardRecognizer::
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
ScoreboardHazardRecognizer(const InstrItineraryData *II,
|
|
|
|
const ScheduleDAG *SchedDAG,
|
|
|
|
const char *ParentDebugType) :
|
|
|
|
ScheduleHazardRecognizer(), ItinData(II), DAG(SchedDAG), IssueWidth(0),
|
|
|
|
IssueCount(0) {
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
DebugType = ParentDebugType;
|
|
|
|
#endif
|
|
|
|
|
2012-06-05 03:44:32 +00:00
|
|
|
// Determine the maximum depth of any itinerary. This determines the depth of
|
|
|
|
// the scoreboard. We always make the scoreboard at least 1 cycle deep to
|
|
|
|
// avoid dealing with the boundary condition.
|
2010-04-07 18:19:24 +00:00
|
|
|
unsigned ScoreboardDepth = 1;
|
2010-09-10 01:29:16 +00:00
|
|
|
if (ItinData && !ItinData->isEmpty()) {
|
2009-08-10 15:55:25 +00:00
|
|
|
for (unsigned idx = 0; ; ++idx) {
|
2010-09-10 01:29:16 +00:00
|
|
|
if (ItinData->isEndMarker(idx))
|
2009-08-10 15:55:25 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-10 01:29:16 +00:00
|
|
|
const InstrStage *IS = ItinData->beginStage(idx);
|
|
|
|
const InstrStage *E = ItinData->endStage(idx);
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
unsigned CurCycle = 0;
|
2009-08-10 15:55:25 +00:00
|
|
|
unsigned ItinDepth = 0;
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
for (; IS != E; ++IS) {
|
|
|
|
unsigned StageDepth = CurCycle + IS->getCycles();
|
|
|
|
if (ItinDepth < StageDepth) ItinDepth = StageDepth;
|
|
|
|
CurCycle += IS->getNextCycles();
|
|
|
|
}
|
2009-08-10 15:55:25 +00:00
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
// Find the next power-of-2 >= ItinDepth
|
|
|
|
while (ItinDepth > ScoreboardDepth) {
|
|
|
|
ScoreboardDepth *= 2;
|
2012-06-05 03:44:32 +00:00
|
|
|
// Don't set MaxLookAhead until we find at least one nonzero stage.
|
|
|
|
// This way, an itinerary with no stages has MaxLookAhead==0, which
|
|
|
|
// completely bypasses the scoreboard hazard logic.
|
|
|
|
MaxLookAhead = ScoreboardDepth;
|
2010-12-08 20:04:29 +00:00
|
|
|
}
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-07 18:19:32 +00:00
|
|
|
ReservedScoreboard.reset(ScoreboardDepth);
|
|
|
|
RequiredScoreboard.reset(ScoreboardDepth);
|
2009-08-10 15:55:25 +00:00
|
|
|
|
2012-06-05 03:44:40 +00:00
|
|
|
if (!isEnabled())
|
2012-06-05 03:44:32 +00:00
|
|
|
DEBUG(dbgs() << "Disabled scoreboard hazard recognizer\n");
|
2012-06-05 03:44:40 +00:00
|
|
|
else {
|
|
|
|
IssueWidth = ItinData->Props.IssueWidth;
|
2012-06-05 03:44:32 +00:00
|
|
|
DEBUG(dbgs() << "Using scoreboard hazard recognizer: Depth = "
|
|
|
|
<< ScoreboardDepth << '\n');
|
2012-06-05 03:44:40 +00:00
|
|
|
}
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
void ScoreboardHazardRecognizer::Reset() {
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
IssueCount = 0;
|
2010-04-07 18:19:32 +00:00
|
|
|
RequiredScoreboard.reset();
|
|
|
|
ReservedScoreboard.reset();
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
void ScoreboardHazardRecognizer::Scoreboard::dump() const {
|
2010-01-04 21:26:07 +00:00
|
|
|
dbgs() << "Scoreboard:\n";
|
2010-04-07 18:19:24 +00:00
|
|
|
|
|
|
|
unsigned last = Depth - 1;
|
|
|
|
while ((last > 0) && ((*this)[last] == 0))
|
2009-08-10 15:55:25 +00:00
|
|
|
last--;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i <= last; i++) {
|
2012-06-18 21:08:18 +00:00
|
|
|
uint64_t FUs = (*this)[i];
|
2010-01-04 21:26:07 +00:00
|
|
|
dbgs() << "\t";
|
2012-06-18 21:08:18 +00:00
|
|
|
for (int j = 63; j >= 0; j--)
|
2010-01-04 21:26:07 +00:00
|
|
|
dbgs() << ((FUs & (1 << j)) ? '1' : '0');
|
|
|
|
dbgs() << '\n';
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
bool ScoreboardHazardRecognizer::atIssueLimit() const {
|
|
|
|
if (IssueWidth == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return IssueCount == IssueWidth;
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:35:02 +00:00
|
|
|
ScheduleHazardRecognizer::HazardType
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
ScoreboardHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
|
2010-09-10 01:29:16 +00:00
|
|
|
if (!ItinData || ItinData->isEmpty())
|
2009-09-22 16:47:52 +00:00
|
|
|
return NoHazard;
|
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
// Note that stalls will be negative for bottom-up scheduling.
|
|
|
|
int cycle = Stalls;
|
2009-09-22 16:47:52 +00:00
|
|
|
|
|
|
|
// Use the itinerary for the underlying instruction to check for
|
|
|
|
// free FU's in the scoreboard at the appropriate future cycles.
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
|
|
|
|
if (MCID == NULL) {
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
// Don't check hazards for non-machineinstr Nodes.
|
|
|
|
return NoHazard;
|
|
|
|
}
|
2011-06-28 19:10:37 +00:00
|
|
|
unsigned idx = MCID->getSchedClass();
|
2010-09-10 01:29:16 +00:00
|
|
|
for (const InstrStage *IS = ItinData->beginStage(idx),
|
|
|
|
*E = ItinData->endStage(idx); IS != E; ++IS) {
|
2009-09-22 16:47:52 +00:00
|
|
|
// We must find one of the stage's units free for every cycle the
|
|
|
|
// stage is occupied. FIXME it would be more accurate to find the
|
|
|
|
// same unit free in all the cycles.
|
|
|
|
for (unsigned int i = 0; i < IS->getCycles(); ++i) {
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
int StageCycle = cycle + (int)i;
|
|
|
|
if (StageCycle < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (StageCycle >= (int)RequiredScoreboard.getDepth()) {
|
|
|
|
assert((StageCycle - Stalls) < (int)RequiredScoreboard.getDepth() &&
|
|
|
|
"Scoreboard depth exceeded!");
|
|
|
|
// This stage was stalled beyond pipeline depth, so cannot conflict.
|
|
|
|
break;
|
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2012-06-18 21:08:18 +00:00
|
|
|
uint64_t freeUnits = IS->getUnits();
|
2010-04-07 18:19:32 +00:00
|
|
|
switch (IS->getReservationKind()) {
|
|
|
|
case InstrStage::Required:
|
|
|
|
// Required FUs conflict with both reserved and required ones
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
freeUnits &= ~ReservedScoreboard[StageCycle];
|
2010-04-07 18:19:32 +00:00
|
|
|
// FALLTHROUGH
|
|
|
|
case InstrStage::Reserved:
|
|
|
|
// Reserved FUs can conflict only with required ones.
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
freeUnits &= ~RequiredScoreboard[StageCycle];
|
2010-04-07 18:19:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-22 16:47:52 +00:00
|
|
|
if (!freeUnits) {
|
2012-05-26 11:37:37 +00:00
|
|
|
DEBUG(dbgs() << "*** Hazard in cycle +" << StageCycle << ", ");
|
2010-01-04 21:26:07 +00:00
|
|
|
DEBUG(dbgs() << "SU(" << SU->NodeNum << "): ");
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
DEBUG(DAG->dumpNode(SU));
|
2009-09-22 16:47:52 +00:00
|
|
|
return Hazard;
|
|
|
|
}
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2009-09-22 16:47:52 +00:00
|
|
|
// Advance the cycle to the next stage.
|
|
|
|
cycle += IS->getNextCycles();
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NoHazard;
|
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
void ScoreboardHazardRecognizer::EmitInstruction(SUnit *SU) {
|
2010-09-10 01:29:16 +00:00
|
|
|
if (!ItinData || ItinData->isEmpty())
|
2009-09-22 16:47:52 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Use the itinerary for the underlying instruction to reserve FU's
|
|
|
|
// in the scoreboard at the appropriate future cycles.
|
2011-06-28 19:10:37 +00:00
|
|
|
const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
|
|
|
|
assert(MCID && "The scheduler must filter non-machineinstrs");
|
|
|
|
if (DAG->TII->isZeroCost(MCID->Opcode))
|
2011-01-21 05:51:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
++IssueCount;
|
|
|
|
|
|
|
|
unsigned cycle = 0;
|
|
|
|
|
2011-06-28 19:10:37 +00:00
|
|
|
unsigned idx = MCID->getSchedClass();
|
2010-09-10 01:29:16 +00:00
|
|
|
for (const InstrStage *IS = ItinData->beginStage(idx),
|
|
|
|
*E = ItinData->endStage(idx); IS != E; ++IS) {
|
2009-09-22 16:47:52 +00:00
|
|
|
// We must reserve one of the stage's units for every cycle the
|
|
|
|
// stage is occupied. FIXME it would be more accurate to reserve
|
|
|
|
// the same unit free in all the cycles.
|
|
|
|
for (unsigned int i = 0; i < IS->getCycles(); ++i) {
|
2010-04-07 18:19:32 +00:00
|
|
|
assert(((cycle + i) < RequiredScoreboard.getDepth()) &&
|
2009-09-22 16:47:52 +00:00
|
|
|
"Scoreboard depth exceeded!");
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2012-06-18 21:08:18 +00:00
|
|
|
uint64_t freeUnits = IS->getUnits();
|
2010-04-07 18:19:32 +00:00
|
|
|
switch (IS->getReservationKind()) {
|
|
|
|
case InstrStage::Required:
|
|
|
|
// Required FUs conflict with both reserved and required ones
|
|
|
|
freeUnits &= ~ReservedScoreboard[cycle + i];
|
|
|
|
// FALLTHROUGH
|
|
|
|
case InstrStage::Reserved:
|
|
|
|
// Reserved FUs can conflict only with required ones.
|
|
|
|
freeUnits &= ~RequiredScoreboard[cycle + i];
|
|
|
|
break;
|
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2009-09-22 16:47:52 +00:00
|
|
|
// reduce to a single unit
|
2012-06-18 21:08:18 +00:00
|
|
|
uint64_t freeUnit = 0;
|
2009-09-22 16:47:52 +00:00
|
|
|
do {
|
|
|
|
freeUnit = freeUnits;
|
|
|
|
freeUnits = freeUnit & (freeUnit - 1);
|
|
|
|
} while (freeUnits);
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2010-04-07 18:19:32 +00:00
|
|
|
if (IS->getReservationKind() == InstrStage::Required)
|
|
|
|
RequiredScoreboard[cycle + i] |= freeUnit;
|
|
|
|
else
|
|
|
|
ReservedScoreboard[cycle + i] |= freeUnit;
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2009-09-22 16:47:52 +00:00
|
|
|
// Advance the cycle to the next stage.
|
|
|
|
cycle += IS->getNextCycles();
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2010-04-07 18:19:32 +00:00
|
|
|
DEBUG(ReservedScoreboard.dump());
|
|
|
|
DEBUG(RequiredScoreboard.dump());
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
2010-04-07 18:19:24 +00:00
|
|
|
|
2010-12-08 20:04:29 +00:00
|
|
|
void ScoreboardHazardRecognizer::AdvanceCycle() {
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
IssueCount = 0;
|
2010-04-07 18:19:32 +00:00
|
|
|
ReservedScoreboard[0] = 0; ReservedScoreboard.advance();
|
|
|
|
RequiredScoreboard[0] = 0; RequiredScoreboard.advance();
|
2009-08-10 15:55:25 +00:00
|
|
|
}
|
2010-12-08 20:04:29 +00:00
|
|
|
|
|
|
|
void ScoreboardHazardRecognizer::RecedeCycle() {
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
IssueCount = 0;
|
2010-12-08 20:04:29 +00:00
|
|
|
ReservedScoreboard[ReservedScoreboard.getDepth()-1] = 0;
|
|
|
|
ReservedScoreboard.recede();
|
|
|
|
RequiredScoreboard[RequiredScoreboard.getDepth()-1] = 0;
|
|
|
|
RequiredScoreboard.recede();
|
|
|
|
}
|