LLVM 20.0.0git
ScheduleDAGPrinter.cpp
Go to the documentation of this file.
1//===-- ScheduleDAGPrinter.cpp - Implement ScheduleDAG::viewGraph() -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This implements the ScheduleDAG::viewGraph method.
10//
11//===----------------------------------------------------------------------===//
12
17using namespace llvm;
18
19namespace llvm {
20 template<>
22
24
25 static std::string getGraphName(const ScheduleDAG *G) {
26 return std::string(G->MF.getName());
27 }
28
30 return true;
31 }
32
33 static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G) {
34 return (Node->NumPreds > 10 || Node->NumSuccs > 10);
35 }
36
37 static std::string getNodeIdentifierLabel(const SUnit *Node,
38 const ScheduleDAG *Graph) {
39 std::string R;
41 OS << static_cast<const void *>(Node);
42 return R;
43 }
44
45 /// If you want to override the dot attributes printed for a particular
46 /// edge, override this method.
47 static std::string getEdgeAttributes(const SUnit *Node,
49 const ScheduleDAG *Graph) {
50 if (EI.isArtificialDep())
51 return "color=cyan,style=dashed";
52 if (EI.isCtrlDep())
53 return "color=blue,style=dashed";
54 return "";
55 }
56
57
58 std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *Graph);
59 static std::string getNodeAttributes(const SUnit *N,
60 const ScheduleDAG *Graph) {
61 return "shape=Mrecord";
62 }
63
66 return G->addCustomGraphFeatures(GW);
67 }
68 };
69}
70
72 const ScheduleDAG *G) {
73 return G->getGraphNodeLabel(SU);
74}
75
76/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
77/// rendered using 'dot'.
78///
79void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
80 // This code is only for debugging!
81#ifndef NDEBUG
82 ViewGraph(this, Name, false, Title);
83#else
84 errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
85 << "systems with Graphviz or gv!\n";
86#endif // NDEBUG
87}
88
89/// Out-of-line implementation with no arguments is handy for gdb.
91 viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
92}
std::string Name
#define G(x, y, z)
Definition: MD5.cpp:56
static bool isSimple(Instruction *I)
raw_pwrite_stream & OS
bool isArtificialDep() const
Definition: ScheduleDAG.h:686
bool isCtrlDep() const
Tests if this is not an SDep::Data dependence.
Definition: ScheduleDAG.h:683
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:242
virtual std::string getDAGName() const =0
Returns a label for the region of code covered by the DAG.
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
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:427
#define N
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.
static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G)
static void addCustomGraphFeatures(ScheduleDAG *G, GraphWriter< ScheduleDAG * > &GW)
static std::string getGraphName(const ScheduleDAG *G)
static std::string getNodeIdentifierLabel(const SUnit *Node, const ScheduleDAG *Graph)
std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *Graph)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
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...