summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-18 20:31:42 +0000
committerChris Lattner <sabre@nondot.org>2001-10-18 20:31:42 +0000
commit9e06a475259937f07bd4a6130fbe364e86b50f5b (patch)
treea982cd0bdd6543ce75dd383dcb8f4afd25eb02f9
parent2b4a64a31b4aa76439d52af473953c6621e1455d (diff)
downloadbcm5719-llvm-9e06a475259937f07bd4a6130fbe364e86b50f5b.tar.gz
bcm5719-llvm-9e06a475259937f07bd4a6130fbe364e86b50f5b.zip
initial checkin
llvm-svn: 902
-rw-r--r--llvm/include/llvm/Assembly/PrintModulePass.h49
-rw-r--r--llvm/include/llvm/Bytecode/WriteBytecodePass.h32
2 files changed, 81 insertions, 0 deletions
diff --git a/llvm/include/llvm/Assembly/PrintModulePass.h b/llvm/include/llvm/Assembly/PrintModulePass.h
new file mode 100644
index 00000000000..a03b3492e62
--- /dev/null
+++ b/llvm/include/llvm/Assembly/PrintModulePass.h
@@ -0,0 +1,49 @@
+//===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
+//
+// This file defines a simple pass to print out methods of a module as they are
+// processed.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H
+#define LLVM_ASSEMBLY_PRINTMODULEPASS_H
+
+#include "llvm/Pass.h"
+#include "llvm/Assembly/Writer.h"
+
+class PrintModulePass : public Pass {
+ string Banner; // String to print before each method
+ ostream *Out; // ostream to print on
+ bool DeleteStream; // Delete the ostream in our dtor?
+ bool PrintPerMethod; // Print one method at a time rather than the whole?
+public:
+ inline PrintModulePass(const string &B, ostream *o = &cout,
+ bool DS = false,
+ bool printPerMethod = true)
+ : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
+ }
+
+ inline ~PrintModulePass() {
+ if (DeleteStream) delete Out;
+ }
+
+ // doPerMethodWork - This pass just prints a banner followed by the method as
+ // it's processed.
+ //
+ bool doPerMethodWork(Method *M) {
+ if (PrintPerMethod)
+ (*Out) << Banner << M;
+ return false;
+ }
+
+ // doPassFinalization - Virtual method overriden by subclasses to do any post
+ // processing needed after all passes have run.
+ //
+ bool doPassFinalization(Module *M) {
+ if (! PrintPerMethod)
+ (*Out) << Banner << M;
+ return false;
+ }
+};
+
+#endif
diff --git a/llvm/include/llvm/Bytecode/WriteBytecodePass.h b/llvm/include/llvm/Bytecode/WriteBytecodePass.h
new file mode 100644
index 00000000000..6a0edbcd99f
--- /dev/null
+++ b/llvm/include/llvm/Bytecode/WriteBytecodePass.h
@@ -0,0 +1,32 @@
+//===- llvm/Bytecode/WriteBytecodePass.h - Bytecode Writer Pass --*- C++ -*--=//
+//
+// This file defines a simple pass to write the working module to a file after
+// pass processing is completed.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_BYTECODE_WRITEBYTECODEPASS_H
+#define LLVM_BYTECODE_WRITEBYTECODEPASS_H
+
+#include "llvm/Pass.h"
+#include "llvm/Bytecode/Writer.h"
+
+class WriteBytecodePass : public Pass {
+ ostream *Out; // ostream to print on
+ bool DeleteStream;
+public:
+ inline WriteBytecodePass(ostream *o = &cout, bool DS = false)
+ : Out(o), DeleteStream(DS) {
+ }
+
+ inline ~WriteBytecodePass() {
+ if (DeleteStream) delete Out;
+ }
+
+ bool doPassFinalization(Module *M) {
+ WriteBytecodeToFile(M, *Out);
+ return false;
+ }
+};
+
+#endif
OpenPOWER on IntegriCloud