Line data Source code
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"
15 : #include "llvm/CodeGen/MachineConstantPool.h"
16 : #include "llvm/CodeGen/MachineFunction.h"
17 : #include "llvm/CodeGen/ScheduleDAG.h"
18 : #include "llvm/CodeGen/TargetRegisterInfo.h"
19 : #include "llvm/IR/Constants.h"
20 : #include "llvm/Support/Debug.h"
21 : #include "llvm/Support/GraphWriter.h"
22 : #include "llvm/Support/raw_ostream.h"
23 : using namespace llvm;
24 :
25 : namespace llvm {
26 : template<>
27 : struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
28 :
29 : DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
30 :
31 : static std::string getGraphName(const ScheduleDAG *G) {
32 : return G->MF.getName();
33 : }
34 :
35 : static bool renderGraphFromBottomUp() {
36 : return true;
37 : }
38 :
39 : static bool isNodeHidden(const SUnit *Node) {
40 : return (Node->NumPreds > 10 || Node->NumSuccs > 10);
41 : }
42 :
43 : static std::string getNodeIdentifierLabel(const SUnit *Node,
44 : const ScheduleDAG *Graph) {
45 : std::string R;
46 : raw_string_ostream OS(R);
47 : OS << static_cast<const void *>(Node);
48 : return R;
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 *SU, const ScheduleDAG *Graph);
65 : static std::string getNodeAttributes(const SUnit *N,
66 : const ScheduleDAG *Graph) {
67 : return "shape=Mrecord";
68 : }
69 :
70 : static void addCustomGraphFeatures(ScheduleDAG *G,
71 : GraphWriter<ScheduleDAG*> &GW) {
72 : return G->addCustomGraphFeatures(GW);
73 : }
74 : };
75 : }
76 :
77 0 : std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
78 : const ScheduleDAG *G) {
79 0 : 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 0 : 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 0 : errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
91 0 : << "systems with Graphviz or gv!\n";
92 : #endif // NDEBUG
93 0 : }
94 :
95 : /// Out-of-line implementation with no arguments is handy for gdb.
96 0 : void ScheduleDAG::viewGraph() {
97 0 : viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
98 0 : }
|