Change allowsUnalignedMemoryAccesses to take type argument since some targets
[llvm/avr.git] / lib / Support / GraphWriter.cpp
blob4ec0bf86e5691e9c926a7a4fe8763d1ab5ab6648
1 //===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements misc. GraphWriter support routines.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/GraphWriter.h"
15 #include "llvm/Support/Streams.h"
16 #include "llvm/System/Path.h"
17 #include "llvm/System/Program.h"
18 #include "llvm/Config/config.h"
19 using namespace llvm;
21 void llvm::DisplayGraph(const sys::Path &Filename, bool wait,
22 GraphProgram::Name program) {
23 std::string ErrMsg;
24 #if HAVE_GRAPHVIZ
25 sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
27 std::vector<const char*> args;
28 args.push_back(Graphviz.c_str());
29 args.push_back(Filename.c_str());
30 args.push_back(0);
32 cerr << "Running 'Graphviz' program... ";
33 if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,0,&ErrMsg)) {
34 cerr << "Error viewing graph " << Filename << ": " << ErrMsg << "\n";
36 else {
37 Filename.eraseFromDisk();
40 #elif (HAVE_GV && (HAVE_DOT || HAVE_FDP || HAVE_NEATO || \
41 HAVE_TWOPI || HAVE_CIRCO))
42 sys::Path PSFilename = Filename;
43 PSFilename.appendSuffix("ps");
45 sys::Path prog;
47 // Set default grapher
48 #if HAVE_CIRCO
49 prog = sys::Path(LLVM_PATH_CIRCO);
50 #endif
51 #if HAVE_TWOPI
52 prog = sys::Path(LLVM_PATH_TWOPI);
53 #endif
54 #if HAVE_NEATO
55 prog = sys::Path(LLVM_PATH_NEATO);
56 #endif
57 #if HAVE_FDP
58 prog = sys::Path(LLVM_PATH_FDP);
59 #endif
60 #if HAVE_DOT
61 prog = sys::Path(LLVM_PATH_DOT);
62 #endif
64 // Find which program the user wants
65 #if HAVE_DOT
66 if (program == GraphProgram::DOT) {
67 prog = sys::Path(LLVM_PATH_DOT);
69 #endif
70 #if (HAVE_FDP)
71 if (program == GraphProgram::FDP) {
72 prog = sys::Path(LLVM_PATH_FDP);
74 #endif
75 #if (HAVE_NEATO)
76 if (program == GraphProgram::NEATO) {
77 prog = sys::Path(LLVM_PATH_NEATO);
79 #endif
80 #if (HAVE_TWOPI)
81 if (program == GraphProgram::TWOPI) {
82 prog = sys::Path(LLVM_PATH_TWOPI);
84 #endif
85 #if (HAVE_CIRCO)
86 if (program == GraphProgram::CIRCO) {
87 prog = sys::Path(LLVM_PATH_CIRCO);
89 #endif
91 std::vector<const char*> args;
92 args.push_back(prog.c_str());
93 args.push_back("-Tps");
94 args.push_back("-Nfontname=Courier");
95 args.push_back("-Gsize=7.5,10");
96 args.push_back(Filename.c_str());
97 args.push_back("-o");
98 args.push_back(PSFilename.c_str());
99 args.push_back(0);
101 cerr << "Running '" << prog << "' program... ";
103 if (sys::Program::ExecuteAndWait(prog, &args[0],0,0,0,0,&ErrMsg)) {
104 cerr << "Error viewing graph " << Filename << ": '" << ErrMsg << "\n";
105 } else {
106 cerr << " done. \n";
108 sys::Path gv(LLVM_PATH_GV);
109 args.clear();
110 args.push_back(gv.c_str());
111 args.push_back(PSFilename.c_str());
112 args.push_back("-spartan");
113 args.push_back(0);
115 ErrMsg.clear();
116 if (wait) {
117 if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,0,&ErrMsg)) {
118 cerr << "Error viewing graph: " << ErrMsg << "\n";
120 Filename.eraseFromDisk();
121 PSFilename.eraseFromDisk();
123 else {
124 sys::Program::ExecuteNoWait(gv, &args[0],0,0,0,&ErrMsg);
125 cerr << "Remember to erase graph files: " << Filename << " " << PSFilename << "\n";
128 #elif HAVE_DOTTY
129 sys::Path dotty(LLVM_PATH_DOTTY);
131 std::vector<const char*> args;
132 args.push_back(dotty.c_str());
133 args.push_back(Filename.c_str());
134 args.push_back(0);
136 cerr << "Running 'dotty' program... ";
137 if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,0,&ErrMsg)) {
138 cerr << "Error viewing graph " << Filename << ": " << ErrMsg << "\n";
139 } else {
140 #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns
141 return;
142 #endif
143 Filename.eraseFromDisk();
145 #endif