LLVM  6.0.0svn
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 
14 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/IR/Constants.h"
21 #include "llvm/Support/Debug.h"
24 #include <fstream>
25 using namespace llvm;
26 
27 namespace llvm {
28  template<>
30 
32 
33  static std::string getGraphName(const ScheduleDAG *G) {
34  return G->MF.getName();
35  }
36 
37  static bool renderGraphFromBottomUp() {
38  return true;
39  }
40 
41  static bool isNodeHidden(const SUnit *Node) {
42  return (Node->NumPreds > 10 || Node->NumSuccs > 10);
43  }
44 
45  static std::string getNodeIdentifierLabel(const SUnit *Node,
46  const ScheduleDAG *Graph) {
47  std::string R;
48  raw_string_ostream OS(R);
49  OS << static_cast<const void *>(Node);
50  return R;
51  }
52 
53  /// If you want to override the dot attributes printed for a particular
54  /// edge, override this method.
55  static std::string getEdgeAttributes(const SUnit *Node,
56  SUnitIterator EI,
57  const ScheduleDAG *Graph) {
58  if (EI.isArtificialDep())
59  return "color=cyan,style=dashed";
60  if (EI.isCtrlDep())
61  return "color=blue,style=dashed";
62  return "";
63  }
64 
65 
66  std::string getNodeLabel(const SUnit *Node, const ScheduleDAG *Graph);
67  static std::string getNodeAttributes(const SUnit *N,
68  const ScheduleDAG *Graph) {
69  return "shape=Mrecord";
70  }
71 
74  return G->addCustomGraphFeatures(GW);
75  }
76  };
77 }
78 
80  const ScheduleDAG *G) {
81  return G->getGraphNodeLabel(SU);
82 }
83 
84 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
85 /// rendered using 'dot'.
86 ///
87 void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
88  // This code is only for debugging!
89 #ifndef NDEBUG
90  ViewGraph(this, Name, false, Title);
91 #else
92  errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
93  << "systems with Graphviz or gv!\n";
94 #endif // NDEBUG
95 }
96 
97 /// Out-of-line implementation with no arguments is handy for gdb.
99  viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
100 }
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
unsigned NumPreds
of SDep::Data preds.
Definition: ScheduleDAG.h:271
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
virtual std::string getGraphNodeLabel(const SUnit *SU) const =0
Returns a label for an SUnit node in a visualization of the ScheduleDAG.
static void addCustomGraphFeatures(ScheduleDAG *G, GraphWriter< ScheduleDAG *> &GW)
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
MachineFunction & MF
Machine function.
Definition: ScheduleDAG.h:570
unsigned NumSuccs
of SDep::Data sucss.
Definition: ScheduleDAG.h:272
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:81
static std::string getGraphName(const ScheduleDAG *G)
static std::string getNodeAttributes(const SUnit *N, const ScheduleDAG *Graph)
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...
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...
static bool isSimple(Instruction *I)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
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 &#39;dot&#39;, run gv on the postscript file, then cleanup.
Definition: GraphWriter.h:348
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to &#39;dot...
virtual void addCustomGraphFeatures(GraphWriter< ScheduleDAG *> &) const
Adds custom features for a visualization of the ScheduleDAG.
Definition: ScheduleDAG.h:609
const DataFlowGraph & G
Definition: RDFGraph.cpp:211
static std::string getNodeIdentifierLabel(const SUnit *Node, const ScheduleDAG *Graph)
static bool isNodeHidden(const SUnit *Node)
#define N
bool isCtrlDep() const
Tests if this is not an SDep::Data dependence.
Definition: ScheduleDAG.h:657
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:462
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:247
bool isArtificialDep() const
Definition: ScheduleDAG.h:660