Cleanup in preparation for misched: Move DAG visualization logic.

Soon, ScheduleDAG will not refer to the BB.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152177 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick 2012-03-07 00:18:22 +00:00
parent 8ceaa660bf
commit 56b94c52c9
6 changed files with 27 additions and 9 deletions

View File

@ -519,6 +519,7 @@ namespace llvm {
/// viewGraph - Pop up a GraphViz/gv window with the ScheduleDAG rendered
/// using 'dot'.
///
void viewGraph(const Twine &Name, const Twine &Title);
void viewGraph();
/// EmitSchedule - Insert MachineInstrs into the MachineBasicBlock
@ -534,6 +535,9 @@ namespace llvm {
/// of the ScheduleDAG.
virtual std::string getGraphNodeLabel(const SUnit *SU) const = 0;
/// getDAGLabel - Return a label for the region of code covered by the DAG.
virtual std::string getDAGName() const = 0;
/// addCustomGraphFeatures - Add custom features for a visualization of
/// the ScheduleDAG.
virtual void addCustomGraphFeatures(GraphWriter<ScheduleDAG*> &) const {}

View File

@ -808,6 +808,12 @@ std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
return oss.str();
}
/// Return the basic block label. It is not necessarilly unique because a block
/// contains multiple scheduling regions. But it is fine for visualization.
std::string ScheduleDAGInstrs::getDAGName() const {
return "dag." + BB->getFullName();
}
// EmitSchedule - Emit the machine code in scheduled order.
MachineBasicBlock *ScheduleDAGInstrs::EmitSchedule() {
Begin = InsertPos;

View File

@ -285,6 +285,8 @@ namespace llvm {
virtual std::string getGraphNodeLabel(const SUnit *SU) const;
virtual std::string getDAGName() const;
protected:
SUnit *getSUnit(MachineInstr *MI) const {
DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI);

View File

@ -81,18 +81,17 @@ std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
/// rendered using 'dot'.
///
void ScheduleDAG::viewGraph() {
// This code is only for debugging!
void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
// This code is only for debugging!
#ifndef NDEBUG
if (BB->getBasicBlock())
ViewGraph(this, "dag." + MF.getFunction()->getName(), false,
"Scheduling-Units Graph for " + MF.getFunction()->getName() +
":" + BB->getBasicBlock()->getName());
else
ViewGraph(this, "dag." + MF.getFunction()->getName(), false,
"Scheduling-Units Graph for " + MF.getFunction()->getName());
ViewGraph(this, Name, false, Title);
#else
errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
<< "systems with Graphviz or gv!\n";
#endif // NDEBUG
}
/// Out-of-line implementation with no arguments is handy for gdb.
void ScheduleDAG::viewGraph() {
viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
}

View File

@ -800,3 +800,8 @@ MachineBasicBlock *ScheduleDAGSDNodes::EmitSchedule() {
InsertPos = Emitter.getInsertPos();
return BB;
}
/// Return the basic block label.
std::string ScheduleDAGSDNodes::getDAGName() const {
return "sunit-dag." + BB->getFullName();
}

View File

@ -115,6 +115,8 @@ namespace llvm {
virtual std::string getGraphNodeLabel(const SUnit *SU) const;
virtual std::string getDAGName() const;
virtual void getCustomGraphFeatures(GraphWriter<ScheduleDAG*> &GW) const;
/// RegDefIter - In place iteration over the values defined by an