16 #define DEBUG_TYPE ::llvm::ScoreboardHazardRecognizer::DebugType
34 const char *ParentDebugType) :
45 unsigned ScoreboardDepth = 1;
46 if (ItinData && !ItinData->
isEmpty()) {
47 for (
unsigned idx = 0; ; ++idx) {
53 unsigned CurCycle = 0;
54 unsigned ItinDepth = 0;
55 for (; IS != E; ++IS) {
56 unsigned StageDepth = CurCycle + IS->
getCycles();
57 if (ItinDepth < StageDepth) ItinDepth = StageDepth;
62 while (ItinDepth > ScoreboardDepth) {
72 ReservedScoreboard.reset(ScoreboardDepth);
73 RequiredScoreboard.reset(ScoreboardDepth);
77 DEBUG(
dbgs() <<
"Disabled scoreboard hazard recognizer\n");
81 DEBUG(
dbgs() <<
"Using scoreboard hazard recognizer: Depth = "
82 << ScoreboardDepth <<
'\n');
88 RequiredScoreboard.reset();
89 ReservedScoreboard.reset();
92 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
94 dbgs() <<
"Scoreboard:\n";
96 unsigned last = Depth - 1;
97 while ((last > 0) && ((*
this)[last] == 0))
100 for (
unsigned i = 0; i <= last; i++) {
101 unsigned FUs = (*this)[i];
103 for (
int j = 31; j >= 0; j--)
104 dbgs() << ((FUs & (1 << j)) ?
'1' :
'0');
114 return IssueCount == IssueWidth;
119 if (!ItinData || ItinData->
isEmpty())
135 *E = ItinData->
endStage(idx); IS != E; ++IS) {
139 for (
unsigned int i = 0; i < IS->getCycles(); ++i) {
140 int StageCycle = cycle + (int)i;
144 if (StageCycle >= (
int)RequiredScoreboard.getDepth()) {
145 assert((StageCycle - Stalls) < (
int)RequiredScoreboard.getDepth() &&
146 "Scoreboard depth exceeded!");
151 unsigned freeUnits = IS->getUnits();
152 switch (IS->getReservationKind()) {
155 freeUnits &= ~ReservedScoreboard[StageCycle];
159 freeUnits &= ~RequiredScoreboard[StageCycle];
164 DEBUG(
dbgs() <<
"*** Hazard in cycle +" << StageCycle <<
", ");
172 cycle += IS->getNextCycles();
179 if (!ItinData || ItinData->
isEmpty())
185 assert(MCID &&
"The scheduler must filter non-machineinstrs");
195 *E = ItinData->
endStage(idx); IS != E; ++IS) {
199 for (
unsigned int i = 0; i < IS->getCycles(); ++i) {
200 assert(((cycle + i) < RequiredScoreboard.getDepth()) &&
201 "Scoreboard depth exceeded!");
203 unsigned freeUnits = IS->getUnits();
204 switch (IS->getReservationKind()) {
207 freeUnits &= ~ReservedScoreboard[cycle + i];
211 freeUnits &= ~RequiredScoreboard[cycle + i];
216 unsigned freeUnit = 0;
218 freeUnit = freeUnits;
219 freeUnits = freeUnit & (freeUnit - 1);
223 RequiredScoreboard[cycle + i] |= freeUnit;
225 ReservedScoreboard[cycle + i] |= freeUnit;
229 cycle += IS->getNextCycles();
232 DEBUG(ReservedScoreboard.dump());
233 DEBUG(RequiredScoreboard.dump());
238 ReservedScoreboard[0] = 0; ReservedScoreboard.advance();
239 RequiredScoreboard[0] = 0; RequiredScoreboard.advance();
244 ReservedScoreboard[ReservedScoreboard.getDepth()-1] = 0;
245 ReservedScoreboard.recede();
246 RequiredScoreboard[RequiredScoreboard.getDepth()-1] = 0;
247 RequiredScoreboard.recede();
virtual void AdvanceCycle()
virtual HazardType getHazardType(SUnit *SU, int Stalls)
unsigned getCycles() const
getCycles - returns the number of cycles the stage is occupied
const MCSchedModel * SchedModel
Basic machine properties.
bool isEndMarker(unsigned ItinClassIndx) const
const InstrStage * beginStage(unsigned ItinClassIndx) const
virtual void RecedeCycle()
ScoreboardHazardRecognizer(const InstrItineraryData *ItinData, const ScheduleDAG *DAG, const char *ParentDebugType="")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
virtual bool atIssueLimit() const
unsigned getNextCycles() const
bool isZeroCost(unsigned Opcode) const
const InstrStage * endStage(unsigned ItinClassIndx) const
virtual void EmitInstruction(SUnit *SU)
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
unsigned getSchedClass() const
Return the scheduling class for this instruction. The scheduling class is an index into the InstrItin...
const TargetInstrInfo * TII
virtual void dumpNode(const SUnit *SU) const =0
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
SUnit - Scheduling unit. This is a node in the scheduling DAG.