aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-dis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-31 00:30:15 +0000
committerChris Lattner <sabre@nondot.org>2002-08-31 00:30:15 +0000
commit0179450064562c765baa70755ef402c860e1134c (patch)
treec3d3abbe2f1f42372ad2c3302a668eaa19a34e26 /tools/llvm-dis
parente8a7d74b0a56490d48ba752ac41b711fb1d6d698 (diff)
downloadexternal_llvm-0179450064562c765baa70755ef402c860e1134c.zip
external_llvm-0179450064562c765baa70755ef402c860e1134c.tar.gz
external_llvm-0179450064562c765baa70755ef402c860e1134c.tar.bz2
- Converted CWriter to be an LLVM pass.
- Convert dis to use a PassManager to do it's work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-dis')
-rw-r--r--tools/llvm-dis/dis.cpp24
-rw-r--r--tools/llvm-dis/llvm-dis.cpp24
2 files changed, 28 insertions, 20 deletions
diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp
index bc0c55b..8efc29f 100644
--- a/tools/llvm-dis/dis.cpp
+++ b/tools/llvm-dis/dis.cpp
@@ -12,13 +12,14 @@
//===----------------------------------------------------------------------===//
#include "llvm/Module.h"
+#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
-#include "llvm/Support/CFG.h"
+#include "llvm/Assembly/CWriter.h"
+#include "llvm/Assembly/PrintModulePass.h"
#include "Support/CommandLine.h"
#include "Support/Signals.h"
-#include "llvm/Assembly/CWriter.h"
#include <fstream>
-#include <iostream>
+#include <memory>
using std::cerr;
// OutputMode - The different orderings to print basic blocks in...
@@ -48,8 +49,8 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
std::ostream *Out = &std::cout; // Default to printing to stdout...
- Module *M = ParseBytecodeFile(InputFilename);
- if (M == 0) {
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
+ if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
return 1;
}
@@ -101,15 +102,18 @@ int main(int argc, char **argv) {
// All that dis does is write the assembly or C out to a file...
//
+ PassManager Passes;
+
switch (WriteMode) {
- case llvm:
- (*Out) << M; // Output LLVM assembly
+ case llvm: // Output LLVM assembly
+ Passes.add(new PrintModulePass(Out, Out != &std::cout));
break;
- case c:
- WriteToC(M, *Out); // Convert LLVM to C
+ case c: // Convert LLVM to C
+ Passes.add(createWriteToCPass(*Out));
break;
}
- delete M;
+
+ Passes.run(*M.get());
if (Out != &std::cout) delete Out;
return 0;
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index bc0c55b..8efc29f 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -12,13 +12,14 @@
//===----------------------------------------------------------------------===//
#include "llvm/Module.h"
+#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
-#include "llvm/Support/CFG.h"
+#include "llvm/Assembly/CWriter.h"
+#include "llvm/Assembly/PrintModulePass.h"
#include "Support/CommandLine.h"
#include "Support/Signals.h"
-#include "llvm/Assembly/CWriter.h"
#include <fstream>
-#include <iostream>
+#include <memory>
using std::cerr;
// OutputMode - The different orderings to print basic blocks in...
@@ -48,8 +49,8 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
std::ostream *Out = &std::cout; // Default to printing to stdout...
- Module *M = ParseBytecodeFile(InputFilename);
- if (M == 0) {
+ std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
+ if (M.get() == 0) {
cerr << argv[0] << ": bytecode didn't read correctly.\n";
return 1;
}
@@ -101,15 +102,18 @@ int main(int argc, char **argv) {
// All that dis does is write the assembly or C out to a file...
//
+ PassManager Passes;
+
switch (WriteMode) {
- case llvm:
- (*Out) << M; // Output LLVM assembly
+ case llvm: // Output LLVM assembly
+ Passes.add(new PrintModulePass(Out, Out != &std::cout));
break;
- case c:
- WriteToC(M, *Out); // Convert LLVM to C
+ case c: // Convert LLVM to C
+ Passes.add(createWriteToCPass(*Out));
break;
}
- delete M;
+
+ Passes.run(*M.get());
if (Out != &std::cout) delete Out;
return 0;