aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-07-09 17:06:18 +0000
committerDavid Greene <greened@obbligato.org>2009-07-09 17:06:18 +0000
commit00ad26ff5760ff2d1b24acb18718e63541088923 (patch)
treef54e1d9a35767638a1bab8a43d014e583d998a8e
parent354b5ac1610424a5fa56735425a43b8a475f5980 (diff)
Add support for other GraphViz display tools. This can help
with very large graphs, where dot isn't necessarily the most visually pleasing way of looking at the graph. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75144 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--autoconf/configure.ac40
-rw-r--r--include/llvm/Config/config.h.in24
-rw-r--r--include/llvm/Support/GraphWriter.h17
-rw-r--r--lib/Support/GraphWriter.cpp54
4 files changed, 126 insertions, 9 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 6b3c4caac0..b3940f08e5 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -673,6 +673,46 @@ if test "$DOT" != "echo dot" ; then
AC_DEFINE_UNQUOTED([LLVM_PATH_DOT],"$DOT${EXEEXT}",
[Define to path to dot program if found or 'echo dot' otherwise])
fi
+AC_PATH_PROG(FDP, [fdp], [echo fdp])
+if test "$FDP" != "echo fdp" ; then
+ AC_DEFINE([HAVE_FDP],[1],[Define if the neat program is available])
+ dnl If we're targeting for mingw we should emit windows paths, not msys
+ if test "$llvm_cv_os_type" = "MingW" ; then
+ FDP=`echo $FDP | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
+ fi
+ AC_DEFINE_UNQUOTED([LLVM_PATH_FDP],"$FDP${EXEEXT}",
+ [Define to path to fdp program if found or 'echo fdp' otherwise])
+fi
+AC_PATH_PROG(NEATO, [neato], [echo neato])
+if test "$NEATO" != "echo neato" ; then
+ AC_DEFINE([HAVE_NEATO],[1],[Define if the neat program is available])
+ dnl If we're targeting for mingw we should emit windows paths, not msys
+ if test "$llvm_cv_os_type" = "MingW" ; then
+ NEATO=`echo $NEATO | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
+ fi
+ AC_DEFINE_UNQUOTED([LLVM_PATH_NEATO],"$NEATO${EXEEXT}",
+ [Define to path to neato program if found or 'echo neato' otherwise])
+fi
+AC_PATH_PROG(TWOPI, [twopi], [echo twopi])
+if test "$TWOPI" != "echo twopi" ; then
+ AC_DEFINE([HAVE_TWOPI],[1],[Define if the neat program is available])
+ dnl If we're targeting for mingw we should emit windows paths, not msys
+ if test "$llvm_cv_os_type" = "MingW" ; then
+ TWOPI=`echo $TWOPI | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
+ fi
+ AC_DEFINE_UNQUOTED([LLVM_PATH_TWOPI],"$TWOPI${EXEEXT}",
+ [Define to path to twopi program if found or 'echo twopi' otherwise])
+fi
+AC_PATH_PROG(CIRCO, [circo], [echo circo])
+if test "$CIRCO" != "echo circo" ; then
+ AC_DEFINE([HAVE_CIRCO],[1],[Define if the neat program is available])
+ dnl If we're targeting for mingw we should emit windows paths, not msys
+ if test "$llvm_cv_os_type" = "MingW" ; then
+ CIRCO=`echo $CIRCO | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
+ fi
+ AC_DEFINE_UNQUOTED([LLVM_PATH_CIRCO],"$CIRCO${EXEEXT}",
+ [Define to path to circo program if found or 'echo circo' otherwise])
+fi
AC_PATH_PROGS(GV, [gv gsview32], [echo gv])
if test "$GV" != "echo gv" ; then
AC_DEFINE([HAVE_GV],[1],[Define if the gv program is available])
diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in
index 4dd1345d0e..b78814f2b7 100644
--- a/include/llvm/Config/config.h.in
+++ b/include/llvm/Config/config.h.in
@@ -60,6 +60,9 @@
/* Define to 1 if you have the `ceilf' function. */
#undef HAVE_CEILF
+/* Define if the neat program is available */
+#undef HAVE_CIRCO
+
/* Define to 1 if you have the `closedir' function. */
#undef HAVE_CLOSEDIR
@@ -109,6 +112,9 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
+/* Define if the neat program is available */
+#undef HAVE_FDP
+
/* Define if libffi is available on this platform. */
#undef HAVE_FFI_CALL
@@ -267,6 +273,9 @@
/* Define to 1 if you have the `nearbyintf' function. */
#undef HAVE_NEARBYINTF
+/* Define if the neat program is available */
+#undef HAVE_NEATO
+
/* Define to 1 if you have the `opendir' function. */
#undef HAVE_OPENDIR
@@ -431,6 +440,9 @@
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
+/* Define if the neat program is available */
+#undef HAVE_TWOPI
+
/* Define to 1 if the system has the type `uint64_t'. */
#undef HAVE_UINT64_T
@@ -491,18 +503,30 @@
/* Define if this is Win32ish platform */
#undef LLVM_ON_WIN32
+/* Define to path to circo program if found or 'echo circo' otherwise */
+#undef LLVM_PATH_CIRCO
+
/* Define to path to dot program if found or 'echo dot' otherwise */
#undef LLVM_PATH_DOT
/* Define to path to dotty program if found or 'echo dotty' otherwise */
#undef LLVM_PATH_DOTTY
+/* Define to path to fdp program if found or 'echo fdp' otherwise */
+#undef LLVM_PATH_FDP
+
/* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */
#undef LLVM_PATH_GRAPHVIZ
/* Define to path to gv program if found or 'echo gv' otherwise */
#undef LLVM_PATH_GV
+/* Define to path to neato program if found or 'echo neato' otherwise */
+#undef LLVM_PATH_NEATO
+
+/* Define to path to twopi program if found or 'echo twopi' otherwise */
+#undef LLVM_PATH_TWOPI
+
/* Installation prefix directory */
#undef LLVM_PREFIX
diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h
index 4944788b9e..3ebfca2b30 100644
--- a/include/llvm/Support/GraphWriter.h
+++ b/include/llvm/Support/GraphWriter.h
@@ -67,7 +67,17 @@ namespace DOT { // Private functions...
}
}
-void DisplayGraph(const sys::Path& Filename, bool wait=true);
+namespace GraphProgram {
+ enum Name {
+ DOT,
+ FDP,
+ NEATO,
+ TWOPI,
+ CIRCO
+ };
+}
+
+void DisplayGraph(const sys::Path& Filename, bool wait=true, GraphProgram::Name program = GraphProgram::DOT);
template<typename GraphType>
class GraphWriter {
@@ -314,14 +324,15 @@ template<typename GraphType>
void ViewGraph(const GraphType& G,
const std::string& Name,
bool ShortNames = false,
- const std::string& Title = "") {
+ const std::string& Title = "",
+ GraphProgram::Name Program = GraphProgram::DOT) {
sys::Path Filename = WriteGraph(G, Name, ShortNames, Title);
if (Filename.isEmpty()) {
return;
}
- DisplayGraph(Filename);
+ DisplayGraph(Filename, true, Program);
}
} // End llvm namespace
diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp
index 80458865f5..d0be7a180c 100644
--- a/lib/Support/GraphWriter.cpp
+++ b/lib/Support/GraphWriter.cpp
@@ -18,7 +18,8 @@
#include "llvm/Config/config.h"
using namespace llvm;
-void llvm::DisplayGraph(const sys::Path &Filename, bool wait) {
+void llvm::DisplayGraph(const sys::Path &Filename, bool wait,
+ GraphProgram::Name program) {
std::string ErrMsg;
#if HAVE_GRAPHVIZ
sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
@@ -35,15 +36,56 @@ void llvm::DisplayGraph(const sys::Path &Filename, bool wait) {
else {
Filename.eraseFromDisk();
}
-
-#elif (HAVE_GV && (HAVE_DOT || HAVE_FDP))
+
+#elif (HAVE_GV && (HAVE_DOT || HAVE_FDP || HAVE_NEATO || \
+ HAVE_TWOPI || HAVE_CIRCO))
sys::Path PSFilename = Filename;
PSFilename.appendSuffix("ps");
+ sys::Path prog;
+
+ // Set default grapher
+#if HAVE_CIRCO
+ prog = sys::Path(LLVM_PATH_CIRCO);
+#endif
+#if HAVE_TWOPI
+ prog = sys::Path(LLVM_PATH_TWOPI);
+#endif
+#if HAVE_NEATO
+ prog = sys::Path(LLVM_PATH_NEATO);
+#endif
#if HAVE_FDP
- sys::Path prog(LLVM_PATH_FDP);
-#else
- sys::Path prog(LLVM_PATH_DOT);
+ prog = sys::Path(LLVM_PATH_FDP);
+#endif
+#if HAVE_DOT
+ prog = sys::Path(LLVM_PATH_DOT);
+#endif
+
+ // Find which program the user wants
+#if HAVE_DOT
+ if (program == GraphProgram::DOT) {
+ prog = sys::Path(LLVM_PATH_DOT);
+ }
+#endif
+#if (HAVE_FDP)
+ if (program == GraphProgram::FDP) {
+ prog = sys::Path(LLVM_PATH_FDP);
+ }
+#endif
+#if (HAVE_NEATO)
+ if (program == GraphProgram::NEATO) {
+ prog = sys::Path(LLVM_PATH_NEATO);
+ }
+#endif
+#if (HAVE_TWOPI)
+ if (program == GraphProgram::TWOPI) {
+ prog = sys::Path(LLVM_PATH_TWOPI);
+ }
+#endif
+#if (HAVE_CIRCO)
+ if (program == GraphProgram::CIRCO) {
+ prog = sys::Path(LLVM_PATH_CIRCO);
+ }
#endif
std::vector<const char*> args;