diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-10 23:08:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-10 23:08:40 +0000 |
commit | 66328480bb3eb6aa52e2c155657f3d19d4efea7a (patch) | |
tree | a3a85d1c3a93b93f3f85256eda8a6af246804e3f /lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp | |
parent | 1080b9ee534579c67f7c99364cc6fa11edbcd919 (diff) |
Implement initial selectiondag printing support. This gets us a nice
graph with no labels! :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp new file mode 100644 index 0000000000..9c48333226 --- /dev/null +++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -0,0 +1,48 @@ +//===-- SelectionDAGPrinter.cpp - Implement SelectionDAG::viewGraph() -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This implements the SelectionDAG::viewGraph method. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/Function.h" +#include "llvm/Support/GraphWriter.h" +#include <fstream> +using namespace llvm; + +/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG +/// rendered using 'dot'. +/// +void SelectionDAG::viewGraph() { + std::string Filename = "/tmp/dag." + + getMachineFunction().getFunction()->getName() + ".dot"; + std::cerr << "Writing '" << Filename << "'... "; + std::ofstream F(Filename.c_str()); + + if (!F) { + std::cerr << " error opening file for writing!\n"; + return; + } + + WriteGraph(F, this); + F.close(); + std::cerr << "\n"; + + std::cerr << "Running 'dot' program... " << std::flush; + if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename + + " > /tmp/dag.tempgraph.ps").c_str())) { + std::cerr << "Error running dot: 'dot' not in path?\n"; + } else { + std::cerr << "\n"; + system("gv /tmp/dag.tempgraph.ps"); + } + system(("rm " + Filename + " /tmp/dag.tempgraph.ps").c_str()); +} |