Add support for other GraphViz display tools. This can help
authorDavid Greene <greened@obbligato.org>
Thu, 9 Jul 2009 17:06:18 +0000 (17:06 +0000)
committerDavid Greene <greened@obbligato.org>
Thu, 9 Jul 2009 17:06:18 +0000 (17:06 +0000)
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

autoconf/configure.ac
include/llvm/Config/config.h.in
include/llvm/Support/GraphWriter.h
lib/Support/GraphWriter.cpp

index 6b3c4caac0ca5871e57141f7320044c04f5b323b..b3940f08e5b602c95f46e6c8a1e94c4b91cfe9bf 100644 (file)
@@ -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])
index 4dd1345d0e60987aa2f2a1bcc50c72e65c1bd50f..b78814f2b7e0732e00d9cd6052da40b78e7b97d8 100644 (file)
@@ -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
 
 /* 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
 
 /* 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
 
 /* 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
 
 /* 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
 
index 4944788b9e473339bd7e07d8cb931422fa9996ee..3ebfca2b30d98b9fb0e5219438cd45f086cbf00c 100644 (file)
@@ -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
index 80458865f58265a55971d0ef6509803efd7674b4..d0be7a180c126ea90d90213a69b8d6db35bf30bb 100644 (file)
@@ -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;