LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
17 #include "llvm/Assembly/Writer.h"
21 #include "llvm/IR/Constants.h"
22 #include "llvm/Support/Debug.h"
27 #include <fstream>
28 using namespace llvm;
29 
30 namespace llvm {
31  template<>
33 
34  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
35 
36  static std::string getGraphName(const ScheduleDAG *G) {
37  return G->MF.getName();
38  }
39 
40  static bool renderGraphFromBottomUp() {
41  return true;
42  }
43 
44  static bool isNodeHidden(const SUnit *Node) {
45  return (Node->NumPreds > 10 || Node->NumSuccs > 10);
46  }
47 
48  static bool hasNodeAddressLabel(const SUnit *Node,
49  const ScheduleDAG *Graph) {
50  return true;
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()
bool isArtificialDep() const
Definition: ScheduleDAG.h:641
unsigned NumPreds
Definition: ScheduleDAG.h:273
virtual std::string getGraphNodeLabel(const SUnit *SU) const =0
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
MachineFunction & MF
Definition: ScheduleDAG.h:543
unsigned NumSuccs
Definition: ScheduleDAG.h:274
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)
#define G(x, y, z)
Definition: MD5.cpp:52
std::string getNodeLabel(const void *, const GraphType &)
virtual void addCustomGraphFeatures(GraphWriter< ScheduleDAG * > &) const
Definition: ScheduleDAG.h:586
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
Definition: GraphWriter.h:346
static void addCustomGraphFeatures(ScheduleDAG *G, GraphWriter< ScheduleDAG * > &GW)
bool isCtrlDep() const
isCtrlDep - Test if this is not an SDep::Data dependence.
Definition: ScheduleDAG.h:638
static bool isNodeHidden(const SUnit *Node)
#define N
static bool hasNodeAddressLabel(const SUnit *Node, const ScheduleDAG *Graph)
StringRef getName() const
SUnit - Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:249