1 //===-- ScheduleDAGPrinter.cpp - Implement ScheduleDAG::viewGraph() -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements the ScheduleDAG::viewGraph method.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Constants.h"
15 #include "llvm/Assembly/Writer.h"
16 #include "llvm/CodeGen/ScheduleDAG.h"
17 #include "llvm/CodeGen/MachineConstantPool.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/MachineModuleInfo.h"
20 #include "llvm/Target/TargetRegisterInfo.h"
21 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Support/Debug.h"
23 #include "llvm/Support/GraphWriter.h"
24 #include "llvm/Support/raw_ostream.h"
25 #include "llvm/ADT/DenseSet.h"
26 #include "llvm/ADT/StringExtras.h"
32 struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
34 DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
36 static std::string getGraphName(const ScheduleDAG *G) {
37 return G->MF.getName();
40 static bool renderGraphFromBottomUp() {
44 static bool hasNodeAddressLabel(const SUnit *Node,
45 const ScheduleDAG *Graph) {
49 /// If you want to override the dot attributes printed for a particular
50 /// edge, override this method.
51 static std::string getEdgeAttributes(const SUnit *Node,
53 const ScheduleDAG *Graph) {
54 if (EI.isArtificialDep())
55 return "color=cyan,style=dashed";
57 return "color=blue,style=dashed";
62 std::string getNodeLabel(const SUnit *Node, const ScheduleDAG *Graph);
63 static std::string getNodeAttributes(const SUnit *N,
64 const ScheduleDAG *Graph) {
65 return "shape=Mrecord";
68 static void addCustomGraphFeatures(ScheduleDAG *G,
69 GraphWriter<ScheduleDAG*> &GW) {
70 return G->addCustomGraphFeatures(GW);
75 std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
76 const ScheduleDAG *G) {
77 return G->getGraphNodeLabel(SU);
80 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
81 /// rendered using 'dot'.
83 void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
84 // This code is only for debugging!
86 ViewGraph(this, Name, false, Title);
88 errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
89 << "systems with Graphviz or gv!\n";
93 /// Out-of-line implementation with no arguments is handy for gdb.
94 void ScheduleDAG::viewGraph() {
95 viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());