26 #define DEBUG_TYPE DebugType
30 const char *ParentDebugType)
32 DAG(SchedDAG), IssueWidth(0), IssueCount(0) {
37 unsigned ScoreboardDepth = 1;
38 if (ItinData && !ItinData->
isEmpty()) {
39 for (
unsigned idx = 0; ; ++idx) {
45 unsigned CurCycle = 0;
46 unsigned ItinDepth = 0;
47 for (; IS !=
E; ++IS) {
48 unsigned StageDepth = CurCycle + IS->
getCycles();
49 if (ItinDepth < StageDepth) ItinDepth = StageDepth;
54 while (ItinDepth > ScoreboardDepth) {
64 ReservedScoreboard.reset(ScoreboardDepth);
65 RequiredScoreboard.reset(ScoreboardDepth);
69 DEBUG(
dbgs() <<
"Disabled scoreboard hazard recognizer\n");
73 DEBUG(
dbgs() <<
"Using scoreboard hazard recognizer: Depth = "
74 << ScoreboardDepth <<
'\n');
80 RequiredScoreboard.reset();
81 ReservedScoreboard.reset();
84 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
86 dbgs() <<
"Scoreboard:\n";
88 unsigned last =
Depth - 1;
89 while ((last > 0) && ((*
this)[last] == 0))
92 for (
unsigned i = 0;
i <= last;
i++) {
93 unsigned FUs = (*this)[
i];
95 for (
int j = 31; j >= 0; j--)
96 dbgs() << ((FUs & (1 << j)) ?
'1' :
'0');
106 return IssueCount == IssueWidth;
111 if (!ItinData || ItinData->
isEmpty())
127 *
E = ItinData->
endStage(idx); IS !=
E; ++IS) {
131 for (
unsigned int i = 0;
i < IS->getCycles(); ++
i) {
132 int StageCycle = cycle + (int)
i;
136 if (StageCycle >= (
int)RequiredScoreboard.getDepth()) {
137 assert((StageCycle - Stalls) < (
int)RequiredScoreboard.getDepth() &&
138 "Scoreboard depth exceeded!");
143 unsigned freeUnits = IS->getUnits();
144 switch (IS->getReservationKind()) {
147 freeUnits &= ~ReservedScoreboard[StageCycle];
151 freeUnits &= ~RequiredScoreboard[StageCycle];
156 DEBUG(
dbgs() <<
"*** Hazard in cycle +" << StageCycle <<
", ");
164 cycle += IS->getNextCycles();
171 if (!ItinData || ItinData->
isEmpty())
177 assert(MCID &&
"The scheduler must filter non-machineinstrs");
187 *
E = ItinData->
endStage(idx); IS !=
E; ++IS) {
191 for (
unsigned int i = 0;
i < IS->getCycles(); ++
i) {
192 assert(((cycle +
i) < RequiredScoreboard.getDepth()) &&
193 "Scoreboard depth exceeded!");
195 unsigned freeUnits = IS->getUnits();
196 switch (IS->getReservationKind()) {
199 freeUnits &= ~ReservedScoreboard[cycle +
i];
203 freeUnits &= ~RequiredScoreboard[cycle +
i];
208 unsigned freeUnit = 0;
210 freeUnit = freeUnits;
211 freeUnits = freeUnit & (freeUnit - 1);
215 RequiredScoreboard[cycle +
i] |= freeUnit;
217 ReservedScoreboard[cycle +
i] |= freeUnit;
221 cycle += IS->getNextCycles();
224 DEBUG(ReservedScoreboard.dump());
225 DEBUG(RequiredScoreboard.dump());
230 ReservedScoreboard[0] = 0; ReservedScoreboard.advance();
231 RequiredScoreboard[0] = 0; RequiredScoreboard.advance();
236 ReservedScoreboard[ReservedScoreboard.getDepth()-1] = 0;
237 ReservedScoreboard.recede();
238 RequiredScoreboard[RequiredScoreboard.getDepth()-1] = 0;
239 RequiredScoreboard.recede();
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void RecedeCycle() override
RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot...
Describe properties that are true of each instruction in the target description file.
static void dump(StringRef Title, SpillInfo const &Spills)
unsigned getCycles() const
Returns the number of cycles the stage is occupied.
bool isEndMarker(unsigned ItinClassIndx) const
Returns true if the index is for the end marker itinerary.
const InstrStage * beginStage(unsigned ItinClassIndx) const
Return the first stage of the itinerary.
bool atIssueLimit() const override
atIssueLimit - Return true if no more instructions may be issued in this cycle.
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
Itinerary data supplied by a subtarget to be used by a target.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
unsigned MaxLookAhead
MaxLookAhead - Indicate the number of cycles in the scoreboard state.
ScoreboardHazardRecognizer(const InstrItineraryData *ItinData, const ScheduleDAG *DAG, const char *ParentDebugType="")
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - Return the hazard type of emitting this node.
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
unsigned getNextCycles() const
Returns the number of cycles from the start of this stage to the start of the next stage in the itine...
bool isZeroCost(unsigned Opcode) const
Return true for pseudo instructions that don't consume any machine resources in their current form...
void Reset() override
Reset - This callback is invoked when a new block of instructions is about to be schedule.
const InstrStage * endStage(unsigned ItinClassIndx) const
Return the last+1 stage of the itinerary.
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
MCSchedModel SchedModel
Basic machine properties.
These values represent a non-pipelined step in the execution of an instruction.
const TargetInstrInfo * TII
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void dumpNode(const SUnit *SU) const =0
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
getInstrDesc - Return the MCInstrDesc of this SUnit.
bool isEmpty() const
Returns true if there are no itineraries.
SUnit - Scheduling unit. This is a node in the scheduling DAG.