BitcodeWriterPass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===--- Bitcode/Writer/BitcodeWriterPass.cpp - Bitcode Writer ------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // BitcodeWriterPass implementation.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/Bitcode/ReaderWriter.h"
  14. #include "llvm/Pass.h"
  15. using namespace llvm;
  16. namespace {
  17. class WriteBitcodePass : public ModulePass {
  18. raw_ostream &OS; // raw_ostream to print on
  19. public:
  20. static char ID; // Pass identification, replacement for typeid
  21. explicit WriteBitcodePass(raw_ostream &o)
  22. : ModulePass(ID), OS(o) {}
  23. const char *getPassName() const { return "Bitcode Writer"; }
  24. bool runOnModule(Module &M) {
  25. WriteBitcodeToFile(&M, OS);
  26. return false;
  27. }
  28. };
  29. }
  30. char WriteBitcodePass::ID = 0;
  31. /// createBitcodeWriterPass - Create and return a pass that writes the module
  32. /// to the specified ostream.
  33. ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str) {
  34. return new WriteBitcodePass(Str);
  35. }