LLVM  4.0.0
BitcodeWriter.h
Go to the documentation of this file.
1 //===-- llvm/Bitcode/BitcodeWriter.h - Bitcode writers ----*- 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 //
10 // This header defines interfaces to write LLVM bitcode files/streams.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_BITCODE_BITCODEWRITER_H
15 #define LLVM_BITCODE_BITCODEWRITER_H
16 
18 #include <string>
19 
20 namespace llvm {
21  class BitstreamWriter;
22  class Module;
23  class raw_ostream;
24 
25  class BitcodeWriter {
26  SmallVectorImpl<char> &Buffer;
27  std::unique_ptr<BitstreamWriter> Stream;
28 
29  public:
30  /// Create a BitcodeWriter that writes to Buffer.
32 
34 
35  /// Write the specified module to the buffer specified at construction time.
36  ///
37  /// If \c ShouldPreserveUseListOrder, encode the use-list order for each \a
38  /// Value in \c M. These will be reconstructed exactly when \a M is
39  /// deserialized.
40  ///
41  /// If \c Index is supplied, the bitcode will contain the summary index
42  /// (currently for use in ThinLTO optimization).
43  ///
44  /// \p GenerateHash enables hashing the Module and including the hash in the
45  /// bitcode (currently for use in ThinLTO incremental build).
46  void writeModule(const Module *M, bool ShouldPreserveUseListOrder = false,
47  const ModuleSummaryIndex *Index = nullptr,
48  bool GenerateHash = false);
49  };
50 
51  /// \brief Write the specified module to the specified raw output stream.
52  ///
53  /// For streams where it matters, the given stream should be in "binary"
54  /// mode.
55  ///
56  /// If \c ShouldPreserveUseListOrder, encode the use-list order for each \a
57  /// Value in \c M. These will be reconstructed exactly when \a M is
58  /// deserialized.
59  ///
60  /// If \c Index is supplied, the bitcode will contain the summary index
61  /// (currently for use in ThinLTO optimization).
62  ///
63  /// \p GenerateHash enables hashing the Module and including the hash in the
64  /// bitcode (currently for use in ThinLTO incremental build).
65  void WriteBitcodeToFile(const Module *M, raw_ostream &Out,
66  bool ShouldPreserveUseListOrder = false,
67  const ModuleSummaryIndex *Index = nullptr,
68  bool GenerateHash = false);
69 
70  /// Write the specified module summary index to the given raw output stream,
71  /// where it will be written in a new bitcode block. This is used when
72  /// writing the combined index file for ThinLTO. When writing a subset of the
73  /// index for a distributed backend, provide the \p ModuleToSummariesForIndex
74  /// map.
75  void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out,
76  const std::map<std::string, GVSummaryMapTy>
77  *ModuleToSummariesForIndex = nullptr);
78 } // End llvm namespace
79 
80 #endif
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
Class to hold module path string table and global value map, and encapsulate methods for operating on...
void writeModule(const Module *M, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false)
Write the specified module to the buffer specified at construction time.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false)
Write the specified module to the specified raw output stream.
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44