LLVM  3.7.0
ScheduleDAGPrinter.cpp
Go to the documentation of this file.
1 //===-- ScheduleDAGPrinter.cpp - Implement ScheduleDAG::viewGraph() -------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This implements the ScheduleDAG::viewGraph method.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/DenseSet.h"
16 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/IR/Constants.h"
21 #include "llvm/Support/Debug.h"
25 #include <fstream>
26 using namespace llvm;
27 
28 namespace llvm {
29  template<>
31 
32  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
33 
34  static std::string getGraphName(const ScheduleDAG *G) {
35  return G->MF.getName();
36  }
37 
38  static bool renderGraphFromBottomUp() {
39  return true;
40  }
41 
42  static bool isNodeHidden(const SUnit *Node) {
43  return (Node->NumPreds > 10 || Node->NumSuccs > 10);
44  }
45 
46  static bool hasNodeAddressLabel(const SUnit *Node,
47  const ScheduleDAG *Graph) {
48  return true;
49  }
50 
51  /// If you want to override the dot attributes printed for a particular
52  /// edge, override this method.
53  static std::string getEdgeAttributes(const SUnit *Node,
54  SUnitIterator EI,
55  const ScheduleDAG *Graph) {
56  if (EI.isArtificialDep())
57  return "color=cyan,style=dashed";
58  if (EI.isCtrlDep())
59  return "color=blue,style=dashed";
60  return "";
61  }
62 
63 
64  std::string getNodeLabel(const SUnit *Node, const ScheduleDAG *Graph);
65  static std::string getNodeAttributes(const SUnit *N,
66  const ScheduleDAG *Graph) {
67  return "shape=Mrecord";
68  }
69 
72  return G->addCustomGraphFeatures(GW);
73  }
74  };
75 }
76 
78  const ScheduleDAG *G) {
79  return G->getGraphNodeLabel(SU);
80 }
81 
82 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
83 /// rendered using 'dot'.
84 ///
85 void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
86  // This code is only for debugging!
87 #ifndef NDEBUG
88  ViewGraph(this, Name, false, Title);
89 #else
90  errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
91  << "systems with Graphviz or gv!\n";
92 #endif // NDEBUG
93 }
94 
95 /// Out-of-line implementation with no arguments is handy for gdb.
97  viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
98 }
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool isArtificialDep() const
Definition: ScheduleDAG.h:655
unsigned NumPreds
Definition: ScheduleDAG.h:285
virtual std::string getGraphNodeLabel(const SUnit *SU) const =0
getGraphNodeLabel - Return a label for an SUnit node in a visualization of the ScheduleDAG.
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
MachineFunction & MF
Definition: ScheduleDAG.h:563
unsigned NumSuccs
Definition: ScheduleDAG.h:286
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
static std::string getGraphName(const ScheduleDAG *G)
static std::string getNodeAttributes(const SUnit *N, const ScheduleDAG *Graph)
virtual std::string getDAGName() const =0
getDAGLabel - Return a label for the region of code covered by the DAG.
static std::string getEdgeAttributes(const SUnit *Node, SUnitIterator EI, const ScheduleDAG *Graph)
If you want to override the dot attributes printed for a particular edge, override this method...
#define G(x, y, z)
Definition: MD5.cpp:52
std::string getNodeLabel(const void *, const GraphType &)
getNodeLabel - Given a node and a pointer to the top level graph, return the label to print in the no...
virtual void addCustomGraphFeatures(GraphWriter< ScheduleDAG * > &) const
addCustomGraphFeatures - Add custom features for a visualization of the ScheduleDAG.
Definition: ScheduleDAG.h:606
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
Definition: GraphWriter.h:348
static void addCustomGraphFeatures(ScheduleDAG *G, GraphWriter< ScheduleDAG * > &GW)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
bool isCtrlDep() const
isCtrlDep - Test if this is not an SDep::Data dependence.
Definition: ScheduleDAG.h:652
static bool isNodeHidden(const SUnit *Node)
#define N
static bool hasNodeAddressLabel(const SUnit *Node, const ScheduleDAG *Graph)
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
SUnit - Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:261