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
This commit is contained in:
David Greene 2009-07-09 17:06:18 +00:00
parent 354b5ac161
commit 00ad26ff57
4 changed files with 126 additions and 9 deletions

View File

@ -673,6 +673,46 @@ if test "$DOT" != "echo dot" ; then
AC_DEFINE_UNQUOTED([LLVM_PATH_DOT],"$DOT${EXEEXT}", AC_DEFINE_UNQUOTED([LLVM_PATH_DOT],"$DOT${EXEEXT}",
[Define to path to dot program if found or 'echo dot' otherwise]) [Define to path to dot program if found or 'echo dot' otherwise])
fi 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]) AC_PATH_PROGS(GV, [gv gsview32], [echo gv])
if test "$GV" != "echo gv" ; then if test "$GV" != "echo gv" ; then
AC_DEFINE([HAVE_GV],[1],[Define if the gv program is available]) AC_DEFINE([HAVE_GV],[1],[Define if the gv program is available])

View File

@ -60,6 +60,9 @@
/* Define to 1 if you have the `ceilf' function. */ /* Define to 1 if you have the `ceilf' function. */
#undef HAVE_CEILF #undef HAVE_CEILF
/* Define if the neat program is available */
#undef HAVE_CIRCO
/* Define to 1 if you have the `closedir' function. */ /* Define to 1 if you have the `closedir' function. */
#undef HAVE_CLOSEDIR #undef HAVE_CLOSEDIR
@ -109,6 +112,9 @@
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H #undef HAVE_FCNTL_H
/* Define if the neat program is available */
#undef HAVE_FDP
/* Define if libffi is available on this platform. */ /* Define if libffi is available on this platform. */
#undef HAVE_FFI_CALL #undef HAVE_FFI_CALL
@ -267,6 +273,9 @@
/* Define to 1 if you have the `nearbyintf' function. */ /* Define to 1 if you have the `nearbyintf' function. */
#undef HAVE_NEARBYINTF #undef HAVE_NEARBYINTF
/* Define if the neat program is available */
#undef HAVE_NEATO
/* Define to 1 if you have the `opendir' function. */ /* Define to 1 if you have the `opendir' function. */
#undef HAVE_OPENDIR #undef HAVE_OPENDIR
@ -431,6 +440,9 @@
/* Define to 1 if you have the <termios.h> header file. */ /* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H #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'. */ /* Define to 1 if the system has the type `uint64_t'. */
#undef HAVE_UINT64_T #undef HAVE_UINT64_T
@ -491,18 +503,30 @@
/* Define if this is Win32ish platform */ /* Define if this is Win32ish platform */
#undef LLVM_ON_WIN32 #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 */ /* Define to path to dot program if found or 'echo dot' otherwise */
#undef LLVM_PATH_DOT #undef LLVM_PATH_DOT
/* Define to path to dotty program if found or 'echo dotty' otherwise */ /* Define to path to dotty program if found or 'echo dotty' otherwise */
#undef LLVM_PATH_DOTTY #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 */ /* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */
#undef LLVM_PATH_GRAPHVIZ #undef LLVM_PATH_GRAPHVIZ
/* Define to path to gv program if found or 'echo gv' otherwise */ /* Define to path to gv program if found or 'echo gv' otherwise */
#undef LLVM_PATH_GV #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 */ /* Installation prefix directory */
#undef LLVM_PREFIX #undef LLVM_PREFIX

View 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> template<typename GraphType>
class GraphWriter { class GraphWriter {
@ -314,14 +324,15 @@ template<typename GraphType>
void ViewGraph(const GraphType& G, void ViewGraph(const GraphType& G,
const std::string& Name, const std::string& Name,
bool ShortNames = false, bool ShortNames = false,
const std::string& Title = "") { const std::string& Title = "",
GraphProgram::Name Program = GraphProgram::DOT) {
sys::Path Filename = WriteGraph(G, Name, ShortNames, Title); sys::Path Filename = WriteGraph(G, Name, ShortNames, Title);
if (Filename.isEmpty()) { if (Filename.isEmpty()) {
return; return;
} }
DisplayGraph(Filename); DisplayGraph(Filename, true, Program);
} }
} // End llvm namespace } // End llvm namespace

View File

@ -18,7 +18,8 @@
#include "llvm/Config/config.h" #include "llvm/Config/config.h"
using namespace llvm; 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; std::string ErrMsg;
#if HAVE_GRAPHVIZ #if HAVE_GRAPHVIZ
sys::Path Graphviz(LLVM_PATH_GRAPHVIZ); sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
@ -35,15 +36,56 @@ void llvm::DisplayGraph(const sys::Path &Filename, bool wait) {
else { else {
Filename.eraseFromDisk(); 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; sys::Path PSFilename = Filename;
PSFilename.appendSuffix("ps"); 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 #if HAVE_FDP
sys::Path prog(LLVM_PATH_FDP); prog = sys::Path(LLVM_PATH_FDP);
#else #endif
sys::Path prog(LLVM_PATH_DOT); #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 #endif
std::vector<const char*> args; std::vector<const char*> args;