BitcodeWriterPass.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //===-- BitcodeWriterPass.h - Bitcode writing pass --------------*- C++ -*-===//
  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. /// \file
  10. ///
  11. /// This file provides a bitcode writing pass.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_BITCODE_BITCODEWRITERPASS_H
  15. #define LLVM_BITCODE_BITCODEWRITERPASS_H
  16. #include "llvm/ADT/StringRef.h"
  17. namespace llvm {
  18. class Module;
  19. class ModulePass;
  20. class raw_ostream;
  21. class PreservedAnalyses;
  22. /// \brief Create and return a pass that writes the module to the specified
  23. /// ostream. Note that this pass is designed for use with the legacy pass
  24. /// manager.
  25. ///
  26. /// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
  27. /// reproduced when deserialized.
  28. ModulePass *createBitcodeWriterPass(raw_ostream &Str,
  29. bool ShouldPreserveUseListOrder = false);
  30. /// \brief Pass for writing a module of IR out to a bitcode file.
  31. ///
  32. /// Note that this is intended for use with the new pass manager. To construct
  33. /// a pass for the legacy pass manager, use the function above.
  34. class BitcodeWriterPass {
  35. raw_ostream &OS;
  36. bool ShouldPreserveUseListOrder;
  37. public:
  38. /// \brief Construct a bitcode writer pass around a particular output stream.
  39. ///
  40. /// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
  41. /// reproduced when deserialized.
  42. explicit BitcodeWriterPass(raw_ostream &OS,
  43. bool ShouldPreserveUseListOrder = false)
  44. : OS(OS), ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
  45. /// \brief Run the bitcode writer pass, and output the module to the selected
  46. /// output stream.
  47. PreservedAnalyses run(Module &M);
  48. static StringRef name() { return "BitcodeWriterPass"; }
  49. };
  50. }
  51. #endif