[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / CodeGen / ScheduleDAGPrinter.cpp
blobe7b14944acfeec265d649ffca426ce98b21c1dee
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.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/CodeGen/MachineFunction.h"
14 #include "llvm/CodeGen/ScheduleDAG.h"
15 #include "llvm/Support/GraphWriter.h"
16 #include "llvm/Support/raw_ostream.h"
17 using namespace llvm;
19 namespace llvm {
20 template<>
21 struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
23 DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
25 static std::string getGraphName(const ScheduleDAG *G) {
26 return std::string(G->MF.getName());
29 static bool renderGraphFromBottomUp() {
30 return true;
33 static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G) {
34 return (Node->NumPreds > 10 || Node->NumSuccs > 10);
37 static std::string getNodeIdentifierLabel(const SUnit *Node,
38 const ScheduleDAG *Graph) {
39 std::string R;
40 raw_string_ostream OS(R);
41 OS << static_cast<const void *>(Node);
42 return R;
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,
48 SUnitIterator EI,
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 "";
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";
64 static void addCustomGraphFeatures(ScheduleDAG *G,
65 GraphWriter<ScheduleDAG*> &GW) {
66 return G->addCustomGraphFeatures(GW);
71 std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
72 const ScheduleDAG *G) {
73 return G->getGraphNodeLabel(SU);
76 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
77 /// rendered using 'dot'.
78 ///
79 void 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
89 /// Out-of-line implementation with no arguments is handy for gdb.
90 void ScheduleDAG::viewGraph() {
91 viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());