summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/PrintModulePass.cpp
diff options
context:
space:
mode:
authorSergei Larin <slarin@codeaurora.org>2013-02-08 23:37:41 +0000
committerSergei Larin <slarin@codeaurora.org>2013-02-08 23:37:41 +0000
commitcd1201b98c6d3eb089c6019b424ed6f4ef7fd480 (patch)
tree0a878f1ec1dcaa4fdf2cce0ec92d665aed7c1db4 /llvm/lib/IR/PrintModulePass.cpp
parentf3c171ebeccaf56ca6b89523d851904e7978dec9 (diff)
downloadbcm5719-llvm-cd1201b98c6d3eb089c6019b424ed6f4ef7fd480.tar.gz
bcm5719-llvm-cd1201b98c6d3eb089c6019b424ed6f4ef7fd480.zip
Enable *BasicBlockPass::createPrinterPass()
Enables raw_ostream I/O for BasicBlockPass. llvm-svn: 174776
Diffstat (limited to 'llvm/lib/IR/PrintModulePass.cpp')
-rw-r--r--llvm/lib/IR/PrintModulePass.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/IR/PrintModulePass.cpp b/llvm/lib/IR/PrintModulePass.cpp
index e4e9939f083..5026bc2d984 100644
--- a/llvm/lib/IR/PrintModulePass.cpp
+++ b/llvm/lib/IR/PrintModulePass.cpp
@@ -73,6 +73,31 @@ namespace {
AU.setPreservesAll();
}
};
+
+ class PrintBasicBlockPass : public BasicBlockPass {
+ std::string Banner;
+ raw_ostream *Out; // raw_ostream to print on
+ bool DeleteStream; // Delete the ostream in our dtor?
+ public:
+ static char ID;
+ PrintBasicBlockPass() : BasicBlockPass(ID), Out(&dbgs()),
+ DeleteStream(false) {}
+ PrintBasicBlockPass(const std::string &B, raw_ostream *o, bool DS)
+ : BasicBlockPass(ID), Banner(B), Out(o), DeleteStream(DS) {}
+
+ ~PrintBasicBlockPass() {
+ if (DeleteStream) delete Out;
+ }
+
+ bool runOnBasicBlock(BasicBlock &BB) {
+ (*Out) << Banner << BB;
+ return false;
+ }
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
+ };
}
char PrintModulePass::ID = 0;
@@ -81,6 +106,9 @@ INITIALIZE_PASS(PrintModulePass, "print-module",
char PrintFunctionPass::ID = 0;
INITIALIZE_PASS(PrintFunctionPass, "print-function",
"Print function to stderr", false, false)
+char PrintBasicBlockPass::ID = 0;
+INITIALIZE_PASS(PrintBasicBlockPass, "print-bb",
+ "Print BB to stderr", false, false)
/// createPrintModulePass - Create and return a pass that writes the
/// module to the specified raw_ostream.
@@ -98,3 +126,11 @@ FunctionPass *llvm::createPrintFunctionPass(const std::string &Banner,
return new PrintFunctionPass(Banner, OS, DeleteStream);
}
+/// createPrintBasicBlockPass - Create and return a pass that writes the
+/// BB to the specified raw_ostream.
+BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream *OS,
+ bool DeleteStream,
+ const std::string &Banner) {
+ return new PrintBasicBlockPass(Banner, OS, DeleteStream);
+}
+
OpenPOWER on IntegriCloud