1//===- Bitcode/Writer/DXILBitcodeWriter.cpp - DXIL Bitcode Writer ---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Bitcode writer implementation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_DXILWRITER_DXILBITCODEWRITER_H
14#define LLVM_DXILWRITER_DXILBITCODEWRITER_H
15
16#include "llvm/ADT/StringRef.h"
17#include "llvm/IR/ModuleSummaryIndex.h"
18#include "llvm/MC/StringTableBuilder.h"
19#include "llvm/Support/MemoryBufferRef.h"
20#include <memory>
21#include <vector>
22
23namespace llvm {
24
25class BitstreamWriter;
26class Module;
27class raw_ostream;
28
29namespace dxil {
30
31class DXILDebugInfoMap;
32
33class BitcodeWriter {
34 SmallVectorImpl<char> &Buffer;
35 std::unique_ptr<BitstreamWriter> Stream;
36
37 StringTableBuilder StrtabBuilder{StringTableBuilder::RAW};
38
39 void writeBlob(unsigned Block, unsigned Record, StringRef Blob);
40
41 std::vector<Module *> Mods;
42
43public:
44 /// Create a BitcodeWriter that writes to Buffer.
45 BitcodeWriter(SmallVectorImpl<char> &Buffer);
46
47 ~BitcodeWriter();
48
49 /// Write the specified module to the buffer specified at construction time.
50 void writeModule(const Module &M, const DXILDebugInfoMap &DebugInfo);
51};
52
53/// Write the specified module to the specified raw output stream.
54///
55/// For streams where it matters, the given stream should be in "binary"
56/// mode.
57void WriteDXILToFile(Module &M, raw_ostream &Out);
58
59} // namespace dxil
60
61} // namespace llvm
62
63#endif // LLVM_DXILWRITER_DXILBITCODEWRITER_H
64