Go to the documentation of this file.
18 #include "llvm/Config/llvm-config.h"
28 #define DEBUG_TYPE DebugType
32 const char *ParentDebugType)
33 :
DebugType(ParentDebugType), ItinData(II), DAG(SchedDAG) {
38 unsigned ScoreboardDepth = 1;
39 if (ItinData && !ItinData->
isEmpty()) {
40 for (
unsigned idx = 0; ; ++idx) {
46 unsigned CurCycle = 0;
47 unsigned ItinDepth = 0;
48 for (; IS !=
E; ++IS) {
49 unsigned StageDepth = CurCycle + IS->
getCycles();
50 if (ItinDepth < StageDepth) ItinDepth = StageDepth;
55 while (ItinDepth > ScoreboardDepth) {
65 ReservedScoreboard.reset(ScoreboardDepth);
66 RequiredScoreboard.reset(ScoreboardDepth);
74 LLVM_DEBUG(
dbgs() <<
"Using scoreboard hazard recognizer: Depth = "
75 << ScoreboardDepth <<
'\n');
81 RequiredScoreboard.reset();
82 ReservedScoreboard.reset();
85 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
87 dbgs() <<
"Scoreboard:\n";
90 while ((
last > 0) && ((*
this)[
last] == 0))
93 for (
unsigned i = 0;
i <=
last;
i++) {
96 for (
int j = std::numeric_limits<InstrStage::FuncUnits>::digits - 1;
98 dbgs() << ((FUs & (1ULL <<
j)) ?
'1' :
'0');
108 return IssueCount == IssueWidth;
113 if (!ItinData || ItinData->
isEmpty())
129 *
E = ItinData->
endStage(idx); IS !=
E; ++IS) {
133 for (
unsigned int i = 0;
i < IS->getCycles(); ++
i) {
134 int StageCycle = cycle + (
int)
i;
138 if (StageCycle >= (
int)RequiredScoreboard.getDepth()) {
139 assert((StageCycle - Stalls) < (
int)RequiredScoreboard.getDepth() &&
140 "Scoreboard depth exceeded!");
146 switch (IS->getReservationKind()) {
149 freeUnits &= ~ReservedScoreboard[StageCycle];
153 freeUnits &= ~RequiredScoreboard[StageCycle];
158 LLVM_DEBUG(
dbgs() <<
"*** Hazard in cycle +" << StageCycle <<
", ");
165 cycle += IS->getNextCycles();
172 if (!ItinData || ItinData->
isEmpty())
178 assert(MCID &&
"The scheduler must filter non-machineinstrs");
188 *
E = ItinData->
endStage(idx); IS !=
E; ++IS) {
192 for (
unsigned int i = 0;
i < IS->getCycles(); ++
i) {
193 assert(((cycle +
i) < RequiredScoreboard.getDepth()) &&
194 "Scoreboard depth exceeded!");
197 switch (IS->getReservationKind()) {
200 freeUnits &= ~ReservedScoreboard[cycle +
i];
204 freeUnits &= ~RequiredScoreboard[cycle +
i];
211 freeUnit = freeUnits;
212 freeUnits = freeUnit & (freeUnit - 1);
216 RequiredScoreboard[cycle +
i] |= freeUnit;
218 ReservedScoreboard[cycle +
i] |= freeUnit;
222 cycle += IS->getNextCycles();
231 ReservedScoreboard[0] = 0; ReservedScoreboard.advance();
232 RequiredScoreboard[0] = 0; RequiredScoreboard.advance();
237 ReservedScoreboard[ReservedScoreboard.getDepth()-1] = 0;
238 ReservedScoreboard.recede();
239 RequiredScoreboard[RequiredScoreboard.getDepth()-1] = 0;
240 RequiredScoreboard.recede();
unsigned getCycles() const
Returns the number of cycles the stage is occupied.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
unsigned MaxLookAhead
MaxLookAhead - Indicate the number of cycles in the scoreboard state.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
void Reset() override
Reset - This callback is invoked when a new block of instructions is about to be schedule.
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)
const InstrStage * endStage(unsigned ItinClassIndx) const
Return the last+1 stage of the itinerary.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isZeroCost(unsigned Opcode) const
Return true for pseudo instructions that don't consume any machine resources in their current form.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Describe properties that are true of each instruction in the target description file.
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
Returns the MCInstrDesc of this SUnit.
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
bool isEndMarker(unsigned ItinClassIndx) const
Returns true if the index is for the end marker itinerary.
ScoreboardHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG, const char *ParentDebugType="")
unsigned getNextCycles() const
Returns the number of cycles from the start of this stage to the start of the next stage in the itine...
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.
These values represent a non-pipelined step in the execution of an instruction.
bool atIssueLimit() const override
atIssueLimit - Return true if no more instructions may be issued in this cycle.
const TargetInstrInfo * TII
Target instruction information.
void RecedeCycle() override
RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot...
Scheduling unit. This is a node in the scheduling DAG.
const InstrStage * beginStage(unsigned ItinClassIndx) const
Return the first stage of the itinerary.
bool isEmpty() const
Returns true if there are no itineraries.
Itinerary data supplied by a subtarget to be used by a target.
MCSchedModel SchedModel
Basic machine properties.
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...