2008-11-19 23:18:57 +00:00
|
|
|
//===-- ScheduleDAGPrinter.cpp - Implement ScheduleDAG::viewGraph() -------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This implements the ScheduleDAG::viewGraph method.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/Assembly/Writer.h"
|
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/GraphWriter.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include "llvm/ADT/DenseSet.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include <fstream>
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
template<>
|
|
|
|
struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
|
2009-11-30 12:38:13 +00:00
|
|
|
|
|
|
|
DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
|
|
|
|
|
2008-11-19 23:18:57 +00:00
|
|
|
static std::string getGraphName(const ScheduleDAG *G) {
|
2012-08-22 06:07:19 +00:00
|
|
|
return G->MF.getName();
|
2008-11-19 23:18:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool renderGraphFromBottomUp() {
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-07 00:18:15 +00:00
|
|
|
|
2008-11-19 23:18:57 +00:00
|
|
|
static bool hasNodeAddressLabel(const SUnit *Node,
|
|
|
|
const ScheduleDAG *Graph) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-07 00:18:15 +00:00
|
|
|
|
2008-11-19 23:18:57 +00:00
|
|
|
/// If you want to override the dot attributes printed for a particular
|
|
|
|
/// edge, override this method.
|
2008-12-16 00:55:00 +00:00
|
|
|
static std::string getEdgeAttributes(const SUnit *Node,
|
2011-02-27 04:11:03 +00:00
|
|
|
SUnitIterator EI,
|
|
|
|
const ScheduleDAG *Graph) {
|
2008-11-21 02:18:56 +00:00
|
|
|
if (EI.isArtificialDep())
|
2008-11-19 23:18:57 +00:00
|
|
|
return "color=cyan,style=dashed";
|
|
|
|
if (EI.isCtrlDep())
|
|
|
|
return "color=blue,style=dashed";
|
|
|
|
return "";
|
|
|
|
}
|
2012-03-07 00:18:15 +00:00
|
|
|
|
2008-11-19 23:18:57 +00:00
|
|
|
|
2009-11-30 12:38:47 +00:00
|
|
|
std::string getNodeLabel(const SUnit *Node, const ScheduleDAG *Graph);
|
2008-11-19 23:18:57 +00: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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
|
2009-11-30 12:38:47 +00:00
|
|
|
const ScheduleDAG *G) {
|
2008-11-19 23:18:57 +00:00
|
|
|
return G->getGraphNodeLabel(SU);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
|
|
|
|
/// rendered using 'dot'.
|
|
|
|
///
|
2012-03-07 00:18:22 +00:00
|
|
|
void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
|
|
|
|
// This code is only for debugging!
|
2008-11-19 23:18:57 +00:00
|
|
|
#ifndef NDEBUG
|
2012-03-07 00:18:22 +00:00
|
|
|
ViewGraph(this, Name, false, Title);
|
2008-11-19 23:18:57 +00:00
|
|
|
#else
|
2009-08-23 08:50:52 +00:00
|
|
|
errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
|
|
|
|
<< "systems with Graphviz or gv!\n";
|
2008-11-19 23:18:57 +00:00
|
|
|
#endif // NDEBUG
|
|
|
|
}
|
2012-03-07 00:18:22 +00:00
|
|
|
|
|
|
|
/// Out-of-line implementation with no arguments is handy for gdb.
|
|
|
|
void ScheduleDAG::viewGraph() {
|
|
|
|
viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
|
|
|
|
}
|