LLVM  15.0.0git
DXILBitcodeWriter.h
Go to the documentation of this file.
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 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/Allocator.h"
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 namespace llvm {
24 
25 class BitstreamWriter;
26 class Module;
27 class raw_ostream;
28 
29 namespace dxil {
30 
32  SmallVectorImpl<char> &Buffer;
33  std::unique_ptr<BitstreamWriter> Stream;
34 
36 
37  // Owns any strings created by the irsymtab writer until we create the
38  // string table.
39  BumpPtrAllocator Alloc;
40 
41  bool WroteStrtab = false, WroteSymtab = false;
42 
43  void writeBlob(unsigned Block, unsigned Record, StringRef Blob);
44 
45  std::vector<Module *> Mods;
46 
47 public:
48  /// Create a BitcodeWriter that writes to Buffer.
50 
52 
53  /// Attempt to write a symbol table to the bitcode file. This must be called
54  /// at most once after all modules have been written.
55  ///
56  /// A reader does not require a symbol table to interpret a bitcode file;
57  /// the symbol table is needed only to improve link-time performance. So
58  /// this function may decide not to write a symbol table. It may so decide
59  /// if, for example, the target is unregistered or the IR is malformed.
60  void writeSymtab();
61 
62  /// Write the bitcode file's string table. This must be called exactly once
63  /// after all modules and the optional symbol table have been written.
64  void writeStrtab();
65 
66  /// Copy the string table for another module into this bitcode file. This
67  /// should be called after copying the module itself into the bitcode file.
68  void copyStrtab(StringRef Strtab);
69 
70  /// Write the specified module to the buffer specified at construction time.
71  void writeModule(const Module &M);
72 };
73 
74 /// Write the specified module to the specified raw output stream.
75 ///
76 /// For streams where it matters, the given stream should be in "binary"
77 /// mode.
78 void WriteDXILToFile(const Module &M, raw_ostream &Out);
79 
80 } // namespace dxil
81 
82 } // namespace llvm
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::dxil::BitcodeWriter::BitcodeWriter
BitcodeWriter(SmallVectorImpl< char > &Buffer, raw_fd_stream *FS=nullptr)
Create a BitcodeWriter that writes to Buffer.
Definition: DXILBitcodeWriter.cpp:361
StringRef.h
Allocator.h
MemoryBufferRef.h
ModuleSummaryIndex.h
StringTableBuilder.h
llvm::dxil::BitcodeWriter::writeStrtab
void writeStrtab()
Write the bitcode file's string table.
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::StringTableBuilder::RAW
@ RAW
Definition: StringTableBuilder.h:32
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
llvm::dxil::BitcodeWriter::writeSymtab
void writeSymtab()
Attempt to write a symbol table to the bitcode file.
llvm::dxil::BitcodeWriter::writeModule
void writeModule(const Module &M)
Write the specified module to the buffer specified at construction time.
Definition: DXILBitcodeWriter.cpp:454
llvm::X86AS::FS
@ FS
Definition: X86.h:196
llvm::Record
Definition: Record.h:1543
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::dxil::BitcodeWriter::copyStrtab
void copyStrtab(StringRef Strtab)
Copy the string table for another module into this bitcode file.
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::StringTableBuilder
Utility for building string tables with deduplicated suffixes.
Definition: StringTableBuilder.h:23
llvm::dxil::BitcodeWriter
Definition: DXILBitcodeWriter.h:31
llvm::dxil::BitcodeWriter::~BitcodeWriter
~BitcodeWriter()
Definition: DXILBitcodeWriter.cpp:373
llvm::raw_fd_stream
A raw_ostream of a file for reading/writing/seeking.
Definition: raw_ostream.h:601
llvm::SmallVectorImpl< char >
llvm::dxil::WriteDXILToFile
void WriteDXILToFile(const Module &M, raw_ostream &Out)
Write the specified module to the specified raw output stream.
Definition: DXILBitcodeWriter.cpp:376