2008-11-20 07:18:57 +08:00
|
|
|
//===-- ScheduleDAGPrinter.cpp - Implement ScheduleDAG::viewGraph() -------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2008-11-20 07:18:57 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This implements the ScheduleDAG::viewGraph method.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2008-11-20 07:18:57 +08:00
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Constants.h"
|
2008-11-20 07:18:57 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/GraphWriter.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
template<>
|
|
|
|
struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
|
2009-11-30 20:38:13 +08:00
|
|
|
|
|
|
|
DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
|
|
|
|
|
2008-11-20 07:18:57 +08:00
|
|
|
static std::string getGraphName(const ScheduleDAG *G) {
|
2020-01-29 03:23:46 +08:00
|
|
|
return std::string(G->MF.getName());
|
2008-11-20 07:18:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool renderGraphFromBottomUp() {
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-07 08:18:15 +08:00
|
|
|
|
2013-01-25 15:45:25 +08:00
|
|
|
static bool isNodeHidden(const SUnit *Node) {
|
|
|
|
return (Node->NumPreds > 10 || Node->NumSuccs > 10);
|
|
|
|
}
|
|
|
|
|
2015-10-28 07:09:03 +08:00
|
|
|
static std::string getNodeIdentifierLabel(const SUnit *Node,
|
|
|
|
const ScheduleDAG *Graph) {
|
|
|
|
std::string R;
|
|
|
|
raw_string_ostream OS(R);
|
|
|
|
OS << static_cast<const void *>(Node);
|
|
|
|
return R;
|
2008-11-20 07:18:57 +08:00
|
|
|
}
|
2012-03-07 08:18:15 +08:00
|
|
|
|
2008-11-20 07:18:57 +08:00
|
|
|
/// If you want to override the dot attributes printed for a particular
|
|
|
|
/// edge, override this method.
|
2008-12-16 08:55:00 +08:00
|
|
|
static std::string getEdgeAttributes(const SUnit *Node,
|
2011-02-27 12:11:03 +08:00
|
|
|
SUnitIterator EI,
|
|
|
|
const ScheduleDAG *Graph) {
|
2008-11-21 10:18:56 +08:00
|
|
|
if (EI.isArtificialDep())
|
2008-11-20 07:18:57 +08:00
|
|
|
return "color=cyan,style=dashed";
|
|
|
|
if (EI.isCtrlDep())
|
|
|
|
return "color=blue,style=dashed";
|
|
|
|
return "";
|
|
|
|
}
|
2012-03-07 08:18:15 +08:00
|
|
|
|
2008-11-20 07:18:57 +08:00
|
|
|
|
2018-07-17 02:51:40 +08:00
|
|
|
std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *Graph);
|
2008-11-20 07:18:57 +08:00
|
|
|
static std::string getNodeAttributes(const SUnit *N,
|
|
|
|
const ScheduleDAG *Graph) {
|
|
|
|
return "shape=Mrecord";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void addCustomGraphFeatures(ScheduleDAG *G,
|
|
|
|
GraphWriter<ScheduleDAG*> &GW) {
|
|
|
|
return G->addCustomGraphFeatures(GW);
|
|
|
|
}
|
|
|
|
};
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2008-11-20 07:18:57 +08:00
|
|
|
|
|
|
|
std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
|
2009-11-30 20:38:47 +08:00
|
|
|
const ScheduleDAG *G) {
|
2008-11-20 07:18:57 +08:00
|
|
|
return G->getGraphNodeLabel(SU);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
|
|
|
|
/// rendered using 'dot'.
|
|
|
|
///
|
2012-03-07 08:18:22 +08:00
|
|
|
void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
|
|
|
|
// This code is only for debugging!
|
2008-11-20 07:18:57 +08:00
|
|
|
#ifndef NDEBUG
|
2012-03-07 08:18:22 +08:00
|
|
|
ViewGraph(this, Name, false, Title);
|
2008-11-20 07:18:57 +08:00
|
|
|
#else
|
2009-08-23 16:50:52 +08:00
|
|
|
errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
|
|
|
|
<< "systems with Graphviz or gv!\n";
|
2008-11-20 07:18:57 +08:00
|
|
|
#endif // NDEBUG
|
|
|
|
}
|
2012-03-07 08:18:22 +08:00
|
|
|
|
|
|
|
/// Out-of-line implementation with no arguments is handy for gdb.
|
|
|
|
void ScheduleDAG::viewGraph() {
|
|
|
|
viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
|
|
|
|
}
|