LLVM  14.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 
13 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/Support/Debug.h"
22 using namespace llvm;
23 
24 namespace llvm {
25  template<>
27 
29 
30  static std::string getGraphName(const ScheduleDAG *G) {
31  return std::string(G->MF.getName());
32  }
33 
34  static bool renderGraphFromBottomUp() {
35  return true;
36  }
37 
38  static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G) {
39  return (Node->NumPreds > 10 || Node->NumSuccs > 10);
40  }
41 
42  static std::string getNodeIdentifierLabel(const SUnit *Node,
43  const ScheduleDAG *Graph) {
44  std::string R;
46  OS << static_cast<const void *>(Node);
47  return R;
48  }
49 
50  /// If you want to override the dot attributes printed for a particular
51  /// edge, override this method.
52  static std::string getEdgeAttributes(const SUnit *Node,
53  SUnitIterator EI,
54  const ScheduleDAG *Graph) {
55  if (EI.isArtificialDep())
56  return "color=cyan,style=dashed";
57  if (EI.isCtrlDep())
58  return "color=blue,style=dashed";
59  return "";
60  }
61 
62 
63  std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *Graph);
64  static std::string getNodeAttributes(const SUnit *N,
65  const ScheduleDAG *Graph) {
66  return "shape=Mrecord";
67  }
68 
71  return G->addCustomGraphFeatures(GW);
72  }
73  };
74 }
75 
77  const ScheduleDAG *G) {
78  return G->getGraphNodeLabel(SU);
79 }
80 
81 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
82 /// rendered using 'dot'.
83 ///
84 void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
85  // This code is only for debugging!
86 #ifndef NDEBUG
87  ViewGraph(this, Name, false, Title);
88 #else
89  errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
90  << "systems with Graphviz or gv!\n";
91 #endif // NDEBUG
92 }
93 
94 /// Out-of-line implementation with no arguments is handy for gdb.
96  viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
97 }
ScheduleDAG.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::GraphWriter
Definition: ScheduleDAG.h:34
llvm::DOTGraphTraits< ScheduleDAG * >::getEdgeAttributes
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.
Definition: ScheduleDAGPrinter.cpp:52
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::DOTGraphTraits< ScheduleDAG * >::getNodeIdentifierLabel
static std::string getNodeIdentifierLabel(const SUnit *Node, const ScheduleDAG *Graph)
Definition: ScheduleDAGPrinter.cpp:42
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
llvm::ViewGraph
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:430
llvm::DOTGraphTraits< ScheduleDAG * >::getNodeAttributes
static std::string getNodeAttributes(const SUnit *N, const ScheduleDAG *Graph)
Definition: ScheduleDAGPrinter.cpp:64
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:207
llvm::SUnitIterator::isCtrlDep
bool isCtrlDep() const
Tests if this is not an SDep::Data dependence.
Definition: ScheduleDAG.h:657
Constants.h
llvm::DOTGraphTraits< ScheduleDAG * >::getGraphName
static std::string getGraphName(const ScheduleDAG *G)
Definition: ScheduleDAGPrinter.cpp:30
llvm::DOTGraphTraits
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
Definition: DOTGraphTraits.h:166
llvm::ScheduleDAG::viewGraph
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
Definition: ScheduleDAGPrinter.cpp:95
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::DOTGraphTraits< ScheduleDAG * >::DOTGraphTraits
DOTGraphTraits(bool isSimple=false)
Definition: ScheduleDAGPrinter.cpp:28
StringExtras.h
MachineConstantPool.h
llvm::ScheduleDAG
Definition: ScheduleDAG.h:555
llvm::DOTGraphTraits< ScheduleDAG * >::addCustomGraphFeatures
static void addCustomGraphFeatures(ScheduleDAG *G, GraphWriter< ScheduleDAG * > &GW)
Definition: ScheduleDAGPrinter.cpp:69
llvm::ScheduleDAG::getDAGName
virtual std::string getDAGName() const =0
Returns a label for the region of code covered by the DAG.
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
GraphWriter.h
llvm::DOTGraphTraits< ScheduleDAG * >::renderGraphFromBottomUp
static bool renderGraphFromBottomUp()
Definition: ScheduleDAGPrinter.cpp:34
llvm::SUnitIterator
Definition: ScheduleDAG.h:617
isSimple
static bool isSimple(Instruction *I)
Definition: SLPVectorizer.cpp:593
N
#define N
llvm::DefaultDOTGraphTraits::getNodeLabel
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...
Definition: DOTGraphTraits.h:76
llvm::DefaultDOTGraphTraits
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Definition: DOTGraphTraits.h:28
getNodeLabel
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
Definition: ModuleSummaryIndex.cpp:477
llvm::SUnit
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:242
llvm::SUnitIterator::isArtificialDep
bool isArtificialDep() const
Definition: ScheduleDAG.h:660
raw_ostream.h
llvm::DOTGraphTraits< ScheduleDAG * >::isNodeHidden
static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G)
Definition: ScheduleDAGPrinter.cpp:38
MachineFunction.h
TargetRegisterInfo.h
Debug.h