26 #define DEBUG_TYPE ::llvm::ScoreboardHazardRecognizer::DebugType
29 const char *ScoreboardHazardRecognizer::DebugType =
"";
35 const char *ParentDebugType) :
40 DebugType = ParentDebugType;
46 unsigned ScoreboardDepth = 1;
47 if (ItinData && !ItinData->
isEmpty()) {
48 for (
unsigned idx = 0; ; ++idx) {
54 unsigned CurCycle = 0;
55 unsigned ItinDepth = 0;
56 for (; IS != E; ++IS) {
57 unsigned StageDepth = CurCycle + IS->
getCycles();
58 if (ItinDepth < StageDepth) ItinDepth = StageDepth;
63 while (ItinDepth > ScoreboardDepth) {
73 ReservedScoreboard.reset(ScoreboardDepth);
74 RequiredScoreboard.reset(ScoreboardDepth);
78 DEBUG(
dbgs() <<
"Disabled scoreboard hazard recognizer\n");
82 DEBUG(
dbgs() <<
"Using scoreboard hazard recognizer: Depth = "
83 << ScoreboardDepth <<
'\n');
89 RequiredScoreboard.reset();
90 ReservedScoreboard.reset();
93 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
95 dbgs() <<
"Scoreboard:\n";
97 unsigned last = Depth - 1;
98 while ((last > 0) && ((*
this)[last] == 0))
101 for (
unsigned i = 0; i <= last; i++) {
102 unsigned FUs = (*this)[i];
104 for (
int j = 31; j >= 0; j--)
105 dbgs() << ((FUs & (1 << j)) ?
'1' :
'0');
115 return IssueCount == IssueWidth;
120 if (!ItinData || ItinData->
isEmpty())
136 *E = ItinData->
endStage(idx); IS != E; ++IS) {
140 for (
unsigned int i = 0; i < IS->getCycles(); ++i) {
141 int StageCycle = cycle + (
int)i;
145 if (StageCycle >= (
int)RequiredScoreboard.getDepth()) {
146 assert((StageCycle - Stalls) < (
int)RequiredScoreboard.getDepth() &&
147 "Scoreboard depth exceeded!");
152 unsigned freeUnits = IS->getUnits();
153 switch (IS->getReservationKind()) {
156 freeUnits &= ~ReservedScoreboard[StageCycle];
160 freeUnits &= ~RequiredScoreboard[StageCycle];
165 DEBUG(
dbgs() <<
"*** Hazard in cycle +" << StageCycle <<
", ");
173 cycle += IS->getNextCycles();
180 if (!ItinData || ItinData->
isEmpty())
186 assert(MCID &&
"The scheduler must filter non-machineinstrs");
196 *E = ItinData->
endStage(idx); IS != E; ++IS) {
200 for (
unsigned int i = 0; i < IS->getCycles(); ++i) {
201 assert(((cycle + i) < RequiredScoreboard.getDepth()) &&
202 "Scoreboard depth exceeded!");
204 unsigned freeUnits = IS->getUnits();
205 switch (IS->getReservationKind()) {
208 freeUnits &= ~ReservedScoreboard[cycle + i];
212 freeUnits &= ~RequiredScoreboard[cycle + i];
217 unsigned freeUnit = 0;
219 freeUnit = freeUnits;
220 freeUnits = freeUnit & (freeUnit - 1);
224 RequiredScoreboard[cycle + i] |= freeUnit;
226 ReservedScoreboard[cycle + i] |= freeUnit;
230 cycle += IS->getNextCycles();
233 DEBUG(ReservedScoreboard.dump());
234 DEBUG(RequiredScoreboard.dump());
239 ReservedScoreboard[0] = 0; ReservedScoreboard.advance();
240 RequiredScoreboard[0] = 0; RequiredScoreboard.advance();
245 ReservedScoreboard[ReservedScoreboard.getDepth()-1] = 0;
246 ReservedScoreboard.recede();
247 RequiredScoreboard[RequiredScoreboard.getDepth()-1] = 0;
248 RequiredScoreboard.recede();
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.
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.
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.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
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
virtual void dumpNode(const SUnit *SU) const =0
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.