29 #define DEBUG_TYPE "misched"
35 cl::desc(
"The OOO window for processor "
36 "resources during scheduling."),
41 SchedModel(nullptr) {}
43 unsigned SystemZHazardRecognizer::
44 getNumDecoderSlots(
SUnit *SU)
const {
59 unsigned SystemZHazardRecognizer::getCurrCycleIdx() {
60 unsigned Idx = CurrGroupSize;
73 clearProcResCounters();
75 LastFPdOpCycleIdx = UINT_MAX;
80 SystemZHazardRecognizer::fitsIntoCurrentGroup(
SUnit *SU)
const {
88 return (CurrGroupSize == 0);
93 assert ((getNumDecoderSlots(SU) <= 1) && (CurrGroupSize < 3) &&
94 "Expected normal instruction to fit in non-full group!");
99 void SystemZHazardRecognizer::nextGroup(
bool DbgOutput) {
100 if (CurrGroupSize > 0) {
111 if (ProcResourceCounters[
i] > 0)
112 ProcResourceCounters[
i]--;
115 if (CriticalResourceIdx != UINT_MAX &&
116 (ProcResourceCounters[CriticalResourceIdx] <=
118 CriticalResourceIdx = UINT_MAX;
125 #ifndef NDEBUG // Debug output
127 OS <<
"SU(" << SU->
NodeNum <<
"):";
139 std::string FU(PRD.
Name);
141 FU = FU.substr(FU.find(
"_") + 1);
142 FU.resize(FU.find(
"Unit"));
146 OS <<
"(" << PI->Cycles <<
"cyc)";
152 OS <<
"/GroupsAlone";
154 OS <<
"/BeginsGroup";
162 dbgs() <<
"+++ " << Msg;
166 dbgs() <<
" <empty>\n";
169 dbgs() <<
" (" << CurrGroupSize <<
" decoder slot"
170 << (CurrGroupSize > 1 ?
"s":
"")
179 if (ProcResourceCounters[
i] > 0) {
187 dbgs() <<
"+++ Resource counters:\n";
189 if (ProcResourceCounters[
i] > 0) {
190 dbgs() <<
"+++ Extra schedule for execution unit "
192 <<
": " << ProcResourceCounters[
i] <<
"\n";
198 void SystemZHazardRecognizer::clearProcResCounters() {
200 CriticalResourceIdx = UINT_MAX;
211 if (!fitsIntoCurrentGroup(SU))
223 DEBUG (
dbgs() <<
"+++ Clearing state after call.\n";);
224 clearProcResCounters();
225 LastFPdOpCycleIdx = UINT_MAX;
226 CurrGroupSize += getNumDecoderSlots(SU);
227 assert (CurrGroupSize <= 3);
240 ProcResourceCounters[PI->ProcResourceIdx];
241 CurrCounter += PI->Cycles;
244 (CriticalResourceIdx == UINT_MAX ||
245 (PI->ProcResourceIdx != CriticalResourceIdx &&
247 ProcResourceCounters[CriticalResourceIdx]))) {
248 DEBUG(
dbgs() <<
"+++ New critical resource: "
251 CriticalResourceIdx = PI->ProcResourceIdx;
257 LastFPdOpCycleIdx = getCurrCycleIdx();
258 DEBUG (
dbgs() <<
"+++ Last FPd cycle index: "
259 << LastFPdOpCycleIdx <<
"\n";);
264 CurrGroupSize += getNumDecoderSlots(SU);
265 assert (CurrGroupSize <= 3);
269 if (CurrGroupSize == 3 || SC->
EndGroup)
282 return 3 - CurrGroupSize;
289 unsigned resultingGroupSize =
290 (CurrGroupSize + getNumDecoderSlots(SU));
291 if (resultingGroupSize < 3)
292 return (3 - resultingGroupSize);
300 bool SystemZHazardRecognizer::isFPdOpPreferred_distance(
const SUnit *SU) {
303 if (LastFPdOpCycleIdx == UINT_MAX)
309 if (LastFPdOpCycleIdx > getCurrCycleIdx())
310 return ((LastFPdOpCycleIdx - getCurrCycleIdx()) == 3);
311 return ((getCurrCycleIdx() - LastFPdOpCycleIdx) == 3);
325 Cost = (isFPdOpPreferred_distance(SU) ? INT_MIN : INT_MAX);
327 else if (CriticalResourceIdx != UINT_MAX) {
331 if (PI->ProcResourceIdx == CriticalResourceIdx)
unsigned short NumMicroOps
MachineInstr * getInstr() const
getInstr - Return the representative MachineInstr for this SUnit.
void dumpCurrGroup(std::string Msg="") const
const MCSchedClassDesc * getSchedClass(SUnit *SU) const
Resolve and cache a resolved scheduling class for an SUnit.
void dumpProcResourceCounters() const
const TargetInstrInfo * getInstrInfo() const
TargetInstrInfo getter.
int groupingCost(SUnit *SU) const
Return the cost of decoder grouping for SU.
void Reset() override
Reset - This callback is invoked when a new block of instructions is about to be schedule.
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
SystemZHazardRecognizer(const MachineSchedContext *C)
void assign(size_type NumElts, const T &Elt)
HazardType getHazardType(SUnit *m, int Stalls=0) override
getHazardType - Return the hazard type of emitting this node.
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
initializer< Ty > init(const Ty &Val)
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
Summarize the scheduling resources required for an instruction of a particular scheduling class...
int resourcesCost(SUnit *SU)
Return the cost of SU in regards to processor resources usage.
unsigned getNumProcResourceKinds() const
Get the number of kinds of resources for this target.
ProcResIter getWriteProcResEnd(const MCSchedClassDesc *SC) const
const MCProcResourceDesc * getProcResource(unsigned PIdx) const
Get a processor resource by ID for convenience.
Define a kind of processor resource that will be modeled by the scheduler.
CHAIN = SC CHAIN, Imm128 - System call.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
bool isCall(QueryType Type=AnyInBundle) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
static cl::opt< int > ProcResCostLim("procres-cost-lim", cl::Hidden, cl::desc("The OOO window for processor ""resources during scheduling."), cl::init(8))
This class implements an extremely fast bulk output stream that can only output to a stream...
ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const
SUnit - Scheduling unit. This is a node in the scheduling DAG.
void dumpSU(SUnit *SU, raw_ostream &OS) const