#include "Views/BottleneckAnalysis.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MCA/Support.h"
#include "llvm/Support/Format.h"
namespace llvm {
namespace mca {
#define DEBUG_TYPE …
PressureTracker::PressureTracker(const MCSchedModel &Model)
: … { … }
void PressureTracker::getResourceUsers(uint64_t ResourceMask,
SmallVectorImpl<User> &Users) const { … }
void PressureTracker::onInstructionDispatched(unsigned IID) { … }
void PressureTracker::onInstructionExecuted(unsigned IID) { … }
void PressureTracker::handleInstructionIssuedEvent(
const HWInstructionIssuedEvent &Event) { … }
void PressureTracker::updateResourcePressureDistribution(
uint64_t CumulativeMask) { … }
void PressureTracker::handlePressureEvent(const HWPressureEvent &Event) { … }
#ifndef NDEBUG
void DependencyGraph::dumpDependencyEdge(raw_ostream &OS,
const DependencyEdge &DepEdge,
MCInstPrinter &MCIP) const {
unsigned FromIID = DepEdge.FromIID;
unsigned ToIID = DepEdge.ToIID;
assert(FromIID < ToIID && "Graph should be acyclic!");
const DependencyEdge::Dependency &DE = DepEdge.Dep;
assert(DE.Type != DependencyEdge::DT_INVALID && "Unexpected invalid edge!");
OS << " FROM: " << FromIID << " TO: " << ToIID << " ";
if (DE.Type == DependencyEdge::DT_REGISTER) {
OS << " - REGISTER: ";
MCIP.printRegName(OS, DE.ResourceOrRegID);
} else if (DE.Type == DependencyEdge::DT_MEMORY) {
OS << " - MEMORY";
} else {
assert(DE.Type == DependencyEdge::DT_RESOURCE &&
"Unsupported dependency type!");
OS << " - RESOURCE MASK: " << DE.ResourceOrRegID;
}
OS << " - COST: " << DE.Cost << '\n';
}
#endif
void DependencyGraph::pruneEdges(unsigned Iterations) { … }
void DependencyGraph::initializeRootSet(
SmallVectorImpl<unsigned> &RootSet) const { … }
void DependencyGraph::propagateThroughEdges(SmallVectorImpl<unsigned> &RootSet,
unsigned Iterations) { … }
void DependencyGraph::getCriticalSequence(
SmallVectorImpl<const DependencyEdge *> &Seq) const { … }
void BottleneckAnalysis::printInstruction(formatted_raw_ostream &FOS,
const MCInst &MCI,
bool UseDifferentColor) const { … }
void BottleneckAnalysis::printCriticalSequence(raw_ostream &OS) const { … }
#ifndef NDEBUG
void DependencyGraph::dump(raw_ostream &OS, MCInstPrinter &MCIP) const {
OS << "\nREG DEPS\n";
for (const DGNode &Node : Nodes)
for (const DependencyEdge &DE : Node.OutgoingEdges)
if (DE.Dep.Type == DependencyEdge::DT_REGISTER)
dumpDependencyEdge(OS, DE, MCIP);
OS << "\nMEM DEPS\n";
for (const DGNode &Node : Nodes)
for (const DependencyEdge &DE : Node.OutgoingEdges)
if (DE.Dep.Type == DependencyEdge::DT_MEMORY)
dumpDependencyEdge(OS, DE, MCIP);
OS << "\nRESOURCE DEPS\n";
for (const DGNode &Node : Nodes)
for (const DependencyEdge &DE : Node.OutgoingEdges)
if (DE.Dep.Type == DependencyEdge::DT_RESOURCE)
dumpDependencyEdge(OS, DE, MCIP);
}
#endif
void DependencyGraph::addDependency(unsigned From, unsigned To,
DependencyEdge::Dependency &&Dep) { … }
BottleneckAnalysis::BottleneckAnalysis(const MCSubtargetInfo &sti,
MCInstPrinter &Printer,
ArrayRef<MCInst> S, unsigned NumIter)
: … { … }
void BottleneckAnalysis::addRegisterDep(unsigned From, unsigned To,
unsigned RegID, unsigned Cost) { … }
void BottleneckAnalysis::addMemoryDep(unsigned From, unsigned To,
unsigned Cost) { … }
void BottleneckAnalysis::addResourceDep(unsigned From, unsigned To,
uint64_t Mask, unsigned Cost) { … }
void BottleneckAnalysis::onEvent(const HWInstructionEvent &Event) { … }
void BottleneckAnalysis::onEvent(const HWPressureEvent &Event) { … }
void BottleneckAnalysis::onCycleEnd() { … }
void BottleneckAnalysis::printBottleneckHints(raw_ostream &OS) const { … }
void BottleneckAnalysis::printView(raw_ostream &OS) const { … }
json::Value BottleneckAnalysis::toJSON() const { … }
}
}