#include "SystemZHazardRecognizer.h"
#include "llvm/ADT/Statistic.h"
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<int> ProcResCostLim("procres-cost-lim", cl::Hidden,
cl::desc("The OOO window for processor "
"resources during scheduling."),
cl::init(8));
unsigned SystemZHazardRecognizer::
getNumDecoderSlots(SUnit *SU) const { … }
unsigned SystemZHazardRecognizer::getCurrCycleIdx(SUnit *SU) const { … }
ScheduleHazardRecognizer::HazardType SystemZHazardRecognizer::
getHazardType(SUnit *SU, int Stalls) { … }
void SystemZHazardRecognizer::Reset() { … }
bool
SystemZHazardRecognizer::fitsIntoCurrentGroup(SUnit *SU) const { … }
bool SystemZHazardRecognizer::has4RegOps(const MachineInstr *MI) const { … }
void SystemZHazardRecognizer::nextGroup() { … }
#ifndef NDEBUG
void SystemZHazardRecognizer::dumpSU(SUnit *SU, raw_ostream &OS) const {
OS << "SU(" << SU->NodeNum << "):";
OS << TII->getName(SU->getInstr()->getOpcode());
const MCSchedClassDesc *SC = getSchedClass(SU);
if (!SC->isValid())
return;
for (TargetSchedModel::ProcResIter
PI = SchedModel->getWriteProcResBegin(SC),
PE = SchedModel->getWriteProcResEnd(SC); PI != PE; ++PI) {
const MCProcResourceDesc &PRD =
*SchedModel->getProcResource(PI->ProcResourceIdx);
std::string FU(PRD.Name);
FU = FU.substr(FU.find('_') + 1);
size_t Pos = FU.find("Unit");
if (Pos != std::string::npos)
FU.resize(Pos);
if (FU == "LS")
FU = "LSU";
OS << "/" << FU;
if (PI->ReleaseAtCycle> 1)
OS << "(" << PI->ReleaseAtCycle << "cyc)";
}
if (SC->NumMicroOps > 1)
OS << "/" << SC->NumMicroOps << "uops";
if (SC->BeginGroup && SC->EndGroup)
OS << "/GroupsAlone";
else if (SC->BeginGroup)
OS << "/BeginsGroup";
else if (SC->EndGroup)
OS << "/EndsGroup";
if (SU->isUnbuffered)
OS << "/Unbuffered";
if (has4RegOps(SU->getInstr()))
OS << "/4RegOps";
}
void SystemZHazardRecognizer::dumpCurrGroup(std::string Msg) const {
dbgs() << "++ " << Msg;
dbgs() << ": ";
if (CurGroupDbg.empty())
dbgs() << " <empty>\n";
else {
dbgs() << "{ " << CurGroupDbg << " }";
dbgs() << " (" << CurrGroupSize << " decoder slot"
<< (CurrGroupSize > 1 ? "s":"")
<< (CurrGroupHas4RegOps ? ", 4RegOps" : "")
<< ")\n";
}
}
void SystemZHazardRecognizer::dumpProcResourceCounters() const {
bool any = false;
for (unsigned i = 0; i < SchedModel->getNumProcResourceKinds(); ++i)
if (ProcResourceCounters[i] > 0) {
any = true;
break;
}
if (!any)
return;
dbgs() << "++ | Resource counters: ";
for (unsigned i = 0; i < SchedModel->getNumProcResourceKinds(); ++i)
if (ProcResourceCounters[i] > 0)
dbgs() << SchedModel->getProcResource(i)->Name
<< ":" << ProcResourceCounters[i] << " ";
dbgs() << "\n";
if (CriticalResourceIdx != UINT_MAX)
dbgs() << "++ | Critical resource: "
<< SchedModel->getProcResource(CriticalResourceIdx)->Name
<< "\n";
}
void SystemZHazardRecognizer::dumpState() const {
dumpCurrGroup("| Current decoder group");
dbgs() << "++ | Current cycle index: "
<< getCurrCycleIdx() << "\n";
dumpProcResourceCounters();
if (LastFPdOpCycleIdx != UINT_MAX)
dbgs() << "++ | Last FPd cycle index: " << LastFPdOpCycleIdx << "\n";
}
#endif
void SystemZHazardRecognizer::clearProcResCounters() { … }
static inline bool isBranchRetTrap(MachineInstr *MI) { … }
void SystemZHazardRecognizer::
EmitInstruction(SUnit *SU) { … }
int SystemZHazardRecognizer::groupingCost(SUnit *SU) const { … }
bool SystemZHazardRecognizer::isFPdOpPreferred_distance(SUnit *SU) const { … }
int SystemZHazardRecognizer::
resourcesCost(SUnit *SU) { … }
void SystemZHazardRecognizer::emitInstruction(MachineInstr *MI,
bool TakenBranch) { … }
void SystemZHazardRecognizer::
copyState(SystemZHazardRecognizer *Incoming) { … }