diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-01-12 12:15:39 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-01-12 12:15:39 +0000 |
commit | a59525786d39de4af8d7ee65531c220348ec48b6 (patch) | |
tree | c31cf0ba4e85bc2dd06c56b8687489dd24a17750 /include/llvm/IR/IRPrintingPasses.h | |
parent | 895ada05e91c427afc8c19d1c4267434325948f6 (diff) | |
download | llvm-a59525786d39de4af8d7ee65531c220348ec48b6.tar.gz llvm-a59525786d39de4af8d7ee65531c220348ec48b6.tar.bz2 llvm-a59525786d39de4af8d7ee65531c220348ec48b6.tar.xz |
[PM] Add module and function printing passes for the new pass manager.
This implements the legacy passes in terms of the new ones. It adds
basic testing using explicit runs of the passes. Next up will be wiring
the basic output mechanism of opt up when the new pass manager is
engaged unless bitcode writing is requested.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR/IRPrintingPasses.h')
-rw-r--r-- | include/llvm/IR/IRPrintingPasses.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/include/llvm/IR/IRPrintingPasses.h b/include/llvm/IR/IRPrintingPasses.h index 1d6cf95b0b..3d759ef57d 100644 --- a/include/llvm/IR/IRPrintingPasses.h +++ b/include/llvm/IR/IRPrintingPasses.h @@ -19,12 +19,16 @@ #ifndef LLVM_IR_PRINTMODULEPASS_H #define LLVM_IR_PRINTMODULEPASS_H +#include "llvm/ADT/StringRef.h" #include <string> namespace llvm { +class BasicBlockPass; +class Function; class FunctionPass; +class Module; class ModulePass; -class BasicBlockPass; +class PreservedAnalyses; class raw_ostream; /// \brief Create and return a pass that writes the module to the specified @@ -42,6 +46,40 @@ FunctionPass *createPrintFunctionPass(raw_ostream &OS, BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS, const std::string &Banner = ""); +/// \brief Pass for printing a Module as LLVM's text IR assembly. +/// +/// Note: This pass is for use with the new pass manager. Use the create...Pass +/// functions above to create passes for use with the legacy pass manager. +class PrintModulePass { + raw_ostream &OS; + std::string Banner; + +public: + PrintModulePass(); + PrintModulePass(raw_ostream &OS, const std::string &Banner = ""); + + PreservedAnalyses run(Module *M); + + static StringRef name() { return "PrintModulePass"; } +}; + +/// \brief Pass for printing a Function as LLVM's text IR assembly. +/// +/// Note: This pass is for use with the new pass manager. Use the create...Pass +/// functions above to create passes for use with the legacy pass manager. +class PrintFunctionPass { + raw_ostream &OS; + std::string Banner; + +public: + PrintFunctionPass(); + PrintFunctionPass(raw_ostream &OS, const std::string &Banner = ""); + + PreservedAnalyses run(Function *F); + + static StringRef name() { return "PrintFunctionPass"; } +}; + } // End llvm namespace #endif |