summaryrefslogtreecommitdiff
path: root/include/llvm/Assembly
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
commitb44405a90d9ec3e868f196ed6a3730241d6b4de0 (patch)
tree48ad5a8f42fa35d06244f61620740e052a249fe4 /include/llvm/Assembly
parent986fced5f9b3ef06f514cba66db499acffdc9711 (diff)
downloadllvm-b44405a90d9ec3e868f196ed6a3730241d6b4de0.tar.gz
llvm-b44405a90d9ec3e868f196ed6a3730241d6b4de0.tar.bz2
llvm-b44405a90d9ec3e868f196ed6a3730241d6b4de0.tar.xz
initial checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Assembly')
-rw-r--r--include/llvm/Assembly/PrintModulePass.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h
new file mode 100644
index 0000000000..a03b3492e6
--- /dev/null
+++ b/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