LLVM 24.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
19#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
20template <>
22
24
25 static std::string getGraphName(const ScheduleDAG *G) {
26 return std::string(G->MF.getName());
27 }
28
29 static bool renderGraphFromBottomUp() { return true; }
30
31 static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G) {
32 return (Node->NumPreds > 10 || Node->NumSuccs > 10);
33 }
34
35 static std::string getNodeIdentifierLabel(const SUnit *Node,
36 const ScheduleDAG *Graph) {
37 std::string R;
39 OS << static_cast<const void *>(Node);
40 return R;
41 }
42
43 /// If you want to override the dot attributes printed for a particular
44 /// edge, override this method.
45 static std::string getEdgeAttributes(const SUnit *Node, SUnitIterator EI,
46 const ScheduleDAG *Graph) {
47 if (EI.isArtificialDep())
48 return "color=cyan,style=dashed";
49 if (EI.isCtrlDep())
50 return "color=blue,style=dashed";
51 return "";
52 }
53
54 std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *Graph);
55 static std::string getNodeAttributes(const SUnit *N,
56 const ScheduleDAG *Graph) {
57 return "shape=Mrecord";
58 }
59
62 return G->addCustomGraphFeatures(GW);
63 }
64};
65
67 const ScheduleDAG *G) {
68 return G->getGraphNodeLabel(SU);
69}
70#endif
71
72/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
73/// rendered using 'dot'.
74///
75void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
76 // This code is only for debugging!
77#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
78 ViewGraph(this, Name, false, Title);
79#else
80 errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
81 << "systems with Graphviz or gv!\n";
82#endif // NDEBUG
83}
84
85/// Out-of-line implementation with no arguments is handy for gdb.
87 viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
88}
#define G(x, y, z)
Definition MD5.cpp:55
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
bool isArtificialDep() const
bool isCtrlDep() const
Tests if this is not an SDep::Data dependence.
Scheduling unit. This is a node in the scheduling DAG.
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:82
A raw_ostream that writes to an std::string.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI 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.
#define N
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 ...
static std::string getNodeIdentifierLabel(const void *, const GraphType &)
static bool isNodeHidden(const void *, const GraphType &)
isNodeHidden - If the function returns true, the given node is not displayed in the graph.
static std::string getGraphName(const GraphType &)
getGraphName - Return the label for the graph as a whole.
static std::string getEdgeAttributes(const void *, EdgeIter, const GraphType &)
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 renderGraphFromBottomUp()
renderGraphFromBottomUp - If this function returns true, the graph is emitted bottom-up instead of to...
static void addCustomGraphFeatures(const GraphType &, GraphWriter &)
addCustomGraphFeatures - If a graph is made up of more than just straight-forward nodes and edges,...
static std::string getNodeAttributes(const void *, const GraphType &)
If you want to specify custom node attributes, this is the place to do so.