2014-01-13 08:38:24 +01:00
|
|
|
//===-- BitcodeWriterPass.h - Bitcode writing pass --------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
///
|
|
|
|
/// This file provides a bitcode writing pass.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 18:26:38 +02:00
|
|
|
#ifndef LLVM_BITCODE_BITCODEWRITERPASS_H
|
|
|
|
#define LLVM_BITCODE_BITCODEWRITERPASS_H
|
2014-01-13 08:38:24 +01:00
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class Module;
|
|
|
|
class ModulePass;
|
|
|
|
class raw_ostream;
|
|
|
|
class PreservedAnalyses;
|
|
|
|
|
|
|
|
/// \brief Create and return a pass that writes the module to the specified
|
|
|
|
/// ostream. Note that this pass is designed for use with the legacy pass
|
|
|
|
/// manager.
|
2015-04-15 02:34:24 +02:00
|
|
|
///
|
|
|
|
/// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
|
|
|
|
/// reproduced when deserialized.
|
2015-10-04 16:33:43 +02:00
|
|
|
///
|
|
|
|
/// If \c EmitFunctionSummary, emit the function summary index (currently
|
|
|
|
/// for use in ThinLTO optimization).
|
2015-04-15 02:34:24 +02:00
|
|
|
ModulePass *createBitcodeWriterPass(raw_ostream &Str,
|
2015-10-04 16:33:43 +02:00
|
|
|
bool ShouldPreserveUseListOrder = false,
|
|
|
|
bool EmitFunctionSummary = false);
|
2014-01-13 08:38:24 +01:00
|
|
|
|
|
|
|
/// \brief Pass for writing a module of IR out to a bitcode file.
|
|
|
|
///
|
|
|
|
/// Note that this is intended for use with the new pass manager. To construct
|
|
|
|
/// a pass for the legacy pass manager, use the function above.
|
|
|
|
class BitcodeWriterPass {
|
|
|
|
raw_ostream &OS;
|
2015-04-15 02:34:24 +02:00
|
|
|
bool ShouldPreserveUseListOrder;
|
2015-10-04 16:33:43 +02:00
|
|
|
bool EmitFunctionSummary;
|
2014-01-13 08:38:24 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// \brief Construct a bitcode writer pass around a particular output stream.
|
2015-04-15 02:34:24 +02:00
|
|
|
///
|
|
|
|
/// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
|
|
|
|
/// reproduced when deserialized.
|
2015-10-04 16:33:43 +02:00
|
|
|
///
|
|
|
|
/// If \c EmitFunctionSummary, emit the function summary index (currently
|
|
|
|
/// for use in ThinLTO optimization).
|
2015-04-15 02:34:24 +02:00
|
|
|
explicit BitcodeWriterPass(raw_ostream &OS,
|
2015-10-04 16:33:43 +02:00
|
|
|
bool ShouldPreserveUseListOrder = false,
|
|
|
|
bool EmitFunctionSummary = false)
|
|
|
|
: OS(OS), ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
|
|
|
|
EmitFunctionSummary(EmitFunctionSummary) {}
|
2014-01-13 08:38:24 +01:00
|
|
|
|
|
|
|
/// \brief Run the bitcode writer pass, and output the module to the selected
|
2014-01-13 16:10:11 +01:00
|
|
|
/// output stream.
|
2015-01-05 03:47:05 +01:00
|
|
|
PreservedAnalyses run(Module &M);
|
2014-01-13 08:38:24 +01:00
|
|
|
|
|
|
|
static StringRef name() { return "BitcodeWriterPass"; }
|
|
|
|
};
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
}
|
2014-01-13 08:38:24 +01:00
|
|
|
|
|
|
|
#endif
|